Rev 4143 | Rev 4622 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4143 | Rev 4621 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. 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 ;; |
Line 33... | Line 33... | ||
33 | cmp al, 10 ; it's a newline, continue onto the next line |
33 | cmp al, 10 ; it's a newline, continue onto the next line |
34 | jne .more |
34 | jne .more |
35 | inc edx |
35 | inc edx |
36 | jmp .next_line |
36 | jmp .next_line |
37 | .soft_nl: |
37 | .soft_nl: |
38 | inc edx |
- | |
39 | mov byte[esi-1], ' ' |
38 | mov byte[esi-1], ' ' |
40 | mov ebx, esi |
- | |
41 | jmp .more |
- | |
42 | .space: |
39 | .space: |
43 | mov ebx, esi ; last detected space |
40 | mov ebx, esi ; last detected space |
44 | jmp .more |
41 | jmp .more |
45 | .end_of_line: |
42 | .end_of_line: |
46 | inc edx |
43 | inc edx |
Line 60... | Line 57... | ||
60 | ; out:esi |
57 | ; out:esi |
61 | text_nextline: |
58 | text_nextline: |
Line 62... | Line 59... | ||
62 | 59 | ||
63 | mov ecx, [textbox_width] |
60 | mov ecx, [textbox_width] |
64 | .loop: |
- | |
65 | cmp byte[esi], 0 |
- | |
66 | je .done |
61 | .loop: |
- | 62 | lodsb |
|
- | 63 | test al, al |
|
67 | lodsb |
64 | jz .done |
68 | cmp al, 10 |
65 | cmp al, 10 |
69 | je .done |
66 | je .done |
70 | cmp al, 13 |
67 | cmp al, 13 |
71 | je .done |
68 | je .done |
Line 130... | Line 127... | ||
130 | pop edi esi |
127 | pop edi esi |
Line 131... | Line 128... | ||
131 | 128 | ||
Line 132... | Line 129... | ||
132 | ret |
129 | ret |
133 | - | ||
134 | .uh_ow: |
130 | |
135 | 131 | .uh_ow: |
|
136 | pusha |
132 | pusha |
137 | mov edi, [esi + window.text_start] |
133 | mov edi, [esi + window.text_start] |
138 | mov [esi + window.text_print], edi |
134 | mov [esi + window.text_print], edi |
Line 163... | Line 159... | ||
163 | mov esi, [edi + window.text_scanned] |
159 | mov esi, [edi + window.text_scanned] |
164 | call text_insert_newlines |
160 | call text_insert_newlines |
165 | add [edi + window.text_lines], edx |
161 | add [edi + window.text_lines], edx |
166 | mov [edi + window.text_scanned], esi |
162 | mov [edi + window.text_scanned], esi |
Line -... | Line 163... | ||
- | 163 | ||
- | 164 | ; Is scrollbar at lowest position? |
|
- | 165 | mov edx, [scroll2.position] |
|
- | 166 | test edx, edx |
|
- | 167 | jz .yesscroll |
|
- | 168 | add edx, [scroll2.cur_area] |
|
- | 169 | sub edx, [scroll2.max_area] |
|
- | 170 | jne .noscroll |
|
167 | 171 | .yesscroll: |
|
168 | ; should we scroll up/down some lines ? ; TODO: only scroll down automatically when scrollbar is at lowest position ? |
172 | ; Scrollbar was at lowest position, scroll down automatically when new text arrived. |
169 | mov edx, [edi + window.text_lines] |
173 | mov edx, [edi + window.text_lines] |
170 | sub edx, [textbox_height] |
174 | sub edx, [textbox_height] |
171 | jle .noscroll ; There are less lines of text than fit into the window, dont scroll.. |
175 | jle .noscroll ; There are less lines of text than fit into the window, dont scroll.. |
172 | sub edx, [edi + window.text_line_print] |
176 | sub edx, [edi + window.text_line_print] |
173 | je .noscroll ; We are already at the bottom pos, dont scroll.. |
- | |
174 | 177 | je .noscroll ; We are already at the bottom pos, dont scroll.. |
|
175 | .scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction) |
178 | .scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction) |
176 | pushf |
179 | pushf |
177 | add [edi + window.text_line_print], edx |
180 | add [edi + window.text_line_print], edx |
178 | mov esi, [edi + window.text_print] |
181 | mov esi, [edi + window.text_print] |
179 | popf |
182 | popf |
180 | ja .loop_forward |
183 | ja .loop_forward |
- | 184 | std ; set direction flag so we can scan backwards |
|
181 | std ; set direction flag so we can scan backwards |
185 | dec esi |
182 | dec esi ; move our cursor just in front of newline, for scanning backwards |
- | |
183 | dec edx ;;;;; FIXME: this seems to be needed, but why ??? |
186 | dec esi ; move our cursor just in front of newline, for scanning backwards |
184 | .loop_backward: |
187 | .loop_backward: |
185 | call text_nextline |
188 | call text_nextline |
186 | inc edx |
189 | inc edx |
- | 190 | jnz .loop_backward |
|
187 | jnz .loop_backward |
191 | inc esi |
188 | inc esi ; move the cursor just after last newline |
192 | inc esi ; move the cursor just after last newline |
189 | cld |
193 | cld |
Line 190... | Line 194... | ||
190 | jmp .ok |
194 | jmp .ok |
Line 195... | Line 199... | ||
195 | jnz .loop_forward |
199 | jnz .loop_forward |
196 | .ok: |
200 | .ok: |
197 | mov [edi + window.text_print], esi |
201 | mov [edi + window.text_print], esi |
198 | .noscroll: |
202 | .noscroll: |
Line 199... | Line -... | ||
199 | - | ||
200 | mov edx, [edi + window.text_print] |
203 | |
201 | ; Calculate start coordinates (align text to bottom) |
204 | ; Calculate start offset coordinates (align text to bottom) |
202 | mov ebx, [textbox_height] |
205 | mov ebx, [textbox_height] |
203 | sub ebx, [edi + window.text_lines] |
206 | sub ebx, [edi + window.text_lines] |
204 | jae @f |
- | |
205 | xor ebx, ebx |
- | |
206 | @@: |
207 | jb .no_offset |
- | 208 | imul ebx, FONT_HEIGHT |
|
207 | imul ebx, FONT_HEIGHT |
209 | push [edi + window.text_start] |
- | 210 | pop [edi + window.text_print] |
|
208 | add ebx, TEXT_X shl 16 + TEXT_Y |
211 | jmp .draw_text |
- | 212 | .no_offset: |
|
- | 213 | xor ebx, ebx |
|
209 | 214 | .draw_text: |
|
210 | ; Prepare to actually draw some text |
215 | ; Prepare to actually draw some text |
- | 216 | mov eax, [textbox_height] ; max number of lines to draw |
|
211 | mov eax, [textbox_height] ; max number of lines to draw |
217 | add ebx, TEXT_X shl 16 + TEXT_Y |
- | 218 | mov ecx, [colors.work_text] ; default text color |
|
212 | mov ecx, [colors.work_text] ; default text color |
219 | mov edx, [edi + window.text_print] |
213 | .drawloop: |
220 | .drawloop: |
214 | cmp byte[edx], 0 |
221 | cmp byte[edx], 0 |
Line 215... | Line 222... | ||
215 | je .end |
222 | je .end_of_text |
216 | 223 | ||
217 | ; Clear one row of characters |
224 | ; Clear one row of characters |
218 | pusha |
225 | pusha |
Line 228... | Line 235... | ||
228 | 235 | ||
229 | mov esi, edx |
236 | mov esi, edx |
230 | add esi, [textbox_width] |
237 | add esi, [textbox_width] |
231 | .line: |
238 | .line: |
232 | cmp byte[edx], 0 |
239 | cmp byte[edx], 0 |
Line 233... | Line 240... | ||
233 | je .end |
240 | je .end_of_text |
234 | 241 | ||
Line 235... | Line 242... | ||
235 | cmp byte[edx], 13 |
242 | cmp byte[edx], 13 |
Line 272... | Line 279... | ||
272 | .line_full: |
279 | .line_full: |
273 | and ebx, 0x0000ffff |
280 | and ebx, 0x0000ffff |
274 | add ebx, TEXT_X shl 16 + FONT_HEIGHT |
281 | add ebx, TEXT_X shl 16 + FONT_HEIGHT |
275 | dec eax |
282 | dec eax |
276 | jnz .drawloop |
283 | jnz .drawloop |
- | 284 | .end_of_text: |
|
Line 277... | Line 285... | ||
277 | 285 | ||
278 | ; take care of the scrollbar |
- | |
279 | .scrollbar: |
286 | ; Update and draw scrollbar when nescessary |
280 | mov edi, [window_active] |
287 | mov edi, [window_active] |
281 | mov edx, [edi + window.text_lines] |
288 | mov edx, [edi + window.text_lines] |
282 | cmp edx, [textbox_height] |
- | |
283 | ja .draw_scroll |
- | |
284 | mov [scroll2.position], 0 ; disable scrollbar |
289 | cmp edx, [textbox_height] |
Line 285... | Line -... | ||
285 | jmp .scroll_done |
- | |
286 | 290 | jbe .scroll_done |
|
287 | .draw_scroll: |
291 | |
288 | mov [scroll2.max_area], edx |
292 | mov [scroll2.max_area], edx |
Line 289... | Line 293... | ||
289 | mov eax, [edi + window.text_line_print] |
293 | mov eax, [edi + window.text_line_print] |
290 | mov [scroll2.position], eax |
294 | mov [scroll2.position], eax |
291 | - | ||
292 | push dword scroll2 ; redraw scrollbar |
295 | |
293 | call [scrollbar_draw] |
296 | push dword scroll2 ; redraw scrollbar |
294 | 297 | call [scrollbar_draw] |
|
295 | mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely |
298 | mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely |
Line 308... | Line 311... | ||
308 | sub al, '0' |
311 | sub al, '0' |
309 | jb .done |
312 | jb .done |
310 | cmp al, 9 |
313 | cmp al, 9 |
311 | ja .done |
314 | ja .done |
312 | inc edx |
315 | inc edx |
313 | shl esi, 1 ; esi * 2 |
316 | lea esi, [esi*4 + esi] ; esi * 5 |
314 | lea esi, [esi + 4*esi] ; esi * 5 |
317 | lea esi, [esi*2 + eax] ; esi * 2 + eax |
315 | add esi, eax |
- | |
316 | jmp .loop |
318 | jmp .loop |
317 | .done: |
319 | .done: |
318 | cmp esi, 16 |
320 | cmp esi, 16 |
319 | jae .fail |
321 | jae .fail |
320 | ret |
322 | ret |