Subversion Repositories Kolibri OS

Rev

Rev 4827 | Rev 6023 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
4477 hidnplayr 3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
3545 hidnplayr 4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
4143 hidnplayr 6
;;   Written by hidnplayr@kolibrios.org                            ;;
3545 hidnplayr 7
;;                                                                 ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
9
;;          Version 2, June 1991                                   ;;
10
;;                                                                 ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
 
4477 hidnplayr 13
; window_create_textbox
14
; Initialises the data structure for our multiline textbox
15
;
16
; in:   window ptr in ebx
17
; out:  eax = 0 on error
18
;       ecx, edi = destroyed
3545 hidnplayr 19
 
4477 hidnplayr 20
window_create_textbox:
3545 hidnplayr 21
 
4824 gtament 22
	push	ebx
3545 hidnplayr 23
; allocate the window data block
4824 gtament 24
	mcall	68, 12, sizeof.window_data
25
	test	eax, eax
26
	pop	ebx
27
	jz	.fail
3545 hidnplayr 28
 
29
; fill it with all zeros
4824 gtament 30
	push	eax
31
	mov	edi, eax
32
	mov	ecx, (sizeof.window_data+3)/4
33
	xor	eax, eax
34
	rep	stosd
35
	pop	eax
3545 hidnplayr 36
 
4824 gtament 37
	mov	[ebx + window.data_ptr], eax
4828 gtament 38
	mov	[ebx + window.flags], FLAG_SCROLL_LOW
4143 hidnplayr 39
 
4824 gtament 40
	add	eax, window_data.text+2 	; let text begin at offset 2, this way the text will be prepended with two null bytes
41
	mov	[ebx + window.text_start], eax
42
	mov	[ebx + window.text_print], eax
43
	mov	[ebx + window.text_write], eax
44
	mov	[ebx + window.text_scanned], eax
45
	mov	[ebx + window.text_lines], 0
46
	mov	[ebx + window.text_line_print], 0
47
	add	eax, TEXT_BUFFERSIZE-1
48
	mov	[ebx + window.text_end], eax
4143 hidnplayr 49
 
3545 hidnplayr 50
  .fail:
4824 gtament 51
	ret
3545 hidnplayr 52
 
53
 
4477 hidnplayr 54
; window_set_name
55
; Fills in the window name in window structure
56
;
57
; IN:   esi = ptr to name
58
;       ebx = window ptr
59
; OUT:  esi = ptr to next parameter
60
;       ebx = window ptr
61
;       eax, ecx, edx, edi = destroyed
3545 hidnplayr 62
 
4477 hidnplayr 63
window_set_name:
3545 hidnplayr 64
 
4824 gtament 65
	lea	edi, [ebx + window.name]
66
	mov	ecx, MAX_WINDOWNAME_LEN
3545 hidnplayr 67
  .loop:
4824 gtament 68
	lodsb
69
	cmp	al, 0x21	; name ends with 0, space or !
70
	jbe	.addzero
71
	stosb
72
	dec	ecx
73
	jnz	.loop
3545 hidnplayr 74
  .addzero:
4824 gtament 75
	xor	al, al
76
	stosb
3545 hidnplayr 77
 
4824 gtament 78
	push	esi ebx
79
	call	draw_windowtabs
80
	pop	ebx esi
3545 hidnplayr 81
 
4824 gtament 82
	ret
3545 hidnplayr 83
 
84
 
4824 gtament 85
window_close:	; closes the 'print' window
3981 hidnplayr 86
 
87
; Remove the window (overwrite current structure with trailing ones)
4824 gtament 88
	mov	edi, [window_print]
89
	push	[edi + window.data_ptr] 	; remember data ptr so we can free it later
90
	lea	esi, [edi + sizeof.window]
91
	mov	ecx, windows + MAX_WINDOWS*sizeof.window
92
	sub	ecx, esi
93
	rep	movsb
3981 hidnplayr 94
 
95
; Completely zero the trailing window block (there will always be one!)
4824 gtament 96
	mov	ecx, sizeof.window
97
	xor	al, al
98
	rep	stosb
3981 hidnplayr 99
 
100
; free the window data block
4824 gtament 101
	pop	ecx
102
	mcall	68, 13
3981 hidnplayr 103
 
104
; We closed this window so we need to show another
4824 gtament 105
	mov	edi, [window_active]
106
	cmp	[edi + window.data_ptr], 0
107
	jne	@f
108
	sub	edi, sizeof.window
109
	mov	[window_active], edi
110
	mov	[window_print], edi  ;;;;;;;;
3981 hidnplayr 111
  @@:
112
 
113
; At last, redraw everything
4824 gtament 114
	call	draw_window
3981 hidnplayr 115
 
4824 gtament 116
	ret
3981 hidnplayr 117
 
118
 
4477 hidnplayr 119
; window_find:
120
; search for a window with given name in the window list
121
;
122
; IN:   esi = ptr to start of window name
123
; OUT:  ebx = window ptr, or 0 if none found
124
;       esi = ptr to end of window name, if window was found
3981 hidnplayr 125
 
4477 hidnplayr 126
window_find:
127
 
4824 gtament 128
	mov	ebx, windows
129
	mov	eax, MAX_WINDOWS
4143 hidnplayr 130
  .scanloop:
4824 gtament 131
	push	esi
132
	cmp	[ebx + window.type], WINDOWTYPE_NONE
133
	je	.try_next
134
	lea	edi, [ebx + window.name]
135
	mov	ecx, MAX_WINDOWNAME_LEN
136
	repe	cmpsb
137
	cmp	byte[edi-1], 0		; last equall character was null? yes, the strings match!
138
	je	.got_it
139
	cmp	byte[edi], 0		; we're at the end of string1.. ?
140
	jne	.try_next
141
	cmp	byte[esi], 0x21 	; and the end of string2? yes!
142
	jbe	.got_it
4143 hidnplayr 143
  .try_next:
4824 gtament 144
	pop	esi
145
	add	ebx, sizeof.window
146
	dec	eax
147
	jnz	.scanloop
3981 hidnplayr 148
 
4824 gtament 149
	xor	ebx, ebx
150
	ret
4143 hidnplayr 151
 
152
  .got_it:
4824 gtament 153
	add	esp, 4
154
	ret
4143 hidnplayr 155
 
156
 
157
 
4477 hidnplayr 158
; window_open:
3981 hidnplayr 159
; open a window with a given name, if it does not exist, create it
160
; This procedure only affects window_print ptr, not window_active!
161
;
4477 hidnplayr 162
; IN:   esi = ptr to ASCIIZ windowname
163
; OUT:  esi = ptr to next parameter
4623 hidnplayr 164
;       ebx = window ptr/0 on error
4477 hidnplayr 165
 
3981 hidnplayr 166
window_open:
167
 
4477 hidnplayr 168
; Skip heading spaces
4824 gtament 169
	lodsb
170
	cmp	al, ' '
171
	je	window_open
172
	cmp	al, ':'
173
	je	window_open
174
	dec	esi
3981 hidnplayr 175
 
4824 gtament 176
	call	window_find
177
	test	ebx, ebx
178
	jnz	.got_it
3981 hidnplayr 179
 
180
; create channel window - search for empty slot
181
  .create_it:
4824 gtament 182
	mov	ebx, windows
183
	mov	ecx, MAX_WINDOWS
3981 hidnplayr 184
  .scanloop2:
4824 gtament 185
	cmp	[ebx + window.type], WINDOWTYPE_NONE
186
	je	.free_found
187
	add	ebx, sizeof.window
188
	dec	ecx
189
	jnz	.scanloop2
190
	jmp	.error
3981 hidnplayr 191
 
192
  .free_found:
4824 gtament 193
	call	window_create_textbox
194
	test	eax, eax
195
	jz	.error
196
	mov	[ebx + window.type], WINDOWTYPE_CHAT	; FIXME: let caller handle this ?
3981 hidnplayr 197
 
4824 gtament 198
	call	window_set_name
3981 hidnplayr 199
 
200
  .got_it:
4824 gtament 201
	lodsb
202
	cmp	al, ' '
203
	je	.got_it
204
	cmp	al, ':'
205
	je	.got_it
206
	dec	esi
3981 hidnplayr 207
 
4824 gtament 208
	mov	[window_print], ebx
209
	ret
4477 hidnplayr 210
 
4623 hidnplayr 211
  .error:
4824 gtament 212
	xor	ebx, ebx
213
	ret