kfar: add mouse event, clean code,

t_edit: small fix

git-svn-id: svn://kolibrios.org@8932 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-06-24 11:42:00 +00:00
parent 8e0821a737
commit 1aa78952d7
2 changed files with 98 additions and 37 deletions

View File

@ -2187,8 +2187,23 @@ ted_text_colored:
@@: @@:
call ted_text_find_sel_color call ted_text_find_sel_color
cmp edx,ted_tex_1 cmp edx,ted_tex_1
jg @b
xor ax,ax
mov edx,ted_tex
.cycle0:
call ted_iterat_next
cmp edx,ted_tex_1
jle .no_colors jle .no_colors
jmp @b mov al,byte[edx+1]
or al,al
jz .cycle0
cmp ah,al
jne @f
mov byte[edx+1],0 ;᫨ﭨ¥ à冷¬ áâ®ïé¨å á«®¢ ®¤­®£® 梥â 
@@:
shl ax,8
jmp .cycle0
.no_colors: .no_colors:
pop edx eax pop edx eax
ret ret

View File

@ -15,6 +15,7 @@ max_width = 255
min_height = 8 min_height = 8
max_height = 255 max_height = 255
include '../../../KOSfuncs.inc'
include 'lang.inc' include 'lang.inc'
include 'font.inc' include 'font.inc'
include 'sort.inc' include 'sort.inc'
@ -30,6 +31,9 @@ cursor_normal_size = (font_height*15+50)/100
cursor_big_size = font_height cursor_big_size = font_height
start: start:
mov eax,SF_SET_EVENTS_MASK
mov ebx,(11b shl 30) or 100111b
int 0x40
mov edi, identical_table mov edi, identical_table
mov ecx, 0x100 mov ecx, 0x100
xor eax, eax xor eax, eax
@ -108,16 +112,16 @@ start:
stosd stosd
stosd stosd
stosb stosb
push 68 push SF_SYS_MISC
pop eax pop eax
push 11 push SSF_HEAP_INIT
pop ebx pop ebx
int 0x40 int 0x40
call init_console call init_console
call draw_window call draw_window
push 66 push SF_KEYBOARD
pop eax pop eax
push 1 push SSF_SET_INPUT_MODE
pop ebx pop ebx
mov ecx, ebx mov ecx, ebx
int 40h ; set keyboard mode to scancodes int 40h ; set keyboard mode to scancodes
@ -392,6 +396,8 @@ event:
jz redraw jz redraw
dec eax dec eax
jz key jz key
sub eax,4
jz mouse
; button - we have only one button, close ; button - we have only one button, close
exit: exit:
; close all screens ; close all screens
@ -492,7 +498,7 @@ get_event:
mov ebx, [idle_interval] mov ebx, [idle_interval]
cmp ebx, -1 cmp ebx, -1
jz .infinite jz .infinite
push 23 push SF_WAIT_EVENT_TIMEOUT
pop eax pop eax
int 40h int 40h
pop ebx pop ebx
@ -507,7 +513,7 @@ get_event:
jmp get_event jmp get_event
.infinite: .infinite:
pop ebx pop ebx
push 10 push SF_WAIT_EVENT
pop eax pop eax
int 40h int 40h
.ret: .ret:
@ -515,8 +521,8 @@ get_event:
redraw: redraw:
; query kbd state from OS ; query kbd state from OS
mov al, 66 mov al, SF_KEYBOARD
push 3 push SSF_GET_CONTROL_KEYS
pop ebx pop ebx
int 0x40 int 0x40
and eax, 0x3F and eax, 0x3F
@ -525,7 +531,7 @@ redraw:
jz @f jz @f
call draw_keybar call draw_keybar
@@: @@:
mov al, 9 mov al, SF_THREAD_INFO
mov ebx, procinfo mov ebx, procinfo
or ecx, -1 or ecx, -1
int 40h int 40h
@ -535,15 +541,15 @@ redraw:
sub eax, [skinh] sub eax, [skinh]
cmp eax, 5 cmp eax, 5
ja @f ja @f
mov al, 12 mov al, SF_REDRAW
push 1 push SSF_BEGIN_DRAW
pop ebx pop ebx
int 0x40 int 0x40
xor eax, eax xor eax, eax
; ebx, ecx, edi are ignored by function 0 after first redraw ; ebx, ecx, edi are ignored by function 0 after first redraw
mov edx, 0x53000000 mov edx, 0x53000000
int 0x40 int 0x40
mov al, 12 mov al, SF_REDRAW
inc ebx inc ebx
int 0x40 int 0x40
jmp event jmp event
@ -608,7 +614,7 @@ redraw:
test byte [ebx+70], 1 test byte [ebx+70], 1
jnz @f jnz @f
.resize: .resize:
push 67 push SF_CHANGE_WINDOW
pop eax pop eax
or ebx, -1 or ebx, -1
or ecx, -1 or ecx, -1
@ -646,9 +652,9 @@ alt_f9:
or [saved_height], -1 or [saved_height], -1
jmp redraw.resize jmp redraw.resize
@@: @@:
push 48 push SF_STYLE_SETTINGS
pop eax pop eax
push 5 push SSF_GET_SCREEN_AREA
pop ebx pop ebx
int 0x40 int 0x40
push eax push eax
@ -681,12 +687,12 @@ alt_f9:
imul esi, font_height imul esi, font_height
add esi, [skinh] add esi, [skinh]
add esi, 4 add esi, 4
push 67 push SF_CHANGE_WINDOW
pop eax pop eax
int 0x40 int 0x40
jmp redraw.resize_draw jmp redraw.resize_draw
key: key:
mov al, 2 mov al, SF_GET_KEY
int 40h int 40h
test al, al test al, al
jnz event jnz event
@ -773,6 +779,42 @@ key:
and [ctrlstate], not 0x20 and [ctrlstate], not 0x20
jmp .keybar jmp .keybar
align 16
mouse:
mov eax,SF_MOUSE_GET
mov ebx,SSF_BUTTON_EXT
int 0x40
bt eax,8
jnc event
mov eax,SF_MOUSE_GET
mov ebx,SSF_WINDOW_POSITION
int 0x40
cmp ax, word[skinh]
jl event
shr eax,16
mov ebx, [cur_width]
imul ebx, font_width/2
add ebx, 5 ;window border
cmp eax,ebx
jg @f
cmp [active_panel], panel1_data
je event
jmp .tab
@@:
cmp [active_panel], panel2_data
je event
.tab:
xor [active_panel], panel1_data xor panel2_data
call draw_cmdbar
mov ebp, [active_panel]
xor ebp, panel1_data xor panel2_data
call draw_panel
mov ebp, [active_panel]
call draw_panel
jmp event
align 16
process_ctrl_keys: process_ctrl_keys:
cmp byte [esi], 0 cmp byte [esi], 0
jz .done jz .done
@ -1812,7 +1854,7 @@ panels_OnKey:
cmp esi, 256 cmp esi, 256
ja .bigcmdline ja .bigcmdline
.cmdlinelenok: .cmdlinelenok:
push 70 push SF_FILE
pop eax pop eax
int 40h int 40h
xor esi, esi xor esi, esi
@ -1838,7 +1880,7 @@ panels_OnKey:
@@: @@:
test edx, edx test edx, edx
jz @f jz @f
push 5 push SF_SLEEP
pop eax pop eax
push 20 push 20
pop ebx pop ebx
@ -2073,7 +2115,7 @@ panels_OnKey:
xor ecx, ecx xor ecx, ecx
.drive_loop_e: .drive_loop_e:
mov byte [tmpname+1], 0 mov byte [tmpname+1], 0
push 70 push SF_FILE
pop eax pop eax
int 40h int 40h
mov ebx, dirinfo mov ebx, dirinfo
@ -2089,7 +2131,7 @@ panels_OnKey:
push [ebx+dirinfo.first-dirinfo] push [ebx+dirinfo.first-dirinfo]
and [ebx+dirinfo.first-dirinfo], 0 and [ebx+dirinfo.first-dirinfo], 0
.drive_loop_i: .drive_loop_i:
push 70 push SF_FILE
pop eax pop eax
int 40h int 40h
mov ebx, dirinfo mov ebx, dirinfo
@ -2505,7 +2547,7 @@ end if
mov dl, [edi] mov dl, [edi]
mov byte [edi], 0 mov byte [edi], 0
push eax push eax
push 70 push SF_FILE
pop eax pop eax
mov ebx, attrinfo mov ebx, attrinfo
int 0x40 int 0x40
@ -2565,7 +2607,7 @@ end if
cmp eax, 2 cmp eax, 2
jbe .docopy jbe .docopy
mov [attrinfo.attr], 0 ; assume zero attributes if error mov [attrinfo.attr], 0 ; assume zero attributes if error
push 70 push SF_FILE
pop eax pop eax
mov ebx, attrinfo mov ebx, attrinfo
int 0x40 int 0x40
@ -3651,13 +3693,13 @@ end if
ret ret
draw_window: draw_window:
push 12 push SF_REDRAW
pop eax pop eax
push 1 push SSF_BEGIN_DRAW
pop ebx pop ebx
int 40h int 40h
mov al, 48 mov al, SF_STYLE_SETTINGS
mov bl, 4 mov bl, SSF_GET_SKIN_HEIGHT
int 40h int 40h
mov [skinh], eax mov [skinh], eax
mov ebx, [cur_width] mov ebx, [cur_width]
@ -3670,7 +3712,7 @@ draw_window:
mov edx, 0x53000000 mov edx, 0x53000000
mov edi, header mov edi, header
int 40h int 40h
mov al, 13 mov al, SF_DRAW_RECT
xor edx, edx xor edx, edx
cmp [fill_width], 0 cmp [fill_width], 0
jz @f jz @f
@ -3700,7 +3742,7 @@ draw_window:
@@: @@:
; xor ecx, ecx ; xor ecx, ecx
; call draw_image ; call draw_image
mov al, 65 mov al, SF_PUT_IMAGE_EXT
mov ebx, [MemForImage] mov ebx, [MemForImage]
test ebx, ebx test ebx, ebx
jz @f jz @f
@ -3715,14 +3757,14 @@ draw_window:
xor ebp, ebp xor ebp, ebp
int 0x40 int 0x40
@@: @@:
mov al, 12 mov al, SF_REDRAW
push 2 push SSF_END_DRAW
pop ebx pop ebx
int 40h int 40h
ret ret
draw_image.nomem: draw_image.nomem:
mov al, 13 mov al, SF_DRAW_RECT
xor edx, edx xor edx, edx
mov ebx, [cur_width] mov ebx, [cur_width]
imul ebx, font_width imul ebx, font_width
@ -3731,7 +3773,7 @@ draw_image.nomem:
mov cx, word [cur_height] mov cx, word [cur_height]
imul cx, font_height imul cx, font_height
int 40h int 40h
mov al, 4 mov al, SF_DRAW_TEXT
mov ebx, 32*65536+32 mov ebx, 32*65536+32
mov ecx, 0xFFFFFF mov ecx, 0xFFFFFF
mov edx, nomem_draw mov edx, nomem_draw
@ -3930,7 +3972,7 @@ end if
shr ebp, 16 shr ebp, 16
sub esi, ebp sub esi, ebp
mov ebp, esi mov ebp, esi
push 65 push SF_PUT_IMAGE_EXT
pop eax pop eax
mov edi, console_colors mov edi, console_colors
push 8 push 8
@ -4088,6 +4130,7 @@ draw_cmdbar:
rep stosw rep stosw
ret ret
align 16
draw_border: draw_border:
push edi push edi
mov al, 0xC9 mov al, 0xC9
@ -4217,6 +4260,9 @@ GetPanelTitle_default:
mov byte [edi], 0 mov byte [edi], 0
ret 10h ret 10h
;input:
; ebp - pointer to panel1 or panel2
align 16
draw_panel: draw_panel:
mov eax, [ebp + panel1_left - panel1_data] mov eax, [ebp + panel1_left - panel1_data]
mov edx, [ebp + panel1_top - panel1_data] mov edx, [ebp + panel1_top - panel1_data]
@ -5268,7 +5314,7 @@ read_folder:
mov ebx, [ebx+4] mov ebx, [ebx+4]
jmp .read jmp .read
.native: .native:
push 70 push SF_FILE
pop eax pop eax
mov ebx, dirinfo mov ebx, dirinfo
int 40h int 40h