1,7 → 1,83 |
struct f70 |
func_n dd ? |
param1 dd ? |
param2 dd ? |
param3 dd ? |
param4 dd ? |
rezerv db ? |
name dd ? |
ends |
|
struct TexColViv |
Text rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨ |
f1 dd 0 ; á¯à ¢ª ¯® á«®¢ã |
wwo db ? ; whole words only |
endc db ? ; ᨬ¢®« ª®æ ¢ë¤¥«¥¨ï (wwo&4) |
color db ? ; ®¬¥à 梥â |
ends |
|
struct symbol |
c db ? ; +0 ᨬ¢®« |
col db ? ; +1 梥â |
perv dd ? ; +2 |
next dd ? ; +6 㪠§ ⥫¨ |
tc dd ? ; +10 ¢à¥¬. ᮧ¤ ¨ï |
td dd ? ; +14 ¢à¥¬. 㤠«¥¨ï |
ends |
|
|
hed db 'TextEditor 29.04.10',0 ;¯®¤¯¨áì ®ª |
sc system_colors |
|
fn_icon db 'te_icon.bmp',0 |
bmp_icon dd 0 |
run_file_70 f70 |
|
|
;input: |
; al = ª®¤ ®è¨¡ª¨ |
align 4 |
but_NewFile: |
ted_on_init_synt_err: |
mov byte[msgbox_3.err],al |
stdcall [mb_create],msgbox_3,thread ;message: Can-t open color options file! |
ret |
|
|
;----------------------------------------------------------------------------- |
;äãªæ¨ï ¤«ï ¢ë¤¥«¥¨ï ¯ ¬ï⨠|
;input: |
; ecx = size data |
;otput: |
; eax = pointer to memory |
align 4 |
mem_Alloc: |
push ebx |
mov eax,68 |
mov ebx,12 |
int 0x40 |
pop ebx |
ret |
;----------------------------------------------------------------------------- |
;äãªæ¨ï ¤«ï ®á¢®¡®¦¤¥¨ï ¯ ¬ï⨠|
;input: |
; ecx = pointer to memory |
align 4 |
mem_Free: |
push eax ebx |
stdcall ted_can_save, tedit0 |
cmp ecx,0 |
jz @f |
mov eax,68 |
mov ebx,13 |
int 0x40 |
@@: |
pop ebx eax |
ret |
|
|
align 4 |
ted_but_new_file: |
push eax ebx |
stdcall [ted_can_save], tedit0 |
cmp al,1 |
jne @f |
stdcall [mb_create],msgbox_2,thread ;message: save changes in file? |
18,9 → 94,9 |
|
align 4 |
On_NewFile: |
stdcall ted_clear, tedit0,1 |
stdcall [ted_clear], tedit0,1 |
call draw_but_toolbar |
stdcall draw_main_win, tedit0 |
stdcall [ted_draw], tedit0 |
ret |
|
align 4 |
28,7 → 104,7 |
push edi |
mov edi, tedit0 |
|
stdcall but_SaveFile,edi |
stdcall [ted_but_save_file],edi,run_file_70,[edit1.text] |
cmp ted_err_save,0 |
jne @f |
call On_NewFile |
36,17 → 112,22 |
pop edi |
ret |
|
;description: |
; äãªæ¨ï ®âªàëâ¨ï ä ©« ¡¥§ ®ª® á®®¡é¥¨ï |
align 4 |
but_no_msg_OpenFile: ;äãªæ¨ï ®âªàëâ¨ï ä ©« ç¥à¥§ ¡¥§ ®ª® á®®¡é¥¨ï |
stdcall ted_on_open_file, tedit0 |
but_no_msg_OpenFile: |
push eax ebx |
stdcall [ted_open_file], tedit0,run_file_70,[edit1.text] |
call ted_messages_after_open_file |
pop ebx eax |
ret |
|
|
;description: |
;äãªæ¨ï ®âªàëâ¨ï ä ©« á ¢®§¬®¦ë¬ ®ª®¬ á®®¡é¥¨ï (® ¢®§¬®¦®á⨠®â¬¥¨âì ®âªàë⨥) |
align 4 |
but_OpenFile: |
push eax |
stdcall ted_can_save, tedit0 |
ted_but_open_file: |
push eax ebx |
stdcall [ted_can_save], tedit0 |
cmp al,1 |
jne @f |
stdcall [mb_create],msgbox_5,thread ;message: save changes in file? |
53,28 → 134,19 |
stdcall [mb_setfunctions],msgbox_5_funct |
jmp .ret_f |
@@: |
stdcall ted_on_open_file, tedit0 |
stdcall [ted_open_file], tedit0,run_file_70,[edit1.text] |
call ted_messages_after_open_file |
.ret_f: |
pop eax |
pop ebx eax |
ret |
|
;input: |
; eax = ª®¤ ®è¨¡ª¨ |
; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ëå ¡ ©â |
; edi = pointer to tedit struct |
align 4 |
proc ted_on_open_file, edit:dword ;äãªæ¨ï ®âªàëâ¨ï ä ©« |
push eax ebx edi |
mov edi,dword[edit] |
|
mov eax,70 |
mov [run_file_70.func_n], 0 |
mov [run_file_70.param1], 0 |
mov [run_file_70.param2], 0 |
mov [run_file_70.param3], maxChars-2 ;sizeof.symbol |
m2m [run_file_70.param4], ted_tex |
mov [run_file_70.rezerv], 0 |
push dword[edit1.text] |
pop dword[run_file_70.name] |
mov ebx,run_file_70 |
int 0x40 |
|
ted_messages_after_open_file: |
push ecx |
cmp eax,0 |
je @f |
cmp eax,6 |
93,435 → 165,75 |
cmp ebx,-1 |
je .ret_f |
;if open file |
call OpenFile |
cmp ebx,maxChars-2 |
mov ecx,ted_max_chars |
sub ecx,2 ;ecx = ¬ ªá¨¬ «ì®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë« ¢ë¤¥«¥ ¯ ¬ïâì |
cmp ebx,ecx |
jl .ret_f |
stdcall [mb_create],msgbox_1,thread |
.ret_f: |
pop edi ebx eax |
pop ecx |
ret |
endp |
|
|
align 4 |
proc but_SaveFile, edit:dword |
pushad |
|
stdcall ted_can_save,edi |
cmp al,0 |
je .no_save |
|
mov edi,dword[edit] |
|
mov ecx,maxChars |
call mem_Alloc |
push eax |
|
mov edx,ted_tex |
xor ecx,ecx |
@@: |
call IteratNext |
cmp edx,ted_tex_1 |
jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol |
mov bl,[edx] |
mov byte[eax],bl |
inc eax |
inc ecx |
jmp @b |
@@: |
|
cmp ecx,0 |
je @f |
pop eax |
mov [run_file_70.param4],eax |
push eax |
mov eax,70 |
mov [run_file_70.func_n], 2 |
mov [run_file_70.param1], 0 |
mov [run_file_70.param2], 0 |
mov [run_file_70.param3], ecx |
mov [run_file_70.rezerv], 0 |
push [edit1.text] |
pop [run_file_70.name] |
mov ebx,run_file_70 |
int 0x40 |
|
mov ted_err_save,ax |
|
cmp eax,0 |
je .no_msg |
; cmp eax,6 |
; je @f |
cmp ax,10 |
jl .zifra_0_9 |
mov al,'?' |
sub ax,48 |
.zifra_0_9: |
add ax,48 |
|
ted_save_err_msg: |
mov byte[msgbox_6.err],al |
stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file! |
jmp @f |
.no_msg: |
m2m ted_tim_ls,ted_tim_ch |
@@: |
|
pop ecx |
call mem_Free |
.no_save: |
popad |
ret |
endp |
|
|
align 4 |
proc but_FindText, edit:dword |
pushad |
mov edi,dword[edit] |
|
call GetPos |
mov eax,[edit2.text] |
mov bl,byte[eax] |
@@: |
call GetFindRezult |
cmp bh,1 |
je @f ; find |
|
call IteratNext |
cmp edx,ted_tex_1 |
jle @f |
jmp @b |
@@: |
cmp bh,0 |
je @f |
call GetTexCoords |
inc ebx ;move cursor right |
mov ted_sel_x1,ebx |
mov ted_sel_y1,eax |
mov edx,eax |
mov ecx,ebx |
call GoToPos |
mov edx,esi ;esi ¡ë«® ãáâ ®¢«¥® ¢ GetFindRezult |
call GetTexCoords |
mov ted_sel_x0,ebx |
mov ted_sel_y0,eax |
stdcall draw_main_win,edi |
jmp .end_find |
@@: |
stdcall [mb_create],msgbox_7,thread ;message: Can not find text |
.end_find: |
popad |
ret |
endp |
|
;input: |
; eax - text need find |
; bl - first symbol to find |
; edx - first symbol pointer |
; edi - pointer to tedit struct |
;output: |
; bh - rezult |
; edx - last text position (if find sucess) |
; esi - first symbol pointer |
;description: |
; ãªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax |
; á ⥪á⮬ । ªâ®à ¯® 㪠§ ⥫î edx. |
; â ¤ àâë¥ äãªæ¨¨ ( ¯à. strcmp) âãâ ¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ® |
; ¢ ¯ ¬ï⨠। ªâ®à ⥪áâ ᮤ¥à¦¨âáï ¥ ¢ ¢¨¤¥ ascii áâப. |
align 4 |
GetFindRezult: |
push eax |
mov bh,1 |
mov esi,edx ;copy edx |
@@: |
cmp byte[edx],bl |
jne .no_text |
|
inc eax ;*** get next symbol (in find text) *** |
mov bl,byte[eax] |
cmp bl,0 |
je @f ;end of find text |
|
call IteratNext ;*** get next symbol (in editor text) *** |
cmp edx,ted_tex_1 |
jle @f ;end of editor text |
|
jmp @b |
.no_text: |
xor bh,bh |
mov edx,esi ;restore edx |
@@: |
pop eax |
mov bl,byte[eax] ;restore bl |
ret |
|
align 4 |
proc ted_but_open_syntax, edit:dword |
push edi |
push ebx edi |
mov edi,dword[edit] |
|
cmp ted_panel_id,TE_PANEL_SYNTAX |
cmp ted_panel_id,TED_PANEL_SYNTAX |
jne @f |
stdcall dword[tl_node_get_data], tree1 |
pop dword[fn_col_option] |
stdcall InitColText,edi |
call CmColored |
stdcall draw_main_win,edi |
mov ebx,dword[fn_col_option] |
copy_path ebx,fn_syntax_dir,file_name_rez,0x0 |
copy_path file_name_rez,sys_path,file_name,0x0 |
stdcall [ted_init_syntax_file],edi,run_file_70,file_name |
call [ted_text_colored] |
stdcall [ted_draw],edi |
@@: |
pop edi |
pop edi ebx |
ret |
endp |
|
align 4 |
proc ted_but_select_word, edit:dword |
pushad |
mov edi,dword[edit] |
|
call GetPos |
push edx |
call ItPervColorTag |
cmp edx,ted_tex_1 |
jle @f |
call GetTexCoords |
mov ted_sel_x0,ebx |
mov ted_sel_y0,eax |
@@: |
pop edx |
call ItNextColorTag |
cmp edx,ted_tex_1 |
jle @f |
call GetTexCoords |
mov ted_sel_x1,ebx |
mov ted_sel_y1,eax |
@@: |
|
call draw_but_toolbar |
stdcall draw_main_win,edi |
popad |
ret |
endp |
|
align 4 |
proc ted_but_cut, edit:dword |
proc ted_but_find ;¢ë§®¢/áªàë⨥ ¯ ¥«¨ ¯®¨áª |
push edi |
mov edi,dword[edit] |
mov edi,tedit0 |
|
stdcall ted_but_copy,edi |
stdcall ted_set_undo,edi |
stdcall SelTextDel,ted_opt_ed_change_time |
|
cmp al,1 |
jne @f |
call draw_but_toolbar |
stdcall draw_main_win,edi |
@@: |
pop edi |
ret |
endp |
|
;output: |
; al = 1 if copy text |
align 4 |
proc ted_but_copy, edit:dword |
pushad |
mov edi,dword[edit] |
|
stdcall IsSel,edi |
cmp al,0 |
je .end_f ;if not selected text |
stdcall SelNormalize,edi |
|
mov esi,ted_seln_x1 |
mov ecx,ted_seln_y1 |
call GetPosByParam |
mov ebx,edx |
mov esi,ted_seln_x0 |
mov ecx,ted_seln_y0 |
call GetPosByParam |
mov esi,ebx |
|
xor ecx,ecx |
mov ebx,buf |
;mov edx,ted_tex |
@@: |
cmp edx,ted_tex_1 ;end of file |
jle @f |
cmp edx,esi ;end of select |
cmp ted_panel_id,TED_PANEL_NULL |
je @f |
inc ecx |
cmp ecx,BUF_SIZE ;owerflow bufer |
je @f |
|
mov al,byte[edx] |
mov byte[ebx],al |
inc ebx |
|
call IteratNext |
jmp @b |
@@: |
add ecx,buf |
mov byte[ebx],0 |
|
cmp ecx,0 |
je .end_f |
call draw_but_toolbar |
stdcall draw_bufer,edi |
.end_f: |
popad |
ret |
endp |
|
|
align 4 |
proc ted_but_paste, edit:dword |
push eax ebx esi edi |
mov edi,dword[edit] |
|
mov esi,buf |
call strlen |
cmp eax,1 |
jl @f |
stdcall ted_set_undo,edi |
mov esi,eax |
mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor |
stdcall SelTextDel,ebx |
cmp al,1 |
jne .del |
mov ebx,ted_opt_ed_move_cursor |
.del: |
stdcall ted_text_add,edi,buf,esi,ebx |
call draw_but_toolbar |
stdcall draw_main_win,edi |
@@: |
pop edi esi ebx eax |
ret |
endp |
|
align 4 |
proc but_find, edit:dword ;¢ë§®¢/áªàë⨥ ¯ ¥«¨ ¯®¨áª |
push edi |
mov edi,dword[edit] |
|
cmp ted_panel_id,TE_PANEL_NULL |
je @f |
mov ted_panel_id,TE_PANEL_NULL |
mov ted_panel_id,TED_PANEL_NULL |
mov ted_wnd_l,0 |
jmp .e_if |
@@: |
mov ted_panel_id,TE_PANEL_FIND |
mov ted_wnd_l,TE_PANEL_WIDTH |
mov ted_panel_id,TED_PANEL_FIND |
mov ted_wnd_l,TED_PANEL_WIDTH |
.e_if: |
stdcall EvSize,edi |
stdcall draw_main_win,edi |
stdcall [ted_draw],edi |
pop edi |
ret |
endp |
|
align 4 |
but_replace: |
ted_on_find_err: |
stdcall [mb_create],msgbox_7,thread ;message: Can not find text |
ret |
|
align 4 |
but_find_key_w: |
but_replace: |
ret |
|
align 4 |
proc but_sumb_upper, edit:dword |
push edi esi |
mov edi,dword[edit] |
|
mov [conv_table],EvUpper |
call ConvertSelText |
cmp esi,0 |
je @f |
stdcall draw_main_win,edi |
@@: |
pop esi edi |
but_find_key_w: |
ret |
endp |
|
align 4 |
proc but_sumb_lover, edit:dword |
push edi esi |
mov edi,dword[edit] |
|
mov [conv_table],EvLover |
call ConvertSelText |
cmp esi,0 |
je @f |
stdcall draw_main_win,edi |
@@: |
pop esi edi |
ret |
endp |
|
align 4 |
proc but_reverse, edit:dword |
push eax ebx edi |
mov edi,dword[edit] |
|
stdcall IsSel,edi |
cmp al,0 |
je @f |
stdcall SelNormalize,edi |
push esi ecx edx |
mov esi,ted_seln_x0 |
mov ecx,ted_seln_y0 |
call GetPosByParam |
mov eax,edx |
mov esi,ted_seln_x1 |
cmp esi,0 |
je .beg_str |
dec esi |
.beg_str: |
mov ecx,ted_seln_y1 |
call GetPosByParam |
;call GetTexPervPos |
mov ebx,edx |
pop edx ecx esi |
;cmp eax,... |
;je @f |
call Revers |
@@: |
stdcall draw_main_win,edi |
pop edi ebx eax |
ret |
endp |
|
align 4 |
proc ted_but_undo, edit:dword |
push eax edi |
mov edi,dword[edit] |
|
mov eax,ted_tim_undo |
cmp ted_tim_ch,eax |
jbe @f |
inc ted_tim_undo |
;call CmColored |
stdcall draw_main_win,edi |
call draw_but_toolbar |
@@: |
pop edi eax |
ret |
endp |
|
align 4 |
proc ted_but_redo, edit:dword |
push edi |
mov edi,dword[edit] |
|
cmp ted_tim_undo,1 |
jb @f |
dec ted_tim_undo |
;call CmColored |
stdcall draw_main_win,edi |
call draw_but_toolbar |
@@: |
pop edi |
ret |
endp |
|
align 4 |
proc but_sumb_invis, edit:dword |
push edi |
mov edi,dword[edit] |
528,7 → 240,7 |
|
xor ted_mode_invis,1 |
call draw_but_toolbar |
stdcall draw_main_win,edi |
stdcall [ted_draw],edi |
pop edi |
ret |
endp |
541,153 → 253,30 |
xor ted_mode_color,1 |
cmp ted_mode_color,0 |
je @f |
call CmColored |
call [ted_text_colored] |
@@: |
call draw_but_toolbar |
stdcall draw_main_win,edi |
stdcall [ted_draw],edi |
pop edi |
ret |
endp |
|
|
;input: |
; edi = pointer to tedit struct |
align 4 |
but_CtrlHome: |
mov ted_cur_x,0 |
mov ted_cur_y,0 |
push eax |
mov eax,ted_scr_w |
mov dword[eax+sb_offs_position],0 |
mov eax,ted_scr_h |
mov dword[eax+sb_offs_position],0 |
pop eax |
call draw_but_toolbar |
stdcall draw_main_win,edi |
ret |
|
align 4 |
proc but_synt_show, edit:dword |
push edi |
mov edi,[edit] |
|
cmp ted_panel_id,TE_PANEL_NULL |
cmp ted_panel_id,TED_PANEL_NULL |
je @f |
mov ted_panel_id,TE_PANEL_NULL |
mov ted_panel_id,TED_PANEL_NULL |
mov ted_wnd_l,0 |
jmp .e_if |
@@: |
mov ted_panel_id,TE_PANEL_SYNTAX |
mov ted_wnd_l,TE_PANEL_WIDTH |
mov ted_panel_id,TED_PANEL_SYNTAX |
mov ted_wnd_l,TED_PANEL_WIDTH |
.e_if: |
stdcall EvSize,edi |
stdcall draw_main_win,edi |
stdcall [ted_draw],edi |
pop edi |
ret |
endp |
|
align 4 |
proc ted_sel_key_up, edit:dword |
push edi |
mov edi,dword[edit] |
|
cmp ted_drag_k,1 |
je @f |
stdcall SelStart,edi |
mov ted_drag_k,1 |
@@: |
push dx |
call CurMoveUp |
cmp dl,8 |
jne @f |
call OnInitialUpdate |
@@: |
pop dx |
stdcall SelMove,edi |
stdcall draw_main_win,edi |
pop edi |
ret |
endp |
|
align 4 |
proc ted_sel_key_down, edit:dword |
push edi |
mov edi,dword[edit] |
|
cmp ted_drag_k,1 |
je @f |
stdcall SelStart,edi |
mov ted_drag_k,1 |
@@: |
push dx |
call CurMoveDown |
cmp dl,8 |
jne @f |
call OnInitialUpdate |
@@: |
pop dx |
stdcall SelMove,edi |
stdcall draw_main_win,edi |
pop edi |
ret |
endp |
|
align 4 |
proc ted_sel_key_left, edit:dword |
push edi |
mov edi,dword[edit] |
|
cmp ted_drag_k,1 |
je @f |
stdcall SelStart,edi |
@@: |
push dx |
call CurMoveLeft |
stdcall SelMove,edi |
cmp ted_drag_k,1 |
je @f |
mov ted_drag_k,1 |
mov dl,8 |
@@: |
cmp dl,8 |
jne @f |
call OnInitialUpdate |
stdcall draw_main_win,edi |
jmp .end_f |
@@: |
stdcall draw_cur_line,edi |
.end_f: |
pop dx |
pop edi |
ret |
endp |
|
align 4 |
proc ted_sel_key_right, edit:dword |
push edi |
mov edi,dword[edit] |
|
cmp ted_drag_k,1 |
je @f |
stdcall SelStart,edi |
@@: |
push dx |
call CurMoveRight |
stdcall SelMove,edi |
cmp ted_drag_k,1 |
je @f |
mov ted_drag_k,1 |
mov dl,8 |
@@: |
cmp dl,8 |
jne @f |
call OnInitialUpdate |
stdcall draw_main_win,edi |
jmp .end_f |
@@: |
stdcall draw_cur_line,edi |
.end_f: |
pop dx |
pop edi |
ret |
endp |