kfar: mouse work on panels in viewer, editor; optimize code

picdev: new macros load_lib

git-svn-id: svn://kolibrios.org@9066 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-07-14 11:12:06 +00:00
parent 760c9f36c4
commit 753473ae47
2 changed files with 180 additions and 79 deletions

View File

@ -814,8 +814,6 @@ key:
align 16
mouse:
cmp dword[active_screen],0
jg event
mov eax,SF_MOUSE_GET
mov ebx,SSF_BUTTON_EXT
int 0x40
@ -837,17 +835,19 @@ mouse:
mov bx, font_height
div bx
movzx edx,ax
dec edx ;¢¥àå­ïï à ¬ª 
dec edx ;§ £®«®¢ª¨
shr eax,16
cmp edx, 0
jl .no_ch_pos
mov ebx, [cur_height]
sub ebx, 3
dec ebx
cmp edx, ebx
je .on_panel
sub ebx, 7-3
cmp dword[active_screen],0
jg event ;.on_edit
cmp edx, 2
jl .no_ch_pos
dec edx ;¢¥àå­ïï à ¬ª 
dec edx ;§ £®«®¢ª¨
sub ebx, 7-1
cmp edx, ebx
jge .no_ch_pos
@ -912,13 +912,57 @@ end if
align 4
.on_panel:
call get_keybar_ind
lea eax, [panels_mouse+4*eax]
lea eax, [mouse_panels+4*eax]
cmp [active_screen_keybar], keybar_viewer
jne @f
add eax, mouse_viewer-mouse_panels
@@:
cmp [active_screen_keybar], keybar_editor
jne @f
add eax, mouse_editor-mouse_panels
@@:
cmp dword[eax], 0
je event
mov ebx, [active_screen]
mov ebp, [screens]
mov ebp, [ebp+ebx*8+4]
cmp dword[active_screen],0
jne @f
mov ebp, [active_panel]
mov ecx, [ebp + PanelData.index]
call dword[eax]
@@:
push dword[eax]
sub eax, mouse_panels
shr eax, 2
xor edx, edx
mov ebx, 12
div ebx
lea eax, [edx+0x3B] ;eax - ª®¤ ª« ¢¨è¨ F1...F12
pop ebx
call ebx
jmp event
if 0 ;not work insert text
align 4
.on_edit:
cmp [active_screen_keybar], keybar_editor
jne event
cmp edx, 1
jl event
push edx
xor edx, edx
mov ebx, font_width
div ebx
pop edx
mov ebx, [active_screen]
mov ebp, [screens]
mov ebp, [ebp+ebx*8+4]
mov [ebp + editor_data.cursor_x], eax
mov [ebp + editor_data.cursor_y], edx
call editor_OnRedraw
jmp event
end if
;input:
; eax - coord x
@ -983,22 +1027,6 @@ get_keybar_ind:
pop edi esi edx ecx ebx
ret
align 4
OnMouse_ctrl_f3_9:
sub eax, panels_mouse.ctrl+8
shr eax, 2
add eax, 0x3D
call panels_OnKey.ctrl_f3_9
ret
align 4
OnMouse_alt_f1_2:
sub eax, panels_mouse.alt
shr eax, 2
add eax, 0x3B
call panels_OnKey.alt_f1_2
ret
align 16
process_ctrl_keys:
cmp byte [esi], 0
@ -5744,6 +5772,7 @@ sort_files:
mov [bSilentFolderMode], 0 ; leave silent mode
ret
align 4
highlight_init:
pushad
mov ebp, eax
@ -5812,6 +5841,7 @@ highlight_init:
popad
ret
align 4
compare_name:
test byte [esi], 10h
jnz .1dir
@ -5853,6 +5883,7 @@ compare_name_rev:
stc
ret
align 4
strcmpi:
push eax
@@:
@ -5866,6 +5897,7 @@ strcmpi:
pop eax
ret
align 4
compare_ext:
test byte [esi], 10h
jnz .1dir
@ -5897,6 +5929,7 @@ compare_ext:
stc
ret
align 4
compare_ext_rev:
test byte [esi], 10h
jnz .1dir
@ -5928,6 +5961,7 @@ compare_ext_rev:
stc
ret
align 4
seek_ext:
push eax
xor eax, eax
@ -5947,6 +5981,7 @@ seek_ext:
pop eax
ret
align 4
compare_modified:
test byte [esi], 10h
jnz .1dir
@ -5979,6 +6014,7 @@ compare_modified:
stc
ret
align 4
compare_modified_rev:
test byte [esi], 10h
jnz .1dir
@ -6012,6 +6048,7 @@ compare_modified_rev:
stc
ret
align 4
compare_size:
test byte [esi], 10h
jnz .1dir
@ -6044,6 +6081,7 @@ compare_size:
stc
ret
align 4
compare_size_rev:
test byte [esi], 10h
jnz .1dir
@ -6077,6 +6115,7 @@ compare_size_rev:
stc
ret
align 4
compare_unordered:
cmp esi, edi
ret
@ -6084,6 +6123,7 @@ compare_unordered_rev:
cmp edi, esi
ret
align 4
compare_created:
test byte [esi], 10h
jnz .1dir
@ -6116,6 +6156,7 @@ compare_created:
stc
ret
align 4
compare_created_rev:
test byte [esi], 10h
jnz .1dir
@ -6149,6 +6190,7 @@ compare_created_rev:
stc
ret
align 4
compare_accessed:
test byte [esi], 10h
jnz .1dir
@ -6181,6 +6223,7 @@ compare_accessed:
stc
ret
align 4
compare_accessed_rev:
test byte [esi], 10h
jnz .1dir
@ -6214,6 +6257,7 @@ compare_accessed_rev:
stc
ret
align 4
ReadFolder_default:
mov eax, 2
ret 10h
@ -7555,8 +7599,9 @@ scan2ascii:
db 'dfghjkl;',27h,'`',0,'\zxcv'
db 'bnm,./',0,0,0,' ',0,0,0,0,0,0
;â ¡«¨æë ä㭪権: mouse_panels, mouse_viewer ¨ mouse_editor ¤®«¦­ë ¡ëâì à冷¬ ¤àã£ á ¤à㣮¬
align 4
panels_mouse:
mouse_panels:
dd 0 ;f1
dd 0 ;f2
dd panels_OnKey.f3
@ -7565,7 +7610,9 @@ panels_mouse:
dd 0 ;f6
dd panels_OnKey.f7
dd panels_OnKey.f8
dd 0,0,0 ;f9-f11
dd 0
dd exit ;f10
dd 0
dd F12
; Shift
rd 4
@ -7574,14 +7621,14 @@ panels_mouse:
.ctrl:
rd 2
repeat 9-3+1
dd OnMouse_ctrl_f3_9
dd panels_OnKey.ctrl_f3_9
end repeat
rd 3
; Ctrl+Shift
rd 12
.alt:
dd OnMouse_alt_f1_2
dd OnMouse_alt_f1_2
dd panels_OnKey.alt_f1_2
dd panels_OnKey.alt_f1_2
rd 4
dd panels_OnKey.alt_f7
rd 5
@ -7592,6 +7639,61 @@ end repeat
; Alt+Ctrl+Shift
rd 12
mouse_viewer:
rd 1
dd viewer_OnKey.f2
dd viewer_OnKey.exit ;f3
dd viewer_OnKey.f4
rd 2
dd viewer_OnKey.f7
dd viewer_OnKey.f8
rd 1
dd viewer_OnKey.exit ;f10
rd 1
dd F12
; Shift
rd 6
dd viewer_OnKey.shift_f7
rd 5
; Ctrl
rd 12
; Ctrl+Shift
rd 12
; Alt
rd 12
; Alt+Shift
rd 12
; Alt+Ctrl
rd 12
; Alt+Ctrl+Shift
rd 12
mouse_editor:
rd 1
dd editor_OnKey.f2
rd 4
dd editor_OnKey.f7
rd 2
dd editor_OnKey.exit_confirm ;f10
rd 1
dd F12
; Shift
rd 6
dd editor_OnKey.shift_f7
rd 5
; Ctrl
rd 12
; Ctrl+Shift
rd 12
; Alt
rd 12
; Alt+Shift
rd 12
; Alt+Ctrl
rd 12
; Alt+Ctrl+Shift
rd 12
; Š« ¢¨è­ë¥ á®ç¥â ­¨ï
; db scancode, reserved
; dw ctrlstate

View File

@ -26,18 +26,19 @@
dd IM_END ; size of image
dd I_END ; memory for app
dd stacktop ; esp
dd 0 ; I_Param
dd file_name ; I_Param
dd path ; APPLICATION PATH
;-----------------------------------------------------------------------------
include 'lang.inc' ;language support
include '../../../KOSfuncs.inc'
include '../../../macros.inc'
include '../../../develop/libraries/box_lib/load_lib.mac'
include '../../../load_lib.mac'
;-----------------------------------------------------------------------------
@use_library ; load_lib macro
;-----------------------------------------------------------------------------
START:
mcall 68,11
mcall 66,1,1
mcall SF_SYS_MISC,SSF_HEAP_INIT
mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1
;-----------------------------------------------------------------------------
load_libraries l_libs_start,end_l_libs
;-----------------------------------------------------------------------------
@ -49,12 +50,13 @@ load_libraries l_libs_start,end_l_libs
mov esi,start_temp_file_name
call copy_file_name_path
;-----------------------------------------------------------------------------
mcall 68,12,4096*4 ; 16 Kb - I hope this will be enough for store of data
mcall SF_SYS_MISC,SSF_MEM_ALLOC,4096*4 ; 16 Kb - I hope this will be enough for store of data
mov [store_text_area_start],eax
;-----------------------------------------------------------------------------
call draw_window
align 4
still:
mcall 10 ; wait here for event
mcall SF_WAIT_EVENT
dec eax ; redraw request ?
jz red
dec eax ; key in buffer ?
@ -63,6 +65,7 @@ still:
jz button
jmp still
;-----------------------------------------------------------------------------
align 4
red: ; redraw
call get_window_param
mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
@ -76,8 +79,9 @@ red: ; redraw
call draw_window ; go redraw window now
jmp still
;-----------------------------------------------------------------------------
align 4
key: ; key
mcall 2 ; just read it and ignore
mcall SF_GET_KEY
cmp [extended_key],1
je .extended_key
test al, al
@ -100,14 +104,15 @@ key: ; key
je call_OpenDialog
jmp still
;-----------------------------------------------------------------------------
align 4
button: ; button
mcall 17 ; get id
mcall SF_GET_BUTTON
cmp ah,2
je call_OpenDialog
cmp ah, 1 ; button id = 1 ?
jne still
.exit:
mcall -1 ; close this program
mcall SF_TERMINATE_PROCESS
;-----------------------------------------------------------------------------
call_OpenDialog:
mov [OpenDialog_data.type],1 ; Save
@ -168,17 +173,18 @@ prepare_text_area:
ret
;-----------------------------------------------------------------------------
get_window_param:
mcall 9, Proc_Info, -1 ; window redraw requested so get
mcall SF_THREAD_INFO, Proc_Info, -1 ; window redraw requested so get
; new window coordinates and size
ret
;-----------------------------------------------------------------------------
align 4
draw_window:
call prepare_text_area
mov byte [total], 0
mcall 12, 1 ; start of draw
mcall SF_REDRAW, SSF_BEGIN_DRAW
; DRAW WINDOW
mcall 0,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title
mcall SF_CREATE_WINDOW,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title
call get_window_param
@ -186,11 +192,11 @@ draw_window:
test eax,100b
jne .end
mcall 8,<450,100>,<25,25>,2,0xC0C0C0
mcall SF_DEFINE_BUTTON,<450,100>,<25,25>,2,0xC0C0C0
shr ecx,16
mov bx,cx
add ebx,13 shl 16+4
mcall 4,,0x80000000,text_save_button
mcall SF_DRAW_TEXT,,0x80000000,text_save_button
add bx,11
mcall ,,,text_save_button.1
; Insert horizontal bars in list area
@ -243,7 +249,7 @@ draw_window:
jne @b
; Quantity of devices...
movzx ecx, byte [total] ; number to draw
mcall 47, 0x00020000,,150 * 65536 + 65, 0x224466
mcall SF_DRAW_NUMBER, 0x00020000,,150 * 65536 + 65, 0x224466
mov ebx,ecx
mov ecx,2
@ -264,7 +270,7 @@ draw_window:
call Try_MMIO
@@:
.end:
mcall 12, 2 ; end of draw
mcall SF_REDRAW, SSF_END_DRAW
ret
;-----------------------------------------------------------------------------
store_data:
@ -274,14 +280,14 @@ store_data:
sub ebx,eax
inc ebx
mov [fileinfo.size],ebx
mcall 70,fileinfo
mcall SF_FILE,fileinfo
ret
;-----------------------------------------------------------------------------
;* Gets the PCI Version and Last Bus
Get_PCI_Info:
mcall 62, 0
mcall SF_PCI, 0
mov word [PCI_Version], ax
mcall 62, 1
mcall SF_PCI, 1
mov byte [PCI_LastBus], al
;----------------------------------------------------------
;* Get all devices on PCI Bus
@ -298,7 +304,7 @@ Start_Enum:
mov bh, byte [V_Bus] ; bus of pci device
mov ch, byte [V_Dev] ; device number/function
mov cl, 0 ; offset to device/vendor id
mcall 62 ; get ID's
mcall SF_PCI ; get ID's
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
je nextDev ; check next device if nothing exists here
@ -313,31 +319,31 @@ Start_Enum:
mov bh, byte [V_Bus] ; Bus #
mov ch, byte [V_Dev] ; Device # on bus
mov cl, 0x08 ; Register to read (Get Revision)
mcall 62 ; Read it
mcall SF_PCI ; Read it
mov byte [PCI_Rev], al ; Save it
mov cl, 0x0b ; Register to read (Get class)
mcall 62 ; Read it
mcall SF_PCI ; Read it
mov byte [PCI_Class], al ; Save it
mov cl, 0x0a ; Register to read (Get Subclass)
mcall 62 ; Read it
mcall SF_PCI ; Read it
mov byte [PCI_SubClass], al; Save it
; by Mario79 august 2006
mov cl, 0x09 ; Register to read (Get Interface)
mcall 62 ; Read it
mcall SF_PCI ; Read it
mov [PCI_Interface], al ; Save it
;
; by Ghost april 2007
mov cl, 0x3c ; Register to read (Get IRQ)
@@:
mcall 62 ; Read it
mcall SF_PCI ; Read it
mov [PCI_IRQ], al ; Save it
; by CleverMouse juny 2011
mov cl, 0x0e
mcall 62
mcall SF_PCI
push eax
inc byte [total] ; one more device found
@ -375,7 +381,7 @@ Print_New_Device:
jz no_ummio_here
mov ch, byte [V_Bus]
mov cl, byte [V_Dev]
mcall 62, 11 ; detect uMMIO
mcall SF_PCI, 11 ; detect uMMIO
and ax,0x7fff
inc ax ; -1 returned?
@ -406,7 +412,7 @@ Print_New_Device:
no_ummio_here:
movzx ecx,word [PCI_Vendor] ; Pointer to number to be written
mcall 47, 0x00040100 ; Write Vendor ID
mcall SF_DRAW_NUMBER, 0x00040100 ; Write Vendor ID
call store_4_digits
@ -507,7 +513,7 @@ no_ummio_here:
.find:
mov edx, [edx - 4]
mcall 4,, 0x80000000 ; lets print the vendor Name
mcall SF_DRAW_TEXT,, 0x80000000 ; lets print the vendor Name
mov [store_text_size],42
call store_text
@ -547,7 +553,7 @@ no_ummio_here:
@@:
and ebx, 0x0000FFFF ; clear X position
or ebx, 0x24E0000 ; set X position to 590 pixels
mcall 4,, 0x80000000,, 32 ; draw the text
mcall SF_DRAW_TEXT,, 0x80000000,, 32 ; draw the text
mov [store_text_size],0
call store_text
@ -568,7 +574,7 @@ Try_MMIO:
mov bh, [MMIO_BAR]
or bx, 12 ; function 12
mov ecx, 4096 ; =1 page to map
mcall 62
mcall SF_PCI
mov [MMIO_Map], eax ; store MMIO lin.addr.
mov ecx, 0x80990022 ; print color : red
@ -579,7 +585,7 @@ Try_MMIO:
mov [bar_um+3], bh
mov ebx, [gr_pos]
mov edx, bar_um
mcall 4
mcall SF_DRAW_TEXT
jmp mmio_next_bar
@@:
@ -588,7 +594,7 @@ Try_MMIO:
mov [bar_io+3], bh
mov ebx, [gr_pos]
mov edx, bar_io
mcall 4
mcall SF_DRAW_TEXT
jmp mmio_next_bar
@@:
@ -597,14 +603,14 @@ Try_MMIO:
mov [bar_ram+3], bh
mov ebx, [gr_pos]
mov edx, bar_ram
mcall 4
mcall SF_DRAW_TEXT
jmp mmio_dump
;-----------------------------------------------------------------------------
@@:
mov ebx, [gr_pos]
mov edx, bar_rom
mcall 4
mcall SF_DRAW_TEXT
mmio_dump:
mov edx, [MMIO_Map]
@ -612,10 +618,10 @@ mmio_dump:
mov ecx, 0x099 ; dump color : blue
add ebx, 10
mov [gr_pos], ebx
mcall 4
mcall SF_DRAW_TEXT
mov ecx, [MMIO_Map] ; release the tried page
mcall 62,13
mcall SF_PCI,13
mmio_next_bar:
mov bh, [MMIO_BAR]
@ -670,7 +676,7 @@ store_text:
store_NA:
pusha
mov ebx,edx
mcall 4,,0x80000000,text_NA
mcall SF_DRAW_TEXT,,0x80000000,text_NA
mov edi,[store_text_area_end]
mov ax,[edx]
mov [edi+1],ax
@ -781,17 +787,10 @@ text_NA:
;---------------------------------------------------------------------
system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
err_message_found_lib2 db 'proc_lib.obj - Not found!',0
err_message_import2 db 'proc_lib.obj - Wrong import!',0
head_f_i:
head_f_l db 'error',0
;---------------------------------------------------------------------
l_libs_start:
library02 l_libs system_dir_ProcLib+9, path, library_path, system_dir_ProcLib, \
err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import
end_l_libs:
;---------------------------------------------------------------------