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