t_edit: new algoritm text selection

img_transform: update program

git-svn-id: svn://kolibrios.org@8036 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-06-10 14:53:12 +00:00
parent 05a05aaf23
commit 12edb27757
2 changed files with 268 additions and 91 deletions

View File

@ -1,6 +1,6 @@
; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 29.01.2019 IgorA
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 10.06.2020 IgorA
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
;input:
@ -337,8 +337,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_0:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,80 ;177 ;Down
jne @f
@ -350,8 +349,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_1:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,75 ;176 ;Left
jne @f
@ -363,8 +361,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_2:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,77 ;179 ;Right
jne @f
@ -376,8 +373,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_3:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,71 ;180 ;Home
jne @f
@ -389,8 +385,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_4:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,79 ;181 ;End
jne @f
@ -402,8 +397,7 @@ proc ted_key, edit:dword, table:dword, control:dword
stdcall ted_draw,edi
jmp @f
.no_red_5:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_sel_end
@@:
cmp ah,73 ;184 ;PageUp
jne @f
@ -412,6 +406,7 @@ proc ted_key, edit:dword, table:dword, control:dword
je @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,81 ;183 ;PageDown
jne @f
@ -632,6 +627,29 @@ proc ted_sel_start uses eax ecx
ret
endp
;input:
; edi = pointer to tedit struct
;description:
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ á­ï⨨ ¢ë¤¥«¥­¨ï
align 16
proc ted_sel_end uses eax
mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
call ted_is_select
or al,al
jz @f
xor eax,eax
mov ted_sel_x0,eax
mov ted_sel_x1,eax
mov ted_sel_y0,eax
mov ted_sel_y1,eax
stdcall ted_draw,edi
jmp .end_f
@@:
call ted_draw_main_cursor
.end_f:
ret
endp
;input:
; edi = pointer to tedit struct
;description:
@ -1396,7 +1414,7 @@ proc ted_convert_sel_text, conv_fun:dword
@@:
.end_f:
popad
mov esi,dword[conv_cou]
mov esi,[conv_cou]
ret
endp
@ -3223,56 +3241,56 @@ endp
; edi = pointer to tedit struct
align 16
proc ted_sel_key_left
cmp ted_drag_k,1
je @f
call ted_sel_start
@@:
push dx
call ted_cur_move_left
call ted_sel_move
cmp ted_drag_k,1
je @f
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp .end_f
@@:
stdcall ted_draw_cur_line,edi
.end_f:
pop dx
ret
cmp ted_drag_k,1
je @f
call ted_sel_start
@@:
push dx
call ted_cur_move_left
call ted_sel_move
cmp ted_drag_k,1
je @f
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp .end_f
@@:
stdcall ted_draw_cur_line,edi
.end_f:
pop dx
ret
endp
;input:
; edi = pointer to tedit struct
align 16
proc ted_sel_key_right
cmp ted_drag_k,1
je @f
call ted_sel_start
@@:
push dx
call ted_cur_move_right
call ted_sel_move
cmp ted_drag_k,1
je @f
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp .end_f
@@:
stdcall ted_draw_cur_line,edi
.end_f:
pop dx
ret
cmp ted_drag_k,1
je @f
call ted_sel_start
@@:
push dx
call ted_cur_move_right
call ted_sel_move
cmp ted_drag_k,1
je @f
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp .end_f
@@:
stdcall ted_draw_cur_line,edi
.end_f:
pop dx
ret
endp
;input:

View File

@ -13,7 +13,7 @@ include '../../../programs/develop/libraries/libs-dev/libimg/libimg.inc'
include '../../../programs/develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'Image transform 26.05.20',0 ;ŻŽ¤Ż¨áě ŽŞ­ 
caption db 'Image transform 10.06.20',0 ;¯®¤¯¨áì ®ª­ 
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
@ -27,6 +27,9 @@ buf2d_size_lt equ dword[edi+4] ;
buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
NAV_WND_L equ 145
NAV_WND_T equ 1
include 'select_points.inc'
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
@ -108,6 +111,7 @@ timer_funct:
pop ebx eax
cmp byte[calc],0
je still
call draw_nav_wnd
call draw_buffers
jmp still
@ -142,6 +146,12 @@ pushad
@@:
stdcall [buf2d_resize],buf_0,ebx,eax,1
call calc_nav_params
mov eax,[nav_x]
call nav_x_corect
mov [nav_x],eax
mov eax,[nav_y]
call nav_y_corect
mov [nav_y],eax
mov byte[calc],1
.end0:
@ -174,12 +184,65 @@ pushad
add edx,(25 shl 16) ;
int 0x40
call draw_nav_wnd
call draw_buffers
mcall SF_REDRAW,SSF_END_DRAW
popad
ret
;à¨á®¢ ­¨¥ ­ ¢¨£ æ¨®­­®£® ®ª­ 
align 4
proc draw_nav_wnd
cmp dword[buf_i0],0
je .end0
bt dword[nav_x_min],31
jnc .end0
bt dword[nav_y_min],31
jnc .end0
pushad
mov ebx,(NAV_WND_L shl 16)
add ebx,[nav_wnd_w]
mov ecx,(NAV_WND_T shl 16)
add ecx,[nav_wnd_h]
mcall SF_DRAW_RECT,,,0 ;¨§®¡à ¦¥­¨¥
mov ecx,[nav_wnd_zoom]
mov ebx,[nav_x]
neg ebx
sar ebx,cl
add ebx,NAV_WND_L
shl ebx,16
add ebx,[buf_0.w]
shr bx,cl
mov edx,[nav_y]
neg edx
sar edx,cl
add edx,NAV_WND_T
shl edx,16
add edx,[buf_0.h]
shr dx,cl
mov ecx,edx
mcall ,,,0x404080 ;ç áâì ¨§®¡à ¦¥­¨ï ¯®¯ ¤ îé ï ¢ ®ª­®
mov edi,sel_pt
@@:
mov ecx,[nav_wnd_zoom]
mov ebx,[edi+point2d.x]
shr ebx,cl
add ebx,NAV_WND_L
mov edx,[edi+point2d.y]
shr edx,cl
add edx,NAV_WND_T
mov ecx,edx
mcall SF_PUT_PIXEL,,,0xffff00
add edi,sizeof.point2d
cmp edi,sel_pt+4*sizeof.point2d
jl @b
popad
.end0:
ret
endp
align 4
proc draw_buffers
pushad
@ -456,6 +519,37 @@ proc buf_get_mouse_coord
ret
endp
;output:
; eax - buffer coord X (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
; ebx - buffer coord Y (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
align 4
proc nav_wnd_get_mouse_coord
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
cmp ax,NAV_WND_T
jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ y
cmp eax,NAV_WND_L shl 16
jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ x
mov ebx,eax
shr ebx,16
and eax,0xffff ;®áâ ¢«ï¥¬ ª®®à¤¨­ âã y
sub ax,NAV_WND_T
cmp eax,[nav_wnd_h]
jg .no_buf
sub bx,NAV_WND_L
cmp ebx,[nav_wnd_w]
jg .no_buf
xchg eax,ebx
jmp .end_f
.no_buf:
xor eax,eax
not eax
xor ebx,ebx
not ebx
.end_f:
ret
endp
align 4
mouse_left_d:
pushad
@ -494,7 +588,17 @@ pushad
cmp ecx,4
jl .cycle0
mov dword[sel_act],-1
jmp .end2
.end0:
call nav_wnd_get_mouse_coord
cmp eax,-1
je .end2
mov ecx,[nav_wnd_zoom]
shl eax,cl
shl ebx,cl
stdcall nav_to_point, eax,ebx
mov byte[calc],1
.end2:
popad
ret
@ -543,26 +647,12 @@ proc mouse_left_u uses eax ebx
;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥
mov eax,[nav_y]
sub eax,[mouse_down_y]
cmp eax,[nav_y_min]
jge @f
mov eax,[nav_y_min]
@@:
cmp eax,[nav_y_max]
jle @f
mov eax,[nav_y_max]
@@:
call nav_y_corect
mov [nav_y],eax
mov eax,[nav_x]
sub eax,[mouse_down_x]
cmp eax,[nav_x_min]
jge @f
mov eax,[nav_x_min]
@@:
cmp eax,[nav_x_max]
jle @f
mov eax,[nav_x_max]
@@:
call nav_x_corect
mov [nav_x],eax
.end2:
mov byte[calc],1
@ -585,7 +675,7 @@ open_file_size dd 0 ;ࠧ
;¢ëç¨á«¥­¨¥ ¯ à ¬¥â஢ ¤«ï ­ ¢¨£ æ¨¨ ¯® ¨§®¡à ¦¥­¨î
align 4
proc calc_nav_params uses eax edi
proc calc_nav_params uses eax ecx edi
mov dword[nav_x_max],0
mov edi,buf_0
mov eax,buf2d_w
@ -623,6 +713,33 @@ proc calc_nav_params uses eax edi
mov [nav_sy],edi
@@:
shr dword[nav_sy],1
xor ecx,ecx
mov eax,[buf_i0.w]
@@:
inc ecx
shr eax,1
cmp eax,100
jg @b
mov [nav_wnd_zoom],ecx
xor ecx,ecx
mov eax,[buf_i0.h]
@@:
inc ecx
shr eax,1
cmp eax,32
jg @b
cmp [nav_wnd_zoom],ecx
jg @f
mov [nav_wnd_zoom],ecx
@@:
mov ecx,[nav_wnd_zoom]
mov eax,[buf_i0.w]
shr eax,cl
mov [nav_wnd_w],eax
mov eax,[buf_i0.h]
shr eax,cl
mov [nav_wnd_h],eax
ret
endp
@ -699,23 +816,42 @@ proc but_open_file
mov edi,buf_i0
cmp buf2d_data,0
jne .end3
stdcall getNextPowerOfTwo,[ebx+8]
mov buf2d_h,eax
mov edx,eax
stdcall getNextPowerOfTwo,[ebx+4]
mov buf2d_w,eax
m2m buf2d_h,dword[ebx+8] ;+8 = image height
cmp edx,[ebx+8]
jne @f
cmp eax,[ebx+4]
jg @f
m2m buf2d_w,dword[ebx+4]
jne @f
;ᮧ¤ ­¨¥ ­®¢®£® ¨§®¡à ¦¥­¨ï ¯® ¨á室­ë¬ à §¬¥à ¬
stdcall [buf2d_create_f_img], edi,[open_file_img]
jmp .end_1
@@:
;ᮧ¤ ­¨¥ ­®¢®£® ¨§®¡à ¦¥­¨ï ¯® ¯à¥®¡à §®¢ ­­ë¬ à §¬¥à ¬
cmp eax,[ebx+4]
jge @f
mov eax,[ebx+4]
mov buf2d_w,eax
@@:
sub eax,[ebx+4]
shr eax,1
mov esi,eax
cmp edx,[ebx+8]
jge @f
mov edx,[ebx+8]
mov buf2d_h,edx
@@:
sub edx,[ebx+8]
shr edx,1
stdcall [buf2d_create], edi
mov [buf_cop.l],si
stdcall [buf2d_bit_blt], edi, esi,0, buf_cop
mov [buf_cop.t],dx
stdcall [buf2d_bit_blt], edi, esi,edx, buf_cop
jmp .end_1
.end3:
;¯à¥®¡à §®¢ ­¨¥ ᮧ¤ ­­®£® ¨§®¡à ¦¥­¨ï
stdcall getNextPowerOfTwo,[ebx+4]
cmp eax,[ebx+4]
jg @f
@ -816,13 +952,7 @@ proc nav_to_point, coord_x:dword, coord_y:dword
mov eax,[buf_0.w]
shr eax,1
sub eax,[coord_x]
cmp eax,[nav_x_min]
jge @f
mov eax,[nav_x_min]
@@:
cmp eax,[nav_x_max]
jle .end0
mov eax,[nav_x_max]
call nav_x_corect
.end0:
mov [nav_x],eax
;coord y
@ -836,17 +966,43 @@ proc nav_to_point, coord_x:dword, coord_y:dword
mov eax,[buf_0.h]
shr eax,1
sub eax,[coord_y]
call nav_y_corect
.end1:
mov [nav_y],eax
ret
endp
;input:
; eax - navigation coord x
;output:
; eax - valid coord x
align 4
nav_x_corect:
cmp eax,[nav_x_min]
jge @f
mov eax,[nav_x_min]
@@:
cmp eax,[nav_x_max]
jle @f
mov eax,[nav_x_max]
@@:
ret
;input:
; eax - navigation coord y
;output:
; eax - valid coord y
align 4
nav_y_corect:
cmp eax,[nav_y_min]
jge @f
mov eax,[nav_y_min]
@@:
cmp eax,[nav_y_max]
jle .end1
jle @f
mov eax,[nav_y_max]
.end1:
mov [nav_y],eax
@@:
ret
endp
align 4
proc getNextPowerOfTwo uses ebx, n:dword
@ -1412,6 +1568,9 @@ nav_x dd 0 ;⥪
nav_y dd 0 ;⥪ãé. ª®®à¤. y ¤«ï ­ ¢¨£ æ¨¨
nav_sx dd 0 ;áªà®« ¯® x
nav_sy dd 0 ;áªà®« ¯® y
nav_wnd_w dd 0 ;è¨à¨­  ®ª­  ­ ¢¨£ æ¨¨
nav_wnd_h dd 0 ;¢ëá® â  ®ª­  ­ ¢¨£ æ¨¨
nav_wnd_zoom dd 0
mouse_down_x dd ?
mouse_down_y dd ?
sel_act dd ? ;â®çª  ¢ë¡à ­­ ï ¤«ï । ªâ¨à®¢ ­¨ï á ª« ¢¨ âãàë