Rev 4060 | Rev 4477 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3545 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
||
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 | |||
13 | |||
4143 | hidnplayr | 14 | ; in: window ptr in ebx |
15 | ; out: eax = 0 on error |
||
3545 | hidnplayr | 16 | window_create: |
17 | |||
4143 | hidnplayr | 18 | push ebx |
3545 | hidnplayr | 19 | ; allocate the window data block |
20 | mcall 68, 12, sizeof.window_data |
||
21 | test eax, eax |
||
4143 | hidnplayr | 22 | pop ebx |
3545 | hidnplayr | 23 | jz .fail |
24 | |||
25 | ; fill it with all zeros |
||
26 | push eax |
||
27 | mov edi, eax |
||
28 | mov ecx, (sizeof.window_data+3)/4 |
||
29 | xor eax, eax |
||
30 | rep stosd |
||
31 | pop eax |
||
32 | |||
4143 | hidnplayr | 33 | mov [ebx + window.data_ptr], eax |
34 | mov [ebx + window.flags], 0 |
||
35 | |||
36 | add eax, window_data.text+1 ; let text begin at offset 1, this way the text will be prepended with a 0 |
||
37 | mov [ebx + window.text_start], eax |
||
38 | mov [ebx + window.text_print], eax |
||
39 | mov [ebx + window.text_write], eax |
||
40 | mov [ebx + window.text_scanned], eax |
||
41 | mov [ebx + window.text_lines], 0 |
||
42 | mov [ebx + window.text_line_print], 0 |
||
43 | add eax, TEXT_BUFFERSIZE-1 |
||
44 | mov [ebx + window.text_end], eax |
||
45 | |||
3545 | hidnplayr | 46 | .fail: |
47 | ret |
||
48 | |||
49 | |||
50 | window_set_name: ; esi = ptr to name, ebx = window ptr |
||
51 | |||
52 | pusha |
||
53 | |||
54 | ; Skip heading spaces |
||
55 | .spaceloop: |
||
56 | cmp byte[esi], ' ' |
||
57 | jne .done |
||
58 | inc esi |
||
59 | jmp .spaceloop |
||
60 | .done: |
||
61 | |||
62 | ; Now copy it |
||
63 | lea edi, [ebx + window.name] |
||
64 | mov ecx, MAX_WINDOWNAME_LEN |
||
65 | .loop: |
||
66 | lodsb |
||
67 | cmp al, 0x21 |
||
68 | jbe .addzero |
||
69 | stosb |
||
70 | dec ecx |
||
71 | jnz .loop |
||
72 | .addzero: |
||
73 | xor al, al |
||
74 | stosb |
||
75 | |||
3981 | hidnplayr | 76 | call draw_windowtabs ; redraw it |
3545 | hidnplayr | 77 | |
78 | popa |
||
79 | |||
80 | ret |
||
81 | |||
82 | |||
83 | |||
3981 | hidnplayr | 84 | window_is_updated: |
85 | |||
3545 | hidnplayr | 86 | mov edi, [window_print] |
4143 | hidnplayr | 87 | cmp edi, [window_active] |
88 | je .skip |
||
3545 | hidnplayr | 89 | test [edi + window.flags], FLAG_UPDATED |
90 | jnz .skip |
||
91 | or [edi + window.flags], FLAG_UPDATED |
||
92 | |||
4143 | hidnplayr | 93 | ; TODO: make some noise |
3545 | hidnplayr | 94 | |
3981 | hidnplayr | 95 | call draw_windowtabs ; highlight updated tabs |
3545 | hidnplayr | 96 | .skip: |
97 | |||
98 | ret |
||
99 | |||
100 | |||
3981 | hidnplayr | 101 | |
4143 | hidnplayr | 102 | window_close: ; closes the 'print' window |
3981 | hidnplayr | 103 | |
104 | ; Remove the window (overwrite current structure with trailing ones) |
||
4143 | hidnplayr | 105 | mov edi, [window_print] |
3981 | hidnplayr | 106 | push [edi + window.data_ptr] ; remember data ptr so we can free it later |
107 | lea esi, [edi + sizeof.window] |
||
108 | mov ecx, windows + MAX_WINDOWS*sizeof.window |
||
109 | sub ecx, esi |
||
110 | rep movsb |
||
111 | |||
112 | ; Completely zero the trailing window block (there will always be one!) |
||
113 | mov ecx, sizeof.window |
||
114 | xor al, al |
||
115 | rep stosb |
||
116 | |||
117 | ; free the window data block |
||
118 | pop ecx |
||
119 | mcall 68, 13 |
||
120 | |||
121 | ; We closed this window so we need to show another |
||
122 | mov edi, [window_active] |
||
123 | cmp [edi + window.data_ptr], 0 |
||
124 | jne @f |
||
125 | sub edi, sizeof.window |
||
126 | mov [window_active], edi |
||
4143 | hidnplayr | 127 | mov [window_print], edi ;;;;;;;; |
3981 | hidnplayr | 128 | @@: |
129 | |||
130 | ; At last, redraw everything |
||
131 | call draw_window |
||
132 | |||
133 | ret |
||
134 | |||
135 | |||
136 | |||
4143 | hidnplayr | 137 | window_find: ; esi = window name |
138 | ; search for window in list |
||
139 | mov ebx, windows |
||
140 | mov [window_print], ebx ; set first window (server window) as default output window |
||
141 | mov eax, MAX_WINDOWS |
||
142 | .scanloop: |
||
143 | push esi |
||
144 | cmp [ebx + window.type], WINDOWTYPE_NONE |
||
145 | je .try_next |
||
146 | lea edi, [ebx + window.name] |
||
147 | mov ecx, MAX_WINDOWNAME_LEN |
||
148 | repe cmpsb |
||
149 | cmp byte[edi-1], 0 |
||
150 | jne .try_next |
||
151 | cmp byte[esi-1], 0 |
||
152 | je .got_it |
||
153 | cmp byte[esi-1], 10 |
||
154 | je .got_it |
||
155 | cmp byte[esi-1], 13 |
||
156 | je .got_it |
||
157 | cmp byte[esi-1], ' ' |
||
158 | je .got_it |
||
159 | .try_next: |
||
160 | pop esi |
||
161 | add ebx, sizeof.window |
||
162 | dec eax |
||
163 | jnz .scanloop |
||
3981 | hidnplayr | 164 | |
4143 | hidnplayr | 165 | xor ebx, ebx |
166 | ret |
||
167 | |||
168 | .got_it: |
||
169 | pop esi ;;; TODO: dont reset ESI ? |
||
170 | mov [window_print], ebx |
||
171 | ret |
||
172 | |||
173 | |||
174 | |||
175 | |||
176 | |||
177 | |||
3981 | hidnplayr | 178 | ; open a window with a given name, if it does not exist, create it |
179 | ; This procedure only affects window_print ptr, not window_active! |
||
180 | ; |
||
181 | ; esi = ptr to ASCIIZ windowname |
||
182 | window_open: |
||
183 | |||
184 | push esi |
||
185 | |||
186 | mov edi, esi |
||
187 | call compare_to_nick |
||
188 | jne .nochat |
||
189 | |||
190 | mov esi, servercommand+1 |
||
191 | .nochat: |
||
192 | |||
4143 | hidnplayr | 193 | call window_find |
194 | test ebx, ebx |
||
195 | jne .got_it |
||
3981 | hidnplayr | 196 | |
197 | ; create channel window - search for empty slot |
||
198 | .create_it: |
||
199 | mov ebx, windows |
||
200 | mov ecx, MAX_WINDOWS |
||
201 | .scanloop2: |
||
202 | cmp [ebx + window.data_ptr], 0 |
||
203 | je .free_found |
||
204 | add ebx, sizeof.window |
||
205 | dec ecx |
||
206 | jnz .scanloop2 |
||
207 | ; Error: no more available windows! |
||
4143 | hidnplayr | 208 | jmp .got_it ; TODO: return error |
3981 | hidnplayr | 209 | |
210 | .free_found: |
||
211 | call window_create |
||
212 | test eax, eax |
||
4143 | hidnplayr | 213 | jz .got_it ; TODO: return error |
214 | mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ? |
||
3981 | hidnplayr | 215 | |
216 | call window_set_name |
||
217 | mov [window_print], ebx |
||
218 | |||
219 | call draw_windowtabs |
||
220 | |||
221 | .got_it: |
||
222 | pop esi |
||
223 | .skip1: |
||
224 | ; skip text |
||
225 | lodsb |
||
226 | test al, al |
||
227 | jz .quit |
||
228 | cmp al, ' ' |
||
229 | jne .skip1 |
||
230 | dec esi |
||
231 | ; now skip trailing spaces and semicolons |
||
232 | .skip2: |
||
233 | lodsb |
||
234 | test al, al |
||
235 | jz .quit |
||
236 | cmp al, ' ' |
||
237 | je .skip2 |
||
238 | cmp al, ':' |
||
239 | je .skip2 |
||
240 | dec esi |
||
241 | |||
242 | .quit: |
||
4143 | hidnplayr | 243 | ret |