Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1455 → Rev 1456

/programs/other/t_edit/t_button.inc
1,16 → 1,14
align 4
but_NewFile:
push eax ebx
call CanSave
stdcall ted_can_save, tedit0
cmp al,1
jne @f
push thread
push msgbox_2
call [mb_create] ;message: save changes in file?
stdcall [mb_create],msgbox_2,thread ;message: save changes in file?
;mov eax,5
;mov ebx,50
;int 0x40
push msgbox_2_funct
call [mb_setfunctions]
stdcall [mb_setfunctions],msgbox_2_funct
jmp .ret_f
@@:
call On_NewFile
18,48 → 16,59
pop ebx eax
ret
 
align 4
On_NewFile:
push eax
mov al,1
call Clear
stdcall ted_clear, tedit0,1
call draw_but_toolbar
stdcall draw_main_win, tedit0
pop eax
ret
 
align 4
On_SaveAndNewFile:
call but_SaveFile
cmp byte[err_sav],0
push edi
mov edi, tedit0
 
stdcall but_SaveFile,edi
cmp ted_err_save,0
jne @f
call On_NewFile
@@:
pop edi
ret
 
align 4
but_no_msg_OpenFile: ;äã­ªæ¨ï ®âªàëâ¨ï ä ©«  ç¥à¥§ ¡¥§ ®ª®­  á®®¡é¥­¨ï
stdcall ted_on_open_file, tedit0
ret
 
 
;äã­ªæ¨ï ®âªàëâ¨ï ä ©«  á ¢®§¬®¦­ë¬ ®ª­®¬ á®®¡é¥­¨ï (® ¢®§¬®¦­®á⨠®â¬¥­¨âì ®âªàë⨥)
align 4
but_OpenFile:
push eax
call CanSave
stdcall ted_can_save, tedit0
cmp al,1
jne @f
push thread
push msgbox_5
call [mb_create] ;message: save changes in file?
push msgbox_5_funct
call [mb_setfunctions]
stdcall [mb_create],msgbox_5,thread ;message: save changes in file?
stdcall [mb_setfunctions],msgbox_5_funct
jmp .ret_f
@@:
call On_OpenFile
stdcall ted_on_open_file, tedit0
.ret_f:
pop eax
ret
 
On_OpenFile:
push eax ebx
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], [tex]
m2m [run_file_70.param4], ted_tex
mov [run_file_70.rezerv], 0
push dword[edit1.text]
pop dword[run_file_70.name]
78,9 → 87,7
add ax,48
 
mov byte[msgbox_4.err],al
push thread
push msgbox_4
call [mb_create] ;message: Can-t open text file!
stdcall [mb_create],msgbox_4,thread ;message: Can-t open text file!
jmp .ret_f
@@:
cmp ebx,-1
87,33 → 94,35
je .ret_f
;if open file
call OpenFile
call draw_but_toolbar
stdcall draw_main_win, tedit0
cmp ebx,maxChars-2
jl .ret_f
push thread
push msgbox_1
call [mb_create]
stdcall [mb_create],msgbox_1,thread
.ret_f:
pop ebx eax
pop edi ebx eax
ret
endp
 
but_SaveFile:
push eax ebx ecx edx
call CanSave
 
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,[tex]
mov edx,ted_tex
xor ecx,ecx
@@:
call IteratNext
cmp edx,[tex_1]
jle @f ;edx = [tex] or edx = [tex]+sizeof.symbol
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
137,7 → 146,7
mov ebx,run_file_70
int 0x40
 
mov [err_sav],al
mov ted_err_save,ax
 
cmp eax,0
je .no_msg
151,22 → 160,25
add ax,48
 
mov byte[msgbox_6.err],al
push thread
push msgbox_6
call [mb_create] ;message: Can-t save text file!
stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file!
jmp @f
.no_msg:
m2m [ls_tim],[ch_tim]
m2m ted_tim_ls,ted_tim_ch
@@:
 
pop ecx
call mem_Free
.no_save:
pop edx ecx ebx eax
popad
ret
endp
 
but_FindText:
push eax ebx ecx edx edi
 
align 4
proc but_FindText, edit:dword
pushad
mov edi,dword[edit]
 
call GetPos
mov eax,[edit2.text]
mov bl,byte[eax]
176,7 → 188,7
je @f ; find
 
call IteratNext
cmp edx,[tex_1]
cmp edx,ted_tex_1
jle @f
jmp @b
@@:
184,37 → 196,43
je @f
call GetTexCoords
inc ebx ;move cursor right
mov [sel.x1],ebx
mov [sel.y1],eax
mov ted_sel_x1,ebx
mov ted_sel_y1,eax
mov edx,eax
mov ecx,ebx
call GoToPos
mov edx,edi
mov edx,esi ;esi ¡ë«® ãáâ ­®¢«¥® ¢ GetFindRezult
call GetTexCoords
mov [sel.x0],ebx
mov [sel.y0],eax
stdcall draw_main_win, tedit0
mov ted_sel_x0,ebx
mov ted_sel_y0,eax
stdcall draw_main_win,edi
jmp .end_find
@@:
push thread
push msgbox_7
call [mb_create] ;message: Can not find text
stdcall [mb_create],msgbox_7,thread ;message: Can not find text
.end_find:
pop edi edx ecx ebx eax
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)
; edi - first symbol pointer
; esi - first symbol pointer
;description:
; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax
; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
align 4
GetFindRezult:
push eax
mov bh,1
mov edi,edx ;copy edx
mov esi,edx ;copy edx
@@:
cmp byte[edx],bl
jne .no_text
225,95 → 243,108
je @f ;end of find text
 
call IteratNext ;*** get next symbol (in editor text) ***
cmp edx,[tex_1]
cmp edx,ted_tex_1
jle @f ;end of editor text
 
jmp @b
.no_text:
xor bh,bh
mov edx,edi ;restore edx
mov edx,esi ;restore edx
@@:
pop eax
mov bl,byte[eax] ;restore bl
ret
 
but_OpenSyntax:
cmp byte[panel_id],TE_PANEL_SYNTAX
align 4
proc ted_but_open_syntax, edit:dword
push edi
mov edi,dword[edit]
 
cmp ted_panel_id,TE_PANEL_SYNTAX
jne @f
stdcall dword[tl_node_get_data], dword tree1
stdcall dword[tl_node_get_data], tree1
pop dword[fn_col_option]
call InitColText
stdcall InitColText,edi
call CmColored
stdcall draw_main_win, tedit0
stdcall draw_main_win,edi
@@:
pop edi
ret
endp
 
but_select_word:
push eax ebx ecx edx
align 4
proc ted_but_select_word, edit:dword
pushad
mov edi,dword[edit]
 
call GetPos
push edx
call ItPervColorTag
cmp edx,[tex_1]
cmp edx,ted_tex_1
jle @f
call GetTexCoords
mov [sel.x0],ebx
mov [sel.y0],eax
mov ted_sel_x0,ebx
mov ted_sel_y0,eax
@@:
pop edx
call ItNextColorTag
cmp edx,[tex_1]
cmp edx,ted_tex_1
jle @f
call GetTexCoords
mov [sel.x1],ebx
mov [sel.y1],eax
mov ted_sel_x1,ebx
mov ted_sel_y1,eax
@@:
pop edx ecx ebx eax
 
call draw_but_toolbar
stdcall draw_main_win, tedit0
jmp still
stdcall draw_main_win,edi
popad
ret
endp
 
but_cut:
call but_Copy
call SetUndo
push bx
mov bl,1
call SelTextDel
pop bx
align 4
proc ted_but_cut, edit:dword
push edi
mov edi,dword[edit]
 
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, tedit0
stdcall draw_main_win,edi
@@:
jmp still
pop edi
ret
endp
 
;output:
; al = 1 if copy text
but_Copy:
push ax
stdcall IsSel, tedit0
align 4
proc ted_but_copy, edit:dword
pushad
mov edi,dword[edit]
 
stdcall IsSel,edi
cmp al,0
jne @f
pop ax
ret ;if not selected text
@@:
call SelNormalize
je .end_f ;if not selected text
stdcall SelNormalize,edi
 
push ebx ecx edx esi
mov esi,[seln.x1]
mov ecx,[seln.y1]
mov esi,ted_seln_x1
mov ecx,ted_seln_y1
call GetPosByParam
mov ebx,edx
mov esi,[seln.x0]
mov ecx,[seln.y0]
mov esi,ted_seln_x0
mov ecx,ted_seln_y0
call GetPosByParam
mov esi,ebx
 
xor ecx,ecx
mov ebx,buf
;mov edx,[tex]
;mov edx,ted_tex
@@:
cmp edx,[tex_1] ;end of file
cmp edx,ted_tex_1 ;end of file
jle @f
cmp edx,esi ;end of select
je @f
332,42 → 363,52
mov byte[ebx],0
 
cmp ecx,0
je @f
je .end_f
call draw_but_toolbar
stdcall draw_bufer, tedit0
@@:
pop esi edx ecx ebx ax
stdcall draw_bufer,edi
.end_f:
popad
ret
endp
 
but_paste:
push eax bx esi edi
 
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
call SetUndo
stdcall ted_set_undo,edi
mov esi,eax
mov bx,0x0101
call SelTextDel
mov edi,buf
call TextAdd
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, tedit0
stdcall draw_main_win,edi
@@:
pop edi esi bx eax
jmp still
pop edi esi ebx eax
ret
endp
 
align 4
proc but_find, edit:dword ;¢ë§®¢/áªàë⨥ ¯ ­¥«¨ ¯®¨áª 
push edi
mov edi,[edit]
mov edi,dword[edit]
 
cmp byte[panel_id],TE_PANEL_NULL
cmp ted_panel_id,TE_PANEL_NULL
je @f
mov byte[panel_id],TE_PANEL_NULL
mov ted_panel_id,TE_PANEL_NULL
mov ted_wnd_l,0
jmp .e_if
@@:
mov byte[panel_id],TE_PANEL_FIND
mov ted_panel_id,TE_PANEL_FIND
mov ted_wnd_l,TE_PANEL_WIDTH
.e_if:
stdcall EvSize,edi
376,51 → 417,64
ret
endp
 
align 4
but_replace:
jmp still
ret
 
align 4
but_find_key_w:
jmp still
ret
 
but_sumb_upper:
push edi
align 4
proc but_sumb_upper, edit:dword
push edi esi
mov edi,dword[edit]
 
mov [conv_table],EvUpper
call ConvertSelText
cmp edi,0
cmp esi,0
je @f
stdcall draw_main_win, tedit0
stdcall draw_main_win,edi
@@:
pop edi
jmp still
pop esi edi
ret
endp
 
but_sumb_lover:
push edi
align 4
proc but_sumb_lover, edit:dword
push edi esi
mov edi,dword[edit]
 
mov [conv_table],EvLover
call ConvertSelText
cmp edi,0
cmp esi,0
je @f
stdcall draw_main_win, tedit0
stdcall draw_main_win,edi
@@:
pop edi
jmp still
pop esi edi
ret
endp
 
but_reverse:
push eax ebx
stdcall IsSel, tedit0
align 4
proc but_reverse, edit:dword
push eax ebx edi
mov edi,dword[edit]
 
stdcall IsSel,edi
cmp al,0
je @f
call SelNormalize
stdcall SelNormalize,edi
push esi ecx edx
mov esi,[seln.x0]
mov ecx,[seln.y0]
mov esi,ted_seln_x0
mov ecx,ted_seln_y0
call GetPosByParam
mov eax,edx
mov esi,[seln.x1]
mov esi,ted_seln_x1
cmp esi,0
je .beg_str
dec esi
.beg_str:
mov ecx,[seln.y1]
mov ecx,ted_seln_y1
call GetPosByParam
;call GetTexPervPos
mov ebx,edx
429,95 → 483,101
;je @f
call Revers
@@:
pop ebx eax
stdcall draw_main_win, tedit0
jmp still
stdcall draw_main_win,edi
pop edi ebx eax
ret
endp
 
but_undo:
mov eax,[tim_Undo]
cmp [ch_tim],eax
jbe still
inc [tim_Undo]
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
jmp red_win
stdcall draw_main_win,edi
call draw_but_toolbar
@@:
pop edi eax
ret
endp
 
but_redo:
cmp [tim_Undo],1
jb still
dec [tim_Undo]
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
jmp red_win
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]
 
but_sumb_invis:
xor [invis],1
jmp red_win
xor ted_mode_invis,1
call draw_but_toolbar
stdcall draw_main_win,edi
pop edi
ret
endp
 
but_k_words_show:
xor byte[mode_colored],1
cmp byte[mode_colored],0
je red_win
align 4
proc but_k_words_show, edit:dword
push edi
mov edi,dword[edit]
 
xor ted_mode_color,1
cmp ted_mode_color,0
je @f
call CmColored
@@:
call draw_but_toolbar
stdcall draw_main_win,edi
pop edi
ret
endp
 
; push eax ebx ecx esi edi
; mov eax,dword[cur_x]
; ColToIndexOffset eax,edx
; mov eax,4
; mov ebx,50*65536+75
; mov ecx,0x40ffffff
; mov edi,0x404040
; mov esi,10
; int 0x40
;
; mov eax,47
; mov ecx,250
; mov esi,0xffff80
; mov edx,50*65536+80
; mov esi,FkPos;[keyW]
; @@:
; mov ebx,0x30001
; cmp dx,300
; jl .no_br
; mov dx,80
; add edx,0x200000
; .no_br:
; add dx,10
; push ecx esi
; mov ecx,esi
; cmp dword[ecx],-1
; jne .no_minus
; mov ebx,0x10000
; mov ecx,1
; .no_minus:
; mov esi,0xffff00
; int 0x40
; pop esi ecx
; add esi,4
; loop @b
; pop edi esi ecx ebx eax
jmp red_win
 
;input:
; edi = pointer to tedit struct
align 4
but_CtrlHome:
mov [cur_x],0
mov [cur_y],0
mov [wScr.position],0
mov [hScr.position],0
 
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, tedit0
stdcall draw_main_win,edi
ret
 
align 4
proc but_synt_show, edit:dword
push edi
mov edi,[edit]
 
cmp byte[panel_id],TE_PANEL_NULL
cmp ted_panel_id,TE_PANEL_NULL
je @f
mov byte[panel_id],TE_PANEL_NULL
mov ted_panel_id,TE_PANEL_NULL
mov ted_wnd_l,0
jmp .e_if
@@:
mov byte[panel_id],TE_PANEL_SYNTAX
mov ted_panel_id,TE_PANEL_SYNTAX
mov ted_wnd_l,TE_PANEL_WIDTH
.e_if:
stdcall EvSize,edi
526,11 → 586,15
ret
endp
 
sel_KeyUp:
cmp [dragk],1
align 4
proc ted_sel_key_up, edit:dword
push edi
mov edi,dword[edit]
 
cmp ted_drag_k,1
je @f
call SelStart
mov [dragk],1
stdcall SelStart,edi
mov ted_drag_k,1
@@:
push dx
call CurMoveUp
539,15 → 603,21
call OnInitialUpdate
@@:
pop dx
call SelMove
stdcall draw_main_win, tedit0
stdcall SelMove,edi
stdcall draw_main_win,edi
pop edi
ret
endp
 
sel_KeyDown:
cmp [dragk],1
align 4
proc ted_sel_key_down, edit:dword
push edi
mov edi,dword[edit]
 
cmp ted_drag_k,1
je @f
call SelStart
mov [dragk],1
stdcall SelStart,edi
mov ted_drag_k,1
@@:
push dx
call CurMoveDown
556,54 → 626,68
call OnInitialUpdate
@@:
pop dx
call SelMove
stdcall draw_main_win, tedit0
stdcall SelMove,edi
stdcall draw_main_win,edi
pop edi
ret
endp
 
sel_KeyLeft:
cmp [dragk],1
align 4
proc ted_sel_key_left, edit:dword
push edi
mov edi,dword[edit]
 
cmp ted_drag_k,1
je @f
call SelStart
stdcall SelStart,edi
@@:
push dx
call CurMoveLeft
call SelMove
cmp [dragk],1
stdcall SelMove,edi
cmp ted_drag_k,1
je @f
mov [dragk],1
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call OnInitialUpdate
stdcall draw_main_win, tedit0
stdcall draw_main_win,edi
jmp .end_f
@@:
stdcall draw_cur_line, tedit0
stdcall draw_cur_line,edi
.end_f:
pop dx
pop edi
ret
endp
 
sel_KeyRight:
cmp [dragk],1
align 4
proc ted_sel_key_right, edit:dword
push edi
mov edi,dword[edit]
 
cmp ted_drag_k,1
je @f
call SelStart
stdcall SelStart,edi
@@:
push dx
call CurMoveRight
call SelMove
cmp [dragk],1
stdcall SelMove,edi
cmp ted_drag_k,1
je @f
mov [dragk],1
mov ted_drag_k,1
mov dl,8
@@:
cmp dl,8
jne @f
call OnInitialUpdate
stdcall draw_main_win, tedit0
stdcall draw_main_win,edi
jmp .end_f
@@:
stdcall draw_cur_line, tedit0
stdcall draw_cur_line,edi
.end_f:
pop dx
ret
pop edi
ret
endp