2013-05-28 19:34:26 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
|
|
|
;; 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 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; in: window ptr in ebx
|
|
|
|
; out: eax = 0 on error
|
2013-05-28 19:34:26 +02:00
|
|
|
window_create:
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
push ebx
|
2013-05-28 19:34:26 +02:00
|
|
|
; allocate the window data block
|
|
|
|
mcall 68, 12, sizeof.window_data
|
|
|
|
test eax, eax
|
2013-11-01 15:02:08 +01:00
|
|
|
pop ebx
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
mov [ebx + window.data_ptr], eax
|
|
|
|
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
|
|
|
|
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 19:34:26 +02:00
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
window_set_name: ; esi = ptr to name, ebx = window ptr
|
|
|
|
|
|
|
|
pusha
|
|
|
|
|
|
|
|
; Skip heading spaces
|
|
|
|
.spaceloop:
|
|
|
|
cmp byte[esi], ' '
|
|
|
|
jne .done
|
|
|
|
inc esi
|
|
|
|
jmp .spaceloop
|
|
|
|
.done:
|
|
|
|
|
|
|
|
; Now copy it
|
|
|
|
lea edi, [ebx + window.name]
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
cmp al, 0x21
|
|
|
|
jbe .addzero
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
.addzero:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
call draw_windowtabs ; redraw it
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
popa
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
window_is_updated:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
mov edi, [window_print]
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp edi, [window_active]
|
|
|
|
je .skip
|
2013-05-28 19:34:26 +02:00
|
|
|
test [edi + window.flags], FLAG_UPDATED
|
|
|
|
jnz .skip
|
|
|
|
or [edi + window.flags], FLAG_UPDATED
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; TODO: make some noise
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
call draw_windowtabs ; highlight updated tabs
|
2013-05-28 19:34:26 +02:00
|
|
|
.skip:
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2013-11-01 15:02:08 +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)
|
2013-11-01 15:02:08 +01:00
|
|
|
mov edi, [window_print]
|
2013-10-07 16:02:05 +02: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 15:02:08 +01:00
|
|
|
mov [window_print], edi ;;;;;;;;
|
2013-10-07 16:02:05 +02:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; At last, redraw everything
|
|
|
|
call draw_window
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
window_find: ; esi = window name
|
|
|
|
; search for window in list
|
|
|
|
mov ebx, windows
|
|
|
|
mov [window_print], ebx ; set first window (server window) as default output window
|
|
|
|
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
|
|
|
|
cmp byte[edi-1], 0
|
|
|
|
jne .try_next
|
|
|
|
cmp byte[esi-1], 0
|
|
|
|
je .got_it
|
|
|
|
cmp byte[esi-1], 10
|
|
|
|
je .got_it
|
|
|
|
cmp byte[esi-1], 13
|
|
|
|
je .got_it
|
|
|
|
cmp byte[esi-1], ' '
|
|
|
|
je .got_it
|
|
|
|
.try_next:
|
|
|
|
pop esi
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec eax
|
|
|
|
jnz .scanloop
|
|
|
|
|
|
|
|
xor ebx, ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
.got_it:
|
|
|
|
pop esi ;;; TODO: dont reset ESI ?
|
|
|
|
mov [window_print], ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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!
|
|
|
|
;
|
|
|
|
; esi = ptr to ASCIIZ windowname
|
|
|
|
window_open:
|
|
|
|
|
|
|
|
push esi
|
|
|
|
|
|
|
|
mov edi, esi
|
|
|
|
call compare_to_nick
|
|
|
|
jne .nochat
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
.nochat:
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
|
|
|
jne .got_it
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; create channel window - search for empty slot
|
|
|
|
.create_it:
|
|
|
|
mov ebx, windows
|
|
|
|
mov ecx, MAX_WINDOWS
|
|
|
|
.scanloop2:
|
|
|
|
cmp [ebx + window.data_ptr], 0
|
|
|
|
je .free_found
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .scanloop2
|
|
|
|
; Error: no more available windows!
|
2013-11-01 15:02:08 +01:00
|
|
|
jmp .got_it ; TODO: return error
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
.free_found:
|
|
|
|
call window_create
|
|
|
|
test eax, eax
|
2013-11-01 15:02:08 +01:00
|
|
|
jz .got_it ; TODO: return error
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ?
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
call window_set_name
|
|
|
|
mov [window_print], ebx
|
|
|
|
|
|
|
|
call draw_windowtabs
|
|
|
|
|
|
|
|
.got_it:
|
|
|
|
pop esi
|
|
|
|
.skip1:
|
|
|
|
; skip text
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .quit
|
|
|
|
cmp al, ' '
|
|
|
|
jne .skip1
|
|
|
|
dec esi
|
|
|
|
; now skip trailing spaces and semicolons
|
|
|
|
.skip2:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .quit
|
|
|
|
cmp al, ' '
|
|
|
|
je .skip2
|
|
|
|
cmp al, ':'
|
|
|
|
je .skip2
|
|
|
|
dec esi
|
|
|
|
|
|
|
|
.quit:
|
2013-11-01 15:02:08 +01:00
|
|
|
ret
|