refactored multiline textbox and moved to a separate file.

git-svn-id: svn://kolibrios.org@4060 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-10-20 18:47:47 +00:00
parent b84e1d0e74
commit 00b0341730
6 changed files with 132 additions and 206 deletions

View File

@ -130,103 +130,6 @@ get_byte_utf8:
print_character:
pusha
cmp bl, 13 ; line beginning
jne nobol
mov ecx, [pos]
inc ecx
boll1:
dec ecx
mov eax, ecx
xor edx, edx
mov ebx, [textbox_width]
div ebx
test edx, edx
jnz boll1
mov [pos], ecx
jmp newdata
nobol:
cmp bl, 10 ; line down
jne nolf
addx1:
inc [pos]
mov eax, [pos]
xor edx, edx
mov ecx, [textbox_width]
div ecx
test edx, edx
jnz addx1
mov eax, [pos]
jmp cm1
nolf:
no_lf_ret:
cmp bl, 15 ; character
jbe newdata
mov eax, [irc_data]
shl eax, 8
mov al, bl
mov [irc_data], eax
mov eax, [pos]
;---- draw data
pusha
and ebx, 0xff
add eax, [text_start]
mov [eax], bl
popa
;---- draw data
mov eax, [pos]
inc eax
cm1:
mov ebx, [scroll+4]
imul ebx, [textbox_width]
cmp eax, ebx
jb noeaxz
mov esi, [text_start]
add esi, [textbox_width]
mov edi, [text_start]
mov ecx, ebx
rep movsb
mov esi, [text_start]
mov ecx, [textbox_width]
imul ecx, 61
add esi, ecx
mov edi, [text_start]
mov ecx, [textbox_width]
imul ecx, 60
add edi, ecx
mov ecx, ebx
rep movsb
mov eax, ebx
sub eax, [textbox_width]
noeaxz:
mov [pos], eax
newdata:
call window_is_updated
popa
ret
recode_to_cp866: recode_to_cp866:
rep movsb rep movsb
ret ret

View File

@ -225,68 +225,6 @@ print_channel_list:
ret ret
draw_channel_text:
pusha
mov eax, 4 ; draw text
mov ebx, TEXT_X shl 16 + TEXT_Y
mov ecx, 12 ; 12 lines max ?
mov esi, [textbox_width]
.dct:
pusha
mov cx, bx
shl ecx, 16
mov cx, 9 ; character height
mov eax, 13 ; draw rectangle
mov ebx, TEXT_X shl 16
mov bx, word[textbox_width]
imul bx, 6 ; character width
mov edx, [colors.work]
mcall
popa
push ecx
mov ecx, [colors.work_text]
cmp word[edx], '* '
jne .no_red
mov ecx, 0x00aa0000
jmp .draw
.no_red:
cmp word[edx], '**'
jne .no_light_blue
cmp byte[edx+2], '*'
jne .no_light_blue
mov ecx, 0x000000aa
jmp .draw
.no_light_blue:
cmp byte[edx], '#'
jne .no_blue
mov ecx, 0x0000aa00
; jmp .draw
.no_blue:
.draw:
mcall
add edx, [textbox_width]
add ebx, 10 ; height distance between lines
pop ecx
loop .dct
mov eax, [window_active]
and [eax + window.flags], not FLAG_UPDATED ; clear the 'window is updated' flag
popa
ret
draw_windowtabs: draw_windowtabs:
; Create the buttons ; Create the buttons

View File

@ -73,6 +73,7 @@ SCROLLBAR_WIDTH = 12
USERLIST_X = 98 USERLIST_X = 98
TEXTBOX_LINES = 12
format binary as "" format binary as ""
@ -121,6 +122,7 @@ include "userparser.inc"
include "socket.inc" include "socket.inc"
include "gui.inc" include "gui.inc"
include "users.inc" include "users.inc"
include "textbox.inc"
START: START:
@ -163,8 +165,6 @@ START:
mov [ebx + window.data_ptr], eax mov [ebx + window.data_ptr], eax
mov [ebx + window.flags], 0 mov [ebx + window.flags], 0
mov [ebx + window.type], WINDOWTYPE_SERVER mov [ebx + window.type], WINDOWTYPE_SERVER
add eax, window_data.text
mov [text_start], eax
call window_refresh call window_refresh
@ -431,16 +431,12 @@ sockaddr1:
status dd STATUS_DISCONNECTED status dd STATUS_DISCONNECTED
text_start dd ? ; pointer to current textbox data text_start dd ? ; pointer to current textbox data
irc_data dd 0x0 ; encoder
textbox_width dd 80 ; in characters, not pixels ;) textbox_width dd 80 ; in characters, not pixels ;)
pos dd 66 * 11 ; encoder text_pos dd ? ; text writing cursor
window_active dd windows window_active dd windows
window_print dd windows window_print dd windows
scroll dd 1
dd 12
align 4 align 4
@IMPORT: @IMPORT:

View File

@ -48,7 +48,7 @@ server_commands:
dd '322 ', cmd_322 ; RPL_LIST dd '322 ', cmd_322 ; RPL_LIST
dd '323 ', cmd_323 ; RPL_LISTEND dd '323 ', cmd_323 ; RPL_LISTEND
dd '328 ', cmd_328 dd '328 ', cmd_328 ; RPL_CHANNEL_URL
dd '332 ', cmd_topic dd '332 ', cmd_topic
dd '333 ', cmd_333 ; nickname and time of topic dd '333 ', cmd_333 ; nickname and time of topic
dd '353 ', cmd_353 ; name reply dd '353 ', cmd_353 ; name reply

View File

@ -0,0 +1,123 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print_text: ; eax = start ptr
; dl = end char
pusha
ptr2:
mov bl, [eax]
cmp bl, dl
je .done
test bl, bl
jz .done
call print_character
inc eax
jmp ptr2
.done:
popa
ret
print_text2: ; esi = ptr to ASCIIZ string
pusha
.loop:
lodsb
test al, al
jz .done
mov bl, al
call print_character
jmp .loop
.done:
popa
ret
; Character in bl
print_character:
pusha
mov ecx, TEXTBOX_LINES
imul ecx, [textbox_width]
mov esi, [text_start]
cmp bl, 10 ; line down
je .linefeed
mov eax, [text_pos]
mov byte[esi + eax], bl ; write the byte
inc [text_pos]
cmp [text_pos], ecx
jb .done
.linefeed:
; scroll all text one line to the top
mov edi, esi
add esi, [textbox_width]
rep movsb
mov ecx, TEXTBOX_LINES - 1
imul ecx, [textbox_width]
mov [text_pos], ecx
.done:
call window_is_updated
popa
ret
draw_channel_text: ; edx = pointer to text
pusha
mov ebx, TEXT_X shl 16 + TEXT_Y
mov ecx, TEXTBOX_LINES
.drawloop:
pusha
mov cx, bx
shl ecx, 16
mov cx, 9 ; character height
mov ebx, TEXT_X shl 16
mov bx, word[textbox_width]
imul bx, 6 ; character width
mov edx, [colors.work]
mcall 13 ; draw rectangle
popa
push ecx
mov ecx, [colors.work_text]
.draw:
mov esi, [textbox_width]
mcall 4 ; draw text
add edx, [textbox_width]
add ebx, 10 ; height distance between lines
pop ecx
loop .drawloop
mov eax, [window_active]
and [eax + window.flags], not FLAG_UPDATED ; clear the 'window is updated' flag
popa
ret

View File

@ -65,11 +65,12 @@ window_set_name: ; esi = ptr to name, ebx = window ptr
window_refresh: window_refresh:
; set the correct buffer pointers ; FIXME: what is it good for? ; set text write cursor to beginning of last line
mov eax, [textbox_width] ; mov eax, [textbox_width]
imul eax, 11 ; imul eax, TEXTBOX_LINES - 1
mov [pos], eax ; mov [text_pos], eax
; set the textbuffer pointer
mov eax, [window_print] mov eax, [window_print]
mov eax, [eax + window.data_ptr] mov eax, [eax + window.data_ptr]
add eax, window_data.text add eax, window_data.text
@ -233,41 +234,6 @@ window_open:
ret ret
print_text: ; eax = start ptr
; dl = end char
pusha
ptr2:
mov bl, [eax]
cmp bl, dl
je ptr_ret
cmp bl, 0
je ptr_ret
call print_character
inc eax
jmp ptr2
ptr_ret:
popa
ret
print_text2: ; esi = ptr to ASCIIZ string
pusha
.loop:
lodsb
test al, al
jz .done
mov bl, al
call print_character
jmp .loop
.done:
popa
ret
if TIMESTAMP if TIMESTAMP
print_timestamp: print_timestamp: