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