private chat support for IRCC

git-svn-id: svn://kolibrios.org@3337 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-03-05 20:42:09 +00:00
parent 8db8d59a28
commit 487976c4f2
4 changed files with 106 additions and 34 deletions

View File

@ -140,8 +140,7 @@ print_channel_list:
pusha pusha
; Now, draw the usernames themselves ; Now, draw the usernames themselves
mov eax, 13 ; draw rectangle (clear list) ; first, draw an invisible button
mov ebx, [xsize] mov ebx, [xsize]
sub ebx, USERLIST_X + SCROLLBAR_WIDTH sub ebx, USERLIST_X + SCROLLBAR_WIDTH
shl ebx, 16 shl ebx, 16
@ -149,18 +148,24 @@ print_channel_list:
mov bx, USERLIST_X mov bx, USERLIST_X
mov ecx, [ysize] mov ecx, [ysize]
add ecx, TEXT_Y shl 16 - (TEXT_Y + 15) ;;;;; + 10??? add ecx, TEXT_Y shl 16 - (TEXT_Y + 15) ;;;;; + 10???
mov edx, [colors.work] push ecx ebx
mcall mov edx, 50 + 1 shl 29 + 1 shl 30
mcall 8
; now draw rectangle to clear the names
pop ebx ecx
mov edx, [colors.work]
mcall 13
; now draw the names according with scrollbar position and window size
mov eax, [scroll1.position] mov eax, [scroll1.position]
xor edx, edx xor edx, edx
mov ecx, MAX_NICK_LEN mov ecx, MAX_NICK_LEN
mul ecx mul ecx
mov edx, eax mov edx, eax
mov eax, [window_open] mov eax, [window_open]
mov eax, [eax + window.data_ptr] mov ebp, [eax + window.selected]
add edx, eax add edx, [eax + window.data_ptr]
mov ebp, [eax + window_data.selected]
sub ebp, [scroll1.position] sub ebp, [scroll1.position]
add edx, window_data.names add edx, window_data.names
@ -173,8 +178,11 @@ print_channel_list:
mov edi, [ysize] ; Calculate how many names will fit on screen mov edi, [ysize] ; Calculate how many names will fit on screen
sub edi, TEXT_Y + 15 ;+ 10 ;;;;; sub edi, TEXT_Y + 15 ;+ 10 ;;;;;
.loop: .loop:
cmp byte[edx], 0 ; end of list?
je .done
dec ebp ; is this name selected? dec ebp ; is this name selected?
jnz @f jnz .nothighlight
; yes, highlight it ; yes, highlight it
pusha pusha
mov cx, bx mov cx, bx
@ -184,17 +192,24 @@ print_channel_list:
mov edx, 0x00000055 ; blue! mov edx, 0x00000055 ; blue!
mcall 13 mcall 13
popa popa
@@:
cmp byte[edx], 0 ; end of list? mov ecx, 0x8000ffff ; cyan!
je .done
mcall mcall
mov ecx, [colors.work_text]
or ecx, 0x80000000 ; ASCIIZ string
jmp .next
.nothighlight:
mcall
.next:
add edx, MAX_NICK_LEN ; next name add edx, MAX_NICK_LEN ; next name
add ebx, 10 ; height distance between lines add ebx, 10 ; height distance between lines
sub edi, 10 sub edi, 10
ja .loop ja .loop
.done:
.done:
popa popa
ret ret

View File

@ -101,13 +101,13 @@ struct window
name rb MAX_WINDOWNAME_LEN name rb MAX_WINDOWNAME_LEN
users dd ? users dd ?
users_scroll dd ? users_scroll dd ?
selected dd ? ; selected user, 0 if none selected
ends ends
struct window_data struct window_data
text rb 120*60 text rb 120*60
title rb 256 title rb 256
names rb MAX_NICK_LEN * MAX_USERS names rb MAX_NICK_LEN * MAX_USERS
selected dd ? ; selected user, 0 if none selected
usertext rb 256 usertext rb 256
usertextlen dd ? usertextlen dd ?
ends ends
@ -231,6 +231,24 @@ button:
cmp ax, 1 ; close program cmp ax, 1 ; close program
je exit je exit
cmp ax, 50
jne @f
mcall 37, 1 ; Get mouse position
sub ax, TEXT_Y
mov bl, 10
div bl
and eax, 0x000000ff
inc eax
add eax, [scroll1.position]
mov ebx, [window_open]
mov [ebx + window.selected], eax
call print_channel_list
jmp still
@@:
sub ax, WINDOW_BTN_START sub ax, WINDOW_BTN_START
jb exit jb exit

View File

@ -137,59 +137,98 @@ skip_nick:
align 4 align 4
find_window: ; esi is ptr to windowname find_window: ; esi is ptr to windowname
; TODO: if the window in question does not exist, create it ??? push esi
mov edi, esi
call compare_to_nick
jne .nochat
mov esi, servercommand+1
.nochat:
; now search for window in list ; now search for window in list
mov ebx, windows mov ebx, windows
mov [window_print], ebx ; set first window (server window) as default output window mov [window_print], ebx ; set first window (server window) as default output window
.scanloop: .scanloop:
cmp [ebx + window.data_ptr], 0 cmp [ebx + window.data_ptr], 0
je .just_skip je .create_it
push esi push esi
lea edi, [ebx + window.name] lea edi, [ebx + window.name]
mov ecx, MAX_WINDOWNAME_LEN mov ecx, MAX_WINDOWNAME_LEN
repe cmpsb repe cmpsb
pop esi
cmp byte[edi-1], 0 cmp byte[edi-1], 0
je .got_it je .got_it
pop esi
add ebx, sizeof.window add ebx, sizeof.window
; TODO: check buffer limits ? ; TODO: check buffer limits ?
jmp .scanloop jmp .scanloop
; window not found, just skip this name ; create channel window - search for empty slot
.just_skip: .create_it:
lodsb mov ebx, windows
test al, al mov ecx, MAX_WINDOWS
jz .quit .scanloop2:
cmp al, ' ' cmp [ebx + window.data_ptr], 0
jne .just_skip je .free_found
dec esi add ebx, sizeof.window
jmp .done dec ecx
jnz .scanloop2
; Error: no more available windows!
jmp .just_skip
.free_found:
push ebx
call window_create
pop ebx
test eax, eax
jz .just_skip
mov [ebx + window.data_ptr], eax
mov [ebx + window.type], WINDOWTYPE_CHAT
mov [ebx + window.flags], 0
call window_set_name
mov [window_open], ebx
mov [window_print], ebx
call window_refresh
call draw_windownames
jmp .just_skip
; found it! ; found it!
.got_it: .got_it:
add esp, 4
mov [window_print], ebx mov [window_print], ebx
dec esi call window_refresh
; now skip trailing spaces and semicolons .just_skip:
.done: pop esi
.skip1:
; skip text
lodsb lodsb
test al, al test al, al
jz .quit jz .quit
cmp al, ' ' cmp al, ' '
je .done jne .skip1
dec esi
; now skip trailing spaces and semicolons
.skip2:
lodsb
test al, al
jz .quit
cmp al, ' '
je .skip2
cmp al, ':' cmp al, ':'
je .done je .skip2
dec esi dec esi
.quit: .quit:
call window_refresh
ret ret
cmd_328: cmd_328:
cmd_421: cmd_421:
cmd_372: cmd_372:

View File

@ -46,7 +46,7 @@ window_set_name: ; esi = ptr to name, ebx = window ptr
mov ecx, MAX_WINDOWNAME_LEN mov ecx, MAX_WINDOWNAME_LEN
.loop: .loop:
lodsb lodsb
cmp al, 0x20 cmp al, 0x21
jbe .addzero jbe .addzero
stosb stosb
dec ecx dec ecx