2013-05-28 19:34:26 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-01-01 22:01:59 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
2013-05-28 19:34:26 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 15:02:08 +01:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-05-28 19:34:26 +02:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2014-01-18 16:51:43 +01: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 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
window_create_textbox:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push ebx
|
2013-05-28 19:34:26 +02:00
|
|
|
; allocate the window data block
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 68, 12, sizeof.window_data
|
|
|
|
test eax, eax
|
|
|
|
pop ebx
|
|
|
|
jz .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; fill it with all zeros
|
2016-01-01 22:01:59 +01:00
|
|
|
push eax
|
|
|
|
mov edi, eax
|
|
|
|
mov ecx, (sizeof.window_data+3)/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
mov [ebx + window.data_ptr], eax
|
|
|
|
mov [ebx + window.flags], FLAG_SCROLL_LOW
|
|
|
|
|
|
|
|
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_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-11-01 15:02:08 +01:00
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
.fail:
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
2014-01-18 16:51:43 +01: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 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
window_set_name:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
lea edi, [ebx + window.name]
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
2013-05-28 19:34:26 +02:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
cmp al, 0x21 ; name ends with 0, space or !
|
|
|
|
jbe .addzero
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
2013-05-28 19:34:26 +02:00
|
|
|
.addzero:
|
2016-01-01 22:01:59 +01:00
|
|
|
xor al, al
|
|
|
|
stosb
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push esi ebx
|
2016-01-02 22:03:09 +01:00
|
|
|
call draw_window_tabs
|
2016-01-01 22:01:59 +01:00
|
|
|
pop ebx esi
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
window_close: ; closes the 'print' window
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; Remove the window (overwrite current structure with trailing ones)
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [window_print]
|
|
|
|
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
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; Completely zero the trailing window block (there will always be one!)
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ecx, sizeof.window
|
|
|
|
xor al, al
|
|
|
|
rep stosb
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; free the window data block
|
2016-01-01 22:01:59 +01:00
|
|
|
pop ecx
|
|
|
|
mcall 68, 13
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; We closed this window so we need to show another
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [window_active]
|
|
|
|
cmp [edi + window.data_ptr], 0
|
|
|
|
jne @f
|
|
|
|
sub edi, sizeof.window
|
|
|
|
mov [window_active], edi
|
2016-01-02 22:03:09 +01:00
|
|
|
mov [window_print], edi
|
2013-10-07 16:02:05 +02:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; At last, redraw everything
|
2016-01-01 22:01:59 +01:00
|
|
|
call draw_window
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
|
2014-01-18 16:51:43 +01: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 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, windows
|
|
|
|
mov eax, MAX_WINDOWS
|
2013-11-01 15:02:08 +01:00
|
|
|
.scanloop:
|
2016-01-01 22:01:59 +01:00
|
|
|
push esi
|
|
|
|
cmp [ebx + window.type], WINDOWTYPE_NONE
|
|
|
|
je .try_next
|
|
|
|
lea edi, [ebx + window.name]
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
|
|
|
repe cmpsb
|
|
|
|
cmp byte[edi-1], 0 ; last equall character was null? yes, the strings match!
|
|
|
|
je .got_it
|
|
|
|
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 15:02:08 +01:00
|
|
|
.try_next:
|
2016-01-01 22:01:59 +01:00
|
|
|
pop esi
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec eax
|
|
|
|
jnz .scanloop
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
.got_it:
|
2016-01-01 22:01:59 +01:00
|
|
|
add esp, 4
|
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
; window_open:
|
2013-10-07 16:02:05 +02: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 16:51:43 +01:00
|
|
|
; IN: esi = ptr to ASCIIZ windowname
|
|
|
|
; OUT: esi = ptr to next parameter
|
2014-03-09 22:57:21 +01:00
|
|
|
; ebx = window ptr/0 on error
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
window_open:
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
; Skip heading spaces
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
je window_open
|
|
|
|
cmp al, ':'
|
|
|
|
je window_open
|
|
|
|
dec esi
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
|
|
|
jnz .got_it
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; create channel window - search for empty slot
|
|
|
|
.create_it:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, windows
|
|
|
|
mov ecx, MAX_WINDOWS
|
2013-10-07 16:02:05 +02:00
|
|
|
.scanloop2:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp [ebx + window.type], WINDOWTYPE_NONE
|
|
|
|
je .free_found
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .scanloop2
|
|
|
|
jmp .error
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
.free_found:
|
2016-01-01 22:01:59 +01:00
|
|
|
call window_create_textbox
|
|
|
|
test eax, eax
|
|
|
|
jz .error
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ?
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call window_set_name
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
.got_it:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
je .got_it
|
|
|
|
cmp al, ':'
|
|
|
|
je .got_it
|
|
|
|
dec esi
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [window_print], ebx
|
|
|
|
ret
|
2014-01-18 16:51:43 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
.error:
|
2016-01-01 22:01:59 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
ret
|