forked from KolibriOS/kolibrios
Bugfixes related to scrolling of the text.
git-svn-id: svn://kolibrios.org@4621 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
fd5287e58e
commit
83400f932d
@ -13,7 +13,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
version equ '0.17'
|
version equ '0.18'
|
||||||
|
|
||||||
; connection status
|
; connection status
|
||||||
STATUS_DISCONNECTED = 0
|
STATUS_DISCONNECTED = 0
|
||||||
@ -313,9 +313,10 @@ button:
|
|||||||
je exit
|
je exit
|
||||||
mov [window_active], edx
|
mov [window_active], edx
|
||||||
|
|
||||||
mov [scroll2.position], 1 ;;; FIXME
|
push [edx + window.text_line_print]
|
||||||
call draw_window
|
pop [scroll2.position]
|
||||||
|
|
||||||
|
call draw_window
|
||||||
jmp mainloop
|
jmp mainloop
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -517,10 +518,6 @@ sockaddr1:
|
|||||||
|
|
||||||
status dd STATUS_DISCONNECTED
|
status dd STATUS_DISCONNECTED
|
||||||
|
|
||||||
|
|
||||||
textbox_height dd 12 ; in characters
|
|
||||||
textbox_width dd 78 ; in characters, not pixels ;)
|
|
||||||
|
|
||||||
window_active dd windows
|
window_active dd windows
|
||||||
window_print dd windows
|
window_print dd windows
|
||||||
|
|
||||||
@ -572,6 +569,9 @@ xsize dd ?
|
|||||||
ysize dd ?
|
ysize dd ?
|
||||||
mouse_dd dd ?
|
mouse_dd dd ?
|
||||||
|
|
||||||
|
textbox_height dd ? ; in characters
|
||||||
|
textbox_width dd ? ; in characters, not pixels ;)
|
||||||
|
|
||||||
colors system_colors
|
colors system_colors
|
||||||
|
|
||||||
irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct
|
irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct
|
||||||
@ -581,7 +581,6 @@ user_nick rb MAX_NICK_LEN
|
|||||||
user_real_name rb MAX_REAL_LEN
|
user_real_name rb MAX_REAL_LEN
|
||||||
quit_msg rb 250
|
quit_msg rb 250
|
||||||
|
|
||||||
diff16 "windows", 0, $ + 1*sizeof.window ;+ 6
|
|
||||||
windows rb MAX_WINDOWS*sizeof.window
|
windows rb MAX_WINDOWS*sizeof.window
|
||||||
|
|
||||||
IM_END:
|
IM_END:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Written by hidnplayr@kolibrios.org ;;
|
;; Written by hidnplayr@kolibrios.org ;;
|
||||||
@ -35,10 +35,7 @@ text_insert_newlines: ; esi = ASCIIZ string
|
|||||||
inc edx
|
inc edx
|
||||||
jmp .next_line
|
jmp .next_line
|
||||||
.soft_nl:
|
.soft_nl:
|
||||||
inc edx
|
|
||||||
mov byte[esi-1], ' '
|
mov byte[esi-1], ' '
|
||||||
mov ebx, esi
|
|
||||||
jmp .more
|
|
||||||
.space:
|
.space:
|
||||||
mov ebx, esi ; last detected space
|
mov ebx, esi ; last detected space
|
||||||
jmp .more
|
jmp .more
|
||||||
@ -62,9 +59,9 @@ text_nextline:
|
|||||||
|
|
||||||
mov ecx, [textbox_width]
|
mov ecx, [textbox_width]
|
||||||
.loop:
|
.loop:
|
||||||
cmp byte[esi], 0
|
|
||||||
je .done
|
|
||||||
lodsb
|
lodsb
|
||||||
|
test al, al
|
||||||
|
jz .done
|
||||||
cmp al, 10
|
cmp al, 10
|
||||||
je .done
|
je .done
|
||||||
cmp al, 13
|
cmp al, 13
|
||||||
@ -132,7 +129,6 @@ print_character:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.uh_ow:
|
.uh_ow:
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
mov edi, [esi + window.text_start]
|
mov edi, [esi + window.text_start]
|
||||||
mov [esi + window.text_print], edi
|
mov [esi + window.text_print], edi
|
||||||
@ -165,13 +161,20 @@ draw_channel_text:
|
|||||||
add [edi + window.text_lines], edx
|
add [edi + window.text_lines], edx
|
||||||
mov [edi + window.text_scanned], esi
|
mov [edi + window.text_scanned], esi
|
||||||
|
|
||||||
; should we scroll up/down some lines ? ; TODO: only scroll down automatically when scrollbar is at lowest position ?
|
; Is scrollbar at lowest position?
|
||||||
|
mov edx, [scroll2.position]
|
||||||
|
test edx, edx
|
||||||
|
jz .yesscroll
|
||||||
|
add edx, [scroll2.cur_area]
|
||||||
|
sub edx, [scroll2.max_area]
|
||||||
|
jne .noscroll
|
||||||
|
.yesscroll:
|
||||||
|
; Scrollbar was at lowest position, scroll down automatically when new text arrived.
|
||||||
mov edx, [edi + window.text_lines]
|
mov edx, [edi + window.text_lines]
|
||||||
sub edx, [textbox_height]
|
sub edx, [textbox_height]
|
||||||
jle .noscroll ; There are less lines of text than fit into the window, dont scroll..
|
jle .noscroll ; There are less lines of text than fit into the window, dont scroll..
|
||||||
sub edx, [edi + window.text_line_print]
|
sub edx, [edi + window.text_line_print]
|
||||||
je .noscroll ; We are already at the bottom pos, dont scroll..
|
je .noscroll ; We are already at the bottom pos, dont scroll..
|
||||||
|
|
||||||
.scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction)
|
.scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction)
|
||||||
pushf
|
pushf
|
||||||
add [edi + window.text_line_print], edx
|
add [edi + window.text_line_print], edx
|
||||||
@ -179,12 +182,13 @@ draw_channel_text:
|
|||||||
popf
|
popf
|
||||||
ja .loop_forward
|
ja .loop_forward
|
||||||
std ; set direction flag so we can scan backwards
|
std ; set direction flag so we can scan backwards
|
||||||
|
dec esi
|
||||||
dec esi ; move our cursor just in front of newline, for scanning backwards
|
dec esi ; move our cursor just in front of newline, for scanning backwards
|
||||||
dec edx ;;;;; FIXME: this seems to be needed, but why ???
|
|
||||||
.loop_backward:
|
.loop_backward:
|
||||||
call text_nextline
|
call text_nextline
|
||||||
inc edx
|
inc edx
|
||||||
jnz .loop_backward
|
jnz .loop_backward
|
||||||
|
inc esi
|
||||||
inc esi ; move the cursor just after last newline
|
inc esi ; move the cursor just after last newline
|
||||||
cld
|
cld
|
||||||
jmp .ok
|
jmp .ok
|
||||||
@ -197,22 +201,25 @@ draw_channel_text:
|
|||||||
mov [edi + window.text_print], esi
|
mov [edi + window.text_print], esi
|
||||||
.noscroll:
|
.noscroll:
|
||||||
|
|
||||||
mov edx, [edi + window.text_print]
|
; Calculate start offset coordinates (align text to bottom)
|
||||||
; Calculate start coordinates (align text to bottom)
|
|
||||||
mov ebx, [textbox_height]
|
mov ebx, [textbox_height]
|
||||||
sub ebx, [edi + window.text_lines]
|
sub ebx, [edi + window.text_lines]
|
||||||
jae @f
|
jb .no_offset
|
||||||
xor ebx, ebx
|
|
||||||
@@:
|
|
||||||
imul ebx, FONT_HEIGHT
|
imul ebx, FONT_HEIGHT
|
||||||
add ebx, TEXT_X shl 16 + TEXT_Y
|
push [edi + window.text_start]
|
||||||
|
pop [edi + window.text_print]
|
||||||
|
jmp .draw_text
|
||||||
|
.no_offset:
|
||||||
|
xor ebx, ebx
|
||||||
|
.draw_text:
|
||||||
; Prepare to actually draw some text
|
; Prepare to actually draw some text
|
||||||
mov eax, [textbox_height] ; max number of lines to draw
|
mov eax, [textbox_height] ; max number of lines to draw
|
||||||
|
add ebx, TEXT_X shl 16 + TEXT_Y
|
||||||
mov ecx, [colors.work_text] ; default text color
|
mov ecx, [colors.work_text] ; default text color
|
||||||
|
mov edx, [edi + window.text_print]
|
||||||
.drawloop:
|
.drawloop:
|
||||||
cmp byte[edx], 0
|
cmp byte[edx], 0
|
||||||
je .end
|
je .end_of_text
|
||||||
|
|
||||||
; Clear one row of characters
|
; Clear one row of characters
|
||||||
pusha
|
pusha
|
||||||
@ -230,7 +237,7 @@ draw_channel_text:
|
|||||||
add esi, [textbox_width]
|
add esi, [textbox_width]
|
||||||
.line:
|
.line:
|
||||||
cmp byte[edx], 0
|
cmp byte[edx], 0
|
||||||
je .end
|
je .end_of_text
|
||||||
|
|
||||||
cmp byte[edx], 13
|
cmp byte[edx], 13
|
||||||
je .newline_soft
|
je .newline_soft
|
||||||
@ -274,27 +281,23 @@ draw_channel_text:
|
|||||||
add ebx, TEXT_X shl 16 + FONT_HEIGHT
|
add ebx, TEXT_X shl 16 + FONT_HEIGHT
|
||||||
dec eax
|
dec eax
|
||||||
jnz .drawloop
|
jnz .drawloop
|
||||||
|
.end_of_text:
|
||||||
|
|
||||||
; take care of the scrollbar
|
; Update and draw scrollbar when nescessary
|
||||||
.scrollbar:
|
|
||||||
mov edi, [window_active]
|
mov edi, [window_active]
|
||||||
mov edx, [edi + window.text_lines]
|
mov edx, [edi + window.text_lines]
|
||||||
cmp edx, [textbox_height]
|
cmp edx, [textbox_height]
|
||||||
ja .draw_scroll
|
jbe .scroll_done
|
||||||
mov [scroll2.position], 0 ; disable scrollbar
|
|
||||||
jmp .scroll_done
|
|
||||||
|
|
||||||
.draw_scroll:
|
|
||||||
mov [scroll2.max_area], edx
|
mov [scroll2.max_area], edx
|
||||||
mov eax, [edi + window.text_line_print]
|
mov eax, [edi + window.text_line_print]
|
||||||
mov [scroll2.position], eax
|
mov [scroll2.position], eax
|
||||||
|
|
||||||
push dword scroll2 ; redraw scrollbar
|
push dword scroll2 ; redraw scrollbar
|
||||||
call [scrollbar_draw]
|
call [scrollbar_draw]
|
||||||
|
|
||||||
mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely
|
mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely
|
||||||
.scroll_done:
|
.scroll_done:
|
||||||
.end:
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -310,9 +313,8 @@ dec_to_esi:
|
|||||||
cmp al, 9
|
cmp al, 9
|
||||||
ja .done
|
ja .done
|
||||||
inc edx
|
inc edx
|
||||||
shl esi, 1 ; esi * 2
|
lea esi, [esi*4 + esi] ; esi * 5
|
||||||
lea esi, [esi + 4*esi] ; esi * 5
|
lea esi, [esi*2 + eax] ; esi * 2 + eax
|
||||||
add esi, eax
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.done:
|
.done:
|
||||||
cmp esi, 16
|
cmp esi, 16
|
||||||
|
@ -37,7 +37,7 @@ window_create_textbox:
|
|||||||
mov [ebx + window.data_ptr], eax
|
mov [ebx + window.data_ptr], eax
|
||||||
mov [ebx + window.flags], 0
|
mov [ebx + window.flags], 0
|
||||||
|
|
||||||
add eax, window_data.text+1 ; let text begin at offset 1, this way the text will be prepended with a 0
|
add eax, window_data.text+2 ; let text begin at offset 2, this way the text will be prepended with two null bytes
|
||||||
mov [ebx + window.text_start], eax
|
mov [ebx + window.text_start], eax
|
||||||
mov [ebx + window.text_print], eax
|
mov [ebx + window.text_print], eax
|
||||||
mov [ebx + window.text_write], eax
|
mov [ebx + window.text_write], eax
|
||||||
|
Loading…
Reference in New Issue
Block a user