2013-05-28 21:34:26 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2014-01-18 19:51:43 +04:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
|
2013-05-28 21:34:26 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 18:02:08 +04:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-05-28 21:34:26 +04:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
; window_create_textbox
|
|
|
|
; Initialises the data structure for our multiline textbox
|
|
|
|
;
|
|
|
|
; in: window ptr in ebx
|
|
|
|
; out: eax = 0 on error
|
|
|
|
; ecx, edi = destroyed
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
window_create_textbox:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
push ebx
|
2013-05-28 21:34:26 +04:00
|
|
|
; allocate the window data block
|
|
|
|
mcall 68, 12, sizeof.window_data
|
|
|
|
test eax, eax
|
2013-11-01 18:02:08 +04:00
|
|
|
pop ebx
|
2013-05-28 21:34:26 +04:00
|
|
|
jz .fail
|
|
|
|
|
|
|
|
; fill it with all zeros
|
|
|
|
push eax
|
|
|
|
mov edi, eax
|
|
|
|
mov ecx, (sizeof.window_data+3)/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop eax
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [ebx + window.data_ptr], eax
|
|
|
|
mov [ebx + window.flags], 0
|
|
|
|
|
2014-03-08 21:31:33 +04:00
|
|
|
add eax, window_data.text+2 ; let text begin at offset 2, this way the text will be prepended with two null bytes
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [ebx + window.text_start], eax
|
|
|
|
mov [ebx + window.text_print], eax
|
|
|
|
mov [ebx + window.text_write], eax
|
|
|
|
mov [ebx + window.text_scanned], eax
|
|
|
|
mov [ebx + window.text_lines], 0
|
|
|
|
mov [ebx + window.text_line_print], 0
|
|
|
|
add eax, TEXT_BUFFERSIZE-1
|
|
|
|
mov [ebx + window.text_end], eax
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
; window_set_name
|
|
|
|
; Fills in the window name in window structure
|
|
|
|
;
|
|
|
|
; IN: esi = ptr to name
|
|
|
|
; ebx = window ptr
|
|
|
|
; OUT: esi = ptr to next parameter
|
|
|
|
; ebx = window ptr
|
|
|
|
; eax, ecx, edx, edi = destroyed
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
window_set_name:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
lea edi, [ebx + window.name]
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
|
|
|
.loop:
|
|
|
|
lodsb
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp al, 0x21 ; name ends with 0, space or !
|
2013-05-28 21:34:26 +04:00
|
|
|
jbe .addzero
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
.addzero:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
push esi ebx
|
|
|
|
call draw_windowtabs
|
|
|
|
pop ebx esi
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
window_is_updated:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov edi, [window_print]
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp edi, [window_active]
|
|
|
|
je .skip
|
2013-05-28 21:34:26 +04:00
|
|
|
test [edi + window.flags], FLAG_UPDATED
|
|
|
|
jnz .skip
|
|
|
|
or [edi + window.flags], FLAG_UPDATED
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; TODO: make some noise
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
call draw_windowtabs ; highlight updated tabs
|
2013-05-28 21:34:26 +04:00
|
|
|
.skip:
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
window_close: ; closes the 'print' window
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
; Remove the window (overwrite current structure with trailing ones)
|
2013-11-01 18:02:08 +04:00
|
|
|
mov edi, [window_print]
|
2013-10-07 18:02:05 +04:00
|
|
|
push [edi + window.data_ptr] ; remember data ptr so we can free it later
|
|
|
|
lea esi, [edi + sizeof.window]
|
|
|
|
mov ecx, windows + MAX_WINDOWS*sizeof.window
|
|
|
|
sub ecx, esi
|
|
|
|
rep movsb
|
|
|
|
|
|
|
|
; Completely zero the trailing window block (there will always be one!)
|
|
|
|
mov ecx, sizeof.window
|
|
|
|
xor al, al
|
|
|
|
rep stosb
|
|
|
|
|
|
|
|
; free the window data block
|
|
|
|
pop ecx
|
|
|
|
mcall 68, 13
|
|
|
|
|
|
|
|
; We closed this window so we need to show another
|
|
|
|
mov edi, [window_active]
|
|
|
|
cmp [edi + window.data_ptr], 0
|
|
|
|
jne @f
|
|
|
|
sub edi, sizeof.window
|
|
|
|
mov [window_active], edi
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [window_print], edi ;;;;;;;;
|
2013-10-07 18:02:05 +04:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; At last, redraw everything
|
|
|
|
call draw_window
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
; window_find:
|
|
|
|
; search for a window with given name in the window list
|
|
|
|
;
|
|
|
|
; IN: esi = ptr to start of window name
|
|
|
|
; OUT: ebx = window ptr, or 0 if none found
|
|
|
|
; esi = ptr to end of window name, if window was found
|
|
|
|
|
|
|
|
window_find:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov ebx, windows
|
|
|
|
mov eax, MAX_WINDOWS
|
|
|
|
.scanloop:
|
|
|
|
push esi
|
|
|
|
cmp [ebx + window.type], WINDOWTYPE_NONE
|
|
|
|
je .try_next
|
|
|
|
lea edi, [ebx + window.name]
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
|
|
|
repe cmpsb
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp byte[edi-1], 0 ; last equall character was null? yes, the strings match!
|
2013-11-01 18:02:08 +04:00
|
|
|
je .got_it
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp byte[edi], 0 ; we're at the end of string1.. ?
|
|
|
|
jne .try_next
|
|
|
|
cmp byte[esi], 0x21 ; and the end of string2? yes!
|
|
|
|
jbe .got_it
|
2013-11-01 18:02:08 +04:00
|
|
|
.try_next:
|
|
|
|
pop esi
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec eax
|
|
|
|
jnz .scanloop
|
|
|
|
|
|
|
|
xor ebx, ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
.got_it:
|
2014-01-18 19:51:43 +04:00
|
|
|
add esp, 4
|
2013-11-01 18:02:08 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
; window_open:
|
2013-10-07 18:02:05 +04:00
|
|
|
; open a window with a given name, if it does not exist, create it
|
|
|
|
; This procedure only affects window_print ptr, not window_active!
|
|
|
|
;
|
2014-01-18 19:51:43 +04:00
|
|
|
; IN: esi = ptr to ASCIIZ windowname
|
|
|
|
; OUT: esi = ptr to next parameter
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
window_open:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
; Skip heading spaces
|
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
je window_open
|
|
|
|
cmp al, ':'
|
|
|
|
je window_open
|
|
|
|
dec esi
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
2014-01-18 19:51:43 +04:00
|
|
|
jnz .got_it
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
; create channel window - search for empty slot
|
|
|
|
.create_it:
|
|
|
|
mov ebx, windows
|
|
|
|
mov ecx, MAX_WINDOWS
|
|
|
|
.scanloop2:
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp [ebx + window.type], WINDOWTYPE_NONE
|
2013-10-07 18:02:05 +04:00
|
|
|
je .free_found
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .scanloop2
|
2014-01-18 19:51:43 +04:00
|
|
|
jmp .error
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
.free_found:
|
2014-01-18 19:51:43 +04:00
|
|
|
call window_create_textbox
|
2013-10-07 18:02:05 +04:00
|
|
|
test eax, eax
|
2014-01-18 19:51:43 +04:00
|
|
|
jz .error
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ?
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
call window_set_name
|
|
|
|
|
|
|
|
.got_it:
|
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
2014-01-18 19:51:43 +04:00
|
|
|
je .got_it
|
2013-10-07 18:02:05 +04:00
|
|
|
cmp al, ':'
|
2014-01-18 19:51:43 +04:00
|
|
|
je .got_it
|
2013-10-07 18:02:05 +04:00
|
|
|
dec esi
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
mov [window_print], ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
.error: ; TODO: return error?
|
2013-11-01 18:02:08 +04:00
|
|
|
ret
|