; ¬ ªà®á ¤«ï á¨á⥬®© ¡¨¡«¨®â¥ª¨ box_lib.obj
; í«¥¬¥â TextEditor ¤«ï Kolibri OS
; ä ©« ¯®á«¥¤¨© à § ¨§¬¥ï«áï 29.01.2019 IgorA
; ª®¤ ¯à¨¬¥¥ GPL2 «¨æ¥§¨ï
;input:
; edi = pointer to tedit struct
; reg = index
;output:
; reg = pointer to 'tex' struct
macro ConvertIndexToPointer reg {
imul reg,sizeof.symbol
add reg,ted_tex
}
;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
macro ColToIndexOffset ind_reg,out_reg {
mov out_reg,ind_reg
imul out_reg,sizeof.TexColViv
add out_reg,ted_key_words_data
}
TED_LINES_IN_NEW_FILE equ 30 ;ç¨á«® áâப ¢ ®¢®¬ ä ©«¥
MAX_COLOR_WORD_LEN equ 40
;------------------------------------------------------------------------------
struct TexSelect
x0 dd ?
y0 dd ?
x1 dd ?
y1 dd ?
ends
struct TexColViv
Text rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
f1 dd 0 ; á¯à ¢ª ¯® á«®¢ã
flags db ? ; f1+4 ä« £¨ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ¢ë¤¥«¥¨¨
endc db ? ; f1+5 ᨬ¢®« ª®æ ¢ë¤¥«¥¨ï (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
escc db ? ; f1+6 íªà ¨àãî騩 ᨬ¢®« (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
color db ? ; f1+7 ®¬¥à 梥â
ends
struct symbol
c db ? ; +0 ᨬ¢®«
col db ? ; +1 梥â
perv dd ? ; +2
next dd ? ; +6 㪠§ ⥫¨
tc dd ? ; +10 ¢à¥¬. á®§¤ ¨ï
td dd ? ; +14 ¢à¥¬. 㤠«¥¨ï
ends
;------------------------------------------------------------------------------
ted_symbol_space db 32 ;ascii ª®¤ ¯à®¡¥« , ¨®£¤ ¡ë¢ ¥â 㦥 ¢ ª®¤¥
ted_symbol_tab db 26 ;ascii ª®¤ áâ५ª¨ ¢¯à ¢®, ¨á¯®«ì§ã¥âáï ¤«ï à¨á®¢ ¨ï â ¡ã«ï樨 ¢ ०¨¬¥ ¯®ª § ¥¢¨¤¨¬ëå ᨬ¢®«®¢
if lang eq ru
txtRow db 'âப ',0
txtCol db ' ª',0
txtOtm db '⬥ë',0
txtBuf db 'ãä¥à:',0
else
txtRow db 'Rows',0
txtCol db 'Cols',0
txtOtm db 'Undo',0
txtBuf db 'Buffer:',0
end if
;EvChar - â ¡«¨æ ¤«ï 䨫ìâ஢ ¨ï ¤®¡ ¢«ï¥¬ëå ᨬ¢®«®¢, çâ®-¡ë ¥ ¯®¯ «¨ «¨è¨¥ § ª¨
align 16
EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
KM_SHIFT equ 0x00010000
KM_CTRL equ 0x00020000
KM_ALT equ 0x00040000
KM_NUMLOCK equ 0x00080000
; KEY CODES
KEY_F1 equ 0x0000003B
KEY_F2 equ 0x0000003C
KEY_F3 equ 0x0000003D
align 16
proc ted_init uses eax ecx edi, edit:dword
mov edi,[edit]
mov ecx,sizeof.symbol
imul ecx,ted_max_chars
invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
add eax,ecx
mov ted_tex_end,eax
stdcall ted_clear, edi,1
;-------------------------------------------------
mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ ted_arr_key_pos
add ecx,ted_syntax_file_size
invoke mem.alloc,ecx
mov ted_arr_key_pos,eax
add eax,1024
mov ted_syntax_file,eax
stdcall ted_init_scroll_bars,edi,3
ret
endp
MIN_W_SCRL_ARE equ 3 ;¬¨¨¬ «ì ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï ¢¥àâ. áªà®««¨£
MIN_H_SCRL_ARE equ 3 ;¬¨¨¬ «ì ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï £®à¨§. áªà®««¨£
;input:
; opt = 1 - ¬¥ïâì æ¢¥â áªà®««¨£®¢, 2 - ¨§¬¥¨«¨áì à §¬¥àë ®ª ,
; 4 - ¨§¬¥¨«¨áì à §¬¥àë ¤®ªã¬¥â
align 16
proc ted_init_scroll_bars, edit:dword, opt:dword
pushad
mov edi,[edit]
mov esi,ted_scr_w
mov ebx,ted_scr_h
bt dword[opt],0
jae @f
mov ecx,ted_color_wnd_work
mov dword[esi+sb_offs_bckg_col],ecx
mov dword[ebx+sb_offs_bckg_col],ecx
mov ecx,ted_color_wnd_capt
mov dword[esi+sb_offs_frnt_col],ecx
mov dword[ebx+sb_offs_frnt_col],ecx
mov ecx,ted_color_wnd_bord
mov dword[esi+sb_offs_line_col],ecx
mov dword[ebx+sb_offs_line_col],ecx
@@:
bt dword[opt],2 ; ¨§¬¥¨«¨áì à §¬¥àë ¤®ªã¬¥â ?
jae .doc_resize
call ted_get_num_lines
cmp eax,TED_LINES_IN_NEW_FILE
jge @f
mov eax,TED_LINES_IN_NEW_FILE
@@:
mov dword[esi+sb_offs_max_area],eax
.doc_resize:
bt dword[opt],1 ; ¨§¬¥¨«¨áì à §¬¥àë ®ª ?
jae .no_size
mov edx,ted_wnd_l
add edx,ted_rec_l
mov word[ebx+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠£®à¨§. áªà®««¨£
mov eax,ted_wnd_h ;calculate lines in page
mov edx,ted_wnd_t
add edx,eax
mov word[ebx+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥à娩 ®âáâ㯠£®à¨§. áªà®««¨£
sub eax,ted_rec_t
xor edx,edx
mov ecx,ted_rec_h
div ecx
cmp eax,MIN_W_SCRL_ARE
jg @f
mov eax,MIN_W_SCRL_ARE
@@:
mov dword[esi+sb_offs_cur_area],eax
mov eax,ted_wnd_w ;calculate cols in page
mov edx,ted_wnd_l ;«¥¢ë© ®âáâ㯠®ª
add edx,eax ;¤®¡ ¢«ï¥¬ è¨à¨ã ®ª
mov word[esi+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠¢¥àâ. áªà®««¨£
mov edx,ted_wnd_t
mov word[esi+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥à娩 ®âáâ㯠¢¥àâ. áªà®««¨£
mov edx,ted_wnd_h
mov word[esi+sb_offs_size_y],dx ;¢ëáâ ¢«ï¥¬ ¢ëá®âã ¢¥àâ. áªà®««¨£
sub eax,ted_rec_l
mov word[ebx+sb_offs_size_x],ax ;¢ëáâ ¢«ï¥¬ è¨à¨ã £®à¨§. áªà®««¨£
xor edx,edx
mov ecx,ted_rec_w
div ecx
cmp eax,MIN_H_SCRL_ARE
jg @f
mov eax,MIN_H_SCRL_ARE
@@:
dec eax
mov dword[ebx+sb_offs_cur_area],eax ;ãáâ ¢«¨¢ ¥¬ ç¨á«® ᨬ¢®«®¢, ª®â®àë¥ ¢« §ïâ ¢ íªà ¤«ï £®à¨§. áªà®««¨£
.no_size:
popad
ret
endp
align 16
proc ted_delete uses edi, edit:dword
mov edi,[edit]
invoke mem.free,ted_tex
invoke mem.free,ted_arr_key_pos ;ted_syntax_file
ret
endp
;input:
; eax = key kodes
align 16
proc ted_key, edit:dword, table:dword, control:dword
pushad
mov edi,[edit]
mov esi,ted_el_focus
cmp dword[esi],edi
jne .end_key_fun ;í«¥¬¥â ¥ ¢ 䮪ãᥠ¢ë室¨¬ ¨§ äãªæ¨¨
mov esi,dword[control]
cmp ah,KEY_F1 ;[F1]
jne @f
stdcall ted_show_help_f1,edi
jmp .end_key_fun
@@:
cmp ah,KEY_F3 ;[F3]
jne @f
stdcall ted_but_find,edi,0
jmp .end_key_fun
@@:
test esi,KM_CTRL ;Ctrl+...
jz .key_Ctrl
; *** ¢ë§®¢ ¢¥è¨å äãªæ¨© ª®â®àë¥ âॡãîâ ®ª ®âªàëâ¨ï/á®åà ¥¨ï/¯®¨áª /...
cmp ted_fun_on_key_ctrl_all,0
je .end0
xor al,al
cmp ah,24 ;Ctrl+O
jne @f
mov al,'O'
@@:
cmp ah,31 ;Ctrl+S
jne @f
mov al,'S'
@@:
cmp ah,33 ;Ctrl+F
jne @f
mov al,'F'
@@:
cmp ah,34 ;Ctrl+G
jne @f
mov al,'G'
@@:
cmp ah,35 ;Ctrl+H
jne @f
mov al,'H'
@@:
cmp ah,49 ;Ctrl+N
jne @f
mov al,'N'
@@:
or al,al
jz .end0
and eax,0xff
test esi,KM_SHIFT
jz @f
or eax,0x100
@@:
stdcall ted_fun_on_key_ctrl_all, eax
jmp .end_key_fun
.end0:
; *** ¢ë§®¢ ¢ãâ२å äãªæ¨©
cmp ah,30 ;Ctrl+A
jne @f
call ted_sel_all
@@:
cmp ah,44 ;Ctrl+Z
jne @f
stdcall ted_but_undo,edi
@@:
cmp ah,45 ;Ctrl+X
jne @f
stdcall ted_but_cut,edi
@@:
cmp ah,46 ;Ctrl+C
jne @f
stdcall ted_but_copy,edi
@@:
cmp ah,47 ;Ctrl+V
jne @f
stdcall ted_but_paste,edi
@@:
cmp ah,199 ;Ctrl+Home
jne @f
call ted_key_ctrl_home
@@:
cmp ah,207 ;Ctrl+End
jne @f
call ted_key_ctrl_end
@@:
jmp .end_key_fun
.key_Ctrl:
test esi,KM_SHIFT ;Shift+...
jz .key_Shift
cmp ah,72 ;Shift+Up
jne @f
call ted_sel_key_up
@@:
cmp ah,75 ;Shift+Left
jne @f
call ted_sel_key_left
@@:
cmp ah,77 ;Shift+Right
jne @f
call ted_sel_key_right
@@:
cmp ah,80 ;Shift+Down
jne @f
call ted_sel_key_down
@@:
;mov ted_drag_k,1 ; ç¨ ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
jmp .key_MoveCur
.key_Shift:
;-------------------------------------------------
cmp ah,72 ;178 ;Up
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_up
cmp dl,8
jne .no_red_0
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_0:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,80 ;177 ;Down
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_down
cmp dl,8
jne .no_red_1
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_1:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,75 ;176 ;Left
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_left
cmp dl,8
jne .no_red_2
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_2:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,77 ;179 ;Right
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_right
cmp dl,8
jne .no_red_3
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_3:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,71 ;180 ;Home
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_x_first_char
cmp dl,8
jne .no_red_4
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_4:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,79 ;181 ;End
jne @f
call ted_draw_cursor_sumb
call ted_cur_move_x_last_char
cmp dl,8
jne .no_red_5
call ted_scroll_set_redraw
stdcall ted_draw,edi
jmp @f
.no_red_5:
call ted_draw_main_cursor
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
cmp ah,73 ;184 ;PageUp
jne @f
call ted_cur_move_page_up
cmp dl,0
je @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
@@:
cmp ah,81 ;183 ;PageDown
jne @f
call ted_cur_move_page_down
cmp dl,0
je @f
call ted_scroll_set_redraw
stdcall ted_draw,edi
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
@@:
;-------------------------------------------------
.key_MoveCur:
;¨¦¥ ¯à®¯ã᪠îâáï á«ã¦¥¡ë¥ ª« ¢¨è¨, ª®â®àë¥ ¬®£ãâ ¤ ¢ âì ¬ãá®àë¥ á¨¬¢®«ë ¢ ®ª®
cmp ah,42 ;[L Shift] ª®£¤ ¦ â ¡¥§ ¤àã£¨å ª®¯®ª
je .end_key_fun
cmp ah,54 ;[R Shift] ª®£¤ ¦ â ¡¥§ ¤àã£¨å ª®¯®ª
je .end_key_fun
cmp ah,58 ;[Caps Lock]
je .end_key_fun
cmp ah,69 ;[Pause Break]
je .end_key_fun
cmp ah,120 ;[Fn]
je .end_key_fun
cmp ah,0x80 ;if key up
ja .end_key_fun
cmp dword[table],0
je @f
stdcall KeyConvertToASCII, [table]
@@:
;mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
lea edx,[EvChar] ;¡¥à¥¬ ¤à¥á â ¡«¨æë á ¤®¯ãá⨬묨 ᨬ¢®« ¬¨
add dl,ah
jae @f
add edx,0x100 ;¥á«¨ ¡ë«® ¯¥à¥¯®«¥¨¥ ¯à¨ ¤®¡ ¢«¥¨¨ ª®¤ ᨬ¢®«
@@:
cmp byte[edx],1
jne @f
mov ted_key_new,ah
call ted_set_undo
mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
stdcall ted_sel_text_del,edx
cmp al,1
jne .del
mov edx,ted_opt_ed_move_cursor
.del:
cmp ted_cur_ins,1
je .no_ins_mod
stdcall ted_text_del,edi,ted_opt_ed_change_time
mov edx,ted_opt_ed_move_cursor
.no_ins_mod:
mov ecx,edi
add ecx,ted_offs_key_new
stdcall ted_text_add,edi,ecx,1,edx ;¤®¡ ¢«ï¥¬ ᨬ¢®« ¢¢¥¤¥ë© á ª« ¢¨ âãàë
cmp ted_key_new,13
jne .dr_m_win
;¥á«¨ ¢áâ ¢¨«¨ ᨬ¢®« ®¢®© áâப¨
mov ecx,ted_scr_w
inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì®£® áªà®««¨£
mov edx,ted_cur_y
cmp edx,[ecx+sb_offs_cur_area]
jl .no_change
dec ted_cur_y ;ªãàá®à ®áâ ¢«ï¥¬ ¬¥áâ¥
inc dword[ecx+sb_offs_position] ;ᤢ¨£ ¥¬ ¯®«§ã®ª
.no_change:
stdcall ted_draw,edi
jmp .dr_cur_l
.dr_m_win:
stdcall ted_draw_cur_line,edi
.dr_cur_l:
cmp ted_fun_draw_panel_buttons,0
je @f
call ted_fun_draw_panel_buttons
@@:
cmp ah,8 ;[<-]
jne @f
call ted_set_undo
stdcall ted_sel_text_del,ted_opt_ed_change_time
cmp al,1
je .del_one_b
stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
.del_one_b:
stdcall ted_draw,edi
cmp ted_fun_draw_panel_buttons,0
je .end_key_fun
call ted_fun_draw_panel_buttons
jmp .end_key_fun
align 4
@@:
cmp ah,182 ;Delete
jne @f
call ted_set_undo
stdcall ted_sel_text_del,ted_opt_ed_change_time
cmp al,1
je .del_one_d
stdcall ted_text_del,edi,ted_opt_ed_change_time
.del_one_d:
stdcall ted_draw,edi
cmp ted_fun_draw_panel_buttons,0
je .end_key_fun
call ted_fun_draw_panel_buttons
jmp .end_key_fun
@@:
cmp ah,185 ;Ins
jne @f
call ted_draw_cursor_sumb
xor ted_cur_ins,1
call ted_draw_main_cursor
@@:
.end_key_fun:
popad
ret
endp
;output:
; al = 1 - can save
align 16
proc ted_can_save uses ecx edi, edit:dword
mov edi,[edit]
mov ecx,ted_tim_ch
sub ecx,ted_tim_undo
mov al,1
cmp ted_tim_ls,ecx
jne @f
dec al
@@:
ret
endp
;input:
; edi = pointer to tedit struct
;output:
; al = 1 - selected
align 16
proc ted_is_select uses ebx
xor al,al
cmp ted_drag_m,1
je @f
inc al
mov ebx,ted_sel_x0
cmp ebx,ted_sel_x1
jne @f
mov ebx,ted_sel_y0
cmp ebx,ted_sel_y1
jne @f
xor al,al
@@:
ret
endp
;input:
; edi = pointer to tedit struct
align 16
proc ted_sel_normalize uses ecx esi
push edi
mov esi,edi
add esi,ted_offs_sel
add edi,ted_offs_seln
mov ecx,sizeof.TexSelect/4
rep movsd
pop edi
jmp @f
.swp_f:
mov ecx,ted_seln_x0
m2m ted_seln_x0,ted_seln_x1
mov ted_seln_x1,ecx
mov ecx,ted_seln_y0
cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
jle .end_f
m2m ted_seln_y0,ted_seln_y1
mov ted_seln_y1,ecx
jmp .end_f
align 4
@@:
mov ecx,ted_seln_y0
cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
jg .swp_f
cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
jne .end_f
mov ecx,ted_seln_x0
cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
jg .swp_f
.end_f:
ret
endp
;input:
; edi = pointer to tedit struct
;description:
; ãªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ç «¥ ¢ë¤¥«¥¨ï
align 16
proc ted_sel_start uses eax ecx
mov eax,ted_scr_h
mov ecx,ted_cur_x
add ecx,[eax+sb_offs_position]
mov ted_sel_x0,ecx
mov ted_sel_x1,ecx
mov eax,ted_scr_w
mov ecx,ted_cur_y
add ecx,[eax+sb_offs_position]
mov ted_sel_y0,ecx
mov ted_sel_y1,ecx
ret
endp
;input:
; edi = pointer to tedit struct
;description:
; ãªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¯¥à¥¬¥é¥¨¨ ¢ë¤¥«¥¨ï
align 16
proc ted_sel_move
push eax ecx
mov ecx,ted_cur_x
mov eax,ted_scr_h
add ecx,[eax+sb_offs_position]
mov ted_sel_x1,ecx
mov eax,ted_scr_w
mov ecx,ted_cur_y
add ecx,[eax+sb_offs_position]
mov ted_sel_y1,ecx
pop ecx eax
cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
je @f
call ted_fun_draw_panel_buttons
@@:
ret
endp
;input:
; edi = pointer to tedit struct
;description:
; ãªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¢ë¤¥«¥¨¨ ¢á¥£® ¤®ªã¬¥â
align 16
proc ted_sel_all
push eax
xor eax,eax
mov ted_sel_x0,eax
mov ted_sel_y0,eax
mov ted_sel_x1,eax ;???
call ted_get_num_lines
mov ted_sel_y1,eax
pop eax
stdcall ted_draw,edi
cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
je @f
call ted_fun_draw_panel_buttons
@@:
ret
endp
;input:
; cl_al_mem = 1 - clear all memory
align 16
proc ted_clear uses ecx edi, edit:dword, cl_al_mem:dword
mov edi,[edit]
mov ted_cur_x,0
mov ted_cur_y,0
mov ted_tim_ch,0
mov ted_tim_ls,0
mov ted_tim_co,0
mov ted_tim_undo,0
mov ted_help_id,-1
mov ecx,sizeof.symbol
shl ecx,1
add ecx,ted_tex
mov ted_ptr_free_symb,ecx
mov ecx,ted_scr_w
mov dword[ecx+sb_offs_position],0
mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® áâப ¢¨¤¨¬ëå ¢ ®¢®¬ ¤®ªã¬¥â¥
mov dword[ecx+sb_offs_redraw],1
mov ecx,ted_scr_h
mov dword[ecx+sb_offs_position],0
mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® ᨬ¢®«®¢ ¢¨¤¨¬ëå ¢ ®¢®¬ ¤®ªã¬¥â¥
mov ted_sel_x0,0
mov ted_sel_y0,0
mov ted_sel_x1,0
mov ted_sel_y1,0
cmp dword[cl_al_mem],0
je .exit
push edx
mov ecx,sizeof.symbol
imul ecx,ted_max_chars
mov edx,ted_tex
@@:
mov byte [edx],0
inc edx
loop @b
mov edx,ted_tex
mov dword [edx+symbol.next],1
pop edx
.exit:
ret
endp
align 16
proc ted_init_syntax_file, edit:dword
pushad
mov edi,[edit]
mov ecx,0x100
mov edx,ted_arr_key_pos
@@:
mov dword[edx],-1
add edx,4
loop @b
;init: ted_colors_text_count, ted_key_words_count, ...
mov ted_colors_text_count,1
mov ted_key_words_count,0
mov ted_help_text_f1,0
mov ted_help_id,-1 ;¨¤¥â¨ä¨ª â®à á«®¢ ¤«ï á¯à ¢ª¨
mov eax,edi ;á®åà 塞 § 票¥ edi
mov esi,ted_syntax_file
add edi,ted_offs_count_colors
mov ecx,9
rep movsd
mov edi,eax ;¢®áâ ¢«¨¢ ¥¬ § 票¥ edi
mov eax,ted_syntax_file
add eax,32
mov ted_text_colors,eax
mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
lea eax,[4*eax+32]
add eax,ted_syntax_file
mov ted_key_words_data,eax
mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
xor eax,eax
@@:
ColToIndexOffset eax,edx
movzx ebx,byte[edx]
mov esi,ted_arr_key_pos
lea esi,[esi+4*ebx]
cmp dword[esi],-1
jne .no_ch_key
mov [esi],eax
.no_ch_key:
inc eax
loop @b
;init: ted_help_text_f1
mov ecx,ted_key_words_count ;ª®«¨ç¥á⢮ ª«î祢ëå á«®¢
imul ecx,sizeof.TexColViv ;à §¬¥à áâàãªâãàë á 1-¬ ª«. á«.
add ecx,ted_key_words_data ; ç «® ä ©« á ª«. á«.
mov ted_help_text_f1,ecx ;¬¥âª ¢ ¯ ¬ïâ¨, £¤¥ 稥âáï ⥪áâ á® á¯à ¢ª®©
stdcall ted_init_scroll_bars,edi,1 ;¬¥ï¥¬ 梥â áªà®««¨£®¢
.no_colors:
popad
ret
endp
;input:
; ebx = file size
; edi = pointer to tedit struct
;description:
; ãªæ¨ï ¢ë§ë¢ ¥âáï ¯à¨ ®âªàë⨨ ä ©«
align 16
proc ted_on_open_file
push eax ;destination
push ecx ;for cycle
push edx ;source
push esi
stdcall ted_clear,edi,0 ;ç¨á⨬ ¥ ¢áî ¯ ¬ïâì, ¯®â®¬ã çâ® ¨¦¥ ¡ã¤¥¬ ¥¥ § ¯®«ïâì ®¢ë¬¨ ¤ 묨
;ª®£¤ ᨬ¢®« § ¢¥à襨ï áâப¨ ⮫쪮 10 (¡¥§ 13)
mov edx,ted_tex
mov ecx,ebx
@@:
cmp byte[edx],13
je .no_10 ;¥á«¨ ©¤¥ ᨬ¢®« 13, â® 10-¥ ¨£®à¨à㥬
inc edx
loop @b
mov edx,ted_tex
mov ecx,ebx
.s_10:
cmp byte[edx],10
jne @f
mov byte[edx],13 ;¬¥ï¥¬ 10-© ᨬ¢®« ª®æ áâப¨
@@:
inc edx
loop .s_10
.no_10:
;¯¥à¥¢®¤¨¬ ®âªàëâë© ä ©« ¢ãâàì í«¥¬¥â t_edit
mov eax,ebx
mov ecx,ebx
add eax,2
ConvertIndexToPointer eax
mov edx,ted_tex
add edx,ebx
push ebx
@@:
mov ebx,[edx]
mov byte[eax],bl
mov dword[eax+symbol.perv],ecx
inc dword[eax+symbol.perv]
mov dword[eax+symbol.next],ecx
add dword[eax+symbol.next],3
;mov byte[eax+1],0 ;col=0
mov dword[eax+symbol.tc],-1
mov dword[eax+symbol.td],0
cmp ecx,0
je @f
dec ecx
dec edx
sub eax,sizeof.symbol
jmp @b
@@:
pop ebx
mov dword[eax+symbol.perv],0 ; first sumbol 'perv=0'
mov edx,ted_tex ; áâனª¨ ç «ì®£® á«ã¦¥¡®£® ᨬ¢®«
; begining sumbol 'perv=0' 'next=2'
mov dword[edx+symbol.perv],0
mov dword[edx+symbol.next],2
add edx,sizeof.symbol ; áâனª¨ ª®¥ç®£® á«ã¦¥¡®£® ᨬ¢®«
mov dword[edx+symbol.next],0 ; last sumbol 'next=0'
mov dword[edx+symbol.perv],ebx ; last sumbol 'perv=last'
inc dword[edx+symbol.perv]
mov dword[edx+symbol.tc],0 ; áâ ¢¨¬ ¢à¥¬ï á®§¤ ¨ï à ¢®¥ 0, çâ® ¡ë ᨬ¢®« ¯à ¢¨«ì® ®¡à ¡ âë¢ «áï ¯à¨ ®âªàë⨨ ä ©«®¢ ¡®«ìè¨å 28 ¡ ©â
mov edx,ebx
inc edx ;2 = rezerv sumbols
imul edx,sizeof.symbol
add edx,ted_tex
mov dword[edx+symbol.next],1 ; last sumbol 'next=1'
@@: ;clear memory, need if before was open big file
add edx,sizeof.symbol
cmp edx,ted_tex_end
jge @f
mov dword[edx+symbol.tc],0
mov dword[edx+symbol.td],0
jmp @b
@@:
call ted_get_num_lines
cmp eax,TED_LINES_IN_NEW_FILE
jge @f
mov eax,TED_LINES_IN_NEW_FILE
@@:
mov esi,ted_scr_w
mov dword[esi+sb_offs_max_area],eax
pop esi edx ecx eax
call ted_text_colored
stdcall ted_draw,edi
cmp ted_fun_draw_panel_buttons,0
je @f
call ted_fun_draw_panel_buttons
@@:
ret
endp
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;output:
; edx = pointer to 'perv' visible symbol struct
align 16
ted_iterat_perv:
cmp ted_tim_undo,0
je .else
push ebx
@@:
mov edx,[edx+symbol.perv]
or edx,edx
jz @f
imul edx,sizeof.symbol
add edx,ted_tex
call ted_symbol_not_vis
cmp bl,1
je @b
cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®« á ª®¤®¬ 10
je @b
pop ebx
ret
@@:
mov edx,ted_tex ; ç «® ä ©«
pop ebx
ret
.else:
mov edx,[edx+symbol.perv]
or edx,edx
jz @f
imul edx,sizeof.symbol
add edx,ted_tex
cmp dword[edx+symbol.td],0
jne .else
cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®« á ª®¤®¬ 10
je .else
ret
@@:
mov edx,ted_tex ; ç «® ä ©«
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;output:
; edx = pointer to 'next' visible symbol struct
align 16
ted_iterat_next:
cmp ted_tim_undo,0
je .else
push ebx
@@:
mov edx,[edx+symbol.next]
cmp edx,1
jle @f
imul edx,sizeof.symbol
add edx,ted_tex
call ted_symbol_not_vis
cmp bl,1
je @b
cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®« á ª®¤®¬ 10
je @b
pop ebx
ret
@@:
mov edx,ted_tex_1 ;ª®¥æ ä ©«
pop ebx
ret
.else:
mov edx,[edx+symbol.next]
cmp edx,1
jle @f
imul edx,sizeof.symbol
add edx,ted_tex
cmp dword[edx+symbol.td],0
jne .else
cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®« á ª®¤®¬ 10
je .else
ret
@@:
mov edx,ted_tex_1 ;ª®¥æ ä ©«
ret
;input:
; bl = symbol end of select
; bh = íªà ¨àãî騩 ᨬ¢®« (= 0 ¥á«¨ ¥â ¯à®¢¥àª¨ ¨å)
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;description:
; ©â¨ á«¥¤ãîéãî ¯®§¨æ¨î 㪠§ ®£® ᨬ¢®«
align 16
ted_iterat_next_pos_char:
push ax
mov al,1 ;¯à¥¤ë¤ã騩 ᨬ¢®«, á«ã¦¨â ¤«ï áà ¢¥¨ï á ᨬ¢®«®¬ bh
@@:
cmp bl,byte[edx]
je .found
.no_found:
cmp edx,ted_tex_1
jle @f
mov al,byte[edx]
call ted_iterat_next
jmp @b
.found:
cmp bh,al
je .no_found
@@:
call ted_iterat_next
pop ax
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
align 16
ted_iterat_perv_color_tag:
@@:
cmp byte[edx+1],0
jne @f
call ted_iterat_perv
cmp edx,ted_tex_1
jle @f
jmp @b
align 4
@@:
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
align 16
ted_iterat_next_color_tag:
@@:
call ted_iterat_next
cmp byte[edx+1],0
jne @f
cmp edx,ted_tex_1
jle @f
jmp @b
align 4
@@:
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;output:
; bl = 1 if sumbol not visible
; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
align 16
ted_symbol_not_vis:
push eax
xor bl,bl
cmp dword[edx+symbol.td],0
je @f
mov eax,[edx+symbol.td] ;eax=tex[i].td
add eax,ted_tim_undo
cmp eax,ted_tim_ch
jg @f
mov bl,1
pop eax
ret
@@:
mov eax,ted_tim_ch
sub eax,ted_tim_undo
cmp [edx+symbol.tc],eax
jle @f
or bl,1
@@:
pop eax
ret
;input:
; text - pointer to text string
; add_opt - options
align 16
proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
locals
new_spc dd ? ;count new spaces
new_lin dd ? ;count new lines
endl
;¨á¯®«ì§®¢ ¨¥ ॣ¨áâ஢ ¢ãâਠäãªæ¨¨:
;eax - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨ ⥪áâ
;ebx - ¤«ï ¢à¥¬¥ëå 㦤, ¤«¨ ¢áâ ¢«ï¥¬®£® ⥪áâ
;ecx - ¤«ï ¢à¥¬¥ëå 㦤
;edx - 㪠§ ⥫ì áâàãªâãàã ᨬ¢®«
pushad
cmp dword[t_len],1 ;¯à®¢¥à塞 ¤«¨ã ¤®¡¢«ï¥¬®£® ⥪áâ
jl .no_add ;ª®£¤ ¤«¨ <1 ¯àë£ ¥¬ ª®¥æ äãªæ¨¨, ¢® ¨§¡¥¦ ¨¥ £«îª®¢
mov edi,[edit]
mov esi,[text]
call ted_get_pos_by_cursor
call ted_get_text_perv_pos
call ted_get_text_arr_index ;eax=po_t
mov dword[new_spc],0
cmp ted_gp_opt,2
je @f
push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
mov eax,ted_scr_h
mov eax,[eax+sb_offs_position]
add eax,ted_cur_x ;eax - ®¬¥à ᨬ¢®«
mov [new_spc],eax
mov eax,ted_scr_w
mov eax,[eax+sb_offs_position]
add eax,ted_cur_y ;eax - ®¬¥à áâப¨
call ted_strlen ;ebx = line len
sub [new_spc],ebx ;®â ¯®§¨æ¨¨ ªãàá®à ®â¨¬ ¥¬ ¤«¨ã áâப¨, ã§ ¥¬ ª®««¨ç¥á⢮ ¤®¡ ¢«ï¥¬ëå ¯à®¡¥«®¢
pop eax
@@:
mov ebx,[t_len]
mov dword[new_lin],0
cmp ted_gp_opt,0
jne @f
push eax
mov eax,ted_scr_w
mov eax,[eax+sb_offs_position]
add eax,ted_cur_y
inc eax
mov [new_lin],eax
call ted_get_num_lines
sub [new_lin],eax
;㢥«¨ç¨¢ ¥¬ «¨¨¨ ¢ áªà®««¨£¥ ç¨á«® ¤®¡ ¢«¥ëå ¤®¯®«¨â¥«ìëå áâப
mov ecx,ted_scr_w
add [ecx+sb_offs_max_area],eax ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì®£® áªà®««¨£
pop eax
@@:
mov edx,ted_ptr_free_symb
.beg_cycle: ;for(i=...;i<ted_max_chars;i++)
cmp dword[edx+symbol.tc],0 ;if(!tex[i].tc && !tex[i].td)
jne .u1f
cmp dword[edx+symbol.td],0
jne .u1f
test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
jz .no_tim
inc ted_tim_ch
.no_tim:
test dword[add_opt],ted_opt_ed_move_cursor
jz .no_cur_mov
cmp dword[new_lin],0 ;¥á«¨ ¥áâì ¤®¡ ¢®çë¥ áâப¨, â® ªãàá®à ¥é¥ ¥ ¤¢¨£ ¥¬
jg .no_cur_mov
cmp dword[new_spc],0 ;¥á«¨ ¥â ¤®¡ ¢®çëå ¯à®¡¥«®¢, â® ªãàá®à ⮦¥ ¥ ¤¢¨£ ¥¬
jg .no_cur_mov
inc ted_cur_x ;move cursor
;call ted_go_to_pos
cmp byte[esi],13
jne .no_cur_mov
mov ted_cur_x,0
inc ted_cur_y
;㢥«¨ç¨¢ ¥¬ «¨¨¨ ¢ áªà®««¨£¥ ç¨á«® ¤®¡ ¢«¥ëå ¢ ⥪á⥠áâப
mov ecx,ted_scr_w
inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì®£® áªà®««¨£
.no_cur_mov:
; *** ¢áâ ¢ª ⥪ã饣® ᨬ¢®« ¨§ áâப¨ ***
mov ecx,ted_opt_ed_change_time
not ecx
and [add_opt],ecx ;n_tim=false;
mov cl,byte[esi] ;tex[i].c=ta[ns];
mov byte[edx],cl
m2m dword[edx+symbol.tc],ted_tim_ch ;tex[i].tc=ted_tim_ch;
mov [edx+symbol.perv],eax ;tex[i].perv=po_t;
mov ecx,eax
imul ecx,sizeof.symbol
add ecx,ted_tex ; *** ecx = tex[po_t] ***
add ecx,symbol.next ; *** ecx = tex[po_t].next ***
m2m dword[edx+symbol.next],dword[ecx] ;tex[i].next=tex[po_t].next;
call ted_get_text_arr_index ;*** eax = i ***
mov [ecx],eax ;tex[po_t].next=i; // áá뫪¨ ¯¥à¥ ¯à ¢«ï¥¬
mov ecx,[edx+symbol.next] ; *** ecx = tex[i].next ***
imul ecx,sizeof.symbol
add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
mov [ecx+symbol.perv],eax ;tex[tex[i].next].perv=i;
; *** ¢áâ ¢ª ¤®¯®«¨â¥«ìëå áâப ¨ ¯à®¡¥«®¢
; ¥á«¨ ªãàá®à ¢® ¢à¥¬ï ¢áâ ¢ª¨ 室¨«áï § ⥪á⮬ ***
cmp dword[new_lin],0 ;add lines or text
jle .spc_add
dec dword[new_lin]
mov byte [edx],13
jmp .u1f
.spc_add:
cmp dword[new_spc],0 ;add spaces or text
jle .tex_add
dec dword[new_spc]
mov byte [edx],' '
jmp .u1f
.tex_add:
inc esi ; ¯¥à¥å®¤ ª á«¥¤ãî饬㠢áâ ¢«ï¥¬®¬ã ᨬ¢®«ã
dec ebx
.u1f:
add edx,sizeof.symbol
cmp edx,ted_tex_end
jge @f ;out of memory
cmp ebx,0
jne .beg_cycle
mov ted_ptr_free_symb,edx ;¬¥ï¥¬ 㪠§ ⥫ì ᢮¡®¤ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª ¯ ¬ïâ¨
jmp .add_all
@@:
cmp ted_increase_size,0
je .add_all
call ted_memory_increase
cmp ebx,0
jne .beg_cycle
.add_all: ;¢á¥ ᨬ¢®«ë ¤®¡ ¢«¥ë
call ted_text_colored
.no_add:
popad
ret
endp
;input:
; edx = pointer to sumbol, when insert
; edi = pointer to tedit struct
;output:
; edx = new pointer to sumbol, when insert
align 16
proc ted_memory_increase
cmp ted_increase_size,0
je @f
push eax ebx ecx
mov ecx,ted_increase_size
add ecx,ted_max_chars
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
invoke mem.realloc, ted_tex,ecx
mov ebx,ted_tex
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
sub edx,ebx
add edx,eax
mov ted_ptr_free_symb,edx
add eax,ecx
mov ted_tex_end,eax
pop ecx ebx eax
@@:
ret
endp
;input:
; ecx = position to free insert cell
; edx = pointer to sumbol, when insert
; esi = added symbol
; edi = pointer to tedit struct
;output:
; ecx = position to inserted cell
align 16
ted_char_add:
.loop_b:
cmp ecx,ted_tex_end
jge .end_f
cmp dword[ecx+symbol.tc],0
jne @f
cmp dword[ecx+symbol.td],0
je .loop_e
@@:
add ecx,sizeof.symbol
jmp .loop_b
align 4
.loop_e:
push eax ebx
mov eax,ted_tim_ch
mov [ecx+symbol.tc],eax
mov ax,si
mov byte[ecx],al
call ted_get_text_arr_index ; *** eax=pos ***
mov [ecx+symbol.perv],eax ;tex[i].perv=pos;
m2m dword[ecx+symbol.next],dword[edx+symbol.next] ;tex[i].next=tex[pos].next;
push edx
mov edx,ecx
call ted_get_text_arr_index ; *** eax=i ***
pop edx
mov [edx+symbol.next],eax ;tex[pos].next=i; // áá뫪¨ ¯¥à¥ ¯à ¢«ï¥¬
mov ebx,[ecx+symbol.next]
ConvertIndexToPointer ebx
mov [ebx+symbol.perv],eax ;tex[tex[i].next].perv=i; // ...
pop ebx eax
.end_f:
call ted_text_colored
ret
;description:
; äãªæ¨ï ¤«ï á¬¥ë ª®¤¨à®¢®ª
;input:
; table - â ¡«¨æ ¤«ï ¯¥à¥ª®¤¨à®¢ª¨
align 16
proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword
mov edi,[edit]
mov esi,[table]
mov edx,ted_tex
.cycle:
;¯¥à¥å®¤¨¬ á«¥¤ãî騩 ᨬ¢®«
mov edx,[edx+symbol.next]
cmp edx,1
jle .end_text
imul edx,sizeof.symbol
add edx,ted_tex
movzx eax,byte[edx]
add eax,esi
mov al,byte[eax]
cmp al,0
je @f
mov byte[edx],al ;¬¥ï¥¬ ª®¤¨à®¢ªã ᨬ¢®«
@@:
jmp .cycle
.end_text:
;cmp esi,0
;je @f
stdcall ted_draw,edi ;®¡®¢«ï¥¬ ®ª®
;@@:
ret
endp
;input:
; edi = pointer to tedit struct
;output:
; esi = count converted symbols
;description:
; ãªæ¨ï ¨á¯®«ì§ã¥âáï ¤«ï ᬥë ॣ¨áâà ¢ë¡à ëå ᨬ¢®«®¢
align 16
proc ted_convert_sel_text, conv_fun:dword
locals
conv_cou dd ?
endl
mov dword[conv_cou],0
pushad
call ted_is_select
or al,al
jz .end_f
call ted_set_undo
call ted_sel_normalize
mov esi,ted_seln_x0
mov ecx,ted_seln_y0
call ted_get_pos_by_coords
mov eax,edx
mov esi,ted_seln_x1
mov ecx,ted_seln_y1
call ted_get_pos_by_coords
;call ted_get_text_perv_pos
mov ebx,edx
cmp eax,ebx
je .end_f
inc ted_tim_ch
mov edx,eax ;i=p0;
mov ecx,ted_ptr_free_symb
@@:
push eax
mov al,byte[edx]
call dword[conv_fun] ;¯à¥®¡à §®¢ ¨¥ ᨬ¢®«
mov esi,eax
cmp byte[edx],al
pop eax
je .no_change
m2m dword[edx+symbol.td],ted_tim_ch
call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
call ted_get_text_next_pos ;go to added symbol
inc dword[conv_cou]
.no_change:
call ted_iterat_next
cmp edx,ted_tex
je @f
cmp edx,ebx
jne @b
@@:
cmp dword[conv_cou],0
jne @f
dec ted_tim_ch
@@:
.end_f:
popad
mov esi,dword[conv_cou]
ret
endp
;output:
; bl = 0 - no delete
; bl = 1 - delete
align 16
proc ted_text_del uses ecx edx edi, edit:dword, del_opt:dword
mov edi,[edit]
mov ebx,[del_opt]
xor cl,cl
test ebx,ted_opt_ed_move_cursor
jz @f
call ted_cur_move_left
cmp dl,0
je .no_del
@@:
call ted_get_pos_by_cursor
cmp ted_gp_opt,1
je .no_del
test ebx,ted_opt_ed_change_time
jz @f
inc ted_tim_ch
@@:
m2m dword[edx+symbol.td], ted_tim_ch
mov cl,1
.no_del:
mov bl,cl
ret
endp
;input:
; edi = pointer to tedit struct
;output:
; al = 1 if delete
;description:
; ãªæ¨ï 㤠«ï¥â ¢ë¤¥«¥ë© ⥪áâ
align 16
proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword
call ted_is_select
or al,al
jz .end_f
call ted_sel_normalize
mov esi,ted_seln_x1
mov ecx,ted_seln_y1
call ted_get_pos_by_coords
mov ebx,edx
mov esi,ted_seln_x0
mov ecx,ted_seln_y0
call ted_get_pos_by_coords
test dword[del_opt],ted_opt_ed_change_time
jz @f
inc ted_tim_ch
@@:
cmp edx,ted_tex
je @f
cmp edx,ebx ;if(i==te)break;
je @f
m2m dword[edx+symbol.td],ted_tim_ch
mov esi,ted_opt_ed_change_time
not esi
and dword[del_opt],esi ;n_tim=false;
call ted_iterat_next
jmp @b
align 4
@@:
test dword[del_opt],ted_opt_ed_change_time
jz @f
dec ted_tim_ch
xor al,al
@@:
test dword[del_opt],ted_opt_ed_change_time
jnz @f
mov ecx,ted_seln_x0
mov edx,ted_seln_y0
call ted_go_to_pos
mov ted_sel_x0,0
mov ted_sel_y0,0
mov ted_sel_x1,0
mov ted_sel_y1,0
@@:
.end_f:
ret
endp
;input:
; eax = pointer to begin select
; ebx = pointer to end select
; edi = pointer to tedit struct
align 16
ted_revers:
cmp eax,ebx
jne @f
ret
@@:
push ecx edx
mov edx,ted_tex_1
cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
jne @f
call ted_get_text_perv_pos
mov ebx,edx
@@:
push esi
mov edx,[eax+symbol.perv] ; *** edx = tex[p0].perv ***
ConvertIndexToPointer edx
add edx,symbol.next
mov ecx,[edx] ;ecx = tex[tex[p0].perv].next
mov esi,[ebx+symbol.next] ; *** esi = tex[p1].next ***
ConvertIndexToPointer esi
add esi,symbol.perv
m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv
mov [esi],ecx ;tex[tex[p1].next].perv = ecx
pop esi
mov ecx,[eax+symbol.perv] ;ecx = tex[p0].perv
m2m dword[eax+symbol.perv],dword[ebx+symbol.next] ;tex[p0].perv = tex[p1].next
mov [ebx+symbol.next],ecx ;tex[p1].next = ecx
mov edx,eax ;i=p0;
@@:
mov ecx,[edx+symbol.next] ;ecx = tex[i].next
m2m dword[edx+symbol.next],dword[edx+symbol.perv] ;tex[i].next = tex[i].perv
mov [edx+symbol.perv],ecx ;tex[i].perv = ecx
cmp edx,ebx ;if(i==p1)break;
je @f
; ---
;cmp edx,ted_tex
;je @f
; ---
mov edx,ecx ;i = ecx
ConvertIndexToPointer edx
jmp @b
@@:
pop edx ecx
call ted_text_colored
ret
;input:
; edi = pointer to tedit struct
;output:
; dl = 0 not move
; dl = 2 if move up
; dl = 8 if scroll move up
align 16
ted_cur_move_up:
cmp ted_cur_y,0
je @f
dec ted_cur_y
mov dl,2
ret
@@:
push eax
mov eax,ted_scr_w
cmp dword[eax+sb_offs_position],0
je @f
dec dword[eax+sb_offs_position]
mov dl,8
jmp .ret_f
@@:
mov dl,0
.ret_f:
pop eax
ret
;input:
; edi = pointer to tedit struct
;output:
; dl = 0 not move
; dl = 2 if move down
; dl = 8 if scroll move down
align 16
ted_cur_move_down:
push eax ebx
mov ebx,ted_scr_w
xor dl,dl
mov eax,[ebx+sb_offs_cur_area]
dec eax
cmp ted_cur_y,eax
jge @f
inc ted_cur_y
mov dl,2
jmp .ret_f
@@:
mov eax,ted_cur_y
add eax,[ebx+sb_offs_position]
inc eax
cmp [ebx+sb_offs_max_area],eax
jle @f
inc dword[ebx+sb_offs_position]
mov dl,8
@@:
.ret_f:
pop ebx eax
ret
;input:
; edi = pointer to tedit struct
;output:
; dl = 0 not move
; dl = 1 if move up
align 16
ted_cur_move_page_up:
push eax ebx
mov ebx,ted_scr_w
mov eax,[ebx+sb_offs_cur_area]
xor dl,dl
cmp eax,[ebx+sb_offs_position]
jg @f
sub [ebx+sb_offs_position],eax
mov dl,1
@@:
cmp dword[ebx+sb_offs_position],0
je @f
cmp dl,1
je @f
mov dword[ebx+sb_offs_position],0
mov dl,1
@@:
pop ebx eax
ret
;input:
; edi = pointer to tedit struct
align 16
ted_cur_move_page_down:
push eax ebx ecx
mov ecx,ted_scr_w
xor dl,dl
mov eax,[ecx+sb_offs_max_area]
sub eax,[ecx+sb_offs_cur_area]
cmp [ecx+sb_offs_position],eax
jge @f
mov ebx,[ecx+sb_offs_cur_area]
add [ecx+sb_offs_position],ebx
mov dl,1
mov dword[ecx+sb_offs_redraw],1
cmp [ecx+sb_offs_position],eax
jle @f
mov [ecx+sb_offs_position],eax
@@:
pop ecx ebx eax
ret
;input:
; edi = pointer to tedit struct
;output:
; dl = 0 not move
; dl = 1 if move left
; dl = 3 if move left and up
; dl = 8 if scroll move up
align 16
ted_cur_move_left:
cmp ted_cur_x,0
je @f
dec ted_cur_x
mov dl,1
ret
@@:
push eax
mov eax,ted_scr_h
cmp dword[eax+sb_offs_position],0
je @f
dec dword[eax+sb_offs_position]
mov dl,8
jmp .ret_f
@@:
cmp ted_cur_y,0
jne @f
mov eax,ted_scr_w
mov dl,0
cmp dword[eax+sb_offs_position],0
je .ret_f
dec dword[eax+sb_offs_position]
call ted_scroll_set_redraw
call ted_cur_move_x_last_char
mov dl,8
jmp .ret_f
@@:
cmp ted_cur_y,0
je @f
dec ted_cur_y
call ted_cur_move_x_last_char
cmp dl,8
je .ret_f
mov dl,3
jmp .ret_f
@@:
mov dl,0
.ret_f:
pop eax
ret
;input:
; edi = pointer to tedit struct
align 16
ted_cur_move_right:
push eax ebx
mov eax,ted_scr_h
xor dl,dl
mov ebx,[eax+sb_offs_cur_area]
cmp ted_cur_x,ebx
jge @f
inc ted_cur_x
mov dl,1
jmp .ret_f
@@:
inc dword[eax+sb_offs_position]
mov dl,8
.ret_f:
pop ebx eax
ret
;input:
; edi = pointer to tedit struct
align 16
ted_cur_move_x_last_char:
;[hScr.position]
;[hScr.cur_area]
;dl-???
push eax ebx ecx
mov eax,ted_cur_y
mov ecx,ted_scr_w
add eax,[ecx+sb_offs_position]
call ted_strlen
xor dl,dl
mov ecx,ted_scr_h
cmp ebx,[ecx+sb_offs_position]
jge @f
mov dl,8
mov [ecx+sb_offs_position],ebx
@@:
sub ebx,[ecx+sb_offs_position]
cmp ebx,[ecx+sb_offs_cur_area]
jle @f ; b---[---]---e
add [ecx+sb_offs_position],ebx
mov ebx,[ecx+sb_offs_cur_area]
sub [ecx+sb_offs_position],ebx
mov dl,8
@@:
mov ted_cur_x,ebx
pop ecx ebx eax
ret
;input:
; edi = pointer to tedit struct
;output:
; dl = 0 not move
; dl = 1 move cursor
; dl = 8 move cursor and scroll
align 16
ted_cur_move_x_first_char:
xor dl,dl
cmp ted_cur_x,0
je @f
mov ted_cur_x,0
mov dl,1
@@:
push eax
mov eax,ted_scr_h
cmp dword[eax+sb_offs_position],0
je @f
mov dword[eax+sb_offs_position],0
mov dl,8
@@:
pop eax
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;output:
; eax = array index
align 16
ted_get_text_arr_index:
push ecx edx
mov eax,edx
sub eax,ted_tex
xor edx,edx
mov ecx,sizeof.symbol
div ecx
pop edx ecx
ret
;input:
; edx = pointer to symbol struct
; edi = pointer to tedit struct
;output:
; edx = pointer to 'perv' struct
align 16
ted_get_text_perv_pos:
mov edx,[edx+symbol.perv]
imul edx,sizeof.symbol
add edx,ted_tex
ret
;input:
; edx = pointer to symbol struct
;output:
; edx = pointer to 'next' symbol struct
align 16
ted_get_text_next_pos:
mov edx,[edx+symbol.next]
imul edx,sizeof.symbol
add edx,ted_tex
ret
;input:
; edi = pointer to tedit struct
;output:
; edx = symbol under cursor
; ted_gp_opt = 1,2
; edx = tex[1].perv if error
; ted_gp_opt = 0
align 16
ted_get_pos_by_cursor:
push eax ecx esi
mov esi,ted_cur_x
mov eax,ted_scr_h
add esi,[eax+sb_offs_position]
mov ecx,ted_cur_y
mov eax,ted_scr_w
add ecx,[eax+sb_offs_position]
call ted_get_pos_by_coords
pop esi ecx eax
ret
;input:
; esi = XPos
; ecx = YPos
; edi = pointer to tedit struct
;output:
; edx = symbol under cursor
; ted_gp_opt = 1 if found text line
; ted_gp_opt = 2 if found text line and column
; edx = tex[1] if error
; ted_gp_opt = 0 if text no found
align 16
proc ted_get_pos_by_coords uses eax ebx
xor eax,eax ;Row
xor ebx,ebx ;Col
mov ted_gp_opt,0
mov edx,ted_tex
@@:
call ted_iterat_next
cmp edx,ted_tex_1
jle @f
cmp ebx,esi
jne .u1_0 ;Col <> ted_cur_x
mov ted_gp_opt,1
cmp eax,ecx
jge @f ; Row >= ted_cur_y
.u1_0:
mov ted_gp_opt,0
inc ebx
cmp byte [edx],13
jne @b
cmp eax,ecx
jge @f ; Row >= ted_cur_y
inc eax
xor ebx,ebx
jmp @b
@@:
cmp eax,ecx
jne @f ; Row = ted_cur_y
inc ted_gp_opt
@@:
cmp ted_gp_opt,0
jne @f
mov edx,ted_tex_1
;call ted_get_text_perv_pos
@@:
ret
endp
;input:
; eax = Row
; edi = pointer to tedit struct
;output:
; ebx = str len
align 16
ted_strlen:
push edx ecx
;ecx = Row, from cycle
xor ebx,ebx
xor ecx,ecx
mov edx,ted_tex
@@:
call ted_iterat_next
cmp edx,ted_tex_1
jle @f
inc ebx
cmp byte [edx],13
jne @b
dec ebx ;lenght minus 1 sumbol to paragraph
cmp eax,ecx
je @f
xor ebx,ebx
inc ecx
jmp @b
@@:
cmp eax,ecx
je @f
xor ebx,ebx
@@:
pop ecx edx
ret
;input:
; edx = symbol position
; edi = pointer to tedit struct
;output:
; eax = number of line
; ebx = symbol position in line
align 16
ted_get_text_coords:
push edx
xor eax,eax
xor ebx,ebx
@@:
call ted_iterat_perv
cmp eax,0
jne .no_col_mov
inc ebx
.no_col_mov:
cmp edx,ted_tex_1
jle @f
cmp byte [edx],13
jne @b
inc eax
jmp @b
@@:
dec ebx
pop edx
ret
;input:
; edi = pointer to tedit struct
;output:
; eax = num lines
align 16
ted_get_num_lines:
push edx
mov eax,1
mov edx,ted_tex
@@:
call ted_iterat_next
cmp edx,ted_tex_1
jle @f
cmp byte[edx],13
jne @b
inc eax
jmp @b
@@:
;...
;dec eax
pop edx
ret
;input:
; edi = pointer to tedit struct
;description:
; ®â¬¥ï¥â ®â¬¥¥ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥¥¨¥¬ ¤®ªã¬¥â
align 16
proc ted_set_undo
mov ted_drag_k,0 ;§ ª 稢 ¥¬ ¢ë¤¥«¥¨¥ ®â ª« ¢¨ âãàë
cmp ted_tim_undo,1
jl .no_work
push eax ebx edx
mov edx,ted_tex
call ted_get_text_next_pos ;long i=tex[0].next;
mov eax,ted_tim_undo
sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
mov eax,ted_tim_ch
cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
jle @f
mov ted_tim_ls,0
@@:
cmp edx,ted_tex_1
jle @f
;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ á®§¤ ¨¥ ᨬ¢®« ¡ë«® ®â¬¥¥®
cmp [edx+symbol.tc],eax
jle .no_u1
mov dword[edx+symbol.tc],0
mov dword[edx+symbol.td],0
mov ebx,[edx+symbol.perv]
imul ebx,sizeof.symbol
add ebx,ted_tex ;ebx=tex[i].perv
m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next;
mov ebx,[edx+symbol.next]
imul ebx,sizeof.symbol
add ebx,ted_tex ;ebx=tex[i].next
m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv;
cmp ted_ptr_free_symb,edx
jle .no_cor_free
mov ted_ptr_free_symb,edx ;¬¥ï¥¬ 㪠§ ⥫ì ᢮¡®¤ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª ¯ ¬ïâ¨
.no_cor_free:
mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢ ted_get_text_next_pos ¡ã¤¥â à ¢¥ ebx)
jmp @b
.no_u1:
;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥¨¥ ᨬ¢®« ¡ë«® ®â¬¥¥®
cmp [edx+symbol.td],eax
jle .no_u2
mov dword[edx+symbol.td],0
.no_u2:
call ted_get_text_next_pos
jmp @b
@@:
mov ted_tim_undo,0
mov eax,ted_tim_co
cmp ted_tim_ch,eax
jge @f
mov ted_tim_co,0
@@:
pop edx ebx eax
.no_work:
ret
endp
;description:
; ¯¥à¥å®¤ 㪠§ ãî ¯®§¨æ¨î
;input:
; row = ®¬¥à áâப¨
; col = ᨬ¢®«
align 16
proc ted_go_to_position uses ecx edx edi, edit:dword, row:dword, col:dword
mov edi,[edit]
; ¯®¤£®â®¢ª áâப¨
mov edx,[row]
call ted_get_num_lines
cmp edx,eax
jle @f
mov edx,eax ;®£à ¨ç¥¨¥ ¯® áâப¥ max
@@:
dec edx
cmp edx,0
jge @f
xor edx,edx ;®£à ¨ç¥¨¥ ¯® áâப¥ min
@@:
; ¯®¤£®â®¢ª ᨬ¢®«
mov ecx,[col]
dec ecx
cmp ecx,0
jge @f
xor ecx,ecx
@@:
call ted_go_to_pos
stdcall ted_draw,edi
ret
endp
;input:
; ecx = Col
; edx = Row
; edi = pointer to tedit struct
;output:
; ecx = cursor x
; edx = cursor y
align 16
ted_go_to_pos:
push eax ebx
mov eax,ted_scr_h
sub ecx,[eax+sb_offs_position]
cmp ecx,0 ;ted_cur_x < 0
jge @f
add [eax+sb_offs_position],ecx ;¯à®ªàã⪠áªà®««¨£ ¢«¥¢®
xor ecx,ecx
@@:
mov ebx,5 ;5 - ¦¥« ¥¬ë© ®âáâ㯠᫥¢
cmp ecx,ebx
jge .end0
sub ebx,ecx ;ebx - ᪮«ìª® ᨬ¢®«®¢ 㦮 ᤢ¨ãâì ªãàá®à
cmp [eax+sb_offs_position],ebx
jge @f
add ecx,[eax+sb_offs_position]
mov dword[eax+sb_offs_position],0
jmp .end0
@@:
sub [eax+sb_offs_position],ebx
add ecx,ebx
.end0:
cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area]
jl .end1
mov ebx,ecx
sub ebx,[eax+sb_offs_cur_area]
inc ebx
add [eax+sb_offs_position],ebx ;¯à®ªàã⪠áªà®««¨£ ¢¯à ¢®
sub ecx,ebx
.end1:
mov ted_cur_x,ecx
mov eax,ted_scr_w
sub edx,[eax+sb_offs_position]
cmp edx,0 ;ted_cur_y < 0
jge @f
add [eax+sb_offs_position],edx ;¯à®ªàã⪠áªà®««¨£ ¢¢¥àå
xor edx,edx
jmp .end2
@@:
cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
jl .end2
mov ebx,edx
sub ebx,[eax+sb_offs_cur_area]
inc ebx
add [eax+sb_offs_position],ebx ;¯à®ªàã⪠áªà®««¨£ ¢¨§
sub edx,ebx
.end2:
mov ted_cur_y,edx
pop ebx eax
ret
;input:
; edi = pointer to tedit struct
align 16
ted_text_colored:
push eax edx
mov eax,ted_tim_ch
sub eax,ted_tim_undo
mov ted_tim_co,eax
mov edx,ted_tex
@@:
call ted_iterat_next
cmp edx,ted_tex_1
jle @f
mov byte[edx+1],0
jmp @b
@@:
cmp ted_key_words_count,1
jl .no_colors
mov edx,ted_tex
@@:
call ted_text_find_sel_color
cmp edx,ted_tex_1
jle .no_colors
jmp @b
.no_colors:
pop edx eax
ret
;input:
; edx = pointer to start symbol
; edi = pointer to tedit struct
;output:
; edx = pointer to next symbol
;description:
; ãªæ¨ï ¤«ï ¯®¨áª ¨ ¢ë¤¥«¥¨ï ¯®¤á¢¥ç¥ëå á«®¢
align 16
proc ted_text_find_sel_color uses eax ebx ecx esi
locals
begPos dd ? ; ç «ì ï ¯®§¨æ¨ï
endPos dd ? ;ª®¥ç ï ¯®§¨æ¨ï
find db ? ; ©¤¥® / ¥ ©¤¥®
f_color db ? ;¨¤¥ªá 梥⠩¤¥®£® á«®¢
endl
;eax = word_n ⥪ã騩 ®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢ ¢ ᯨ᪥
;ebx = ¤«ï à §ëå æ¥«¥©
;ecx = l_pos ¯®á«¥¤¨© ®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢ ¢ ᯨ᪥
;esi = ¤«ï à §ëå æ¥«¥©, ®¬¥à ¯à®¢¥à塞®£® ᨬ¢®« ¢ á«®¢¥
mov dword[begPos],1
mov dword[endPos],1
mov byte[find],0
mov byte[f_color],1
@@:
call ted_iterat_next
cmp edx,ted_tex_1
jle @f
xor eax,eax
mov al,byte[edx]
shl ax,2 ;eax*=4
add eax,ted_arr_key_pos
mov eax,[eax]
cmp eax,0
jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
mov ecx,eax
;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
.wh_1b:
cmp ecx,ted_key_words_count
jge .wh_1e
ColToIndexOffset ecx,esi
mov bl,byte[esi]
ColToIndexOffset eax,esi
cmp bl,byte[esi]
jne .wh_1e
inc ecx
jmp .wh_1b
.wh_1e:
mov [begPos],edx ;bP=i;
mov esi,1
align 4
.wh_2b: ;while(1){
call ted_iterat_next
;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
.wh_3b:
cmp ecx,eax
jle .wh_3e
dec ecx
ColToIndexOffset ecx,ebx
inc ecx
;cmp byte[ebx+esi],byte[edx]
mov bl,byte[ebx+esi]
cmp bl,byte[edx]
je .wh_3e
dec ecx
jmp .wh_3b
.wh_3e:
ColToIndexOffset eax,ebx
cmp byte[ebx+esi],0
jne .if_0 ;if(Col[word_n].Text[pos]==0){
mov [endPos],edx ;eP=i;
ColToIndexOffset eax,ebx
mov bl,[ebx+MAX_COLOR_WORD_LEN+7]
mov [f_color],bl ;f_color=Col[word_n].color;
mov byte[find],1
ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
mov bl,[ebx+MAX_COLOR_WORD_LEN+4]
cmp bl,0 ;if(Col[word_n].wwo)
je .if_2n
push edx
mov edx,[begPos]
call ted_iterat_perv
btr bx,0 ;1-1
jae .if_3e ;if(Col[word_n].wwo&1)
;u1= !(isalnum(cont_s)||cont_s=='_')
call isalnum
jae .if_3e
mov byte[find],0
jmp .if_4e
.if_3e:
btr bx,3 ;4-1
jae .if_4e ;if(Col[word_n].wwo&8)
;u1= !isalpha(cont_s);
call isalpha
jae .if_4e
mov byte[find],0
.if_4e:
mov edx,[endPos]
;call ted_iterat_next
btr bx,1 ;2-1
jae .if_5e ;if(Col[word_n].wwo&2)
;u1= !(isalnum(cont_s)||cont_s=='_')
call isalnum
jae .if_5e
mov byte[find],0
jmp .if_6e
.if_5e:
btr bx,4 ;5-1
jae .if_6e ;if(Col[word_n].wwo&16)
;u1= !isalpha(cont_s);
call isalpha
jae .if_6e
mov byte[find],0
.if_6e:
btr bx,2 ;3-1
jae .if_7e ;if(Col[word_n].wwo&4)
ColToIndexOffset eax,ebx
mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
call ted_iterat_next_pos_char
cmp edx,ted_tex_1
jle .if_7e
mov dword[endPos],edx
.if_7e:
pop edx
.if_2n:
;if(i!=1){ // ¥ ª®¥æ ¤®ªã¬¥â
; cont_s=tex[eP].c;
; if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_'); // ¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
; if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ¥ ç¨á«. ᨬ¢®«
; if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
cmp eax,ecx
je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç® ¯®á«¥¤¥¥
.if_0:
cmp edx,ted_tex_1
jle .wh_2e ;if(i==1) break;
;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
.wh_4b:
cmp ecx,eax
jle .wh_4e
ColToIndexOffset eax,ebx
;cmp byte[ebx+esi],byte[edx]
mov bl,byte[ebx+esi]
cmp bl,byte[edx]
je .wh_4e
inc eax
jmp .wh_4b
.wh_4e:
cmp eax,ecx
je .wh_2e;if(word_n==l_pos) break;
inc esi ;pos++;
jmp .wh_2b
.wh_2e:
cmp byte[find],1 ;if(fnd)break;
je @f
mov edx,[begPos];i=bP;
jmp @b
@@:
cmp byte[find],1
jne .if_1e ;if(fnd){ // ¢ë¤¥«¥¨¥ ©¤¥®£® ⥪áâ
;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
mov eax,[begPos]
mov bl,[f_color]
mov [eax+1],bl ;tex[bP].col=f_color;
mov eax,[endPos]
mov byte[eax+1],0xff ;tex[eP].col=255;
;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®æ ¢å®¦¤¥¨ï
mov edx,[endPos]
call ted_get_text_perv_pos
jmp @f
.if_1e:
mov edx,ted_tex
@@:
ret
endp
;input:
; edx = pointer to char (byte)
;output:
; cf=1 if symbol is...
align 16
tab_all_num db 0,0,0,0,0,0,0xff,11b,11111110b,0xff,0xff,10000111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0;,0,0,0,0,0,0,0,0 - tab_alpha_0,0,0,0,0,0,0,0
tab_alpha db 0,0,0,0,0,0,0,0,11111110b,0xff,0xff,10000111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;output:
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà ¨«¨ '_'
align 16
isalnum:
push eax ebx
movzx eax,byte[edx] ;al=offset
shr eax,3
lea ebx,[tab_all_num]
add ebx,eax
movzx ax,byte[edx] ;al=bit
and ax,111b
bt word[ebx],ax
pop ebx eax
ret
;output:
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ ¨«¨ '_'
align 16
isalpha:
push eax ebx
movzx eax,byte[edx] ;al=offset
shr eax,3
lea ebx,[tab_alpha]
add ebx,eax
movzx ax,byte[edx] ;al=bit
and ax,111b
bt word[ebx],ax
pop ebx eax
ret
align 16
proc ted_show_help_f1 uses eax edx edi, edit:dword
mov edi,[edit]
call ted_get_pos_by_cursor
push edx
call ted_iterat_next_color_tag
mov eax,edx
pop edx
call ted_iterat_perv_color_tag
cmp eax,ted_tex
jle @f
cmp edx,ted_tex_1
jle @f
stdcall ted_find_help_id,eax
@@:
;call ted_draw_main_cursor
call ted_draw_help_f1
ret
endp
;input:
; edx = position begin 'symbol' struct
; edi = pointer to tedit struct
; end_pos = position end 'symbol' struct
align 16
proc ted_find_help_id, end_pos:dword
; ecx = word_n
; ebx = l_pos
mov ted_help_id,-1
push ebx ecx
xor ebx,ebx
mov bl,[edx]
shl bx,2 ;ebx*=4
add ebx,ted_arr_key_pos
mov ecx,[ebx]
cmp ecx,0
jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
push esi eax
mov ebx,ecx ;l_pos=word_n;
ColToIndexOffset ecx,esi
push cx
mov cl,[esi]
@@:
cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
jge @f
;ColToIndexOffset ecx,esi
ColToIndexOffset ebx,eax
cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
jne @f
inc ebx ;l_pos++;
jmp @b
@@:
pop cx
call ted_iterat_next ;pos=1;
mov esi,1
@@:
push dx
push word[edx]
pop dx
.wh_0b:
cmp ebx,ecx ;while(l_pos>word_n
jle .wh_0e
dec ebx
ColToIndexOffset ebx,eax
inc ebx
cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
je .wh_0e
dec ebx ;l_pos--;
jmp .wh_0b
.wh_0e:
.wh_1b:
cmp ebx,ecx ;while(l_pos>word_n
jle .wh_1e
ColToIndexOffset ecx,eax
cmp byte[eax+esi],dl
je .wh_1e
inc ecx ;word_n++;
jmp .wh_1b
.wh_1e:
pop dx
cmp ecx,ebx ;if(word_n==l_pos) break;
je @f
call ted_iterat_next ;pos++;
cmp edx,[end_pos] ;for(...;i<strlen;...)
je @f ;jge
inc esi
jmp @b
@@:
pop eax esi
mov ted_help_id,ecx
;return word_n;
.if_0e:
pop ecx ebx
ret
endp
;output:
; eax = ª®¤ ®è¨¡ª¨
; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ëå ¡ ©â
align 16
proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äãªæ¨ï ®âªàëâ¨ï ä ©«
mov edi,[edit]
; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ¥ å¢ â ¥â ⮠㢥«¨ç¨¢ ¥¬ ***
;¯à®¡ã¥¬ ¯®«ãç¨âì ¨ä®à¬ æ¨î ® ä ©«¥
mov ebx,[file]
mov dword[ebx], SSF_GET_INFO
mov dword[ebx+4], 0
mov dword[ebx+8], 0
mov dword[ebx+12], 0
m2m dword[ebx+16], ted_tex
mov byte[ebx+20], 0
push dword[f_name]
pop dword[ebx+21]
mcall SF_FILE
or eax,eax
jz .end_0
mov edx,ted_max_chars
cmp eax,2 ;äãªæ¨ï ¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ®© ä ©«®¢®© á¨á⥬ë
je @f
jmp .ret_f
align 4
.end_0:
;¯à®¢¥à塞 å¢ â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©«
mov ecx,ted_max_chars
sub ecx,2 ;ecx = ¬ ªá¨¬ «ì®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë« ¢ë¤¥«¥ ¯ ¬ïâì
mov edx,ted_tex
mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©« ¢ ¡ ©â å
cmp edx,ecx
jl @f
;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ¥ å¢ â¨«®
mov ecx,edx ;¯ ¬ïâì ¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©«
add ecx,2 ;¯ ¬ïâì ¤«ï á«ã¦¥¡ëå ç «ì®£® ¨ ª®¥ç®£® ᨬ¢®«®¢
add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ¨ï ä ©«
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
invoke mem.realloc, ted_tex,ecx
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
add eax,ecx
mov ted_tex_end,eax
mov ecx,ted_tex_1
add ecx,sizeof.symbol
mov ted_ptr_free_symb,ecx
@@:
; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
mov ebx,[file]
mov dword[ebx], SSF_READ_FILE
mov dword[ebx+4], 0
mov dword[ebx+8], 0
m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ë á ä ©« (¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
m2m dword[ebx+16], ted_tex
mov byte[ebx+20], 0
push dword[f_name]
pop dword[ebx+21]
mcall SF_FILE
or eax,eax
jz @f
cmp eax,6
je @f
jmp .ret_f
@@:
cmp ebx,-1
je .ret_f
;if open file
call ted_on_open_file
.ret_f:
ret
endp
align 16
proc ted_but_select_word, edit:dword
pushad
mov edi,[edit]
call ted_get_pos_by_cursor
push edx
call ted_iterat_perv_color_tag
cmp edx,ted_tex_1
jle @f
call ted_get_text_coords
mov ted_sel_x0,ebx
mov ted_sel_y0,eax
@@:
pop edx
call ted_iterat_next_color_tag
cmp edx,ted_tex_1
jle @f
call ted_get_text_coords
mov ted_sel_x1,ebx
mov ted_sel_y1,eax
@@:
cmp ted_fun_draw_panel_buttons,0
je @f
call ted_fun_draw_panel_buttons
@@:
stdcall ted_draw,edi
popad
ret
endp
;output:
; al = 1 if delete
align 16
proc ted_but_cut uses edi, edit:dword
mov edi,[edit]
stdcall ted_but_copy,edi
call ted_set_undo
stdcall ted_sel_text_del,ted_opt_ed_change_time
cmp al,1
jne @f
stdcall ted_draw,edi
cmp ted_fun_draw_panel_buttons,0
je @f
call ted_fun_draw_panel_buttons
@@:
ret
endp
align 16
proc ted_but_copy, edit:dword
pushad
mov edi,[edit]
call ted_is_select
or al,al
jz .end_f ;if not selected text
call ted_sel_normalize
mov esi,ted_seln_x1
mov ecx,ted_seln_y1
call ted_get_pos_by_coords
mov ebx,edx
mov esi,ted_seln_x0
mov ecx,ted_seln_y0
call ted_get_pos_by_coords
mov esi,ebx
mov ecx,12 ;system buffer header size
mov ebx,ted_buffer
mov dword[ebx+4],0 ;text data
mov dword[ebx+8],1 ;code 866
add ebx,ecx
@@:
cmp edx,ted_tex_1 ;end of file
jle @f
cmp edx,esi ;end of select
je @f
inc ecx
cmp ecx,ted_buffer_size ;owerflow bufer
je @f
mov al,byte[edx]
mov byte[ebx],al
inc ebx
cmp al,13
jne .no_13
mov byte[ebx],10 ;¤¥« ¥¬ ª®¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
inc ebx
inc ecx
.no_13:
call ted_iterat_next
jmp @b
@@:
mov byte[ebx],0
cmp ecx,12
je .end_f
mov ebx,ted_buffer
mov [ebx],ecx
mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer
call ted_draw_buffer
cmp ted_fun_draw_panel_buttons,0
je .end_f
call ted_fun_draw_panel_buttons
.end_f:
popad
ret
endp
align 16
proc ted_but_paste, edit:dword
pushad
mov edi,[edit]
mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
cmp eax,1
jl .no_buf_r
mov esi,eax
.cycle: ;®¡à âë© æ¨ª« ¯® ᫮⠬
dec esi ;®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â
mcall SF_CLIPBOARD,SSF_READ_CB,esi
cmp eax,1
je .no_buf_r
cmp eax,-1
je .no_buf_r
mov ecx,[eax]
cmp ecx,1 ;size
jl .no_buf_r
cmp dword[eax+4],0 ;text
je @f
cmp esi,1
jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ¥ ⥪áâ, ᫮⮢ ¢ ¡ãä¥à¥ ¥áª®