Subversion Repositories Kolibri OS

Rev

Rev 7877 | Rev 8262 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7877 Rev 8036
1
; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
1
; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
2
; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
2
; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
3
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 29.01.2019 IgorA
3
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 10.06.2020 IgorA
4
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
4
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
5
 
5
 
6
;input:
6
;input:
7
; edi = pointer to tedit struct
7
; edi = pointer to tedit struct
8
; reg = index
8
; reg = index
9
;output:
9
;output:
10
; reg = pointer to 'tex' struct
10
; reg = pointer to 'tex' struct
11
macro ConvertIndexToPointer reg {
11
macro ConvertIndexToPointer reg {
12
	imul reg,sizeof.symbol
12
	imul reg,sizeof.symbol
13
	add reg,ted_tex
13
	add reg,ted_tex
14
}
14
}
15
 
15
 
16
;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
16
;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
17
macro ColToIndexOffset ind_reg,out_reg {
17
macro ColToIndexOffset ind_reg,out_reg {
18
	mov out_reg,ind_reg
18
	mov out_reg,ind_reg
19
	imul out_reg,sizeof.TexColViv
19
	imul out_reg,sizeof.TexColViv
20
	add out_reg,ted_key_words_data
20
	add out_reg,ted_key_words_data
21
}
21
}
22
 
22
 
23
TED_LINES_IN_NEW_FILE equ 30 ;ç¨á«® áâப ¢ ­®¢®¬ ä ©«¥
23
TED_LINES_IN_NEW_FILE equ 30 ;ç¨á«® áâப ¢ ­®¢®¬ ä ©«¥
24
MAX_COLOR_WORD_LEN equ 40
24
MAX_COLOR_WORD_LEN equ 40
25
;------------------------------------------------------------------------------
25
;------------------------------------------------------------------------------
26
struct TexSelect
26
struct TexSelect
27
	x0 dd ?
27
	x0 dd ?
28
	y0 dd ?
28
	y0 dd ?
29
	x1 dd ?
29
	x1 dd ?
30
	y1 dd ?
30
	y1 dd ?
31
ends
31
ends
32
 
32
 
33
struct TexColViv
33
struct TexColViv
34
	Text  rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
34
	Text  rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
35
	f1    dd 0 ; á¯à ¢ª  ¯® á«®¢ã
35
	f1    dd 0 ; á¯à ¢ª  ¯® á«®¢ã
36
	flags db ? ; f1+4 ä« £¨ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ¢ë¤¥«¥­¨¨
36
	flags db ? ; f1+4 ä« £¨ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ¢ë¤¥«¥­¨¨
37
	endc  db ? ; f1+5 ᨬ¢®« ª®­æ  ¢ë¤¥«¥­¨ï (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
37
	endc  db ? ; f1+5 ᨬ¢®« ª®­æ  ¢ë¤¥«¥­¨ï (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
38
	escc  db ? ; f1+6 íªà ­¨àãî騩 ᨬ¢®« (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
38
	escc  db ? ; f1+6 íªà ­¨àãî騩 ᨬ¢®« (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
39
	color db ? ; f1+7 ­®¬¥à 梥â 
39
	color db ? ; f1+7 ­®¬¥à 梥â 
40
ends
40
ends
41
 
41
 
42
struct symbol
42
struct symbol
43
	c db ?    ;  +0 ᨬ¢®«
43
	c db ?    ;  +0 ᨬ¢®«
44
	col db ?  ;  +1 梥â
44
	col db ?  ;  +1 梥â
45
	perv dd ? ;  +2
45
	perv dd ? ;  +2
46
	next dd ? ;  +6 㪠§ â¥«¨
46
	next dd ? ;  +6 㪠§ â¥«¨
47
	tc dd ?   ; +10 ¢à¥¬. ᮧ¤ ­¨ï
47
	tc dd ?   ; +10 ¢à¥¬. ᮧ¤ ­¨ï
48
	td dd ?   ; +14 ¢à¥¬. 㤠«¥­¨ï
48
	td dd ?   ; +14 ¢à¥¬. 㤠«¥­¨ï
49
ends
49
ends
50
;------------------------------------------------------------------------------
50
;------------------------------------------------------------------------------
51
 
51
 
52
ted_symbol_space db 32 ;ascii ª®¤ ¯à®¡¥« , ¨­®£¤  ¡ë¢ ¥â ­ã¦¥­ ¢ ª®¤¥
52
ted_symbol_space db 32 ;ascii ª®¤ ¯à®¡¥« , ¨­®£¤  ¡ë¢ ¥â ­ã¦¥­ ¢ ª®¤¥
53
ted_symbol_tab db 26 ;ascii ª®¤ áâ५ª¨ ¢¯à ¢®, ¨á¯®«ì§ã¥âáï ¤«ï à¨á®¢ ­¨ï â ¡ã«ï樨 ¢ ०¨¬¥ ¯®ª §  ­¥¢¨¤¨¬ëå ᨬ¢®«®¢
53
ted_symbol_tab db 26 ;ascii ª®¤ áâ५ª¨ ¢¯à ¢®, ¨á¯®«ì§ã¥âáï ¤«ï à¨á®¢ ­¨ï â ¡ã«ï樨 ¢ ०¨¬¥ ¯®ª §  ­¥¢¨¤¨¬ëå ᨬ¢®«®¢
54
 
54
 
55
if lang eq ru
55
if lang eq ru
56
 
56
 
57
txtRow db '‘âப ',0
57
txtRow db '‘âப ',0
58
txtCol db '‡­ ª',0
58
txtCol db '‡­ ª',0
59
txtOtm db 'Žâ¬¥­ë',0
59
txtOtm db 'Žâ¬¥­ë',0
60
txtBuf db 'ãä¥à:',0
60
txtBuf db 'ãä¥à:',0
61
 
61
 
62
else
62
else
63
 
63
 
64
txtRow db 'Rows',0
64
txtRow db 'Rows',0
65
txtCol db 'Cols',0
65
txtCol db 'Cols',0
66
txtOtm db 'Undo',0
66
txtOtm db 'Undo',0
67
txtBuf db 'Buffer:',0
67
txtBuf db 'Buffer:',0
68
 
68
 
69
end if
69
end if
70
 
70
 
71
;EvChar - â ¡«¨æ  ¤«ï 䨫ìâ஢ ­¨ï ¤®¡ ¢«ï¥¬ëå ᨬ¢®«®¢, çâ®-¡ë ­¥ ¯®¯ «¨ «¨è­¨¥ §­ ª¨
71
;EvChar - â ¡«¨æ  ¤«ï 䨫ìâ஢ ­¨ï ¤®¡ ¢«ï¥¬ëå ᨬ¢®«®¢, çâ®-¡ë ­¥ ¯®¯ «¨ «¨è­¨¥ §­ ª¨
72
align 16
72
align 16
73
EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
73
EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
74
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
74
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
75
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
75
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
76
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
76
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
77
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
77
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
78
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
78
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
79
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
79
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
80
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
80
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
81
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
81
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
82
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
82
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
83
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
83
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
84
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
84
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
85
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
85
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
86
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
86
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
87
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
87
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
88
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
88
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
89
 
89
 
90
KM_SHIFT equ 0x00010000
90
KM_SHIFT equ 0x00010000
91
KM_CTRL equ 0x00020000
91
KM_CTRL equ 0x00020000
92
KM_ALT equ 0x00040000
92
KM_ALT equ 0x00040000
93
KM_NUMLOCK equ 0x00080000
93
KM_NUMLOCK equ 0x00080000
94
 
94
 
95
; KEY CODES
95
; KEY CODES
96
KEY_F1 equ 0x0000003B
96
KEY_F1 equ 0x0000003B
97
KEY_F2 equ 0x0000003C
97
KEY_F2 equ 0x0000003C
98
KEY_F3 equ 0x0000003D
98
KEY_F3 equ 0x0000003D
99
 
99
 
100
 
100
 
101
 
101
 
102
align 16
102
align 16
103
proc ted_init uses eax ecx edi, edit:dword
103
proc ted_init uses eax ecx edi, edit:dword
104
	mov edi,[edit]
104
	mov edi,[edit]
105
 
105
 
106
	mov ecx,sizeof.symbol
106
	mov ecx,sizeof.symbol
107
	imul ecx,ted_max_chars
107
	imul ecx,ted_max_chars
108
	invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
108
	invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
109
	mov ted_tex,eax
109
	mov ted_tex,eax
110
	mov ted_tex_1,eax
110
	mov ted_tex_1,eax
111
	add ted_tex_1,sizeof.symbol
111
	add ted_tex_1,sizeof.symbol
112
	add eax,ecx
112
	add eax,ecx
113
	mov ted_tex_end,eax
113
	mov ted_tex_end,eax
114
 
114
 
115
	stdcall ted_clear, edi,1
115
	stdcall ted_clear, edi,1
116
 
116
 
117
;-------------------------------------------------
117
;-------------------------------------------------
118
	mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ  ted_arr_key_pos
118
	mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ  ted_arr_key_pos
119
	add ecx,ted_syntax_file_size
119
	add ecx,ted_syntax_file_size
120
	invoke mem.alloc,ecx
120
	invoke mem.alloc,ecx
121
	mov ted_arr_key_pos,eax
121
	mov ted_arr_key_pos,eax
122
	add eax,1024
122
	add eax,1024
123
	mov ted_syntax_file,eax
123
	mov ted_syntax_file,eax
124
 
124
 
125
	stdcall ted_init_scroll_bars,edi,3
125
	stdcall ted_init_scroll_bars,edi,3
126
	ret
126
	ret
127
endp
127
endp
128
 
128
 
129
MIN_W_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï ¢¥àâ. áªà®««¨­£ 
129
MIN_W_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï ¢¥àâ. áªà®««¨­£ 
130
MIN_H_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï £®à¨§. áªà®««¨­£ 
130
MIN_H_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï £®à¨§. áªà®««¨­£ 
131
;input:
131
;input:
132
; opt = 1 - ¬¥­ïâì 梥â áªà®««¨­£®¢, 2 - ¨§¬¥­¨«¨áì à §¬¥àë ®ª­ ,
132
; opt = 1 - ¬¥­ïâì 梥â áªà®««¨­£®¢, 2 - ¨§¬¥­¨«¨áì à §¬¥àë ®ª­ ,
133
;  4 - ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â 
133
;  4 - ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â 
134
align 16
134
align 16
135
proc ted_init_scroll_bars, edit:dword, opt:dword
135
proc ted_init_scroll_bars, edit:dword, opt:dword
136
	pushad
136
	pushad
137
	mov edi,[edit]
137
	mov edi,[edit]
138
	mov esi,ted_scr_w
138
	mov esi,ted_scr_w
139
	mov ebx,ted_scr_h
139
	mov ebx,ted_scr_h
140
	bt dword[opt],0
140
	bt dword[opt],0
141
	jae @f
141
	jae @f
142
		mov ecx,ted_color_wnd_work
142
		mov ecx,ted_color_wnd_work
143
		mov dword[esi+sb_offs_bckg_col],ecx
143
		mov dword[esi+sb_offs_bckg_col],ecx
144
		mov dword[ebx+sb_offs_bckg_col],ecx
144
		mov dword[ebx+sb_offs_bckg_col],ecx
145
		mov ecx,ted_color_wnd_capt
145
		mov ecx,ted_color_wnd_capt
146
		mov dword[esi+sb_offs_frnt_col],ecx
146
		mov dword[esi+sb_offs_frnt_col],ecx
147
		mov dword[ebx+sb_offs_frnt_col],ecx
147
		mov dword[ebx+sb_offs_frnt_col],ecx
148
		mov ecx,ted_color_wnd_bord
148
		mov ecx,ted_color_wnd_bord
149
		mov dword[esi+sb_offs_line_col],ecx
149
		mov dword[esi+sb_offs_line_col],ecx
150
		mov dword[ebx+sb_offs_line_col],ecx
150
		mov dword[ebx+sb_offs_line_col],ecx
151
	@@:
151
	@@:
152
	bt dword[opt],2 ; ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â  ?
152
	bt dword[opt],2 ; ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â  ?
153
	jae .doc_resize
153
	jae .doc_resize
154
		call ted_get_num_lines
154
		call ted_get_num_lines
155
		cmp eax,TED_LINES_IN_NEW_FILE
155
		cmp eax,TED_LINES_IN_NEW_FILE
156
		jge @f
156
		jge @f
157
			mov eax,TED_LINES_IN_NEW_FILE
157
			mov eax,TED_LINES_IN_NEW_FILE
158
		@@:
158
		@@:
159
		mov dword[esi+sb_offs_max_area],eax
159
		mov dword[esi+sb_offs_max_area],eax
160
	.doc_resize:
160
	.doc_resize:
161
	bt dword[opt],1 ; ¨§¬¥­¨«¨áì à §¬¥àë ®ª­  ?
161
	bt dword[opt],1 ; ¨§¬¥­¨«¨áì à §¬¥àë ®ª­  ?
162
	jae .no_size
162
	jae .no_size
163
			mov edx,ted_wnd_l
163
			mov edx,ted_wnd_l
164
			add edx,ted_rec_l
164
			add edx,ted_rec_l
165
			mov word[ebx+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠£®à¨§. áªà®««¨­£ 
165
			mov word[ebx+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠£®à¨§. áªà®««¨­£ 
166
			mov eax,ted_wnd_h ;calculate lines in page
166
			mov eax,ted_wnd_h ;calculate lines in page
167
			mov edx,ted_wnd_t
167
			mov edx,ted_wnd_t
168
			add edx,eax
168
			add edx,eax
169
			mov word[ebx+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠£®à¨§. áªà®««¨­£ 
169
			mov word[ebx+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠£®à¨§. áªà®««¨­£ 
170
		sub eax,ted_rec_t
170
		sub eax,ted_rec_t
171
		xor edx,edx
171
		xor edx,edx
172
		mov ecx,ted_rec_h
172
		mov ecx,ted_rec_h
173
		div ecx
173
		div ecx
174
		cmp eax,MIN_W_SCRL_ARE
174
		cmp eax,MIN_W_SCRL_ARE
175
		jg @f
175
		jg @f
176
			mov eax,MIN_W_SCRL_ARE
176
			mov eax,MIN_W_SCRL_ARE
177
		@@:
177
		@@:
178
		mov dword[esi+sb_offs_cur_area],eax
178
		mov dword[esi+sb_offs_cur_area],eax
179
 
179
 
180
		mov eax,ted_wnd_w ;calculate cols in page
180
		mov eax,ted_wnd_w ;calculate cols in page
181
			mov edx,ted_wnd_l ;«¥¢ë© ®âáâ㯠®ª­ 
181
			mov edx,ted_wnd_l ;«¥¢ë© ®âáâ㯠®ª­ 
182
			add edx,eax ;¤®¡ ¢«ï¥¬ è¨à¨­ã ®ª­ 
182
			add edx,eax ;¤®¡ ¢«ï¥¬ è¨à¨­ã ®ª­ 
183
			mov word[esi+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
183
			mov word[esi+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
184
			mov edx,ted_wnd_t
184
			mov edx,ted_wnd_t
185
			mov word[esi+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
185
			mov word[esi+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
186
			mov edx,ted_wnd_h
186
			mov edx,ted_wnd_h
187
			mov word[esi+sb_offs_size_y],dx ;¢ëáâ ¢«ï¥¬ ¢ëá®âã ¢¥àâ. áªà®««¨­£ 
187
			mov word[esi+sb_offs_size_y],dx ;¢ëáâ ¢«ï¥¬ ¢ëá®âã ¢¥àâ. áªà®««¨­£ 
188
		sub eax,ted_rec_l
188
		sub eax,ted_rec_l
189
			mov word[ebx+sb_offs_size_x],ax ;¢ëáâ ¢«ï¥¬ è¨à¨­ã £®à¨§. áªà®««¨­£ 
189
			mov word[ebx+sb_offs_size_x],ax ;¢ëáâ ¢«ï¥¬ è¨à¨­ã £®à¨§. áªà®««¨­£ 
190
		xor edx,edx
190
		xor edx,edx
191
		mov ecx,ted_rec_w
191
		mov ecx,ted_rec_w
192
		div ecx
192
		div ecx
193
		cmp eax,MIN_H_SCRL_ARE
193
		cmp eax,MIN_H_SCRL_ARE
194
		jg @f
194
		jg @f
195
			mov eax,MIN_H_SCRL_ARE
195
			mov eax,MIN_H_SCRL_ARE
196
		@@:
196
		@@:
197
		dec eax
197
		dec eax
198
		mov dword[ebx+sb_offs_cur_area],eax ;ãáâ ­ ¢«¨¢ ¥¬ ç¨á«® ᨬ¢®«®¢, ª®â®àë¥ ¢« §ïâ ¢ íªà ­ ¤«ï £®à¨§. áªà®««¨­£ 
198
		mov dword[ebx+sb_offs_cur_area],eax ;ãáâ ­ ¢«¨¢ ¥¬ ç¨á«® ᨬ¢®«®¢, ª®â®àë¥ ¢« §ïâ ¢ íªà ­ ¤«ï £®à¨§. áªà®««¨­£ 
199
	.no_size:
199
	.no_size:
200
	popad
200
	popad
201
	ret
201
	ret
202
endp
202
endp
203
 
203
 
204
align 16
204
align 16
205
proc ted_delete uses edi, edit:dword
205
proc ted_delete uses edi, edit:dword
206
	mov edi,[edit]
206
	mov edi,[edit]
207
	invoke mem.free,ted_tex
207
	invoke mem.free,ted_tex
208
	invoke mem.free,ted_arr_key_pos ;ted_syntax_file
208
	invoke mem.free,ted_arr_key_pos ;ted_syntax_file
209
	ret
209
	ret
210
endp
210
endp
211
 
211
 
212
 
212
 
213
;input:
213
;input:
214
; eax = key kodes
214
; eax = key kodes
215
align 16
215
align 16
216
proc ted_key, edit:dword, table:dword, control:dword
216
proc ted_key, edit:dword, table:dword, control:dword
217
	pushad
217
	pushad
218
	mov edi,[edit]
218
	mov edi,[edit]
219
	mov esi,ted_el_focus
219
	mov esi,ted_el_focus
220
	cmp dword[esi],edi
220
	cmp dword[esi],edi
221
	jne .end_key_fun ;í«¥¬¥­â ­¥ ¢ 䮪ãᥠ¢ë室¨¬ ¨§ ä㭪樨
221
	jne .end_key_fun ;í«¥¬¥­â ­¥ ¢ 䮪ãᥠ¢ë室¨¬ ¨§ ä㭪樨
222
	mov esi,dword[control]
222
	mov esi,dword[control]
223
 
223
 
224
	cmp ah,KEY_F1 ;[F1]
224
	cmp ah,KEY_F1 ;[F1]
225
	jne @f
225
	jne @f
226
		stdcall ted_show_help_f1,edi
226
		stdcall ted_show_help_f1,edi
227
		jmp .end_key_fun
227
		jmp .end_key_fun
228
	@@:
228
	@@:
229
	cmp ah,KEY_F3 ;[F3]
229
	cmp ah,KEY_F3 ;[F3]
230
	jne @f
230
	jne @f
231
		stdcall ted_but_find,edi,0
231
		stdcall ted_but_find,edi,0
232
		jmp .end_key_fun
232
		jmp .end_key_fun
233
	@@:
233
	@@:
234
 
234
 
235
	test esi,KM_CTRL ;Ctrl+...
235
	test esi,KM_CTRL ;Ctrl+...
236
	jz .key_Ctrl
236
	jz .key_Ctrl
237
		; *** ¢ë§®¢ ¢­¥è­¨å ä㭪権 ª®â®àë¥ âॡãîâ ®ª­  ®âªàëâ¨ï/á®åà ­¥­¨ï/¯®¨áª /...
237
		; *** ¢ë§®¢ ¢­¥è­¨å ä㭪権 ª®â®àë¥ âॡãîâ ®ª­  ®âªàëâ¨ï/á®åà ­¥­¨ï/¯®¨áª /...
238
		cmp ted_fun_on_key_ctrl_all,0
238
		cmp ted_fun_on_key_ctrl_all,0
239
		je .end0
239
		je .end0
240
		xor al,al
240
		xor al,al
241
		cmp ah,24 ;Ctrl+O
241
		cmp ah,24 ;Ctrl+O
242
		jne @f
242
		jne @f
243
			mov al,'O'
243
			mov al,'O'
244
		@@:
244
		@@:
245
		cmp ah,31 ;Ctrl+S
245
		cmp ah,31 ;Ctrl+S
246
		jne @f
246
		jne @f
247
			mov al,'S'
247
			mov al,'S'
248
		@@:
248
		@@:
249
		cmp ah,33 ;Ctrl+F
249
		cmp ah,33 ;Ctrl+F
250
		jne @f
250
		jne @f
251
			mov al,'F'
251
			mov al,'F'
252
		@@:
252
		@@:
253
		cmp ah,34 ;Ctrl+G
253
		cmp ah,34 ;Ctrl+G
254
		jne @f
254
		jne @f
255
			mov al,'G'
255
			mov al,'G'
256
		@@:
256
		@@:
257
		cmp ah,35 ;Ctrl+H
257
		cmp ah,35 ;Ctrl+H
258
		jne @f
258
		jne @f
259
			mov al,'H'
259
			mov al,'H'
260
		@@:
260
		@@:
261
		cmp ah,49 ;Ctrl+N
261
		cmp ah,49 ;Ctrl+N
262
		jne @f
262
		jne @f
263
			mov al,'N'
263
			mov al,'N'
264
		@@:
264
		@@:
265
		or al,al
265
		or al,al
266
		jz .end0
266
		jz .end0
267
			and eax,0xff
267
			and eax,0xff
268
			test esi,KM_SHIFT
268
			test esi,KM_SHIFT
269
			jz @f
269
			jz @f
270
				or eax,0x100
270
				or eax,0x100
271
			@@:
271
			@@:
272
			stdcall ted_fun_on_key_ctrl_all, eax
272
			stdcall ted_fun_on_key_ctrl_all, eax
273
			jmp .end_key_fun
273
			jmp .end_key_fun
274
		.end0:
274
		.end0:
275
 
275
 
276
		; *** ¢ë§®¢ ¢­ãâ७­¨å ä㭪権
276
		; *** ¢ë§®¢ ¢­ãâ७­¨å ä㭪権
277
		cmp ah,30 ;Ctrl+A
277
		cmp ah,30 ;Ctrl+A
278
		jne @f
278
		jne @f
279
			call ted_sel_all
279
			call ted_sel_all
280
		@@:
280
		@@:
281
		cmp ah,44 ;Ctrl+Z
281
		cmp ah,44 ;Ctrl+Z
282
		jne @f
282
		jne @f
283
			stdcall ted_but_undo,edi
283
			stdcall ted_but_undo,edi
284
		@@:
284
		@@:
285
		cmp ah,45 ;Ctrl+X
285
		cmp ah,45 ;Ctrl+X
286
		jne @f
286
		jne @f
287
			stdcall ted_but_cut,edi
287
			stdcall ted_but_cut,edi
288
		@@:
288
		@@:
289
		cmp ah,46 ;Ctrl+C
289
		cmp ah,46 ;Ctrl+C
290
		jne @f
290
		jne @f
291
			stdcall ted_but_copy,edi
291
			stdcall ted_but_copy,edi
292
		@@:
292
		@@:
293
		cmp ah,47 ;Ctrl+V
293
		cmp ah,47 ;Ctrl+V
294
		jne @f
294
		jne @f
295
			stdcall ted_but_paste,edi
295
			stdcall ted_but_paste,edi
296
		@@:
296
		@@:
297
		cmp ah,199 ;Ctrl+Home
297
		cmp ah,199 ;Ctrl+Home
298
		jne @f
298
		jne @f
299
			call ted_key_ctrl_home
299
			call ted_key_ctrl_home
300
		@@:
300
		@@:
301
		cmp ah,207 ;Ctrl+End
301
		cmp ah,207 ;Ctrl+End
302
		jne @f
302
		jne @f
303
			call ted_key_ctrl_end
303
			call ted_key_ctrl_end
304
		@@:
304
		@@:
305
		jmp .end_key_fun
305
		jmp .end_key_fun
306
	.key_Ctrl:
306
	.key_Ctrl:
307
 
307
 
308
	test esi,KM_SHIFT ;Shift+...
308
	test esi,KM_SHIFT ;Shift+...
309
	jz .key_Shift
309
	jz .key_Shift
310
		cmp ah,72 ;Shift+Up
310
		cmp ah,72 ;Shift+Up
311
		jne @f
311
		jne @f
312
			call ted_sel_key_up
312
			call ted_sel_key_up
313
		@@:
313
		@@:
314
		cmp ah,75 ;Shift+Left
314
		cmp ah,75 ;Shift+Left
315
		jne @f
315
		jne @f
316
			call ted_sel_key_left
316
			call ted_sel_key_left
317
		@@:
317
		@@:
318
		cmp ah,77 ;Shift+Right
318
		cmp ah,77 ;Shift+Right
319
		jne @f
319
		jne @f
320
			call ted_sel_key_right
320
			call ted_sel_key_right
321
		@@:
321
		@@:
322
		cmp ah,80 ;Shift+Down
322
		cmp ah,80 ;Shift+Down
323
		jne @f
323
		jne @f
324
			call ted_sel_key_down
324
			call ted_sel_key_down
325
		@@:
325
		@@:
326
		;mov ted_drag_k,1 ;­ ç¨­ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
326
		;mov ted_drag_k,1 ;­ ç¨­ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
327
		jmp .key_MoveCur
327
		jmp .key_MoveCur
328
	.key_Shift:
328
	.key_Shift:
329
;-------------------------------------------------
329
;-------------------------------------------------
330
	cmp ah,72 ;178 ;Up
330
	cmp ah,72 ;178 ;Up
331
	jne @f
331
	jne @f
332
		call ted_draw_cursor_sumb
332
		call ted_draw_cursor_sumb
333
		call ted_cur_move_up
333
		call ted_cur_move_up
334
		cmp dl,8
334
		cmp dl,8
335
		jne .no_red_0
335
		jne .no_red_0
336
			call ted_scroll_set_redraw
336
			call ted_scroll_set_redraw
337
			stdcall ted_draw,edi
337
			stdcall ted_draw,edi
338
			jmp @f
338
			jmp @f
339
		.no_red_0:
339
		.no_red_0:
340
		call ted_draw_main_cursor
340
		call ted_sel_end
341
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
342
	@@:
341
	@@:
343
	cmp ah,80 ;177 ;Down
342
	cmp ah,80 ;177 ;Down
344
	jne @f
343
	jne @f
345
		call ted_draw_cursor_sumb
344
		call ted_draw_cursor_sumb
346
		call ted_cur_move_down
345
		call ted_cur_move_down
347
		cmp dl,8
346
		cmp dl,8
348
		jne .no_red_1
347
		jne .no_red_1
349
			call ted_scroll_set_redraw
348
			call ted_scroll_set_redraw
350
			stdcall ted_draw,edi
349
			stdcall ted_draw,edi
351
			jmp @f
350
			jmp @f
352
		.no_red_1:
351
		.no_red_1:
353
		call ted_draw_main_cursor
352
		call ted_sel_end
354
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
355
	@@:
353
	@@:
356
	cmp ah,75 ;176 ;Left
354
	cmp ah,75 ;176 ;Left
357
	jne @f
355
	jne @f
358
		call ted_draw_cursor_sumb
356
		call ted_draw_cursor_sumb
359
		call ted_cur_move_left
357
		call ted_cur_move_left
360
		cmp dl,8
358
		cmp dl,8
361
		jne .no_red_2
359
		jne .no_red_2
362
			call ted_scroll_set_redraw
360
			call ted_scroll_set_redraw
363
			stdcall ted_draw,edi
361
			stdcall ted_draw,edi
364
			jmp @f
362
			jmp @f
365
		.no_red_2:
363
		.no_red_2:
366
		call ted_draw_main_cursor
364
		call ted_sel_end
367
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
368
	@@:
365
	@@:
369
	cmp ah,77 ;179 ;Right
366
	cmp ah,77 ;179 ;Right
370
	jne @f
367
	jne @f
371
		call ted_draw_cursor_sumb
368
		call ted_draw_cursor_sumb
372
		call ted_cur_move_right
369
		call ted_cur_move_right
373
		cmp dl,8
370
		cmp dl,8
374
		jne .no_red_3
371
		jne .no_red_3
375
			call ted_scroll_set_redraw
372
			call ted_scroll_set_redraw
376
			stdcall ted_draw,edi
373
			stdcall ted_draw,edi
377
			jmp @f
374
			jmp @f
378
		.no_red_3:
375
		.no_red_3:
379
		call ted_draw_main_cursor
376
		call ted_sel_end
380
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
381
	@@:
377
	@@:
382
	cmp ah,71 ;180 ;Home
378
	cmp ah,71 ;180 ;Home
383
	jne @f
379
	jne @f
384
		call ted_draw_cursor_sumb
380
		call ted_draw_cursor_sumb
385
		call ted_cur_move_x_first_char
381
		call ted_cur_move_x_first_char
386
		cmp dl,8
382
		cmp dl,8
387
		jne .no_red_4
383
		jne .no_red_4
388
			call ted_scroll_set_redraw
384
			call ted_scroll_set_redraw
389
			stdcall ted_draw,edi
385
			stdcall ted_draw,edi
390
			jmp @f
386
			jmp @f
391
		.no_red_4:
387
		.no_red_4:
392
		call ted_draw_main_cursor
388
		call ted_sel_end
393
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
394
	@@:
389
	@@:
395
	cmp ah,79 ;181 ;End
390
	cmp ah,79 ;181 ;End
396
	jne @f
391
	jne @f
397
		call ted_draw_cursor_sumb
392
		call ted_draw_cursor_sumb
398
		call ted_cur_move_x_last_char
393
		call ted_cur_move_x_last_char
399
		cmp dl,8
394
		cmp dl,8
400
		jne .no_red_5
395
		jne .no_red_5
401
			call ted_scroll_set_redraw
396
			call ted_scroll_set_redraw
402
			stdcall ted_draw,edi
397
			stdcall ted_draw,edi
403
			jmp @f
398
			jmp @f
404
		.no_red_5:
399
		.no_red_5:
405
		call ted_draw_main_cursor
400
		call ted_sel_end
406
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
407
	@@:
401
	@@:
408
	cmp ah,73 ;184 ;PageUp
402
	cmp ah,73 ;184 ;PageUp
409
	jne @f
403
	jne @f
410
		call ted_cur_move_page_up
404
		call ted_cur_move_page_up
411
		cmp dl,0
405
		cmp dl,0
412
		je @f
406
		je @f
413
		call ted_scroll_set_redraw
407
		call ted_scroll_set_redraw
414
		stdcall ted_draw,edi
408
		stdcall ted_draw,edi
-
 
409
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
415
	@@:
410
	@@:
416
	cmp ah,81 ;183 ;PageDown
411
	cmp ah,81 ;183 ;PageDown
417
	jne @f
412
	jne @f
418
		call ted_cur_move_page_down
413
		call ted_cur_move_page_down
419
		cmp dl,0
414
		cmp dl,0
420
		je @f
415
		je @f
421
		call ted_scroll_set_redraw
416
		call ted_scroll_set_redraw
422
		stdcall ted_draw,edi
417
		stdcall ted_draw,edi
423
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
418
		mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
424
	@@:
419
	@@:
425
;-------------------------------------------------
420
;-------------------------------------------------
426
	.key_MoveCur:
421
	.key_MoveCur:
427
 
422
 
428
	;­¨¦¥ ¯à®¯ã᪠îâáï á«ã¦¥¡­ë¥ ª« ¢¨è¨, ª®â®àë¥ ¬®£ãâ ¤ ¢ âì ¬ãá®à­ë¥ ᨬ¢®«ë ¢ ®ª­®
423
	;­¨¦¥ ¯à®¯ã᪠îâáï á«ã¦¥¡­ë¥ ª« ¢¨è¨, ª®â®àë¥ ¬®£ãâ ¤ ¢ âì ¬ãá®à­ë¥ ᨬ¢®«ë ¢ ®ª­®
429
	cmp ah,42 ;[L Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
424
	cmp ah,42 ;[L Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
430
	je .end_key_fun
425
	je .end_key_fun
431
	cmp ah,54 ;[R Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
426
	cmp ah,54 ;[R Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
432
	je .end_key_fun
427
	je .end_key_fun
433
	cmp ah,58 ;[Caps Lock]
428
	cmp ah,58 ;[Caps Lock]
434
	je .end_key_fun
429
	je .end_key_fun
435
	cmp ah,69 ;[Pause Break]
430
	cmp ah,69 ;[Pause Break]
436
	je .end_key_fun
431
	je .end_key_fun
437
	cmp ah,120 ;[Fn]
432
	cmp ah,120 ;[Fn]
438
	je .end_key_fun
433
	je .end_key_fun
439
	cmp ah,0x80 ;if key up
434
	cmp ah,0x80 ;if key up
440
	ja .end_key_fun
435
	ja .end_key_fun
441
 
436
 
442
	cmp dword[table],0
437
	cmp dword[table],0
443
	je @f
438
	je @f
444
		stdcall KeyConvertToASCII, [table]
439
		stdcall KeyConvertToASCII, [table]
445
	@@:
440
	@@:
446
 
441
 
447
	;mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
442
	;mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
448
 
443
 
449
	lea edx,[EvChar] ;¡¥à¥¬  ¤à¥á â ¡«¨æë á ¤®¯ãá⨬묨 ᨬ¢®« ¬¨
444
	lea edx,[EvChar] ;¡¥à¥¬  ¤à¥á â ¡«¨æë á ¤®¯ãá⨬묨 ᨬ¢®« ¬¨
450
	add dl,ah
445
	add dl,ah
451
	jae @f
446
	jae @f
452
		add edx,0x100 ;¥á«¨ ¡ë«® ¯¥à¥¯®«­¥­¨¥ ¯à¨ ¤®¡ ¢«¥­¨¨ ª®¤  ᨬ¢®« 
447
		add edx,0x100 ;¥á«¨ ¡ë«® ¯¥à¥¯®«­¥­¨¥ ¯à¨ ¤®¡ ¢«¥­¨¨ ª®¤  ᨬ¢®« 
453
	@@:
448
	@@:
454
	cmp byte[edx],1
449
	cmp byte[edx],1
455
	jne @f
450
	jne @f
456
		mov ted_key_new,ah
451
		mov ted_key_new,ah
457
		call ted_set_undo
452
		call ted_set_undo
458
		mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
453
		mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
459
		stdcall ted_sel_text_del,edx
454
		stdcall ted_sel_text_del,edx
460
		cmp al,1
455
		cmp al,1
461
		jne .del
456
		jne .del
462
			mov edx,ted_opt_ed_move_cursor
457
			mov edx,ted_opt_ed_move_cursor
463
		.del:
458
		.del:
464
		cmp ted_cur_ins,1
459
		cmp ted_cur_ins,1
465
		je .no_ins_mod
460
		je .no_ins_mod
466
			stdcall ted_text_del,edi,ted_opt_ed_change_time
461
			stdcall ted_text_del,edi,ted_opt_ed_change_time
467
			mov edx,ted_opt_ed_move_cursor
462
			mov edx,ted_opt_ed_move_cursor
468
		.no_ins_mod:
463
		.no_ins_mod:
469
		mov ecx,edi
464
		mov ecx,edi
470
		add ecx,ted_offs_key_new
465
		add ecx,ted_offs_key_new
471
		stdcall ted_text_add,edi,ecx,1,edx ;¤®¡ ¢«ï¥¬ ᨬ¢®« ¢¢¥¤¥­­ë© á ª« ¢¨ âãàë
466
		stdcall ted_text_add,edi,ecx,1,edx ;¤®¡ ¢«ï¥¬ ᨬ¢®« ¢¢¥¤¥­­ë© á ª« ¢¨ âãàë
472
		cmp ted_key_new,13
467
		cmp ted_key_new,13
473
		jne .dr_m_win
468
		jne .dr_m_win
474
			;¥á«¨ ¢áâ ¢¨«¨ ᨬ¢®« ­®¢®© áâப¨
469
			;¥á«¨ ¢áâ ¢¨«¨ ᨬ¢®« ­®¢®© áâப¨
475
			mov ecx,ted_scr_w
470
			mov ecx,ted_scr_w
476
			inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
471
			inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
477
			mov edx,ted_cur_y
472
			mov edx,ted_cur_y
478
			cmp edx,[ecx+sb_offs_cur_area]
473
			cmp edx,[ecx+sb_offs_cur_area]
479
			jl .no_change
474
			jl .no_change
480
				dec ted_cur_y ;ªãàá®à ®áâ ¢«ï¥¬ ­  ¬¥áâ¥
475
				dec ted_cur_y ;ªãàá®à ®áâ ¢«ï¥¬ ­  ¬¥áâ¥
481
				inc dword[ecx+sb_offs_position] ;ᤢ¨£ ¥¬ ¯®«§ã­®ª
476
				inc dword[ecx+sb_offs_position] ;ᤢ¨£ ¥¬ ¯®«§ã­®ª
482
			.no_change:
477
			.no_change:
483
			stdcall ted_draw,edi
478
			stdcall ted_draw,edi
484
			jmp .dr_cur_l
479
			jmp .dr_cur_l
485
		.dr_m_win:
480
		.dr_m_win:
486
			stdcall ted_draw_cur_line,edi
481
			stdcall ted_draw_cur_line,edi
487
		.dr_cur_l:
482
		.dr_cur_l:
488
		cmp ted_fun_draw_panel_buttons,0
483
		cmp ted_fun_draw_panel_buttons,0
489
		je @f
484
		je @f
490
			call ted_fun_draw_panel_buttons
485
			call ted_fun_draw_panel_buttons
491
	@@:
486
	@@:
492
 
487
 
493
	cmp ah,8 ;[<-]
488
	cmp ah,8 ;[<-]
494
	jne @f
489
	jne @f
495
		call ted_set_undo
490
		call ted_set_undo
496
		stdcall ted_sel_text_del,ted_opt_ed_change_time
491
		stdcall ted_sel_text_del,ted_opt_ed_change_time
497
		cmp al,1
492
		cmp al,1
498
		je .del_one_b
493
		je .del_one_b
499
			stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
494
			stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
500
		.del_one_b:
495
		.del_one_b:
501
		stdcall ted_draw,edi
496
		stdcall ted_draw,edi
502
		cmp ted_fun_draw_panel_buttons,0
497
		cmp ted_fun_draw_panel_buttons,0
503
		je .end_key_fun
498
		je .end_key_fun
504
			call ted_fun_draw_panel_buttons
499
			call ted_fun_draw_panel_buttons
505
		jmp .end_key_fun
500
		jmp .end_key_fun
506
align 4
501
align 4
507
	@@:
502
	@@:
508
 
503
 
509
	cmp ah,182 ;Delete
504
	cmp ah,182 ;Delete
510
	jne @f
505
	jne @f
511
		call ted_set_undo
506
		call ted_set_undo
512
		stdcall ted_sel_text_del,ted_opt_ed_change_time
507
		stdcall ted_sel_text_del,ted_opt_ed_change_time
513
		cmp al,1
508
		cmp al,1
514
		je .del_one_d
509
		je .del_one_d
515
			stdcall ted_text_del,edi,ted_opt_ed_change_time
510
			stdcall ted_text_del,edi,ted_opt_ed_change_time
516
		.del_one_d:
511
		.del_one_d:
517
		stdcall ted_draw,edi
512
		stdcall ted_draw,edi
518
		cmp ted_fun_draw_panel_buttons,0
513
		cmp ted_fun_draw_panel_buttons,0
519
		je .end_key_fun
514
		je .end_key_fun
520
			call ted_fun_draw_panel_buttons
515
			call ted_fun_draw_panel_buttons
521
		jmp .end_key_fun
516
		jmp .end_key_fun
522
	@@:
517
	@@:
523
 
518
 
524
	cmp ah,185 ;Ins
519
	cmp ah,185 ;Ins
525
	jne @f
520
	jne @f
526
		call ted_draw_cursor_sumb
521
		call ted_draw_cursor_sumb
527
		xor ted_cur_ins,1
522
		xor ted_cur_ins,1
528
		call ted_draw_main_cursor
523
		call ted_draw_main_cursor
529
	@@:
524
	@@:
530
 
525
 
531
	.end_key_fun:
526
	.end_key_fun:
532
	popad
527
	popad
533
	ret
528
	ret
534
endp
529
endp
535
 
530
 
536
;output:
531
;output:
537
; al = 1 - can save
532
; al = 1 - can save
538
align 16
533
align 16
539
proc ted_can_save uses ecx edi, edit:dword
534
proc ted_can_save uses ecx edi, edit:dword
540
	mov edi,[edit]
535
	mov edi,[edit]
541
 
536
 
542
	mov ecx,ted_tim_ch
537
	mov ecx,ted_tim_ch
543
	sub ecx,ted_tim_undo
538
	sub ecx,ted_tim_undo
544
	mov al,1
539
	mov al,1
545
	cmp ted_tim_ls,ecx
540
	cmp ted_tim_ls,ecx
546
	jne @f
541
	jne @f
547
		dec al
542
		dec al
548
	@@:
543
	@@:
549
	ret
544
	ret
550
endp
545
endp
551
 
546
 
552
;input:
547
;input:
553
; edi = pointer to tedit struct
548
; edi = pointer to tedit struct
554
;output:
549
;output:
555
; al = 1 - selected
550
; al = 1 - selected
556
align 16
551
align 16
557
proc ted_is_select uses ebx
552
proc ted_is_select uses ebx
558
	xor al,al
553
	xor al,al
559
	cmp ted_drag_m,1
554
	cmp ted_drag_m,1
560
	je @f
555
	je @f
561
		inc al
556
		inc al
562
		mov ebx,ted_sel_x0
557
		mov ebx,ted_sel_x0
563
		cmp ebx,ted_sel_x1
558
		cmp ebx,ted_sel_x1
564
		jne @f
559
		jne @f
565
		mov ebx,ted_sel_y0
560
		mov ebx,ted_sel_y0
566
		cmp ebx,ted_sel_y1
561
		cmp ebx,ted_sel_y1
567
		jne @f
562
		jne @f
568
		xor al,al
563
		xor al,al
569
	@@:
564
	@@:
570
	ret
565
	ret
571
endp
566
endp
572
 
567
 
573
;input:
568
;input:
574
; edi = pointer to tedit struct
569
; edi = pointer to tedit struct
575
align 16
570
align 16
576
proc ted_sel_normalize uses ecx esi
571
proc ted_sel_normalize uses ecx esi
577
	push edi
572
	push edi
578
		mov esi,edi
573
		mov esi,edi
579
		add esi,ted_offs_sel
574
		add esi,ted_offs_sel
580
		add edi,ted_offs_seln
575
		add edi,ted_offs_seln
581
		mov ecx,sizeof.TexSelect/4
576
		mov ecx,sizeof.TexSelect/4
582
		rep movsd
577
		rep movsd
583
	pop edi
578
	pop edi
584
 
579
 
585
	jmp @f
580
	jmp @f
586
		.swp_f:
581
		.swp_f:
587
		mov ecx,ted_seln_x0
582
		mov ecx,ted_seln_x0
588
		m2m ted_seln_x0,ted_seln_x1
583
		m2m ted_seln_x0,ted_seln_x1
589
		mov ted_seln_x1,ecx
584
		mov ted_seln_x1,ecx
590
 
585
 
591
		mov ecx,ted_seln_y0
586
		mov ecx,ted_seln_y0
592
		cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
587
		cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
593
		jle .end_f
588
		jle .end_f
594
		m2m ted_seln_y0,ted_seln_y1
589
		m2m ted_seln_y0,ted_seln_y1
595
		mov ted_seln_y1,ecx
590
		mov ted_seln_y1,ecx
596
 
591
 
597
		jmp .end_f
592
		jmp .end_f
598
align 4
593
align 4
599
	@@:
594
	@@:
600
 
595
 
601
	mov ecx,ted_seln_y0
596
	mov ecx,ted_seln_y0
602
	cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
597
	cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
603
	jg .swp_f
598
	jg .swp_f
604
 
599
 
605
	cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
600
	cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
606
	jne .end_f
601
	jne .end_f
607
		mov ecx,ted_seln_x0
602
		mov ecx,ted_seln_x0
608
		cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
603
		cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
609
		jg .swp_f
604
		jg .swp_f
610
 
605
 
611
	.end_f:
606
	.end_f:
612
	ret
607
	ret
613
endp
608
endp
614
 
609
 
615
;input:
610
;input:
616
; edi = pointer to tedit struct
611
; edi = pointer to tedit struct
617
;description:
612
;description:
618
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ­ ç «¥ ¢ë¤¥«¥­¨ï
613
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ­ ç «¥ ¢ë¤¥«¥­¨ï
619
align 16
614
align 16
620
proc ted_sel_start uses eax ecx
615
proc ted_sel_start uses eax ecx
621
	mov eax,ted_scr_h
616
	mov eax,ted_scr_h
622
	mov ecx,ted_cur_x
617
	mov ecx,ted_cur_x
623
	add ecx,[eax+sb_offs_position]
618
	add ecx,[eax+sb_offs_position]
624
	mov ted_sel_x0,ecx
619
	mov ted_sel_x0,ecx
625
	mov ted_sel_x1,ecx
620
	mov ted_sel_x1,ecx
626
 
621
 
627
	mov eax,ted_scr_w
622
	mov eax,ted_scr_w
628
	mov ecx,ted_cur_y
623
	mov ecx,ted_cur_y
629
	add ecx,[eax+sb_offs_position]
624
	add ecx,[eax+sb_offs_position]
630
	mov ted_sel_y0,ecx
625
	mov ted_sel_y0,ecx
631
	mov ted_sel_y1,ecx
626
	mov ted_sel_y1,ecx
632
	ret
627
	ret
633
endp
628
endp
634
 
629
 
635
;input:
630
;input:
636
; edi = pointer to tedit struct
631
; edi = pointer to tedit struct
637
;description:
632
;description:
-
 
633
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ á­ï⨨ ¢ë¤¥«¥­¨ï
-
 
634
align 16
-
 
635
proc ted_sel_end uses eax
-
 
636
	mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
-
 
637
	call ted_is_select
-
 
638
	or al,al
-
 
639
	jz @f
-
 
640
		xor eax,eax
-
 
641
		mov ted_sel_x0,eax
-
 
642
		mov ted_sel_x1,eax
-
 
643
		mov ted_sel_y0,eax
-
 
644
		mov ted_sel_y1,eax
-
 
645
		stdcall ted_draw,edi
-
 
646
		jmp .end_f
-
 
647
	@@:
-
 
648
	call ted_draw_main_cursor
-
 
649
	.end_f:
-
 
650
	ret
-
 
651
endp
-
 
652
 
-
 
653
;input:
-
 
654
; edi = pointer to tedit struct
-
 
655
;description:
638
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¯¥à¥¬¥é¥­¨¨ ¢ë¤¥«¥­¨ï
656
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¯¥à¥¬¥é¥­¨¨ ¢ë¤¥«¥­¨ï
639
align 16
657
align 16
640
proc ted_sel_move
658
proc ted_sel_move
641
	push eax ecx
659
	push eax ecx
642
		mov ecx,ted_cur_x
660
		mov ecx,ted_cur_x
643
		mov eax,ted_scr_h
661
		mov eax,ted_scr_h
644
		add ecx,[eax+sb_offs_position]
662
		add ecx,[eax+sb_offs_position]
645
		mov ted_sel_x1,ecx
663
		mov ted_sel_x1,ecx
646
 
664
 
647
		mov eax,ted_scr_w
665
		mov eax,ted_scr_w
648
		mov ecx,ted_cur_y
666
		mov ecx,ted_cur_y
649
		add ecx,[eax+sb_offs_position]
667
		add ecx,[eax+sb_offs_position]
650
		mov ted_sel_y1,ecx
668
		mov ted_sel_y1,ecx
651
	pop ecx eax
669
	pop ecx eax
652
	cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
670
	cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
653
	je @f
671
	je @f
654
		call ted_fun_draw_panel_buttons
672
		call ted_fun_draw_panel_buttons
655
	@@:
673
	@@:
656
	ret
674
	ret
657
endp
675
endp
658
 
676
 
659
;input:
677
;input:
660
; edi = pointer to tedit struct
678
; edi = pointer to tedit struct
661
;description:
679
;description:
662
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¢ë¤¥«¥­¨¨ ¢á¥£® ¤®ªã¬¥­â 
680
; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¢ë¤¥«¥­¨¨ ¢á¥£® ¤®ªã¬¥­â 
663
align 16
681
align 16
664
proc ted_sel_all
682
proc ted_sel_all
665
	push eax
683
	push eax
666
		xor eax,eax
684
		xor eax,eax
667
		mov ted_sel_x0,eax
685
		mov ted_sel_x0,eax
668
		mov ted_sel_y0,eax
686
		mov ted_sel_y0,eax
669
 
687
 
670
		mov ted_sel_x1,eax ;???
688
		mov ted_sel_x1,eax ;???
671
		call ted_get_num_lines
689
		call ted_get_num_lines
672
		mov ted_sel_y1,eax
690
		mov ted_sel_y1,eax
673
	pop eax
691
	pop eax
674
	stdcall ted_draw,edi
692
	stdcall ted_draw,edi
675
	cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
693
	cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
676
	je @f
694
	je @f
677
		call ted_fun_draw_panel_buttons
695
		call ted_fun_draw_panel_buttons
678
	@@:
696
	@@:
679
	ret
697
	ret
680
endp
698
endp
681
 
699
 
682
;input:
700
;input:
683
; cl_al_mem = 1 - clear all memory
701
; cl_al_mem = 1 - clear all memory
684
align 16
702
align 16
685
proc ted_clear uses ecx edi, edit:dword, cl_al_mem:dword
703
proc ted_clear uses ecx edi, edit:dword, cl_al_mem:dword
686
	mov edi,[edit]
704
	mov edi,[edit]
687
 
705
 
688
	mov ted_cur_x,0
706
	mov ted_cur_x,0
689
	mov ted_cur_y,0
707
	mov ted_cur_y,0
690
	mov ted_tim_ch,0
708
	mov ted_tim_ch,0
691
	mov ted_tim_ls,0
709
	mov ted_tim_ls,0
692
	mov ted_tim_co,0
710
	mov ted_tim_co,0
693
	mov ted_tim_undo,0
711
	mov ted_tim_undo,0
694
	mov ted_help_id,-1
712
	mov ted_help_id,-1
695
	mov ecx,sizeof.symbol
713
	mov ecx,sizeof.symbol
696
	shl ecx,1
714
	shl ecx,1
697
	add ecx,ted_tex
715
	add ecx,ted_tex
698
	mov ted_ptr_free_symb,ecx
716
	mov ted_ptr_free_symb,ecx
699
 
717
 
700
	mov ecx,ted_scr_w
718
	mov ecx,ted_scr_w
701
	mov dword[ecx+sb_offs_position],0
719
	mov dword[ecx+sb_offs_position],0
702
	mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® áâப ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
720
	mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® áâப ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
703
	mov dword[ecx+sb_offs_redraw],1
721
	mov dword[ecx+sb_offs_redraw],1
704
	mov ecx,ted_scr_h
722
	mov ecx,ted_scr_h
705
	mov dword[ecx+sb_offs_position],0
723
	mov dword[ecx+sb_offs_position],0
706
	mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® ᨬ¢®«®¢ ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
724
	mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® ᨬ¢®«®¢ ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
707
 
725
 
708
	mov ted_sel_x0,0
726
	mov ted_sel_x0,0
709
	mov ted_sel_y0,0
727
	mov ted_sel_y0,0
710
	mov ted_sel_x1,0
728
	mov ted_sel_x1,0
711
	mov ted_sel_y1,0
729
	mov ted_sel_y1,0
712
 
730
 
713
	cmp dword[cl_al_mem],0
731
	cmp dword[cl_al_mem],0
714
	je .exit
732
	je .exit
715
 
733
 
716
	push edx
734
	push edx
717
	mov ecx,sizeof.symbol
735
	mov ecx,sizeof.symbol
718
	imul ecx,ted_max_chars
736
	imul ecx,ted_max_chars
719
	mov edx,ted_tex
737
	mov edx,ted_tex
720
	@@:
738
	@@:
721
		mov byte [edx],0
739
		mov byte [edx],0
722
		inc edx
740
		inc edx
723
	loop @b
741
	loop @b
724
	mov edx,ted_tex
742
	mov edx,ted_tex
725
	mov dword [edx+symbol.next],1
743
	mov dword [edx+symbol.next],1
726
	pop edx
744
	pop edx
727
 
745
 
728
	.exit:
746
	.exit:
729
	ret
747
	ret
730
endp
748
endp
731
 
749
 
732
 
750
 
733
align 16
751
align 16
734
proc ted_init_syntax_file, edit:dword
752
proc ted_init_syntax_file, edit:dword
735
	pushad
753
	pushad
736
	mov edi,[edit]
754
	mov edi,[edit]
737
 
755
 
738
	mov ecx,0x100
756
	mov ecx,0x100
739
	mov edx,ted_arr_key_pos
757
	mov edx,ted_arr_key_pos
740
	@@:
758
	@@:
741
		mov dword[edx],-1
759
		mov dword[edx],-1
742
		add edx,4
760
		add edx,4
743
	loop @b
761
	loop @b
744
 
762
 
745
	;init: ted_colors_text_count, ted_key_words_count, ...
763
	;init: ted_colors_text_count, ted_key_words_count, ...
746
	mov ted_colors_text_count,1
764
	mov ted_colors_text_count,1
747
	mov ted_key_words_count,0
765
	mov ted_key_words_count,0
748
	mov ted_help_text_f1,0
766
	mov ted_help_text_f1,0
749
	mov ted_help_id,-1 ;¨¤¥­â¨ä¨ª â®à á«®¢  ¤«ï á¯à ¢ª¨
767
	mov ted_help_id,-1 ;¨¤¥­â¨ä¨ª â®à á«®¢  ¤«ï á¯à ¢ª¨
750
 
768
 
751
	mov eax,edi ;á®å࠭塞 §­ ç¥­¨¥ edi
769
	mov eax,edi ;á®å࠭塞 §­ ç¥­¨¥ edi
752
	mov esi,ted_syntax_file
770
	mov esi,ted_syntax_file
753
	add edi,ted_offs_count_colors
771
	add edi,ted_offs_count_colors
754
	mov ecx,9
772
	mov ecx,9
755
	rep movsd
773
	rep movsd
756
	mov edi,eax ;¢®áâ ­ ¢«¨¢ ¥¬ §­ ç¥­¨¥ edi
774
	mov edi,eax ;¢®áâ ­ ¢«¨¢ ¥¬ §­ ç¥­¨¥ edi
757
 
775
 
758
	mov eax,ted_syntax_file
776
	mov eax,ted_syntax_file
759
	add eax,32
777
	add eax,32
760
	mov ted_text_colors,eax
778
	mov ted_text_colors,eax
761
 
779
 
762
	mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
780
	mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
763
	lea eax,[4*eax+32]
781
	lea eax,[4*eax+32]
764
	add eax,ted_syntax_file
782
	add eax,ted_syntax_file
765
	mov ted_key_words_data,eax
783
	mov ted_key_words_data,eax
766
 
784
 
767
	mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
785
	mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
768
	xor eax,eax
786
	xor eax,eax
769
	@@:
787
	@@:
770
		ColToIndexOffset eax,edx
788
		ColToIndexOffset eax,edx
771
		movzx ebx,byte[edx]
789
		movzx ebx,byte[edx]
772
		mov esi,ted_arr_key_pos
790
		mov esi,ted_arr_key_pos
773
		lea esi,[esi+4*ebx]
791
		lea esi,[esi+4*ebx]
774
		cmp dword[esi],-1
792
		cmp dword[esi],-1
775
		jne .no_ch_key
793
		jne .no_ch_key
776
			mov [esi],eax
794
			mov [esi],eax
777
		.no_ch_key:
795
		.no_ch_key:
778
		inc eax
796
		inc eax
779
	loop @b
797
	loop @b
780
 
798
 
781
	;init: ted_help_text_f1
799
	;init: ted_help_text_f1
782
	mov ecx,ted_key_words_count ;ª®«¨ç¥á⢮ ª«î祢ëå á«®¢
800
	mov ecx,ted_key_words_count ;ª®«¨ç¥á⢮ ª«î祢ëå á«®¢
783
	imul ecx,sizeof.TexColViv   ;à §¬¥à áâàãªâãàë á 1-¬ ª«. á«.
801
	imul ecx,sizeof.TexColViv   ;à §¬¥à áâàãªâãàë á 1-¬ ª«. á«.
784
	add ecx,ted_key_words_data  ;­ ç «® ä ©«  á ª«. á«.
802
	add ecx,ted_key_words_data  ;­ ç «® ä ©«  á ª«. á«.
785
	mov ted_help_text_f1,ecx    ;¬¥âª  ¢ ¯ ¬ïâ¨, £¤¥ ­ ç¨­¥âáï ⥪áâ á® á¯à ¢ª®©
803
	mov ted_help_text_f1,ecx    ;¬¥âª  ¢ ¯ ¬ïâ¨, £¤¥ ­ ç¨­¥âáï ⥪áâ á® á¯à ¢ª®©
786
 
804
 
787
	stdcall ted_init_scroll_bars,edi,1 ;¬¥­ï¥¬ æ¢¥â  áªà®««¨­£®¢
805
	stdcall ted_init_scroll_bars,edi,1 ;¬¥­ï¥¬ æ¢¥â  áªà®««¨­£®¢
788
	.no_colors:
806
	.no_colors:
789
	popad
807
	popad
790
	ret
808
	ret
791
endp
809
endp
792
 
810
 
793
;input:
811
;input:
794
; ebx = file size
812
; ebx = file size
795
; edi = pointer to tedit struct
813
; edi = pointer to tedit struct
796
;description:
814
;description:
797
; ”ã­ªæ¨ï ¢ë§ë¢ ¥âáï ¯à¨ ®âªàë⨨ ä ©« 
815
; ”ã­ªæ¨ï ¢ë§ë¢ ¥âáï ¯à¨ ®âªàë⨨ ä ©« 
798
align 16
816
align 16
799
proc ted_on_open_file
817
proc ted_on_open_file
800
	push eax ;destination
818
	push eax ;destination
801
	push ecx ;for cycle
819
	push ecx ;for cycle
802
	push edx ;source
820
	push edx ;source
803
	push esi
821
	push esi
804
 
822
 
805
	stdcall ted_clear,edi,0 ;ç¨á⨬ ­¥ ¢áî ¯ ¬ïâì, ¯®â®¬ã çâ® ­¨¦¥ ¡ã¤¥¬ ¥¥ § ¯®«­ïâì ­®¢ë¬¨ ¤ ­ë¬¨
823
	stdcall ted_clear,edi,0 ;ç¨á⨬ ­¥ ¢áî ¯ ¬ïâì, ¯®â®¬ã çâ® ­¨¦¥ ¡ã¤¥¬ ¥¥ § ¯®«­ïâì ­®¢ë¬¨ ¤ ­ë¬¨
806
 
824
 
807
	;ª®£¤  ᨬ¢®« § ¢¥à襭¨ï áâப¨ ⮫쪮 10 (¡¥§ 13)
825
	;ª®£¤  ᨬ¢®« § ¢¥à襭¨ï áâப¨ ⮫쪮 10 (¡¥§ 13)
808
	mov edx,ted_tex
826
	mov edx,ted_tex
809
	mov ecx,ebx
827
	mov ecx,ebx
810
	@@:
828
	@@:
811
		cmp byte[edx],13
829
		cmp byte[edx],13
812
		je .no_10 ;¥á«¨ ­ ©¤¥­ ᨬ¢®« 13, â® 10-¥ ¨£­®à¨à㥬
830
		je .no_10 ;¥á«¨ ­ ©¤¥­ ᨬ¢®« 13, â® 10-¥ ¨£­®à¨à㥬
813
		inc edx
831
		inc edx
814
		loop @b
832
		loop @b
815
	mov edx,ted_tex
833
	mov edx,ted_tex
816
	mov ecx,ebx
834
	mov ecx,ebx
817
	.s_10:
835
	.s_10:
818
		cmp byte[edx],10
836
		cmp byte[edx],10
819
		jne @f
837
		jne @f
820
			mov byte[edx],13 ;¬¥­ï¥¬ 10-© ᨬ¢®« ª®­æ  áâப¨
838
			mov byte[edx],13 ;¬¥­ï¥¬ 10-© ᨬ¢®« ª®­æ  áâப¨
821
		@@:
839
		@@:
822
		inc edx
840
		inc edx
823
		loop .s_10
841
		loop .s_10
824
	.no_10:
842
	.no_10:
825
 
843
 
826
	;¯¥à¥¢®¤¨¬ ®âªàëâë© ä ©« ¢­ãâàì í«¥¬¥­â  t_edit
844
	;¯¥à¥¢®¤¨¬ ®âªàëâë© ä ©« ¢­ãâàì í«¥¬¥­â  t_edit
827
	mov eax,ebx
845
	mov eax,ebx
828
	mov ecx,ebx
846
	mov ecx,ebx
829
	add eax,2
847
	add eax,2
830
	ConvertIndexToPointer eax
848
	ConvertIndexToPointer eax
831
	mov edx,ted_tex
849
	mov edx,ted_tex
832
	add edx,ebx
850
	add edx,ebx
833
	push ebx
851
	push ebx
834
	@@:
852
	@@:
835
		mov ebx,[edx]
853
		mov ebx,[edx]
836
		mov byte[eax],bl
854
		mov byte[eax],bl
837
		mov dword[eax+symbol.perv],ecx
855
		mov dword[eax+symbol.perv],ecx
838
		inc dword[eax+symbol.perv]
856
		inc dword[eax+symbol.perv]
839
		mov dword[eax+symbol.next],ecx
857
		mov dword[eax+symbol.next],ecx
840
		add dword[eax+symbol.next],3
858
		add dword[eax+symbol.next],3
841
		;mov byte[eax+1],0 ;col=0
859
		;mov byte[eax+1],0 ;col=0
842
		mov dword[eax+symbol.tc],-1
860
		mov dword[eax+symbol.tc],-1
843
		mov dword[eax+symbol.td],0
861
		mov dword[eax+symbol.td],0
844
 
862
 
845
		cmp ecx,0
863
		cmp ecx,0
846
		je @f
864
		je @f
847
		dec ecx
865
		dec ecx
848
		dec edx
866
		dec edx
849
		sub eax,sizeof.symbol
867
		sub eax,sizeof.symbol
850
		jmp @b
868
		jmp @b
851
	@@:
869
	@@:
852
	pop ebx
870
	pop ebx
853
	mov dword[eax+symbol.perv],0 ; first sumbol 'perv=0'
871
	mov dword[eax+symbol.perv],0 ; first sumbol 'perv=0'
854
 
872
 
855
	mov edx,ted_tex ; ­ áâனª¨ ­ ç «ì­®£® á«ã¦¥¡­®£® ᨬ¢®« 
873
	mov edx,ted_tex ; ­ áâனª¨ ­ ç «ì­®£® á«ã¦¥¡­®£® ᨬ¢®« 
856
	; begining sumbol 'perv=0' 'next=2'
874
	; begining sumbol 'perv=0' 'next=2'
857
	mov dword[edx+symbol.perv],0
875
	mov dword[edx+symbol.perv],0
858
	mov dword[edx+symbol.next],2
876
	mov dword[edx+symbol.next],2
859
 
877
 
860
	add edx,sizeof.symbol ; ­ áâனª¨ ª®­¥ç­®£® á«ã¦¥¡­®£® ᨬ¢®« 
878
	add edx,sizeof.symbol ; ­ áâனª¨ ª®­¥ç­®£® á«ã¦¥¡­®£® ᨬ¢®« 
861
	mov dword[edx+symbol.next],0 ; last sumbol 'next=0'
879
	mov dword[edx+symbol.next],0 ; last sumbol 'next=0'
862
	mov dword[edx+symbol.perv],ebx ; last sumbol 'perv=last'
880
	mov dword[edx+symbol.perv],ebx ; last sumbol 'perv=last'
863
	inc dword[edx+symbol.perv]
881
	inc dword[edx+symbol.perv]
864
	mov dword[edx+symbol.tc],0 ; áâ ¢¨¬ ¢à¥¬ï ᮧ¤ ­¨ï à ¢­®¥ 0, çâ® ¡ë ᨬ¢®« ¯à ¢¨«ì­® ®¡à ¡ â뢠«áï ¯à¨ ®âªàë⨨ ä ©«®¢ ¡®«ìè¨å 28 ¡ ©â
882
	mov dword[edx+symbol.tc],0 ; áâ ¢¨¬ ¢à¥¬ï ᮧ¤ ­¨ï à ¢­®¥ 0, çâ® ¡ë ᨬ¢®« ¯à ¢¨«ì­® ®¡à ¡ â뢠«áï ¯à¨ ®âªàë⨨ ä ©«®¢ ¡®«ìè¨å 28 ¡ ©â
865
 
883
 
866
	mov edx,ebx
884
	mov edx,ebx
867
	inc edx ;2 = rezerv sumbols
885
	inc edx ;2 = rezerv sumbols
868
	imul edx,sizeof.symbol
886
	imul edx,sizeof.symbol
869
	add edx,ted_tex
887
	add edx,ted_tex
870
	mov dword[edx+symbol.next],1 ; last sumbol 'next=1'
888
	mov dword[edx+symbol.next],1 ; last sumbol 'next=1'
871
 
889
 
872
	@@: ;clear memory, need if before was open big file
890
	@@: ;clear memory, need if before was open big file
873
		add edx,sizeof.symbol
891
		add edx,sizeof.symbol
874
		cmp edx,ted_tex_end
892
		cmp edx,ted_tex_end
875
		jge @f
893
		jge @f
876
			mov dword[edx+symbol.tc],0
894
			mov dword[edx+symbol.tc],0
877
			mov dword[edx+symbol.td],0
895
			mov dword[edx+symbol.td],0
878
		jmp @b
896
		jmp @b
879
	@@:
897
	@@:
880
 
898
 
881
	call ted_get_num_lines
899
	call ted_get_num_lines
882
	cmp eax,TED_LINES_IN_NEW_FILE
900
	cmp eax,TED_LINES_IN_NEW_FILE
883
	jge @f
901
	jge @f
884
		mov eax,TED_LINES_IN_NEW_FILE
902
		mov eax,TED_LINES_IN_NEW_FILE
885
	@@:
903
	@@:
886
	mov esi,ted_scr_w
904
	mov esi,ted_scr_w
887
	mov dword[esi+sb_offs_max_area],eax
905
	mov dword[esi+sb_offs_max_area],eax
888
	pop esi edx ecx eax
906
	pop esi edx ecx eax
889
 
907
 
890
	call ted_text_colored
908
	call ted_text_colored
891
	stdcall ted_draw,edi
909
	stdcall ted_draw,edi
892
	cmp ted_fun_draw_panel_buttons,0
910
	cmp ted_fun_draw_panel_buttons,0
893
	je @f
911
	je @f
894
		call ted_fun_draw_panel_buttons
912
		call ted_fun_draw_panel_buttons
895
	@@:
913
	@@:
896
	ret
914
	ret
897
endp
915
endp
898
 
916
 
899
;input:
917
;input:
900
; edx = pointer to symbol struct
918
; edx = pointer to symbol struct
901
; edi = pointer to tedit struct
919
; edi = pointer to tedit struct
902
;output:
920
;output:
903
; edx = pointer to 'perv' visible symbol struct
921
; edx = pointer to 'perv' visible symbol struct
904
align 16
922
align 16
905
ted_iterat_perv:
923
ted_iterat_perv:
906
	cmp ted_tim_undo,0
924
	cmp ted_tim_undo,0
907
	je .else
925
	je .else
908
	push ebx
926
	push ebx
909
	@@:
927
	@@:
910
		mov edx,[edx+symbol.perv]
928
		mov edx,[edx+symbol.perv]
911
		or edx,edx
929
		or edx,edx
912
		jz @f
930
		jz @f
913
		imul edx,sizeof.symbol
931
		imul edx,sizeof.symbol
914
		add edx,ted_tex
932
		add edx,ted_tex
915
		call ted_symbol_not_vis
933
		call ted_symbol_not_vis
916
		cmp bl,1
934
		cmp bl,1
917
		je @b
935
		je @b
918
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
936
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
919
		je @b
937
		je @b
920
	pop ebx
938
	pop ebx
921
	ret
939
	ret
922
	@@:
940
	@@:
923
	mov edx,ted_tex ;­ ç «® ä ©« 
941
	mov edx,ted_tex ;­ ç «® ä ©« 
924
	pop ebx
942
	pop ebx
925
	ret
943
	ret
926
	.else:
944
	.else:
927
		mov edx,[edx+symbol.perv]
945
		mov edx,[edx+symbol.perv]
928
		or edx,edx
946
		or edx,edx
929
		jz @f
947
		jz @f
930
		imul edx,sizeof.symbol
948
		imul edx,sizeof.symbol
931
		add edx,ted_tex
949
		add edx,ted_tex
932
		cmp dword[edx+symbol.td],0
950
		cmp dword[edx+symbol.td],0
933
		jne .else
951
		jne .else
934
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
952
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
935
		je .else
953
		je .else
936
	ret
954
	ret
937
	@@:
955
	@@:
938
	mov edx,ted_tex ;­ ç «® ä ©« 
956
	mov edx,ted_tex ;­ ç «® ä ©« 
939
	ret
957
	ret
940
 
958
 
941
 
959
 
942
;input:
960
;input:
943
; edx = pointer to symbol struct
961
; edx = pointer to symbol struct
944
; edi = pointer to tedit struct
962
; edi = pointer to tedit struct
945
;output:
963
;output:
946
; edx = pointer to 'next' visible symbol struct
964
; edx = pointer to 'next' visible symbol struct
947
align 16
965
align 16
948
ted_iterat_next:
966
ted_iterat_next:
949
	cmp ted_tim_undo,0
967
	cmp ted_tim_undo,0
950
	je .else
968
	je .else
951
	push ebx
969
	push ebx
952
	@@:
970
	@@:
953
		mov edx,[edx+symbol.next]
971
		mov edx,[edx+symbol.next]
954
		cmp edx,1
972
		cmp edx,1
955
		jle @f
973
		jle @f
956
		imul edx,sizeof.symbol
974
		imul edx,sizeof.symbol
957
		add edx,ted_tex
975
		add edx,ted_tex
958
 
976
 
959
		call ted_symbol_not_vis
977
		call ted_symbol_not_vis
960
		cmp bl,1
978
		cmp bl,1
961
		je @b
979
		je @b
962
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
980
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
963
		je @b
981
		je @b
964
	pop ebx
982
	pop ebx
965
	ret
983
	ret
966
	@@:
984
	@@:
967
	mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
985
	mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
968
	pop ebx
986
	pop ebx
969
	ret
987
	ret
970
	.else:
988
	.else:
971
		mov edx,[edx+symbol.next]
989
		mov edx,[edx+symbol.next]
972
		cmp edx,1
990
		cmp edx,1
973
		jle @f
991
		jle @f
974
		imul edx,sizeof.symbol
992
		imul edx,sizeof.symbol
975
		add edx,ted_tex
993
		add edx,ted_tex
976
 
994
 
977
		cmp dword[edx+symbol.td],0
995
		cmp dword[edx+symbol.td],0
978
		jne .else
996
		jne .else
979
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
997
		cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
980
		je .else
998
		je .else
981
	ret
999
	ret
982
	@@:
1000
	@@:
983
	mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
1001
	mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
984
	ret
1002
	ret
985
 
1003
 
986
;input:
1004
;input:
987
; bl = symbol end of select
1005
; bl = symbol end of select
988
; bh = íªà ­¨àãî騩 ᨬ¢®« (= 0 ¥á«¨ ­¥â ¯à®¢¥àª¨ ­  ­¨å)
1006
; bh = íªà ­¨àãî騩 ᨬ¢®« (= 0 ¥á«¨ ­¥â ¯à®¢¥àª¨ ­  ­¨å)
989
; edx = pointer to symbol struct
1007
; edx = pointer to symbol struct
990
; edi = pointer to tedit struct
1008
; edi = pointer to tedit struct
991
;description:
1009
;description:
992
; ­ ©â¨ á«¥¤ãîéãî ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
1010
; ­ ©â¨ á«¥¤ãîéãî ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
993
align 16
1011
align 16
994
ted_iterat_next_pos_char:
1012
ted_iterat_next_pos_char:
995
	push ax
1013
	push ax
996
	mov al,1 ;¯à¥¤ë¤ã騩 ᨬ¢®«, á«ã¦¨â ¤«ï áà ¢­¥­¨ï á ᨬ¢®«®¬ bh
1014
	mov al,1 ;¯à¥¤ë¤ã騩 ᨬ¢®«, á«ã¦¨â ¤«ï áà ¢­¥­¨ï á ᨬ¢®«®¬ bh
997
	@@:
1015
	@@:
998
		cmp bl,byte[edx]
1016
		cmp bl,byte[edx]
999
		je .found
1017
		je .found
1000
		.no_found:
1018
		.no_found:
1001
		cmp edx,ted_tex_1
1019
		cmp edx,ted_tex_1
1002
		jle @f
1020
		jle @f
1003
			mov al,byte[edx]
1021
			mov al,byte[edx]
1004
			call ted_iterat_next
1022
			call ted_iterat_next
1005
			jmp @b
1023
			jmp @b
1006
	.found:
1024
	.found:
1007
		cmp bh,al
1025
		cmp bh,al
1008
		je .no_found
1026
		je .no_found
1009
	@@:
1027
	@@:
1010
	call ted_iterat_next
1028
	call ted_iterat_next
1011
	pop ax
1029
	pop ax
1012
	ret
1030
	ret
1013
 
1031
 
1014
;input:
1032
;input:
1015
; edx = pointer to symbol struct
1033
; edx = pointer to symbol struct
1016
; edi = pointer to tedit struct
1034
; edi = pointer to tedit struct
1017
align 16
1035
align 16
1018
ted_iterat_perv_color_tag:
1036
ted_iterat_perv_color_tag:
1019
	@@:
1037
	@@:
1020
		cmp byte[edx+1],0
1038
		cmp byte[edx+1],0
1021
		jne @f
1039
		jne @f
1022
		call ted_iterat_perv
1040
		call ted_iterat_perv
1023
		cmp edx,ted_tex_1
1041
		cmp edx,ted_tex_1
1024
		jle @f
1042
		jle @f
1025
		jmp @b
1043
		jmp @b
1026
align 4
1044
align 4
1027
	@@:
1045
	@@:
1028
	ret
1046
	ret
1029
 
1047
 
1030
;input:
1048
;input:
1031
; edx = pointer to symbol struct
1049
; edx = pointer to symbol struct
1032
; edi = pointer to tedit struct
1050
; edi = pointer to tedit struct
1033
align 16
1051
align 16
1034
ted_iterat_next_color_tag:
1052
ted_iterat_next_color_tag:
1035
	@@:
1053
	@@:
1036
		call ted_iterat_next
1054
		call ted_iterat_next
1037
		cmp byte[edx+1],0
1055
		cmp byte[edx+1],0
1038
		jne @f
1056
		jne @f
1039
		cmp edx,ted_tex_1
1057
		cmp edx,ted_tex_1
1040
		jle @f
1058
		jle @f
1041
		jmp @b
1059
		jmp @b
1042
align 4
1060
align 4
1043
	@@:
1061
	@@:
1044
	ret
1062
	ret
1045
 
1063
 
1046
;input:
1064
;input:
1047
; edx = pointer to symbol struct
1065
; edx = pointer to symbol struct
1048
; edi = pointer to tedit struct
1066
; edi = pointer to tedit struct
1049
;output:
1067
;output:
1050
; bl = 1 if sumbol not visible
1068
; bl = 1 if sumbol not visible
1051
; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
1069
; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
1052
align 16
1070
align 16
1053
ted_symbol_not_vis:
1071
ted_symbol_not_vis:
1054
	push eax
1072
	push eax
1055
 
1073
 
1056
	xor bl,bl
1074
	xor bl,bl
1057
	cmp dword[edx+symbol.td],0
1075
	cmp dword[edx+symbol.td],0
1058
	je @f
1076
	je @f
1059
	mov eax,[edx+symbol.td] ;eax=tex[i].td
1077
	mov eax,[edx+symbol.td] ;eax=tex[i].td
1060
	add eax,ted_tim_undo
1078
	add eax,ted_tim_undo
1061
	cmp eax,ted_tim_ch
1079
	cmp eax,ted_tim_ch
1062
	jg @f
1080
	jg @f
1063
		mov bl,1
1081
		mov bl,1
1064
		pop eax
1082
		pop eax
1065
		ret
1083
		ret
1066
	@@:
1084
	@@:
1067
 
1085
 
1068
	mov eax,ted_tim_ch
1086
	mov eax,ted_tim_ch
1069
	sub eax,ted_tim_undo
1087
	sub eax,ted_tim_undo
1070
	cmp [edx+symbol.tc],eax
1088
	cmp [edx+symbol.tc],eax
1071
	jle @f
1089
	jle @f
1072
		or bl,1
1090
		or bl,1
1073
	@@:
1091
	@@:
1074
 
1092
 
1075
	pop eax
1093
	pop eax
1076
	ret
1094
	ret
1077
 
1095
 
1078
;input:
1096
;input:
1079
; text - pointer to text string
1097
; text - pointer to text string
1080
; add_opt - options
1098
; add_opt - options
1081
align 16
1099
align 16
1082
proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
1100
proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
1083
	locals
1101
	locals
1084
		new_spc dd ? ;count new spaces
1102
		new_spc dd ? ;count new spaces
1085
		new_lin dd ? ;count new lines
1103
		new_lin dd ? ;count new lines
1086
	endl
1104
	endl
1087
;¨á¯®«ì§®¢ ­¨¥ ॣ¨áâ஢ ¢­ãâਠä㭪樨:
1105
;¨á¯®«ì§®¢ ­¨¥ ॣ¨áâ஢ ¢­ãâਠä㭪樨:
1088
;eax - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨ ⥪áâ 
1106
;eax - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨ ⥪áâ 
1089
;ebx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤, ¤«¨­­  ¢áâ ¢«ï¥¬®£® ⥪áâ 
1107
;ebx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤, ¤«¨­­  ¢áâ ¢«ï¥¬®£® ⥪áâ 
1090
;ecx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤
1108
;ecx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤
1091
;edx - 㪠§ â¥«ì ­  áâàãªâãàã ᨬ¢®« 
1109
;edx - 㪠§ â¥«ì ­  áâàãªâãàã ᨬ¢®« 
1092
	pushad
1110
	pushad
1093
	cmp dword[t_len],1 ;¯à®¢¥à塞 ¤«¨­­ã ¤®¡¢«ï¥¬®£® ⥪áâ 
1111
	cmp dword[t_len],1 ;¯à®¢¥à塞 ¤«¨­­ã ¤®¡¢«ï¥¬®£® ⥪áâ 
1094
	jl .no_add ;ª®£¤  ¤«¨­­  <1 ¯à룠¥¬ ­  ª®­¥æ ä㭪樨, ¢® ¨§¡¥¦ ­¨¥ £«îª®¢
1112
	jl .no_add ;ª®£¤  ¤«¨­­  <1 ¯à룠¥¬ ­  ª®­¥æ ä㭪樨, ¢® ¨§¡¥¦ ­¨¥ £«îª®¢
1095
 
1113
 
1096
	mov edi,[edit]
1114
	mov edi,[edit]
1097
	mov esi,[text]
1115
	mov esi,[text]
1098
 
1116
 
1099
	call ted_get_pos_by_cursor
1117
	call ted_get_pos_by_cursor
1100
	call ted_get_text_perv_pos
1118
	call ted_get_text_perv_pos
1101
	call ted_get_text_arr_index ;eax=po_t
1119
	call ted_get_text_arr_index ;eax=po_t
1102
 
1120
 
1103
	mov dword[new_spc],0
1121
	mov dword[new_spc],0
1104
	cmp ted_gp_opt,2
1122
	cmp ted_gp_opt,2
1105
	je @f
1123
	je @f
1106
		push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
1124
		push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
1107
			mov eax,ted_scr_h
1125
			mov eax,ted_scr_h
1108
			mov eax,[eax+sb_offs_position]
1126
			mov eax,[eax+sb_offs_position]
1109
			add eax,ted_cur_x ;eax - ­®¬¥à ᨬ¢®« 
1127
			add eax,ted_cur_x ;eax - ­®¬¥à ᨬ¢®« 
1110
			mov [new_spc],eax
1128
			mov [new_spc],eax
1111
 
1129
 
1112
			mov eax,ted_scr_w
1130
			mov eax,ted_scr_w
1113
			mov eax,[eax+sb_offs_position]
1131
			mov eax,[eax+sb_offs_position]
1114
			add eax,ted_cur_y ;eax - ­®¬¥à áâப¨
1132
			add eax,ted_cur_y ;eax - ­®¬¥à áâப¨
1115
			call ted_strlen ;ebx = line len
1133
			call ted_strlen ;ebx = line len
1116
			sub [new_spc],ebx ;®â ¯®§¨æ¨¨ ªãàá®à  ®â­¨¬ ¥¬ ¤«¨­­ã áâப¨, 㧭 ¥¬ ª®««¨ç¥á⢮ ¤®¡ ¢«ï¥¬ëå ¯à®¡¥«®¢
1134
			sub [new_spc],ebx ;®â ¯®§¨æ¨¨ ªãàá®à  ®â­¨¬ ¥¬ ¤«¨­­ã áâப¨, 㧭 ¥¬ ª®««¨ç¥á⢮ ¤®¡ ¢«ï¥¬ëå ¯à®¡¥«®¢
1117
		pop eax
1135
		pop eax
1118
	@@:
1136
	@@:
1119
 
1137
 
1120
	mov ebx,[t_len]
1138
	mov ebx,[t_len]
1121
 
1139
 
1122
	mov dword[new_lin],0
1140
	mov dword[new_lin],0
1123
	cmp ted_gp_opt,0
1141
	cmp ted_gp_opt,0
1124
	jne @f
1142
	jne @f
1125
		push eax
1143
		push eax
1126
			mov eax,ted_scr_w
1144
			mov eax,ted_scr_w
1127
			mov eax,[eax+sb_offs_position]
1145
			mov eax,[eax+sb_offs_position]
1128
			add eax,ted_cur_y
1146
			add eax,ted_cur_y
1129
			inc eax
1147
			inc eax
1130
			mov [new_lin],eax
1148
			mov [new_lin],eax
1131
 
1149
 
1132
			call ted_get_num_lines
1150
			call ted_get_num_lines
1133
			sub [new_lin],eax
1151
			sub [new_lin],eax
1134
			;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¤®¯®«­¨â¥«ì­ëå áâப
1152
			;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¤®¯®«­¨â¥«ì­ëå áâப
1135
			mov ecx,ted_scr_w
1153
			mov ecx,ted_scr_w
1136
			add [ecx+sb_offs_max_area],eax ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
1154
			add [ecx+sb_offs_max_area],eax ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
1137
		pop eax
1155
		pop eax
1138
	@@:
1156
	@@:
1139
 
1157
 
1140
	mov edx,ted_ptr_free_symb
1158
	mov edx,ted_ptr_free_symb
1141
	.beg_cycle: ;for(i=...;i
1159
	.beg_cycle: ;for(i=...;i
1142
		cmp dword[edx+symbol.tc],0 ;if(!tex[i].tc && !tex[i].td)
1160
		cmp dword[edx+symbol.tc],0 ;if(!tex[i].tc && !tex[i].td)
1143
		jne .u1f
1161
		jne .u1f
1144
		cmp dword[edx+symbol.td],0
1162
		cmp dword[edx+symbol.td],0
1145
		jne .u1f
1163
		jne .u1f
1146
			test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
1164
			test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
1147
			jz .no_tim
1165
			jz .no_tim
1148
				inc ted_tim_ch
1166
				inc ted_tim_ch
1149
			.no_tim:
1167
			.no_tim:
1150
			test dword[add_opt],ted_opt_ed_move_cursor
1168
			test dword[add_opt],ted_opt_ed_move_cursor
1151
			jz .no_cur_mov
1169
			jz .no_cur_mov
1152
			cmp dword[new_lin],0 ;¥á«¨ ¥áâì ¤®¡ ¢®ç­ë¥ áâப¨, â® ªãàá®à ¥é¥ ­¥ ¤¢¨£ ¥¬
1170
			cmp dword[new_lin],0 ;¥á«¨ ¥áâì ¤®¡ ¢®ç­ë¥ áâப¨, â® ªãàá®à ¥é¥ ­¥ ¤¢¨£ ¥¬
1153
			jg .no_cur_mov
1171
			jg .no_cur_mov
1154
			cmp dword[new_spc],0 ;¥á«¨ ­¥â ¤®¡ ¢®ç­ëå ¯à®¡¥«®¢, â® ªãàá®à ⮦¥ ­¥ ¤¢¨£ ¥¬
1172
			cmp dword[new_spc],0 ;¥á«¨ ­¥â ¤®¡ ¢®ç­ëå ¯à®¡¥«®¢, â® ªãàá®à ⮦¥ ­¥ ¤¢¨£ ¥¬
1155
			jg .no_cur_mov
1173
			jg .no_cur_mov
1156
				inc ted_cur_x ;move cursor
1174
				inc ted_cur_x ;move cursor
1157
				;call ted_go_to_pos
1175
				;call ted_go_to_pos
1158
				cmp byte[esi],13
1176
				cmp byte[esi],13
1159
				jne .no_cur_mov
1177
				jne .no_cur_mov
1160
					mov ted_cur_x,0
1178
					mov ted_cur_x,0
1161
					inc ted_cur_y
1179
					inc ted_cur_y
1162
					;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¢ ⥪á⥠áâப
1180
					;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¢ ⥪á⥠áâப
1163
					mov ecx,ted_scr_w
1181
					mov ecx,ted_scr_w
1164
					inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
1182
					inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
1165
			.no_cur_mov:
1183
			.no_cur_mov:
1166
 
1184
 
1167
			; *** ¢áâ ¢ª  ⥪ã饣® ᨬ¢®«  ¨§ áâப¨ ***
1185
			; *** ¢áâ ¢ª  ⥪ã饣® ᨬ¢®«  ¨§ áâப¨ ***
1168
			mov ecx,ted_opt_ed_change_time
1186
			mov ecx,ted_opt_ed_change_time
1169
			not ecx
1187
			not ecx
1170
			and [add_opt],ecx ;n_tim=false;
1188
			and [add_opt],ecx ;n_tim=false;
1171
 
1189
 
1172
			mov cl,byte[esi] ;tex[i].c=ta[ns];
1190
			mov cl,byte[esi] ;tex[i].c=ta[ns];
1173
			mov byte[edx],cl
1191
			mov byte[edx],cl
1174
			m2m dword[edx+symbol.tc],ted_tim_ch ;tex[i].tc=ted_tim_ch;
1192
			m2m dword[edx+symbol.tc],ted_tim_ch ;tex[i].tc=ted_tim_ch;
1175
			mov [edx+symbol.perv],eax ;tex[i].perv=po_t;
1193
			mov [edx+symbol.perv],eax ;tex[i].perv=po_t;
1176
 
1194
 
1177
			mov ecx,eax
1195
			mov ecx,eax
1178
			imul ecx,sizeof.symbol
1196
			imul ecx,sizeof.symbol
1179
			add ecx,ted_tex ; *** ecx = tex[po_t] ***
1197
			add ecx,ted_tex ; *** ecx = tex[po_t] ***
1180
			add ecx,symbol.next ; *** ecx = tex[po_t].next ***
1198
			add ecx,symbol.next ; *** ecx = tex[po_t].next ***
1181
			m2m dword[edx+symbol.next],dword[ecx] ;tex[i].next=tex[po_t].next;
1199
			m2m dword[edx+symbol.next],dword[ecx] ;tex[i].next=tex[po_t].next;
1182
 
1200
 
1183
			call ted_get_text_arr_index ;*** eax = i ***
1201
			call ted_get_text_arr_index ;*** eax = i ***
1184
			mov [ecx],eax ;tex[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
1202
			mov [ecx],eax ;tex[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
1185
			mov ecx,[edx+symbol.next] ; *** ecx = tex[i].next ***
1203
			mov ecx,[edx+symbol.next] ; *** ecx = tex[i].next ***
1186
			imul ecx,sizeof.symbol
1204
			imul ecx,sizeof.symbol
1187
			add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
1205
			add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
1188
			mov [ecx+symbol.perv],eax ;tex[tex[i].next].perv=i;
1206
			mov [ecx+symbol.perv],eax ;tex[tex[i].next].perv=i;
1189
 
1207
 
1190
			; *** ¢áâ ¢ª  ¤®¯®«­¨â¥«ì­ëå áâப ¨ ¯à®¡¥«®¢
1208
			; *** ¢áâ ¢ª  ¤®¯®«­¨â¥«ì­ëå áâப ¨ ¯à®¡¥«®¢
1191
			; ¥á«¨ ªãàá®à ¢® ¢à¥¬ï ¢áâ ¢ª¨ ­ å®¤¨«áï §  ⥪á⮬ ***
1209
			; ¥á«¨ ªãàá®à ¢® ¢à¥¬ï ¢áâ ¢ª¨ ­ å®¤¨«áï §  ⥪á⮬ ***
1192
			cmp dword[new_lin],0 ;add lines or text
1210
			cmp dword[new_lin],0 ;add lines or text
1193
			jle .spc_add
1211
			jle .spc_add
1194
				dec dword[new_lin]
1212
				dec dword[new_lin]
1195
				mov byte [edx],13
1213
				mov byte [edx],13
1196
				jmp .u1f
1214
				jmp .u1f
1197
			.spc_add:
1215
			.spc_add:
1198
			cmp dword[new_spc],0 ;add spaces or text
1216
			cmp dword[new_spc],0 ;add spaces or text
1199
			jle .tex_add
1217
			jle .tex_add
1200
				dec dword[new_spc]
1218
				dec dword[new_spc]
1201
				mov byte [edx],' '
1219
				mov byte [edx],' '
1202
				jmp .u1f
1220
				jmp .u1f
1203
			.tex_add:
1221
			.tex_add:
1204
			inc esi ; ¯¥à¥å®¤ ª á«¥¤ãî饬㠢áâ ¢«ï¥¬®¬ã ᨬ¢®«ã
1222
			inc esi ; ¯¥à¥å®¤ ª á«¥¤ãî饬㠢áâ ¢«ï¥¬®¬ã ᨬ¢®«ã
1205
			dec ebx
1223
			dec ebx
1206
		.u1f:
1224
		.u1f:
1207
		add edx,sizeof.symbol
1225
		add edx,sizeof.symbol
1208
		cmp edx,ted_tex_end
1226
		cmp edx,ted_tex_end
1209
		jge @f ;out of memory
1227
		jge @f ;out of memory
1210
		cmp ebx,0
1228
		cmp ebx,0
1211
		jne .beg_cycle
1229
		jne .beg_cycle
1212
		mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
1230
		mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
1213
		jmp .add_all
1231
		jmp .add_all
1214
	@@:
1232
	@@:
1215
	cmp ted_increase_size,0
1233
	cmp ted_increase_size,0
1216
	je .add_all
1234
	je .add_all
1217
		call ted_memory_increase
1235
		call ted_memory_increase
1218
		cmp ebx,0
1236
		cmp ebx,0
1219
		jne .beg_cycle
1237
		jne .beg_cycle
1220
	.add_all: ;¢á¥ ᨬ¢®«ë ¤®¡ ¢«¥­ë
1238
	.add_all: ;¢á¥ ᨬ¢®«ë ¤®¡ ¢«¥­ë
1221
 
1239
 
1222
	call ted_text_colored
1240
	call ted_text_colored
1223
	.no_add:
1241
	.no_add:
1224
	popad
1242
	popad
1225
	ret
1243
	ret
1226
endp
1244
endp
1227
 
1245
 
1228
;input:
1246
;input:
1229
;  edx = pointer to sumbol, when insert
1247
;  edx = pointer to sumbol, when insert
1230
;  edi = pointer to tedit struct
1248
;  edi = pointer to tedit struct
1231
;output:
1249
;output:
1232
;  edx = new pointer to sumbol, when insert
1250
;  edx = new pointer to sumbol, when insert
1233
align 16
1251
align 16
1234
proc ted_memory_increase
1252
proc ted_memory_increase
1235
	cmp ted_increase_size,0
1253
	cmp ted_increase_size,0
1236
	je @f
1254
	je @f
1237
		push eax ebx ecx
1255
		push eax ebx ecx
1238
		mov ecx,ted_increase_size
1256
		mov ecx,ted_increase_size
1239
		add ecx,ted_max_chars
1257
		add ecx,ted_max_chars
1240
		mov ted_max_chars,ecx
1258
		mov ted_max_chars,ecx
1241
		imul ecx,sizeof.symbol
1259
		imul ecx,sizeof.symbol
1242
		invoke mem.realloc, ted_tex,ecx
1260
		invoke mem.realloc, ted_tex,ecx
1243
		mov ebx,ted_tex
1261
		mov ebx,ted_tex
1244
		mov ted_tex,eax
1262
		mov ted_tex,eax
1245
		mov ted_tex_1,eax
1263
		mov ted_tex_1,eax
1246
		add ted_tex_1,sizeof.symbol
1264
		add ted_tex_1,sizeof.symbol
1247
			sub edx,ebx
1265
			sub edx,ebx
1248
			add edx,eax
1266
			add edx,eax
1249
			mov ted_ptr_free_symb,edx
1267
			mov ted_ptr_free_symb,edx
1250
		add eax,ecx
1268
		add eax,ecx
1251
		mov ted_tex_end,eax
1269
		mov ted_tex_end,eax
1252
		pop ecx ebx eax
1270
		pop ecx ebx eax
1253
	@@:
1271
	@@:
1254
	ret
1272
	ret
1255
endp
1273
endp
1256
 
1274
 
1257
;input:
1275
;input:
1258
;  ecx = position to free insert cell
1276
;  ecx = position to free insert cell
1259
;  edx = pointer to sumbol, when insert
1277
;  edx = pointer to sumbol, when insert
1260
;  esi = added symbol
1278
;  esi = added symbol
1261
;  edi = pointer to tedit struct
1279
;  edi = pointer to tedit struct
1262
;output:
1280
;output:
1263
;  ecx = position to inserted cell
1281
;  ecx = position to inserted cell
1264
align 16
1282
align 16
1265
ted_char_add:
1283
ted_char_add:
1266
	.loop_b:
1284
	.loop_b:
1267
		cmp ecx,ted_tex_end
1285
		cmp ecx,ted_tex_end
1268
		jge .end_f
1286
		jge .end_f
1269
		cmp dword[ecx+symbol.tc],0
1287
		cmp dword[ecx+symbol.tc],0
1270
		jne @f
1288
		jne @f
1271
			cmp dword[ecx+symbol.td],0
1289
			cmp dword[ecx+symbol.td],0
1272
			je .loop_e
1290
			je .loop_e
1273
		@@:
1291
		@@:
1274
		add ecx,sizeof.symbol
1292
		add ecx,sizeof.symbol
1275
		jmp .loop_b
1293
		jmp .loop_b
1276
align 4
1294
align 4
1277
	.loop_e:
1295
	.loop_e:
1278
 
1296
 
1279
	push eax ebx
1297
	push eax ebx
1280
	mov eax,ted_tim_ch
1298
	mov eax,ted_tim_ch
1281
	mov [ecx+symbol.tc],eax
1299
	mov [ecx+symbol.tc],eax
1282
	mov ax,si
1300
	mov ax,si
1283
	mov byte[ecx],al
1301
	mov byte[ecx],al
1284
 
1302
 
1285
	call ted_get_text_arr_index ; *** eax=pos ***
1303
	call ted_get_text_arr_index ; *** eax=pos ***
1286
	mov [ecx+symbol.perv],eax ;tex[i].perv=pos;
1304
	mov [ecx+symbol.perv],eax ;tex[i].perv=pos;
1287
	m2m dword[ecx+symbol.next],dword[edx+symbol.next] ;tex[i].next=tex[pos].next;
1305
	m2m dword[ecx+symbol.next],dword[edx+symbol.next] ;tex[i].next=tex[pos].next;
1288
 
1306
 
1289
	push edx
1307
	push edx
1290
		mov edx,ecx
1308
		mov edx,ecx
1291
		call ted_get_text_arr_index ; *** eax=i ***
1309
		call ted_get_text_arr_index ; *** eax=i ***
1292
	pop edx
1310
	pop edx
1293
 
1311
 
1294
	mov [edx+symbol.next],eax ;tex[pos].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
1312
	mov [edx+symbol.next],eax ;tex[pos].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
1295
	mov ebx,[ecx+symbol.next]
1313
	mov ebx,[ecx+symbol.next]
1296
	ConvertIndexToPointer ebx
1314
	ConvertIndexToPointer ebx
1297
	mov [ebx+symbol.perv],eax ;tex[tex[i].next].perv=i; // ...
1315
	mov [ebx+symbol.perv],eax ;tex[tex[i].next].perv=i; // ...
1298
	pop ebx eax
1316
	pop ebx eax
1299
 
1317
 
1300
	.end_f:
1318
	.end_f:
1301
	call ted_text_colored
1319
	call ted_text_colored
1302
	ret
1320
	ret
1303
 
1321
 
1304
;description:
1322
;description:
1305
; äã­ªæ¨ï ¤«ï ᬥ­ë ª®¤¨à®¢®ª
1323
; äã­ªæ¨ï ¤«ï ᬥ­ë ª®¤¨à®¢®ª
1306
;input:
1324
;input:
1307
; table - â ¡«¨æ  ¤«ï ¯¥à¥ª®¤¨à®¢ª¨
1325
; table - â ¡«¨æ  ¤«ï ¯¥à¥ª®¤¨à®¢ª¨
1308
align 16
1326
align 16
1309
proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword
1327
proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword
1310
	mov edi,[edit]
1328
	mov edi,[edit]
1311
	mov esi,[table]
1329
	mov esi,[table]
1312
	mov edx,ted_tex
1330
	mov edx,ted_tex
1313
	.cycle:
1331
	.cycle:
1314
		;¯¥à¥å®¤¨¬ ­  á«¥¤ãî騩 ᨬ¢®«
1332
		;¯¥à¥å®¤¨¬ ­  á«¥¤ãî騩 ᨬ¢®«
1315
		mov edx,[edx+symbol.next]
1333
		mov edx,[edx+symbol.next]
1316
		cmp edx,1
1334
		cmp edx,1
1317
		jle .end_text
1335
		jle .end_text
1318
		imul edx,sizeof.symbol
1336
		imul edx,sizeof.symbol
1319
		add edx,ted_tex
1337
		add edx,ted_tex
1320
 
1338
 
1321
		movzx eax,byte[edx]
1339
		movzx eax,byte[edx]
1322
		add eax,esi
1340
		add eax,esi
1323
		mov al,byte[eax]
1341
		mov al,byte[eax]
1324
		cmp al,0
1342
		cmp al,0
1325
		je @f
1343
		je @f
1326
			mov byte[edx],al ;¬¥­ï¥¬ ª®¤¨à®¢ªã ᨬ¢®« 
1344
			mov byte[edx],al ;¬¥­ï¥¬ ª®¤¨à®¢ªã ᨬ¢®« 
1327
		@@:
1345
		@@:
1328
		jmp .cycle
1346
		jmp .cycle
1329
	.end_text:
1347
	.end_text:
1330
	;cmp esi,0
1348
	;cmp esi,0
1331
	;je @f
1349
	;je @f
1332
		stdcall ted_draw,edi ;®¡­®¢«ï¥¬ ®ª­®
1350
		stdcall ted_draw,edi ;®¡­®¢«ï¥¬ ®ª­®
1333
	;@@:
1351
	;@@:
1334
	ret
1352
	ret
1335
endp
1353
endp
1336
 
1354
 
1337
;input:
1355
;input:
1338
; edi = pointer to tedit struct
1356
; edi = pointer to tedit struct
1339
;output:
1357
;output:
1340
; esi = count converted symbols
1358
; esi = count converted symbols
1341
;description:
1359
;description:
1342
; ”ã­ªæ¨ï ¨á¯®«ì§ã¥âáï ¤«ï ᬥ­ë ॣ¨áâà  ¢ë¡à ­­ëå ᨬ¢®«®¢
1360
; ”ã­ªæ¨ï ¨á¯®«ì§ã¥âáï ¤«ï ᬥ­ë ॣ¨áâà  ¢ë¡à ­­ëå ᨬ¢®«®¢
1343
align 16
1361
align 16
1344
proc ted_convert_sel_text, conv_fun:dword
1362
proc ted_convert_sel_text, conv_fun:dword
1345
	locals
1363
	locals
1346
		conv_cou dd ?
1364
		conv_cou dd ?
1347
	endl
1365
	endl
1348
	mov dword[conv_cou],0
1366
	mov dword[conv_cou],0
1349
	pushad
1367
	pushad
1350
 
1368
 
1351
	call ted_is_select
1369
	call ted_is_select
1352
	or al,al
1370
	or al,al
1353
	jz .end_f
1371
	jz .end_f
1354
		call ted_set_undo
1372
		call ted_set_undo
1355
		call ted_sel_normalize
1373
		call ted_sel_normalize
1356
 
1374
 
1357
		mov esi,ted_seln_x0
1375
		mov esi,ted_seln_x0
1358
		mov ecx,ted_seln_y0
1376
		mov ecx,ted_seln_y0
1359
		call ted_get_pos_by_coords
1377
		call ted_get_pos_by_coords
1360
		mov eax,edx
1378
		mov eax,edx
1361
		mov esi,ted_seln_x1
1379
		mov esi,ted_seln_x1
1362
		mov ecx,ted_seln_y1
1380
		mov ecx,ted_seln_y1
1363
		call ted_get_pos_by_coords
1381
		call ted_get_pos_by_coords
1364
		;call ted_get_text_perv_pos
1382
		;call ted_get_text_perv_pos
1365
		mov ebx,edx
1383
		mov ebx,edx
1366
 
1384
 
1367
		cmp eax,ebx
1385
		cmp eax,ebx
1368
		je .end_f
1386
		je .end_f
1369
 
1387
 
1370
		inc ted_tim_ch
1388
		inc ted_tim_ch
1371
		mov edx,eax ;i=p0;
1389
		mov edx,eax ;i=p0;
1372
		mov ecx,ted_ptr_free_symb
1390
		mov ecx,ted_ptr_free_symb
1373
		@@:
1391
		@@:
1374
		push eax
1392
		push eax
1375
		mov al,byte[edx]
1393
		mov al,byte[edx]
1376
		call dword[conv_fun] ;¯à¥®¡à §®¢ ­¨¥ ᨬ¢®« 
1394
		call dword[conv_fun] ;¯à¥®¡à §®¢ ­¨¥ ᨬ¢®« 
1377
		mov esi,eax
1395
		mov esi,eax
1378
		cmp byte[edx],al
1396
		cmp byte[edx],al
1379
		pop eax
1397
		pop eax
1380
		je .no_change
1398
		je .no_change
1381
			m2m dword[edx+symbol.td],ted_tim_ch
1399
			m2m dword[edx+symbol.td],ted_tim_ch
1382
			call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
1400
			call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
1383
			call ted_get_text_next_pos ;go to added symbol
1401
			call ted_get_text_next_pos ;go to added symbol
1384
			inc dword[conv_cou]
1402
			inc dword[conv_cou]
1385
		.no_change:
1403
		.no_change:
1386
 
1404
 
1387
		call ted_iterat_next
1405
		call ted_iterat_next
1388
		cmp edx,ted_tex
1406
		cmp edx,ted_tex
1389
		je @f 
1407
		je @f 
1390
		cmp edx,ebx
1408
		cmp edx,ebx
1391
		jne @b
1409
		jne @b
1392
		@@:
1410
		@@:
1393
		cmp dword[conv_cou],0
1411
		cmp dword[conv_cou],0
1394
		jne @f
1412
		jne @f
1395
			dec ted_tim_ch
1413
			dec ted_tim_ch
1396
		@@:
1414
		@@:
1397
	.end_f:
1415
	.end_f:
1398
	popad
1416
	popad
1399
	mov esi,dword[conv_cou]
1417
	mov esi,[conv_cou]
1400
	ret
1418
	ret
1401
endp
1419
endp
1402
 
1420
 
1403
;output:
1421
;output:
1404
; bl = 0 - no delete
1422
; bl = 0 - no delete
1405
; bl = 1 - delete
1423
; bl = 1 - delete
1406
align 16
1424
align 16
1407
proc ted_text_del uses ecx edx edi, edit:dword, del_opt:dword
1425
proc ted_text_del uses ecx edx edi, edit:dword, del_opt:dword
1408
	mov edi,[edit]
1426
	mov edi,[edit]
1409
	mov ebx,[del_opt]
1427
	mov ebx,[del_opt]
1410
 
1428
 
1411
	xor cl,cl
1429
	xor cl,cl
1412
	test ebx,ted_opt_ed_move_cursor
1430
	test ebx,ted_opt_ed_move_cursor
1413
	jz @f
1431
	jz @f
1414
		call ted_cur_move_left
1432
		call ted_cur_move_left
1415
		cmp dl,0
1433
		cmp dl,0
1416
		je .no_del
1434
		je .no_del
1417
	@@:
1435
	@@:
1418
	call ted_get_pos_by_cursor
1436
	call ted_get_pos_by_cursor
1419
	cmp ted_gp_opt,1
1437
	cmp ted_gp_opt,1
1420
	je .no_del
1438
	je .no_del
1421
		test ebx,ted_opt_ed_change_time
1439
		test ebx,ted_opt_ed_change_time
1422
		jz @f
1440
		jz @f
1423
			inc ted_tim_ch
1441
			inc ted_tim_ch
1424
		@@:
1442
		@@:
1425
		m2m dword[edx+symbol.td], ted_tim_ch
1443
		m2m dword[edx+symbol.td], ted_tim_ch
1426
		mov cl,1
1444
		mov cl,1
1427
	.no_del:
1445
	.no_del:
1428
	mov bl,cl
1446
	mov bl,cl
1429
	ret
1447
	ret
1430
endp
1448
endp
1431
 
1449
 
1432
;input:
1450
;input:
1433
; edi = pointer to tedit struct
1451
; edi = pointer to tedit struct
1434
;output:
1452
;output:
1435
; al = 1 if delete
1453
; al = 1 if delete
1436
;description:
1454
;description:
1437
; ”ã­ªæ¨ï 㤠«ï¥â ¢ë¤¥«¥­­ë© ⥪áâ
1455
; ”ã­ªæ¨ï 㤠«ï¥â ¢ë¤¥«¥­­ë© ⥪áâ
1438
align 16
1456
align 16
1439
proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword
1457
proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword
1440
	call ted_is_select
1458
	call ted_is_select
1441
	or al,al
1459
	or al,al
1442
	jz .end_f
1460
	jz .end_f
1443
		call ted_sel_normalize
1461
		call ted_sel_normalize
1444
 
1462
 
1445
		mov esi,ted_seln_x1
1463
		mov esi,ted_seln_x1
1446
		mov ecx,ted_seln_y1
1464
		mov ecx,ted_seln_y1
1447
		call ted_get_pos_by_coords
1465
		call ted_get_pos_by_coords
1448
		mov ebx,edx
1466
		mov ebx,edx
1449
 
1467
 
1450
		mov esi,ted_seln_x0
1468
		mov esi,ted_seln_x0
1451
		mov ecx,ted_seln_y0
1469
		mov ecx,ted_seln_y0
1452
		call ted_get_pos_by_coords
1470
		call ted_get_pos_by_coords
1453
 
1471
 
1454
		test dword[del_opt],ted_opt_ed_change_time
1472
		test dword[del_opt],ted_opt_ed_change_time
1455
		jz @f
1473
		jz @f
1456
			inc ted_tim_ch
1474
			inc ted_tim_ch
1457
		@@:
1475
		@@:
1458
		cmp edx,ted_tex
1476
		cmp edx,ted_tex
1459
		je @f
1477
		je @f
1460
		cmp edx,ebx ;if(i==te)break;
1478
		cmp edx,ebx ;if(i==te)break;
1461
		je @f
1479
		je @f
1462
			m2m dword[edx+symbol.td],ted_tim_ch
1480
			m2m dword[edx+symbol.td],ted_tim_ch
1463
			mov esi,ted_opt_ed_change_time
1481
			mov esi,ted_opt_ed_change_time
1464
			not esi
1482
			not esi
1465
			and dword[del_opt],esi ;n_tim=false;
1483
			and dword[del_opt],esi ;n_tim=false;
1466
			call ted_iterat_next
1484
			call ted_iterat_next
1467
			jmp @b
1485
			jmp @b
1468
align 4
1486
align 4
1469
		@@:
1487
		@@:
1470
		test dword[del_opt],ted_opt_ed_change_time
1488
		test dword[del_opt],ted_opt_ed_change_time
1471
		jz @f
1489
		jz @f
1472
			dec ted_tim_ch
1490
			dec ted_tim_ch
1473
			xor al,al
1491
			xor al,al
1474
		@@:
1492
		@@:
1475
		test dword[del_opt],ted_opt_ed_change_time
1493
		test dword[del_opt],ted_opt_ed_change_time
1476
		jnz @f
1494
		jnz @f
1477
			mov ecx,ted_seln_x0
1495
			mov ecx,ted_seln_x0
1478
			mov edx,ted_seln_y0
1496
			mov edx,ted_seln_y0
1479
			call ted_go_to_pos
1497
			call ted_go_to_pos
1480
			mov ted_sel_x0,0
1498
			mov ted_sel_x0,0
1481
			mov ted_sel_y0,0
1499
			mov ted_sel_y0,0
1482
			mov ted_sel_x1,0
1500
			mov ted_sel_x1,0
1483
			mov ted_sel_y1,0
1501
			mov ted_sel_y1,0
1484
		@@:
1502
		@@:
1485
	.end_f:
1503
	.end_f:
1486
	ret
1504
	ret
1487
endp
1505
endp
1488
 
1506
 
1489
 
1507
 
1490
;input:
1508
;input:
1491
; eax = pointer to begin select
1509
; eax = pointer to begin select
1492
; ebx = pointer to end select
1510
; ebx = pointer to end select
1493
; edi = pointer to tedit struct
1511
; edi = pointer to tedit struct
1494
align 16
1512
align 16
1495
ted_revers:
1513
ted_revers:
1496
	cmp eax,ebx
1514
	cmp eax,ebx
1497
	jne @f
1515
	jne @f
1498
		ret
1516
		ret
1499
	@@:
1517
	@@:
1500
 
1518
 
1501
	push ecx edx
1519
	push ecx edx
1502
 
1520
 
1503
	mov edx,ted_tex_1
1521
	mov edx,ted_tex_1
1504
	cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
1522
	cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
1505
	jne @f
1523
	jne @f
1506
		call ted_get_text_perv_pos
1524
		call ted_get_text_perv_pos
1507
		mov ebx,edx
1525
		mov ebx,edx
1508
	@@:
1526
	@@:
1509
 
1527
 
1510
	push esi
1528
	push esi
1511
		mov edx,[eax+symbol.perv] ; *** edx = tex[p0].perv ***
1529
		mov edx,[eax+symbol.perv] ; *** edx = tex[p0].perv ***
1512
		ConvertIndexToPointer edx
1530
		ConvertIndexToPointer edx
1513
		add edx,symbol.next
1531
		add edx,symbol.next
1514
		mov ecx,[edx] ;ecx = tex[tex[p0].perv].next
1532
		mov ecx,[edx] ;ecx = tex[tex[p0].perv].next
1515
 
1533
 
1516
		mov esi,[ebx+symbol.next] ; *** esi = tex[p1].next ***
1534
		mov esi,[ebx+symbol.next] ; *** esi = tex[p1].next ***
1517
		ConvertIndexToPointer esi
1535
		ConvertIndexToPointer esi
1518
		add esi,symbol.perv
1536
		add esi,symbol.perv
1519
		m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv
1537
		m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv
1520
 
1538
 
1521
		mov [esi],ecx ;tex[tex[p1].next].perv = ecx
1539
		mov [esi],ecx ;tex[tex[p1].next].perv = ecx
1522
	pop esi
1540
	pop esi
1523
 
1541
 
1524
	mov ecx,[eax+symbol.perv] ;ecx = tex[p0].perv
1542
	mov ecx,[eax+symbol.perv] ;ecx = tex[p0].perv
1525
	m2m dword[eax+symbol.perv],dword[ebx+symbol.next] ;tex[p0].perv = tex[p1].next
1543
	m2m dword[eax+symbol.perv],dword[ebx+symbol.next] ;tex[p0].perv = tex[p1].next
1526
	mov [ebx+symbol.next],ecx ;tex[p1].next = ecx
1544
	mov [ebx+symbol.next],ecx ;tex[p1].next = ecx
1527
 
1545
 
1528
	mov edx,eax ;i=p0;
1546
	mov edx,eax ;i=p0;
1529
	@@:
1547
	@@:
1530
		mov ecx,[edx+symbol.next] ;ecx = tex[i].next
1548
		mov ecx,[edx+symbol.next] ;ecx = tex[i].next
1531
		m2m dword[edx+symbol.next],dword[edx+symbol.perv] ;tex[i].next = tex[i].perv
1549
		m2m dword[edx+symbol.next],dword[edx+symbol.perv] ;tex[i].next = tex[i].perv
1532
		mov [edx+symbol.perv],ecx ;tex[i].perv = ecx
1550
		mov [edx+symbol.perv],ecx ;tex[i].perv = ecx
1533
		cmp edx,ebx ;if(i==p1)break;
1551
		cmp edx,ebx ;if(i==p1)break;
1534
		je @f
1552
		je @f
1535
; ---
1553
; ---
1536
;cmp edx,ted_tex
1554
;cmp edx,ted_tex
1537
;je @f
1555
;je @f
1538
; ---
1556
; ---
1539
		mov edx,ecx ;i = ecx
1557
		mov edx,ecx ;i = ecx
1540
		ConvertIndexToPointer edx
1558
		ConvertIndexToPointer edx
1541
		jmp @b
1559
		jmp @b
1542
	@@:
1560
	@@:
1543
	pop edx ecx
1561
	pop edx ecx
1544
	call ted_text_colored
1562
	call ted_text_colored
1545
	ret
1563
	ret
1546
 
1564
 
1547
 
1565
 
1548
;input:
1566
;input:
1549
; edi = pointer to tedit struct
1567
; edi = pointer to tedit struct
1550
;output:
1568
;output:
1551
; dl = 0 not move
1569
; dl = 0 not move
1552
; dl = 2 if move up
1570
; dl = 2 if move up
1553
; dl = 8 if scroll move up
1571
; dl = 8 if scroll move up
1554
align 16
1572
align 16
1555
ted_cur_move_up:
1573
ted_cur_move_up:
1556
  cmp ted_cur_y,0
1574
  cmp ted_cur_y,0
1557
  je @f
1575
  je @f
1558
    dec ted_cur_y
1576
    dec ted_cur_y
1559
    mov dl,2
1577
    mov dl,2
1560
    ret
1578
    ret
1561
  @@:
1579
  @@:
1562
  push eax
1580
  push eax
1563
  mov eax,ted_scr_w
1581
  mov eax,ted_scr_w
1564
  cmp dword[eax+sb_offs_position],0
1582
  cmp dword[eax+sb_offs_position],0
1565
  je @f
1583
  je @f
1566
    dec dword[eax+sb_offs_position]
1584
    dec dword[eax+sb_offs_position]
1567
    mov dl,8
1585
    mov dl,8
1568
    jmp .ret_f
1586
    jmp .ret_f
1569
  @@:
1587
  @@:
1570
  mov dl,0
1588
  mov dl,0
1571
  .ret_f:
1589
  .ret_f:
1572
  pop eax
1590
  pop eax
1573
  ret
1591
  ret
1574
 
1592
 
1575
;input:
1593
;input:
1576
; edi = pointer to tedit struct
1594
; edi = pointer to tedit struct
1577
;output:
1595
;output:
1578
; dl = 0 not move
1596
; dl = 0 not move
1579
; dl = 2 if move down
1597
; dl = 2 if move down
1580
; dl = 8 if scroll move down
1598
; dl = 8 if scroll move down
1581
align 16
1599
align 16
1582
ted_cur_move_down:
1600
ted_cur_move_down:
1583
  push eax ebx
1601
  push eax ebx
1584
  mov ebx,ted_scr_w
1602
  mov ebx,ted_scr_w
1585
  xor dl,dl
1603
  xor dl,dl
1586
  mov eax,[ebx+sb_offs_cur_area]
1604
  mov eax,[ebx+sb_offs_cur_area]
1587
  dec eax
1605
  dec eax
1588
  cmp ted_cur_y,eax
1606
  cmp ted_cur_y,eax
1589
  jge @f
1607
  jge @f
1590
    inc ted_cur_y
1608
    inc ted_cur_y
1591
    mov dl,2
1609
    mov dl,2
1592
    jmp .ret_f
1610
    jmp .ret_f
1593
  @@:
1611
  @@:
1594
  mov eax,ted_cur_y
1612
  mov eax,ted_cur_y
1595
  add eax,[ebx+sb_offs_position]
1613
  add eax,[ebx+sb_offs_position]
1596
  inc eax
1614
  inc eax
1597
  cmp [ebx+sb_offs_max_area],eax
1615
  cmp [ebx+sb_offs_max_area],eax
1598
  jle @f
1616
  jle @f
1599
    inc dword[ebx+sb_offs_position]
1617
    inc dword[ebx+sb_offs_position]
1600
    mov dl,8
1618
    mov dl,8
1601
  @@:
1619
  @@:
1602
  .ret_f:
1620
  .ret_f:
1603
  pop ebx eax
1621
  pop ebx eax
1604
  ret
1622
  ret
1605
 
1623
 
1606
 
1624
 
1607
;input:
1625
;input:
1608
; edi = pointer to tedit struct
1626
; edi = pointer to tedit struct
1609
;output:
1627
;output:
1610
; dl = 0 not move
1628
; dl = 0 not move
1611
; dl = 1 if move up
1629
; dl = 1 if move up
1612
align 16
1630
align 16
1613
ted_cur_move_page_up:
1631
ted_cur_move_page_up:
1614
	push eax ebx
1632
	push eax ebx
1615
	mov ebx,ted_scr_w
1633
	mov ebx,ted_scr_w
1616
	mov eax,[ebx+sb_offs_cur_area]
1634
	mov eax,[ebx+sb_offs_cur_area]
1617
	xor dl,dl
1635
	xor dl,dl
1618
	cmp eax,[ebx+sb_offs_position]
1636
	cmp eax,[ebx+sb_offs_position]
1619
	jg @f
1637
	jg @f
1620
		sub [ebx+sb_offs_position],eax
1638
		sub [ebx+sb_offs_position],eax
1621
		mov dl,1
1639
		mov dl,1
1622
	@@:
1640
	@@:
1623
	cmp dword[ebx+sb_offs_position],0
1641
	cmp dword[ebx+sb_offs_position],0
1624
	je @f
1642
	je @f
1625
	cmp dl,1
1643
	cmp dl,1
1626
	je @f
1644
	je @f
1627
		mov dword[ebx+sb_offs_position],0
1645
		mov dword[ebx+sb_offs_position],0
1628
		mov dl,1
1646
		mov dl,1
1629
	@@:
1647
	@@:
1630
	pop ebx eax
1648
	pop ebx eax
1631
	ret
1649
	ret
1632
 
1650
 
1633
;input:
1651
;input:
1634
; edi = pointer to tedit struct
1652
; edi = pointer to tedit struct
1635
align 16
1653
align 16
1636
ted_cur_move_page_down:
1654
ted_cur_move_page_down:
1637
	push eax ebx ecx
1655
	push eax ebx ecx
1638
	mov ecx,ted_scr_w
1656
	mov ecx,ted_scr_w
1639
 
1657
 
1640
	xor dl,dl
1658
	xor dl,dl
1641
	mov eax,[ecx+sb_offs_max_area]
1659
	mov eax,[ecx+sb_offs_max_area]
1642
	sub eax,[ecx+sb_offs_cur_area]
1660
	sub eax,[ecx+sb_offs_cur_area]
1643
	cmp [ecx+sb_offs_position],eax
1661
	cmp [ecx+sb_offs_position],eax
1644
	jge @f
1662
	jge @f
1645
		mov ebx,[ecx+sb_offs_cur_area]
1663
		mov ebx,[ecx+sb_offs_cur_area]
1646
		add [ecx+sb_offs_position],ebx
1664
		add [ecx+sb_offs_position],ebx
1647
		mov dl,1
1665
		mov dl,1
1648
		mov dword[ecx+sb_offs_redraw],1
1666
		mov dword[ecx+sb_offs_redraw],1
1649
		cmp [ecx+sb_offs_position],eax
1667
		cmp [ecx+sb_offs_position],eax
1650
		jle @f
1668
		jle @f
1651
			mov [ecx+sb_offs_position],eax
1669
			mov [ecx+sb_offs_position],eax
1652
	@@:
1670
	@@:
1653
	pop ecx ebx eax
1671
	pop ecx ebx eax
1654
	ret
1672
	ret
1655
 
1673
 
1656
;input:
1674
;input:
1657
; edi = pointer to tedit struct
1675
; edi = pointer to tedit struct
1658
;output:
1676
;output:
1659
; dl = 0 not move
1677
; dl = 0 not move
1660
; dl = 1 if move left
1678
; dl = 1 if move left
1661
; dl = 3 if move left and up
1679
; dl = 3 if move left and up
1662
; dl = 8 if scroll move up
1680
; dl = 8 if scroll move up
1663
align 16
1681
align 16
1664
ted_cur_move_left:
1682
ted_cur_move_left:
1665
	cmp ted_cur_x,0
1683
	cmp ted_cur_x,0
1666
	je @f
1684
	je @f
1667
		dec ted_cur_x
1685
		dec ted_cur_x
1668
		mov dl,1
1686
		mov dl,1
1669
		ret
1687
		ret
1670
	@@:
1688
	@@:
1671
	push eax
1689
	push eax
1672
	mov eax,ted_scr_h
1690
	mov eax,ted_scr_h
1673
	cmp dword[eax+sb_offs_position],0
1691
	cmp dword[eax+sb_offs_position],0
1674
	je @f
1692
	je @f
1675
		dec dword[eax+sb_offs_position]
1693
		dec dword[eax+sb_offs_position]
1676
		mov dl,8
1694
		mov dl,8
1677
		jmp .ret_f
1695
		jmp .ret_f
1678
	@@:
1696
	@@:
1679
	cmp ted_cur_y,0
1697
	cmp ted_cur_y,0
1680
	jne @f
1698
	jne @f
1681
		mov eax,ted_scr_w
1699
		mov eax,ted_scr_w
1682
		mov dl,0
1700
		mov dl,0
1683
		cmp dword[eax+sb_offs_position],0
1701
		cmp dword[eax+sb_offs_position],0
1684
		je .ret_f
1702
		je .ret_f
1685
			dec dword[eax+sb_offs_position]
1703
			dec dword[eax+sb_offs_position]
1686
			call ted_scroll_set_redraw
1704
			call ted_scroll_set_redraw
1687
			call ted_cur_move_x_last_char
1705
			call ted_cur_move_x_last_char
1688
			mov dl,8
1706
			mov dl,8
1689
			jmp .ret_f
1707
			jmp .ret_f
1690
	@@:
1708
	@@:
1691
	cmp ted_cur_y,0
1709
	cmp ted_cur_y,0
1692
	je @f
1710
	je @f
1693
		dec ted_cur_y
1711
		dec ted_cur_y
1694
		call ted_cur_move_x_last_char
1712
		call ted_cur_move_x_last_char
1695
		cmp dl,8
1713
		cmp dl,8
1696
		je .ret_f
1714
		je .ret_f
1697
		mov dl,3
1715
		mov dl,3
1698
		jmp .ret_f
1716
		jmp .ret_f
1699
	@@:
1717
	@@:
1700
	mov dl,0
1718
	mov dl,0
1701
	.ret_f:
1719
	.ret_f:
1702
	pop eax
1720
	pop eax
1703
	ret
1721
	ret
1704
 
1722
 
1705
;input:
1723
;input:
1706
; edi = pointer to tedit struct
1724
; edi = pointer to tedit struct
1707
align 16
1725
align 16
1708
ted_cur_move_right:
1726
ted_cur_move_right:
1709
	push eax ebx
1727
	push eax ebx
1710
	mov eax,ted_scr_h
1728
	mov eax,ted_scr_h
1711
	xor dl,dl
1729
	xor dl,dl
1712
	mov ebx,[eax+sb_offs_cur_area]
1730
	mov ebx,[eax+sb_offs_cur_area]
1713
	cmp ted_cur_x,ebx
1731
	cmp ted_cur_x,ebx
1714
	jge @f
1732
	jge @f
1715
		inc ted_cur_x
1733
		inc ted_cur_x
1716
		mov dl,1
1734
		mov dl,1
1717
		jmp .ret_f
1735
		jmp .ret_f
1718
	@@:
1736
	@@:
1719
		inc dword[eax+sb_offs_position]
1737
		inc dword[eax+sb_offs_position]
1720
		mov dl,8
1738
		mov dl,8
1721
	.ret_f:
1739
	.ret_f:
1722
	pop ebx eax
1740
	pop ebx eax
1723
	ret
1741
	ret
1724
 
1742
 
1725
;input:
1743
;input:
1726
; edi = pointer to tedit struct
1744
; edi = pointer to tedit struct
1727
align 16
1745
align 16
1728
ted_cur_move_x_last_char:
1746
ted_cur_move_x_last_char:
1729
;[hScr.position]
1747
;[hScr.position]
1730
;[hScr.cur_area]
1748
;[hScr.cur_area]
1731
;dl-???
1749
;dl-???
1732
  push eax ebx ecx
1750
  push eax ebx ecx
1733
  mov eax,ted_cur_y
1751
  mov eax,ted_cur_y
1734
  mov ecx,ted_scr_w
1752
  mov ecx,ted_scr_w
1735
  add eax,[ecx+sb_offs_position]
1753
  add eax,[ecx+sb_offs_position]
1736
  call ted_strlen
1754
  call ted_strlen
1737
  xor dl,dl
1755
  xor dl,dl
1738
 
1756
 
1739
  mov ecx,ted_scr_h
1757
  mov ecx,ted_scr_h
1740
  cmp ebx,[ecx+sb_offs_position]
1758
  cmp ebx,[ecx+sb_offs_position]
1741
  jge @f
1759
  jge @f
1742
    mov dl,8
1760
    mov dl,8
1743
    mov [ecx+sb_offs_position],ebx
1761
    mov [ecx+sb_offs_position],ebx
1744
  @@:
1762
  @@:
1745
  sub ebx,[ecx+sb_offs_position]
1763
  sub ebx,[ecx+sb_offs_position]
1746
 
1764
 
1747
  cmp ebx,[ecx+sb_offs_cur_area]
1765
  cmp ebx,[ecx+sb_offs_cur_area]
1748
  jle @f ; b---[---]---e
1766
  jle @f ; b---[---]---e
1749
    add [ecx+sb_offs_position],ebx
1767
    add [ecx+sb_offs_position],ebx
1750
    mov ebx,[ecx+sb_offs_cur_area]
1768
    mov ebx,[ecx+sb_offs_cur_area]
1751
    sub [ecx+sb_offs_position],ebx
1769
    sub [ecx+sb_offs_position],ebx
1752
    mov dl,8
1770
    mov dl,8
1753
  @@:
1771
  @@:
1754
  mov ted_cur_x,ebx
1772
  mov ted_cur_x,ebx
1755
  pop ecx ebx eax
1773
  pop ecx ebx eax
1756
  ret
1774
  ret
1757
 
1775
 
1758
;input:
1776
;input:
1759
; edi = pointer to tedit struct
1777
; edi = pointer to tedit struct
1760
;output:
1778
;output:
1761
; dl = 0 not move
1779
; dl = 0 not move
1762
; dl = 1 move cursor
1780
; dl = 1 move cursor
1763
; dl = 8 move cursor and scroll
1781
; dl = 8 move cursor and scroll
1764
align 16
1782
align 16
1765
ted_cur_move_x_first_char:
1783
ted_cur_move_x_first_char:
1766
	xor dl,dl
1784
	xor dl,dl
1767
	cmp ted_cur_x,0
1785
	cmp ted_cur_x,0
1768
	je @f
1786
	je @f
1769
		mov ted_cur_x,0
1787
		mov ted_cur_x,0
1770
		mov dl,1
1788
		mov dl,1
1771
	@@:
1789
	@@:
1772
	push eax
1790
	push eax
1773
	mov eax,ted_scr_h
1791
	mov eax,ted_scr_h
1774
	cmp dword[eax+sb_offs_position],0
1792
	cmp dword[eax+sb_offs_position],0
1775
	je @f
1793
	je @f
1776
		mov dword[eax+sb_offs_position],0
1794
		mov dword[eax+sb_offs_position],0
1777
		mov dl,8
1795
		mov dl,8
1778
	@@:
1796
	@@:
1779
	pop eax
1797
	pop eax
1780
	ret
1798
	ret
1781
 
1799
 
1782
;input:
1800
;input:
1783
; edx = pointer to symbol struct
1801
; edx = pointer to symbol struct
1784
; edi = pointer to tedit struct
1802
; edi = pointer to tedit struct
1785
;output:
1803
;output:
1786
; eax = array index
1804
; eax = array index
1787
align 16
1805
align 16
1788
ted_get_text_arr_index:
1806
ted_get_text_arr_index:
1789
	push ecx edx
1807
	push ecx edx
1790
		mov eax,edx
1808
		mov eax,edx
1791
		sub eax,ted_tex
1809
		sub eax,ted_tex
1792
		xor edx,edx
1810
		xor edx,edx
1793
		mov ecx,sizeof.symbol
1811
		mov ecx,sizeof.symbol
1794
		div ecx
1812
		div ecx
1795
	pop edx ecx
1813
	pop edx ecx
1796
	ret
1814
	ret
1797
 
1815
 
1798
;input:
1816
;input:
1799
; edx = pointer to symbol struct
1817
; edx = pointer to symbol struct
1800
; edi = pointer to tedit struct
1818
; edi = pointer to tedit struct
1801
;output:
1819
;output:
1802
; edx = pointer to 'perv' struct
1820
; edx = pointer to 'perv' struct
1803
align 16
1821
align 16
1804
ted_get_text_perv_pos:
1822
ted_get_text_perv_pos:
1805
	mov edx,[edx+symbol.perv]
1823
	mov edx,[edx+symbol.perv]
1806
	imul edx,sizeof.symbol
1824
	imul edx,sizeof.symbol
1807
	add edx,ted_tex
1825
	add edx,ted_tex
1808
	ret
1826
	ret
1809
 
1827
 
1810
;input:
1828
;input:
1811
; edx = pointer to symbol struct
1829
; edx = pointer to symbol struct
1812
;output:
1830
;output:
1813
; edx = pointer to 'next' symbol struct
1831
; edx = pointer to 'next' symbol struct
1814
align 16
1832
align 16
1815
ted_get_text_next_pos:
1833
ted_get_text_next_pos:
1816
	mov edx,[edx+symbol.next]
1834
	mov edx,[edx+symbol.next]
1817
	imul edx,sizeof.symbol
1835
	imul edx,sizeof.symbol
1818
	add edx,ted_tex
1836
	add edx,ted_tex
1819
	ret
1837
	ret
1820
 
1838
 
1821
;input:
1839
;input:
1822
; edi = pointer to tedit struct
1840
; edi = pointer to tedit struct
1823
;output:
1841
;output:
1824
; edx = symbol under cursor
1842
; edx = symbol under cursor
1825
; ted_gp_opt = 1,2
1843
; ted_gp_opt = 1,2
1826
; edx = tex[1].perv if error
1844
; edx = tex[1].perv if error
1827
; ted_gp_opt = 0
1845
; ted_gp_opt = 0
1828
align 16
1846
align 16
1829
ted_get_pos_by_cursor:
1847
ted_get_pos_by_cursor:
1830
	push eax ecx esi
1848
	push eax ecx esi
1831
		mov esi,ted_cur_x
1849
		mov esi,ted_cur_x
1832
		mov eax,ted_scr_h
1850
		mov eax,ted_scr_h
1833
		add esi,[eax+sb_offs_position]
1851
		add esi,[eax+sb_offs_position]
1834
		mov ecx,ted_cur_y
1852
		mov ecx,ted_cur_y
1835
		mov eax,ted_scr_w
1853
		mov eax,ted_scr_w
1836
		add ecx,[eax+sb_offs_position]
1854
		add ecx,[eax+sb_offs_position]
1837
		call ted_get_pos_by_coords
1855
		call ted_get_pos_by_coords
1838
	pop esi ecx eax
1856
	pop esi ecx eax
1839
	ret
1857
	ret
1840
 
1858
 
1841
;input:
1859
;input:
1842
; esi = XPos
1860
; esi = XPos
1843
; ecx = YPos
1861
; ecx = YPos
1844
; edi = pointer to tedit struct
1862
; edi = pointer to tedit struct
1845
;output:
1863
;output:
1846
; edx = symbol under cursor
1864
; edx = symbol under cursor
1847
; ted_gp_opt = 1 if found text line
1865
; ted_gp_opt = 1 if found text line
1848
; ted_gp_opt = 2 if found text line and column
1866
; ted_gp_opt = 2 if found text line and column
1849
; edx = tex[1] if error
1867
; edx = tex[1] if error
1850
; ted_gp_opt = 0 if text no found
1868
; ted_gp_opt = 0 if text no found
1851
align 16
1869
align 16
1852
proc ted_get_pos_by_coords uses eax ebx 
1870
proc ted_get_pos_by_coords uses eax ebx 
1853
	xor eax,eax ;Row
1871
	xor eax,eax ;Row
1854
	xor ebx,ebx ;Col
1872
	xor ebx,ebx ;Col
1855
  mov ted_gp_opt,0
1873
  mov ted_gp_opt,0
1856
  mov edx,ted_tex
1874
  mov edx,ted_tex
1857
  @@:
1875
  @@:
1858
    call ted_iterat_next
1876
    call ted_iterat_next
1859
    cmp edx,ted_tex_1
1877
    cmp edx,ted_tex_1
1860
    jle @f 
1878
    jle @f 
1861
    cmp ebx,esi
1879
    cmp ebx,esi
1862
    jne .u1_0 ;Col <> ted_cur_x
1880
    jne .u1_0 ;Col <> ted_cur_x
1863
      mov ted_gp_opt,1
1881
      mov ted_gp_opt,1
1864
      cmp eax,ecx
1882
      cmp eax,ecx
1865
      jge @f ; Row >= ted_cur_y
1883
      jge @f ; Row >= ted_cur_y
1866
    .u1_0:
1884
    .u1_0:
1867
    mov ted_gp_opt,0
1885
    mov ted_gp_opt,0
1868
    inc ebx
1886
    inc ebx
1869
    cmp byte [edx],13
1887
    cmp byte [edx],13
1870
    jne @b
1888
    jne @b
1871
    cmp eax,ecx
1889
    cmp eax,ecx
1872
    jge @f ; Row >= ted_cur_y
1890
    jge @f ; Row >= ted_cur_y
1873
    inc eax
1891
    inc eax
1874
    xor ebx,ebx
1892
    xor ebx,ebx
1875
    jmp @b
1893
    jmp @b
1876
  @@:
1894
  @@:
1877
  cmp eax,ecx
1895
  cmp eax,ecx
1878
  jne @f ; Row = ted_cur_y
1896
  jne @f ; Row = ted_cur_y
1879
    inc ted_gp_opt
1897
    inc ted_gp_opt
1880
  @@:
1898
  @@:
1881
  cmp ted_gp_opt,0
1899
  cmp ted_gp_opt,0
1882
  jne @f
1900
  jne @f
1883
    mov edx,ted_tex_1
1901
    mov edx,ted_tex_1
1884
    ;call ted_get_text_perv_pos
1902
    ;call ted_get_text_perv_pos
1885
  @@:
1903
  @@:
1886
  ret
1904
  ret
1887
endp
1905
endp
1888
 
1906
 
1889
;input:
1907
;input:
1890
; eax = Row
1908
; eax = Row
1891
; edi = pointer to tedit struct
1909
; edi = pointer to tedit struct
1892
;output:
1910
;output:
1893
; ebx = str len
1911
; ebx = str len
1894
align 16
1912
align 16
1895
ted_strlen:
1913
ted_strlen:
1896
  push edx ecx
1914
  push edx ecx
1897
  ;ecx = Row, from cycle
1915
  ;ecx = Row, from cycle
1898
 
1916
 
1899
  xor ebx,ebx
1917
  xor ebx,ebx
1900
  xor ecx,ecx
1918
  xor ecx,ecx
1901
  mov edx,ted_tex
1919
  mov edx,ted_tex
1902
  @@:
1920
  @@:
1903
    call ted_iterat_next
1921
    call ted_iterat_next
1904
    cmp edx,ted_tex_1
1922
    cmp edx,ted_tex_1
1905
    jle @f 
1923
    jle @f 
1906
    inc ebx
1924
    inc ebx
1907
    cmp byte [edx],13
1925
    cmp byte [edx],13
1908
    jne @b
1926
    jne @b
1909
    dec ebx ;lenght minus 1 sumbol to paragraph
1927
    dec ebx ;lenght minus 1 sumbol to paragraph
1910
    cmp eax,ecx
1928
    cmp eax,ecx
1911
    je @f
1929
    je @f
1912
    xor ebx,ebx
1930
    xor ebx,ebx
1913
    inc ecx
1931
    inc ecx
1914
    jmp @b
1932
    jmp @b
1915
  @@:
1933
  @@:
1916
 
1934
 
1917
  cmp eax,ecx
1935
  cmp eax,ecx
1918
  je @f
1936
  je @f
1919
    xor ebx,ebx
1937
    xor ebx,ebx
1920
  @@:
1938
  @@:
1921
 
1939
 
1922
  pop ecx edx
1940
  pop ecx edx
1923
  ret
1941
  ret
1924
 
1942
 
1925
 
1943
 
1926
;input:
1944
;input:
1927
; edx = symbol position
1945
; edx = symbol position
1928
; edi = pointer to tedit struct
1946
; edi = pointer to tedit struct
1929
;output:
1947
;output:
1930
; eax = number of line
1948
; eax = number of line
1931
; ebx = symbol position in line
1949
; ebx = symbol position in line
1932
align 16
1950
align 16
1933
ted_get_text_coords:
1951
ted_get_text_coords:
1934
  push edx
1952
  push edx
1935
  xor eax,eax
1953
  xor eax,eax
1936
  xor ebx,ebx
1954
  xor ebx,ebx
1937
  @@:
1955
  @@:
1938
    call ted_iterat_perv
1956
    call ted_iterat_perv
1939
 
1957
 
1940
    cmp eax,0
1958
    cmp eax,0
1941
    jne .no_col_mov
1959
    jne .no_col_mov
1942
    inc ebx
1960
    inc ebx
1943
    .no_col_mov:
1961
    .no_col_mov:
1944
 
1962
 
1945
    cmp edx,ted_tex_1
1963
    cmp edx,ted_tex_1
1946
    jle @f
1964
    jle @f
1947
    cmp byte [edx],13
1965
    cmp byte [edx],13
1948
    jne @b
1966
    jne @b
1949
    inc eax
1967
    inc eax
1950
    jmp @b
1968
    jmp @b
1951
  @@:
1969
  @@:
1952
  dec ebx
1970
  dec ebx
1953
  pop edx
1971
  pop edx
1954
  ret
1972
  ret
1955
 
1973
 
1956
;input:
1974
;input:
1957
; edi = pointer to tedit struct
1975
; edi = pointer to tedit struct
1958
;output:
1976
;output:
1959
; eax = num lines
1977
; eax = num lines
1960
align 16
1978
align 16
1961
ted_get_num_lines:
1979
ted_get_num_lines:
1962
	push edx
1980
	push edx
1963
	mov eax,1
1981
	mov eax,1
1964
	mov edx,ted_tex
1982
	mov edx,ted_tex
1965
	@@:
1983
	@@:
1966
		call ted_iterat_next
1984
		call ted_iterat_next
1967
		cmp edx,ted_tex_1
1985
		cmp edx,ted_tex_1
1968
		jle @f
1986
		jle @f
1969
		cmp byte[edx],13
1987
		cmp byte[edx],13
1970
		jne @b
1988
		jne @b
1971
		inc eax
1989
		inc eax
1972
		jmp @b
1990
		jmp @b
1973
	@@:
1991
	@@:
1974
;...
1992
;...
1975
;dec eax
1993
;dec eax
1976
	pop edx
1994
	pop edx
1977
	ret
1995
	ret
1978
 
1996
 
1979
 
1997
 
1980
;input:
1998
;input:
1981
; edi = pointer to tedit struct
1999
; edi = pointer to tedit struct
1982
;description:
2000
;description:
1983
; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
2001
; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
1984
align 16
2002
align 16
1985
proc ted_set_undo
2003
proc ted_set_undo
1986
	mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
2004
	mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
1987
	cmp ted_tim_undo,1
2005
	cmp ted_tim_undo,1
1988
	jl .no_work
2006
	jl .no_work
1989
 
2007
 
1990
	push eax ebx edx
2008
	push eax ebx edx
1991
	mov edx,ted_tex
2009
	mov edx,ted_tex
1992
	call ted_get_text_next_pos ;long i=tex[0].next;
2010
	call ted_get_text_next_pos ;long i=tex[0].next;
1993
	mov eax,ted_tim_undo
2011
	mov eax,ted_tim_undo
1994
	sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
2012
	sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
1995
	mov eax,ted_tim_ch
2013
	mov eax,ted_tim_ch
1996
	cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
2014
	cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
1997
	jle @f
2015
	jle @f
1998
		mov ted_tim_ls,0
2016
		mov ted_tim_ls,0
1999
	@@:
2017
	@@:
2000
		cmp edx,ted_tex_1
2018
		cmp edx,ted_tex_1
2001
		jle @f
2019
		jle @f
2002
 
2020
 
2003
		;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
2021
		;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
2004
		cmp [edx+symbol.tc],eax
2022
		cmp [edx+symbol.tc],eax
2005
		jle .no_u1
2023
		jle .no_u1
2006
			mov dword[edx+symbol.tc],0
2024
			mov dword[edx+symbol.tc],0
2007
			mov dword[edx+symbol.td],0
2025
			mov dword[edx+symbol.td],0
2008
 
2026
 
2009
			mov ebx,[edx+symbol.perv]
2027
			mov ebx,[edx+symbol.perv]
2010
			imul ebx,sizeof.symbol
2028
			imul ebx,sizeof.symbol
2011
			add ebx,ted_tex ;ebx=tex[i].perv
2029
			add ebx,ted_tex ;ebx=tex[i].perv
2012
			m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next;
2030
			m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next;
2013
 
2031
 
2014
			mov ebx,[edx+symbol.next]
2032
			mov ebx,[edx+symbol.next]
2015
			imul ebx,sizeof.symbol
2033
			imul ebx,sizeof.symbol
2016
			add ebx,ted_tex ;ebx=tex[i].next
2034
			add ebx,ted_tex ;ebx=tex[i].next
2017
			m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv;
2035
			m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv;
2018
 
2036
 
2019
			cmp ted_ptr_free_symb,edx
2037
			cmp ted_ptr_free_symb,edx
2020
			jle .no_cor_free
2038
			jle .no_cor_free
2021
				mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
2039
				mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
2022
			.no_cor_free:
2040
			.no_cor_free:
2023
			mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢  ted_get_text_next_pos ¡ã¤¥â à ¢¥­ ebx)
2041
			mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢  ted_get_text_next_pos ¡ã¤¥â à ¢¥­ ebx)
2024
			jmp @b
2042
			jmp @b
2025
		.no_u1:
2043
		.no_u1:
2026
 
2044
 
2027
		;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
2045
		;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
2028
		cmp [edx+symbol.td],eax
2046
		cmp [edx+symbol.td],eax
2029
		jle .no_u2
2047
		jle .no_u2
2030
			mov dword[edx+symbol.td],0
2048
			mov dword[edx+symbol.td],0
2031
		.no_u2:
2049
		.no_u2:
2032
 
2050
 
2033
		call ted_get_text_next_pos
2051
		call ted_get_text_next_pos
2034
		jmp @b
2052
		jmp @b
2035
	@@:
2053
	@@:
2036
	mov ted_tim_undo,0
2054
	mov ted_tim_undo,0
2037
	mov eax,ted_tim_co
2055
	mov eax,ted_tim_co
2038
	cmp ted_tim_ch,eax
2056
	cmp ted_tim_ch,eax
2039
	jge @f
2057
	jge @f
2040
		mov ted_tim_co,0
2058
		mov ted_tim_co,0
2041
	@@:
2059
	@@:
2042
	pop edx ebx eax
2060
	pop edx ebx eax
2043
	.no_work:
2061
	.no_work:
2044
	ret
2062
	ret
2045
endp
2063
endp
2046
 
2064
 
2047
;description:
2065
;description:
2048
; ¯¥à¥å®¤ ­  㪠§ ­­ãî ¯®§¨æ¨î
2066
; ¯¥à¥å®¤ ­  㪠§ ­­ãî ¯®§¨æ¨î
2049
;input:
2067
;input:
2050
; row = ­®¬¥à áâப¨
2068
; row = ­®¬¥à áâப¨
2051
; col = ᨬ¢®«
2069
; col = ᨬ¢®«
2052
align 16
2070
align 16
2053
proc ted_go_to_position uses ecx edx edi, edit:dword, row:dword, col:dword
2071
proc ted_go_to_position uses ecx edx edi, edit:dword, row:dword, col:dword
2054
	mov edi,[edit]
2072
	mov edi,[edit]
2055
	; ¯®¤£®â®¢ª  áâப¨
2073
	; ¯®¤£®â®¢ª  áâப¨
2056
	mov edx,[row]
2074
	mov edx,[row]
2057
	call ted_get_num_lines
2075
	call ted_get_num_lines
2058
	cmp edx,eax
2076
	cmp edx,eax
2059
	jle @f
2077
	jle @f
2060
		mov edx,eax ;®£à ­¨ç¥­¨¥ ¯® áâப¥ max
2078
		mov edx,eax ;®£à ­¨ç¥­¨¥ ¯® áâப¥ max
2061
	@@:
2079
	@@:
2062
	dec edx
2080
	dec edx
2063
	cmp edx,0
2081
	cmp edx,0
2064
	jge @f
2082
	jge @f
2065
		xor edx,edx ;®£à ­¨ç¥­¨¥ ¯® áâப¥ min
2083
		xor edx,edx ;®£à ­¨ç¥­¨¥ ¯® áâப¥ min
2066
	@@:
2084
	@@:
2067
	; ¯®¤£®â®¢ª  ᨬ¢®« 
2085
	; ¯®¤£®â®¢ª  ᨬ¢®« 
2068
	mov ecx,[col]
2086
	mov ecx,[col]
2069
	dec ecx
2087
	dec ecx
2070
	cmp ecx,0
2088
	cmp ecx,0
2071
	jge @f
2089
	jge @f
2072
		xor ecx,ecx
2090
		xor ecx,ecx
2073
	@@:
2091
	@@:
2074
	call ted_go_to_pos
2092
	call ted_go_to_pos
2075
	stdcall ted_draw,edi
2093
	stdcall ted_draw,edi
2076
	ret
2094
	ret
2077
endp
2095
endp
2078
 
2096
 
2079
;input:
2097
;input:
2080
; ecx = Col
2098
; ecx = Col
2081
; edx = Row
2099
; edx = Row
2082
; edi = pointer to tedit struct
2100
; edi = pointer to tedit struct
2083
;output:
2101
;output:
2084
; ecx = cursor x
2102
; ecx = cursor x
2085
; edx = cursor y
2103
; edx = cursor y
2086
align 16
2104
align 16
2087
ted_go_to_pos:
2105
ted_go_to_pos:
2088
	push eax ebx
2106
	push eax ebx
2089
	mov eax,ted_scr_h
2107
	mov eax,ted_scr_h
2090
	sub ecx,[eax+sb_offs_position]
2108
	sub ecx,[eax+sb_offs_position]
2091
	cmp ecx,0 ;ted_cur_x < 0
2109
	cmp ecx,0 ;ted_cur_x < 0
2092
	jge @f
2110
	jge @f
2093
		add [eax+sb_offs_position],ecx ;¯à®ªàã⪠ áªà®««¨­£  ¢«¥¢®
2111
		add [eax+sb_offs_position],ecx ;¯à®ªàã⪠ áªà®««¨­£  ¢«¥¢®
2094
		xor ecx,ecx
2112
		xor ecx,ecx
2095
	@@:
2113
	@@:
2096
	mov ebx,5 ;5 - ¦¥« ¥¬ë© ®âáâ㯠᫥¢ 
2114
	mov ebx,5 ;5 - ¦¥« ¥¬ë© ®âáâ㯠᫥¢ 
2097
	cmp ecx,ebx
2115
	cmp ecx,ebx
2098
	jge .end0
2116
	jge .end0
2099
		sub ebx,ecx ;ebx - ­  ᪮«ìª® ᨬ¢®«®¢ ­ã¦­® ᤢ¨­ãâì ªãàá®à
2117
		sub ebx,ecx ;ebx - ­  ᪮«ìª® ᨬ¢®«®¢ ­ã¦­® ᤢ¨­ãâì ªãàá®à
2100
		cmp [eax+sb_offs_position],ebx
2118
		cmp [eax+sb_offs_position],ebx
2101
		jge @f 
2119
		jge @f 
2102
			add ecx,[eax+sb_offs_position]
2120
			add ecx,[eax+sb_offs_position]
2103
			mov dword[eax+sb_offs_position],0
2121
			mov dword[eax+sb_offs_position],0
2104
			jmp .end0
2122
			jmp .end0
2105
		@@:
2123
		@@:
2106
			sub [eax+sb_offs_position],ebx
2124
			sub [eax+sb_offs_position],ebx
2107
			add ecx,ebx
2125
			add ecx,ebx
2108
	.end0:
2126
	.end0:
2109
	cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area]
2127
	cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area]
2110
	jl .end1
2128
	jl .end1
2111
		mov ebx,ecx
2129
		mov ebx,ecx
2112
		sub ebx,[eax+sb_offs_cur_area]
2130
		sub ebx,[eax+sb_offs_cur_area]
2113
		inc ebx
2131
		inc ebx
2114
		add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢¯à ¢®
2132
		add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢¯à ¢®
2115
		sub ecx,ebx
2133
		sub ecx,ebx
2116
	.end1:
2134
	.end1:
2117
	mov ted_cur_x,ecx
2135
	mov ted_cur_x,ecx
2118
 
2136
 
2119
	mov eax,ted_scr_w
2137
	mov eax,ted_scr_w
2120
	sub edx,[eax+sb_offs_position]
2138
	sub edx,[eax+sb_offs_position]
2121
	cmp edx,0 ;ted_cur_y < 0
2139
	cmp edx,0 ;ted_cur_y < 0
2122
	jge @f
2140
	jge @f
2123
		add [eax+sb_offs_position],edx ;¯à®ªàã⪠ áªà®««¨­£  ¢¢¥àå
2141
		add [eax+sb_offs_position],edx ;¯à®ªàã⪠ áªà®««¨­£  ¢¢¥àå
2124
		xor edx,edx
2142
		xor edx,edx
2125
		jmp .end2
2143
		jmp .end2
2126
	@@:
2144
	@@:
2127
	cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
2145
	cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
2128
	jl .end2
2146
	jl .end2
2129
		mov ebx,edx
2147
		mov ebx,edx
2130
		sub ebx,[eax+sb_offs_cur_area]
2148
		sub ebx,[eax+sb_offs_cur_area]
2131
		inc ebx
2149
		inc ebx
2132
		add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢­¨§
2150
		add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢­¨§
2133
		sub edx,ebx
2151
		sub edx,ebx
2134
	.end2:
2152
	.end2:
2135
	mov ted_cur_y,edx
2153
	mov ted_cur_y,edx
2136
	pop ebx eax
2154
	pop ebx eax
2137
	ret
2155
	ret
2138
 
2156
 
2139
;input:
2157
;input:
2140
; edi = pointer to tedit struct
2158
; edi = pointer to tedit struct
2141
align 16
2159
align 16
2142
ted_text_colored:
2160
ted_text_colored:
2143
	push eax edx
2161
	push eax edx
2144
	mov eax,ted_tim_ch
2162
	mov eax,ted_tim_ch
2145
	sub eax,ted_tim_undo
2163
	sub eax,ted_tim_undo
2146
	mov ted_tim_co,eax
2164
	mov ted_tim_co,eax
2147
	mov edx,ted_tex
2165
	mov edx,ted_tex
2148
	@@:
2166
	@@:
2149
		call ted_iterat_next
2167
		call ted_iterat_next
2150
		cmp edx,ted_tex_1
2168
		cmp edx,ted_tex_1
2151
		jle @f
2169
		jle @f
2152
		mov byte[edx+1],0
2170
		mov byte[edx+1],0
2153
		jmp @b
2171
		jmp @b
2154
	@@:
2172
	@@:
2155
 
2173
 
2156
	cmp ted_key_words_count,1
2174
	cmp ted_key_words_count,1
2157
	jl .no_colors
2175
	jl .no_colors
2158
	mov edx,ted_tex
2176
	mov edx,ted_tex
2159
	@@:
2177
	@@:
2160
		call ted_text_find_sel_color
2178
		call ted_text_find_sel_color
2161
		cmp edx,ted_tex_1
2179
		cmp edx,ted_tex_1
2162
		jle .no_colors
2180
		jle .no_colors
2163
		jmp @b
2181
		jmp @b
2164
	.no_colors:
2182
	.no_colors:
2165
	pop edx eax
2183
	pop edx eax
2166
	ret
2184
	ret
2167
 
2185
 
2168
 
2186
 
2169
;input:
2187
;input:
2170
; edx = pointer to start symbol
2188
; edx = pointer to start symbol
2171
; edi = pointer to tedit struct
2189
; edi = pointer to tedit struct
2172
;output:
2190
;output:
2173
; edx = pointer to next symbol
2191
; edx = pointer to next symbol
2174
;description:
2192
;description:
2175
; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
2193
; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
2176
align 16
2194
align 16
2177
proc ted_text_find_sel_color uses eax ebx ecx esi
2195
proc ted_text_find_sel_color uses eax ebx ecx esi
2178
locals
2196
locals
2179
	begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
2197
	begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
2180
	endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
2198
	endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
2181
	find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
2199
	find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
2182
	f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
2200
	f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
2183
endl
2201
endl
2184
;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
2202
;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
2185
;ebx = ¤«ï à §­ëå 楫¥©
2203
;ebx = ¤«ï à §­ëå 楫¥©
2186
;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
2204
;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
2187
;esi = ¤«ï à §­ëå 楫¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
2205
;esi = ¤«ï à §­ëå 楫¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
2188
	mov dword[begPos],1
2206
	mov dword[begPos],1
2189
	mov dword[endPos],1
2207
	mov dword[endPos],1
2190
	mov byte[find],0
2208
	mov byte[find],0
2191
	mov byte[f_color],1
2209
	mov byte[f_color],1
2192
	.cycle0:
2210
	.cycle0:
2193
		call ted_iterat_next
2211
		call ted_iterat_next
2194
		cmp edx,ted_tex_1
2212
		cmp edx,ted_tex_1
2195
		jle .cycle0end
2213
		jle .cycle0end
2196
 
2214
 
2197
		xor eax,eax
2215
		xor eax,eax
2198
		mov al,byte[edx]
2216
		mov al,byte[edx]
2199
		shl ax,2 ;eax*=4
2217
		shl ax,2 ;eax*=4
2200
		add eax,ted_arr_key_pos
2218
		add eax,ted_arr_key_pos
2201
		mov eax,[eax]
2219
		mov eax,[eax]
2202
		cmp eax,0
2220
		cmp eax,0
2203
		jl .cycle0 ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
2221
		jl .cycle0 ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
2204
 
2222
 
2205
		mov ecx,eax
2223
		mov ecx,eax
2206
		;while(l_pos
2224
		;while(l_pos
2207
		.wh_1b:
2225
		.wh_1b:
2208
			cmp ecx,ted_key_words_count
2226
			cmp ecx,ted_key_words_count
2209
			jge .wh_1e
2227
			jge .wh_1e
2210
			ColToIndexOffset ecx,esi
2228
			ColToIndexOffset ecx,esi
2211
			mov bl,byte[esi]
2229
			mov bl,byte[esi]
2212
			ColToIndexOffset eax,esi
2230
			ColToIndexOffset eax,esi
2213
			cmp bl,byte[esi]
2231
			cmp bl,byte[esi]
2214
			jne .wh_1e
2232
			jne .wh_1e
2215
				inc ecx
2233
				inc ecx
2216
			jmp .wh_1b
2234
			jmp .wh_1b
2217
		.wh_1e:
2235
		.wh_1e:
2218
 
2236
 
2219
		mov [begPos],edx ;bP=i;
2237
		mov [begPos],edx ;bP=i;
2220
		mov esi,1
2238
		mov esi,1
2221
align 4
2239
align 4
2222
		.wh_2b: ;while(1){
2240
		.wh_2b: ;while(1){
2223
		call ted_iterat_next
2241
		call ted_iterat_next
2224
 
2242
 
2225
		;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
2243
		;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
2226
		@@:
2244
		@@:
2227
			cmp ecx,eax
2245
			cmp ecx,eax
2228
			jle @f
2246
			jle @f
2229
			dec ecx
2247
			dec ecx
2230
			ColToIndexOffset ecx,ebx
2248
			ColToIndexOffset ecx,ebx
2231
			inc ecx
2249
			inc ecx
2232
			;cmp byte[ebx+esi],byte[edx]
2250
			;cmp byte[ebx+esi],byte[edx]
2233
			mov bl,byte[ebx+esi]
2251
			mov bl,byte[ebx+esi]
2234
			cmp bl,byte[edx]
2252
			cmp bl,byte[edx]
2235
			je @f
2253
			je @f
2236
				dec ecx
2254
				dec ecx
2237
			jmp @b
2255
			jmp @b
2238
		@@:
2256
		@@:
2239
 
2257
 
2240
		ColToIndexOffset eax,ebx
2258
		ColToIndexOffset eax,ebx
2241
		cmp byte[ebx+esi],0
2259
		cmp byte[ebx+esi],0
2242
		jne .if_0 ;if(Col[word_n].Text[pos]==0){
2260
		jne .if_0 ;if(Col[word_n].Text[pos]==0){
2243
		mov [endPos],edx ;eP=i;
2261
		mov [endPos],edx ;eP=i;
2244
		ColToIndexOffset eax,ebx
2262
		ColToIndexOffset eax,ebx
2245
		mov bl,[ebx+MAX_COLOR_WORD_LEN+7]
2263
		mov bl,[ebx+MAX_COLOR_WORD_LEN+7]
2246
		mov [f_color],bl ;f_color=Col[word_n].color;
2264
		mov [f_color],bl ;f_color=Col[word_n].color;
2247
 
2265
 
2248
		mov byte[find],1
2266
		mov byte[find],1
2249
		ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
2267
		ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
2250
		mov bl,[ebx+MAX_COLOR_WORD_LEN+4]
2268
		mov bl,[ebx+MAX_COLOR_WORD_LEN+4]
2251
		cmp bl,0 ;if(Col[word_n].wwo)
2269
		cmp bl,0 ;if(Col[word_n].wwo)
2252
		je .if_2n
2270
		je .if_2n
2253
			push edx
2271
			push edx
2254
			mov edx,[begPos]
2272
			mov edx,[begPos]
2255
			call ted_iterat_perv
2273
			call ted_iterat_perv
2256
 
2274
 
2257
			btr bx,0 ;1-1
2275
			btr bx,0 ;1-1
2258
			jae @f ;if(Col[word_n].wwo&1)
2276
			jae @f ;if(Col[word_n].wwo&1)
2259
				;u1= !(isalnum(cont_s)||cont_s=='_')
2277
				;u1= !(isalnum(cont_s)||cont_s=='_')
2260
				call isalnum
2278
				call isalnum
2261
				jae @f
2279
				jae @f
2262
					mov byte[find],0
2280
					mov byte[find],0
2263
					jmp .if_4e
2281
					jmp .if_4e
2264
			@@:
2282
			@@:
2265
 
2283
 
2266
			btr bx,3 ;4-1
2284
			btr bx,3 ;4-1
2267
			jae .if_4e ;if(Col[word_n].wwo&8)
2285
			jae .if_4e ;if(Col[word_n].wwo&8)
2268
				;u1= !isalpha(cont_s);
2286
				;u1= !isalpha(cont_s);
2269
				call isalpha
2287
				call isalpha
2270
				jae .if_4e
2288
				jae .if_4e
2271
					mov byte[find],0
2289
					mov byte[find],0
2272
			.if_4e:
2290
			.if_4e:
2273
 
2291
 
2274
			mov edx,[endPos]
2292
			mov edx,[endPos]
2275
			;call ted_iterat_next
2293
			;call ted_iterat_next
2276
 
2294
 
2277
			btr bx,1 ;2-1
2295
			btr bx,1 ;2-1
2278
			jae @f ;if(Col[word_n].wwo&2)
2296
			jae @f ;if(Col[word_n].wwo&2)
2279
				;u1= !(isalnum(cont_s)||cont_s=='_')
2297
				;u1= !(isalnum(cont_s)||cont_s=='_')
2280
				call isalnum
2298
				call isalnum
2281
				jae @f
2299
				jae @f
2282
					mov byte[find],0
2300
					mov byte[find],0
2283
					jmp .if_6e
2301
					jmp .if_6e
2284
			@@:
2302
			@@:
2285
 
2303
 
2286
			btr bx,4 ;5-1
2304
			btr bx,4 ;5-1
2287
			jae .if_6e ;if(Col[word_n].wwo&16)
2305
			jae .if_6e ;if(Col[word_n].wwo&16)
2288
				;u1= !isalpha(cont_s);
2306
				;u1= !isalpha(cont_s);
2289
				call isalpha
2307
				call isalpha
2290
				jae .if_6e
2308
				jae .if_6e
2291
					mov byte[find],0
2309
					mov byte[find],0
2292
			.if_6e:
2310
			.if_6e:
2293
 
2311
 
2294
			btr bx,2 ;3-1
2312
			btr bx,2 ;3-1
2295
			jae .if_7e ;if(Col[word_n].wwo&4)
2313
			jae .if_7e ;if(Col[word_n].wwo&4)
2296
				ColToIndexOffset eax,ebx
2314
				ColToIndexOffset eax,ebx
2297
				mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
2315
				mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
2298
				call ted_iterat_next_pos_char
2316
				call ted_iterat_next_pos_char
2299
				cmp edx,ted_tex_1
2317
				cmp edx,ted_tex_1
2300
				jg @f
2318
				jg @f
2301
					;¥á«¨ ¤®è«¨ ¤® ª®­æ  ä ©«  ¨ ­¥ ­ è«¨ ᨬ¢®« ª®­æ  à §¬¥âª¨
2319
					;¥á«¨ ¤®è«¨ ¤® ª®­æ  ä ©«  ¨ ­¥ ­ è«¨ ᨬ¢®« ª®­æ  à §¬¥âª¨
2302
					call ted_iterat_perv
2320
					call ted_iterat_perv
2303
				@@:
2321
				@@:
2304
					mov dword[endPos],edx
2322
					mov dword[endPos],edx
2305
			.if_7e:
2323
			.if_7e:
2306
 
2324
 
2307
			pop edx
2325
			pop edx
2308
		.if_2n:
2326
		.if_2n:
2309
;if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
2327
;if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
2310
;  cont_s=tex[eP].c;
2328
;  cont_s=tex[eP].c;
2311
;  if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
2329
;  if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
2312
;  if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
2330
;  if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
2313
;  if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
2331
;  if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
2314
 
2332
 
2315
			cmp eax,ecx
2333
			cmp eax,ecx
2316
			je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
2334
			je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
2317
		.if_0:
2335
		.if_0:
2318
 
2336
 
2319
		cmp edx,ted_tex_1
2337
		cmp edx,ted_tex_1
2320
		jle .wh_2e ;if(i==1) break;
2338
		jle .wh_2e ;if(i==1) break;
2321
 
2339
 
2322
		;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
2340
		;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
2323
		.wh_4b:
2341
		.wh_4b:
2324
		cmp ecx,eax
2342
		cmp ecx,eax
2325
		jle .wh_4e
2343
		jle .wh_4e
2326
			ColToIndexOffset eax,ebx
2344
			ColToIndexOffset eax,ebx
2327
			;cmp byte[ebx+esi],byte[edx]
2345
			;cmp byte[ebx+esi],byte[edx]
2328
			mov bl,byte[ebx+esi]
2346
			mov bl,byte[ebx+esi]
2329
			cmp bl,byte[edx]
2347
			cmp bl,byte[edx]
2330
			je .wh_4e
2348
			je .wh_4e
2331
				inc eax
2349
				inc eax
2332
			jmp .wh_4b
2350
			jmp .wh_4b
2333
		.wh_4e:
2351
		.wh_4e:
2334
 
2352
 
2335
		cmp eax,ecx
2353
		cmp eax,ecx
2336
		je .wh_2e;if(word_n==l_pos) break;
2354
		je .wh_2e;if(word_n==l_pos) break;
2337
			inc esi ;pos++;
2355
			inc esi ;pos++;
2338
			jmp .wh_2b
2356
			jmp .wh_2b
2339
		.wh_2e:
2357
		.wh_2e:
2340
 
2358
 
2341
		cmp byte[find],1 ;if(fnd)break;
2359
		cmp byte[find],1 ;if(fnd)break;
2342
		je .cycle0end
2360
		je .cycle0end
2343
			mov edx,[begPos];i=bP;
2361
			mov edx,[begPos];i=bP;
2344
		jmp .cycle0
2362
		jmp .cycle0
2345
	.cycle0end:
2363
	.cycle0end:
2346
 
2364
 
2347
	cmp byte[find],1
2365
	cmp byte[find],1
2348
	jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
2366
	jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
2349
		;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
2367
		;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
2350
		mov eax,[begPos]
2368
		mov eax,[begPos]
2351
		mov bl,[f_color]
2369
		mov bl,[f_color]
2352
		mov [eax+1],bl ;tex[bP].col=f_color;
2370
		mov [eax+1],bl ;tex[bP].col=f_color;
2353
		mov eax,[endPos]
2371
		mov eax,[endPos]
2354
		mov byte[eax+1],0xff ;tex[eP].col=255;
2372
		mov byte[eax+1],0xff ;tex[eP].col=255;
2355
		;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
2373
		;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
2356
		mov edx,[endPos]
2374
		mov edx,[endPos]
2357
		call ted_get_text_perv_pos
2375
		call ted_get_text_perv_pos
2358
		jmp @f
2376
		jmp @f
2359
	.if_1e:
2377
	.if_1e:
2360
		mov edx,ted_tex
2378
		mov edx,ted_tex
2361
	@@:
2379
	@@:
2362
 
2380
 
2363
	ret
2381
	ret
2364
endp
2382
endp
2365
 
2383
 
2366
;input:
2384
;input:
2367
; edx = pointer to char (byte)
2385
; edx = pointer to char (byte)
2368
;output:
2386
;output:
2369
; cf=1 if symbol is...
2387
; cf=1 if symbol is...
2370
align 16
2388
align 16
2371
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
2389
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
2372
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
2390
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
2373
 
2391
 
2374
;output:
2392
;output:
2375
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà  ¨«¨ '_'
2393
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà  ¨«¨ '_'
2376
align 16
2394
align 16
2377
isalnum:
2395
isalnum:
2378
	push eax ebx
2396
	push eax ebx
2379
	movzx eax,byte[edx] ;al=offset
2397
	movzx eax,byte[edx] ;al=offset
2380
	shr eax,3
2398
	shr eax,3
2381
	lea ebx,[tab_all_num]
2399
	lea ebx,[tab_all_num]
2382
	add ebx,eax
2400
	add ebx,eax
2383
	movzx ax,byte[edx] ;al=bit
2401
	movzx ax,byte[edx] ;al=bit
2384
	and ax,111b
2402
	and ax,111b
2385
	bt word[ebx],ax
2403
	bt word[ebx],ax
2386
	pop ebx eax
2404
	pop ebx eax
2387
	ret
2405
	ret
2388
 
2406
 
2389
;output:
2407
;output:
2390
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢  ¨«¨ '_'
2408
; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢  ¨«¨ '_'
2391
align 16
2409
align 16
2392
isalpha:
2410
isalpha:
2393
	push eax ebx
2411
	push eax ebx
2394
	movzx eax,byte[edx] ;al=offset
2412
	movzx eax,byte[edx] ;al=offset
2395
	shr eax,3
2413
	shr eax,3
2396
	lea ebx,[tab_alpha]
2414
	lea ebx,[tab_alpha]
2397
	add ebx,eax
2415
	add ebx,eax
2398
	movzx ax,byte[edx] ;al=bit
2416
	movzx ax,byte[edx] ;al=bit
2399
	and ax,111b
2417
	and ax,111b
2400
	bt word[ebx],ax
2418
	bt word[ebx],ax
2401
	pop ebx eax
2419
	pop ebx eax
2402
	ret
2420
	ret
2403
 
2421
 
2404
align 16
2422
align 16
2405
proc ted_show_help_f1 uses eax edx edi, edit:dword
2423
proc ted_show_help_f1 uses eax edx edi, edit:dword
2406
	mov edi,[edit]
2424
	mov edi,[edit]
2407
 
2425
 
2408
	call ted_get_pos_by_cursor
2426
	call ted_get_pos_by_cursor
2409
	push edx
2427
	push edx
2410
		call ted_iterat_next_color_tag
2428
		call ted_iterat_next_color_tag
2411
		mov eax,edx
2429
		mov eax,edx
2412
	pop edx
2430
	pop edx
2413
	call ted_iterat_perv_color_tag
2431
	call ted_iterat_perv_color_tag
2414
 
2432
 
2415
	cmp eax,ted_tex
2433
	cmp eax,ted_tex
2416
	jle @f
2434
	jle @f
2417
	cmp edx,ted_tex_1
2435
	cmp edx,ted_tex_1
2418
	jle @f
2436
	jle @f
2419
		stdcall ted_find_help_id,eax
2437
		stdcall ted_find_help_id,eax
2420
	@@:
2438
	@@:
2421
	;call ted_draw_main_cursor
2439
	;call ted_draw_main_cursor
2422
	call ted_draw_help_f1
2440
	call ted_draw_help_f1
2423
	ret 
2441
	ret 
2424
endp
2442
endp
2425
 
2443
 
2426
;input:
2444
;input:
2427
; edx = position begin 'symbol' struct
2445
; edx = position begin 'symbol' struct
2428
; edi = pointer to tedit struct
2446
; edi = pointer to tedit struct
2429
; end_pos = position end 'symbol' struct
2447
; end_pos = position end 'symbol' struct
2430
align 16
2448
align 16
2431
proc ted_find_help_id, end_pos:dword
2449
proc ted_find_help_id, end_pos:dword
2432
; ecx = word_n
2450
; ecx = word_n
2433
; ebx = l_pos
2451
; ebx = l_pos
2434
  mov ted_help_id,-1
2452
  mov ted_help_id,-1
2435
 
2453
 
2436
  push ebx ecx
2454
  push ebx ecx
2437
    xor ebx,ebx
2455
    xor ebx,ebx
2438
    mov bl,[edx]
2456
    mov bl,[edx]
2439
    shl bx,2 ;ebx*=4
2457
    shl bx,2 ;ebx*=4
2440
    add ebx,ted_arr_key_pos
2458
    add ebx,ted_arr_key_pos
2441
    mov ecx,[ebx]
2459
    mov ecx,[ebx]
2442
    cmp ecx,0
2460
    cmp ecx,0
2443
    jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
2461
    jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
2444
      push esi eax
2462
      push esi eax
2445
      mov ebx,ecx ;l_pos=word_n;
2463
      mov ebx,ecx ;l_pos=word_n;
2446
      ColToIndexOffset ecx,esi
2464
      ColToIndexOffset ecx,esi
2447
      push cx
2465
      push cx
2448
      mov cl,[esi]
2466
      mov cl,[esi]
2449
      @@:
2467
      @@:
2450
	cmp ebx,ted_key_words_count ;while(l_pos
2468
	cmp ebx,ted_key_words_count ;while(l_pos
2451
	jge @f
2469
	jge @f
2452
	;ColToIndexOffset ecx,esi
2470
	;ColToIndexOffset ecx,esi
2453
	ColToIndexOffset ebx,eax
2471
	ColToIndexOffset ebx,eax
2454
	cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
2472
	cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
2455
	jne @f
2473
	jne @f
2456
	  inc ebx ;l_pos++;
2474
	  inc ebx ;l_pos++;
2457
	  jmp @b
2475
	  jmp @b
2458
      @@:
2476
      @@:
2459
      pop cx
2477
      pop cx
2460
      call ted_iterat_next ;pos=1;
2478
      call ted_iterat_next ;pos=1;
2461
      mov esi,1
2479
      mov esi,1
2462
      @@:
2480
      @@:
2463
	push dx
2481
	push dx
2464
	push word[edx]
2482
	push word[edx]
2465
	pop dx 
2483
	pop dx 
2466
	  .wh_0b:
2484
	  .wh_0b:
2467
	    cmp ebx,ecx ;while(l_pos>word_n
2485
	    cmp ebx,ecx ;while(l_pos>word_n
2468
	    jle .wh_0e
2486
	    jle .wh_0e
2469
	    dec ebx
2487
	    dec ebx
2470
	    ColToIndexOffset ebx,eax
2488
	    ColToIndexOffset ebx,eax
2471
	    inc ebx
2489
	    inc ebx
2472
	    cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
2490
	    cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
2473
	    je .wh_0e
2491
	    je .wh_0e
2474
	      dec ebx ;l_pos--;
2492
	      dec ebx ;l_pos--;
2475
	    jmp .wh_0b
2493
	    jmp .wh_0b
2476
	  .wh_0e:
2494
	  .wh_0e:
2477
 
2495
 
2478
	  .wh_1b:
2496
	  .wh_1b:
2479
	    cmp ebx,ecx ;while(l_pos>word_n
2497
	    cmp ebx,ecx ;while(l_pos>word_n
2480
	    jle .wh_1e
2498
	    jle .wh_1e
2481
	    ColToIndexOffset ecx,eax
2499
	    ColToIndexOffset ecx,eax
2482
	    cmp byte[eax+esi],dl
2500
	    cmp byte[eax+esi],dl
2483
	    je .wh_1e
2501
	    je .wh_1e
2484
	      inc ecx ;word_n++;
2502
	      inc ecx ;word_n++;
2485
	    jmp .wh_1b
2503
	    jmp .wh_1b
2486
	  .wh_1e:
2504
	  .wh_1e:
2487
	pop dx
2505
	pop dx
2488
 
2506
 
2489
	cmp ecx,ebx ;if(word_n==l_pos) break;
2507
	cmp ecx,ebx ;if(word_n==l_pos) break;
2490
	je @f
2508
	je @f
2491
	call ted_iterat_next ;pos++;
2509
	call ted_iterat_next ;pos++;
2492
	cmp edx,[end_pos] ;for(...;i
2510
	cmp edx,[end_pos] ;for(...;i
2493
	je @f ;jge
2511
	je @f ;jge
2494
	inc esi
2512
	inc esi
2495
	jmp @b
2513
	jmp @b
2496
      @@:
2514
      @@:
2497
      pop eax esi
2515
      pop eax esi
2498
 
2516
 
2499
      mov ted_help_id,ecx
2517
      mov ted_help_id,ecx
2500
      ;return word_n;
2518
      ;return word_n;
2501
 
2519
 
2502
    .if_0e:
2520
    .if_0e:
2503
  pop ecx ebx
2521
  pop ecx ebx
2504
  ret
2522
  ret
2505
endp
2523
endp
2506
 
2524
 
2507
;output:
2525
;output:
2508
; eax = ª®¤ ®è¨¡ª¨
2526
; eax = ª®¤ ®è¨¡ª¨
2509
; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
2527
; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
2510
align 16
2528
align 16
2511
proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
2529
proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
2512
	mov edi,[edit]
2530
	mov edi,[edit]
2513
 
2531
 
2514
	; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
2532
	; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
2515
	;¯à®¡ã¥¬ ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ä ©«¥
2533
	;¯à®¡ã¥¬ ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ä ©«¥
2516
	mov ebx,[file]
2534
	mov ebx,[file]
2517
	mov dword[ebx], SSF_GET_INFO
2535
	mov dword[ebx], SSF_GET_INFO
2518
	mov dword[ebx+4], 0
2536
	mov dword[ebx+4], 0
2519
	mov dword[ebx+8], 0
2537
	mov dword[ebx+8], 0
2520
	mov dword[ebx+12], 0
2538
	mov dword[ebx+12], 0
2521
	m2m dword[ebx+16], ted_tex
2539
	m2m dword[ebx+16], ted_tex
2522
	mov  byte[ebx+20], 0
2540
	mov  byte[ebx+20], 0
2523
	push dword[f_name]
2541
	push dword[f_name]
2524
	pop dword[ebx+21]
2542
	pop dword[ebx+21]
2525
	mcall SF_FILE
2543
	mcall SF_FILE
2526
	or eax,eax
2544
	or eax,eax
2527
	jz .end_0
2545
	jz .end_0
2528
		mov edx,ted_max_chars
2546
		mov edx,ted_max_chars
2529
		cmp eax,2 ;äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
2547
		cmp eax,2 ;äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
2530
		je @f
2548
		je @f
2531
		jmp .ret_f
2549
		jmp .ret_f
2532
align 4
2550
align 4
2533
	.end_0:
2551
	.end_0:
2534
	;¯à®¢¥à塞 墠â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©« 
2552
	;¯à®¢¥à塞 墠â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©« 
2535
	mov ecx,ted_max_chars
2553
	mov ecx,ted_max_chars
2536
	sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
2554
	sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
2537
	mov edx,ted_tex
2555
	mov edx,ted_tex
2538
	mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
2556
	mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
2539
	cmp edx,ecx
2557
	cmp edx,ecx
2540
	jl @f
2558
	jl @f
2541
		;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
2559
		;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
2542
		mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©« 
2560
		mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©« 
2543
		add ecx,2  ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
2561
		add ecx,2  ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
2544
		add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
2562
		add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
2545
		mov ted_max_chars,ecx
2563
		mov ted_max_chars,ecx
2546
		imul ecx,sizeof.symbol
2564
		imul ecx,sizeof.symbol
2547
		invoke mem.realloc, ted_tex,ecx
2565
		invoke mem.realloc, ted_tex,ecx
2548
		mov ted_tex,eax
2566
		mov ted_tex,eax
2549
		mov ted_tex_1,eax
2567
		mov ted_tex_1,eax
2550
		add ted_tex_1,sizeof.symbol
2568
		add ted_tex_1,sizeof.symbol
2551
		add eax,ecx
2569
		add eax,ecx
2552
		mov ted_tex_end,eax
2570
		mov ted_tex_end,eax
2553
		mov ecx,ted_tex_1
2571
		mov ecx,ted_tex_1
2554
		add ecx,sizeof.symbol
2572
		add ecx,sizeof.symbol
2555
		mov ted_ptr_free_symb,ecx
2573
		mov ted_ptr_free_symb,ecx
2556
	@@:
2574
	@@:
2557
 
2575
 
2558
	; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
2576
	; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
2559
	mov ebx,[file]
2577
	mov ebx,[file]
2560
	mov dword[ebx], SSF_READ_FILE
2578
	mov dword[ebx], SSF_READ_FILE
2561
	mov dword[ebx+4], 0
2579
	mov dword[ebx+4], 0
2562
	mov dword[ebx+8], 0
2580
	mov dword[ebx+8], 0
2563
	m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©«  (­¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
2581
	m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©«  (­¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
2564
	m2m dword[ebx+16], ted_tex
2582
	m2m dword[ebx+16], ted_tex
2565
	mov  byte[ebx+20], 0
2583
	mov  byte[ebx+20], 0
2566
	push dword[f_name]
2584
	push dword[f_name]
2567
	pop dword[ebx+21]
2585
	pop dword[ebx+21]
2568
	mcall SF_FILE
2586
	mcall SF_FILE
2569
 
2587
 
2570
	or eax,eax
2588
	or eax,eax
2571
	jz @f
2589
	jz @f
2572
	cmp eax,6
2590
	cmp eax,6
2573
	je @f
2591
	je @f
2574
		jmp .ret_f
2592
		jmp .ret_f
2575
	@@:
2593
	@@:
2576
	cmp ebx,-1
2594
	cmp ebx,-1
2577
	je .ret_f
2595
	je .ret_f
2578
		;if open file
2596
		;if open file
2579
		call ted_on_open_file
2597
		call ted_on_open_file
2580
	.ret_f:
2598
	.ret_f:
2581
	ret
2599
	ret
2582
endp
2600
endp
2583
 
2601
 
2584
align 16
2602
align 16
2585
proc ted_but_select_word, edit:dword
2603
proc ted_but_select_word, edit:dword
2586
	pushad
2604
	pushad
2587
	mov edi,[edit]
2605
	mov edi,[edit]
2588
 
2606
 
2589
	call ted_get_pos_by_cursor
2607
	call ted_get_pos_by_cursor
2590
	push edx
2608
	push edx
2591
		call ted_iterat_perv_color_tag
2609
		call ted_iterat_perv_color_tag
2592
		cmp edx,ted_tex_1
2610
		cmp edx,ted_tex_1
2593
		jle @f
2611
		jle @f
2594
			call ted_get_text_coords
2612
			call ted_get_text_coords
2595
			mov ted_sel_x0,ebx
2613
			mov ted_sel_x0,ebx
2596
			mov ted_sel_y0,eax
2614
			mov ted_sel_y0,eax
2597
		@@:
2615
		@@:
2598
	pop edx
2616
	pop edx
2599
	call ted_iterat_next_color_tag
2617
	call ted_iterat_next_color_tag
2600
	cmp edx,ted_tex_1
2618
	cmp edx,ted_tex_1
2601
	jle @f
2619
	jle @f
2602
		call ted_get_text_coords
2620
		call ted_get_text_coords
2603
		mov ted_sel_x1,ebx
2621
		mov ted_sel_x1,ebx
2604
		mov ted_sel_y1,eax
2622
		mov ted_sel_y1,eax
2605
	@@:
2623
	@@:
2606
 
2624
 
2607
	cmp ted_fun_draw_panel_buttons,0
2625
	cmp ted_fun_draw_panel_buttons,0
2608
	je @f
2626
	je @f
2609
		call ted_fun_draw_panel_buttons
2627
		call ted_fun_draw_panel_buttons
2610
	@@:
2628
	@@:
2611
	stdcall ted_draw,edi
2629
	stdcall ted_draw,edi
2612
	popad
2630
	popad
2613
	ret
2631
	ret
2614
endp
2632
endp
2615
 
2633
 
2616
;output:
2634
;output:
2617
; al = 1 if delete
2635
; al = 1 if delete
2618
align 16
2636
align 16
2619
proc ted_but_cut uses edi, edit:dword
2637
proc ted_but_cut uses edi, edit:dword
2620
	mov edi,[edit]
2638
	mov edi,[edit]
2621
 
2639
 
2622
	stdcall ted_but_copy,edi
2640
	stdcall ted_but_copy,edi
2623
	call ted_set_undo
2641
	call ted_set_undo
2624
	stdcall ted_sel_text_del,ted_opt_ed_change_time
2642
	stdcall ted_sel_text_del,ted_opt_ed_change_time
2625
 
2643
 
2626
	cmp al,1
2644
	cmp al,1
2627
	jne @f
2645
	jne @f
2628
		stdcall ted_draw,edi
2646
		stdcall ted_draw,edi
2629
		cmp ted_fun_draw_panel_buttons,0
2647
		cmp ted_fun_draw_panel_buttons,0
2630
		je @f
2648
		je @f
2631
			call ted_fun_draw_panel_buttons
2649
			call ted_fun_draw_panel_buttons
2632
	@@:
2650
	@@:
2633
	ret
2651
	ret
2634
endp
2652
endp
2635
 
2653
 
2636
align 16
2654
align 16
2637
proc ted_but_copy, edit:dword
2655
proc ted_but_copy, edit:dword
2638
	pushad
2656
	pushad
2639
	mov edi,[edit]
2657
	mov edi,[edit]
2640
 
2658
 
2641
	call ted_is_select
2659
	call ted_is_select
2642
	or al,al
2660
	or al,al
2643
	jz .end_f ;if not selected text
2661
	jz .end_f ;if not selected text
2644
	call ted_sel_normalize
2662
	call ted_sel_normalize
2645
 
2663
 
2646
	mov esi,ted_seln_x1
2664
	mov esi,ted_seln_x1
2647
	mov ecx,ted_seln_y1
2665
	mov ecx,ted_seln_y1
2648
	call ted_get_pos_by_coords
2666
	call ted_get_pos_by_coords
2649
	mov ebx,edx
2667
	mov ebx,edx
2650
	mov esi,ted_seln_x0
2668
	mov esi,ted_seln_x0
2651
	mov ecx,ted_seln_y0
2669
	mov ecx,ted_seln_y0
2652
	call ted_get_pos_by_coords
2670
	call ted_get_pos_by_coords
2653
	mov esi,ebx
2671
	mov esi,ebx
2654
 
2672
 
2655
	mov ecx,12 ;system buffer header size
2673
	mov ecx,12 ;system buffer header size
2656
	mov ebx,ted_buffer
2674
	mov ebx,ted_buffer
2657
	mov dword[ebx+4],0 ;text data
2675
	mov dword[ebx+4],0 ;text data
2658
	mov dword[ebx+8],1 ;code 866
2676
	mov dword[ebx+8],1 ;code 866
2659
	add ebx,ecx
2677
	add ebx,ecx
2660
	@@:
2678
	@@:
2661
		cmp edx,ted_tex_1 ;end of file
2679
		cmp edx,ted_tex_1 ;end of file
2662
		jle @f
2680
		jle @f
2663
		cmp edx,esi ;end of select
2681
		cmp edx,esi ;end of select
2664
		je @f
2682
		je @f
2665
		inc ecx
2683
		inc ecx
2666
		cmp ecx,ted_buffer_size ;owerflow bufer
2684
		cmp ecx,ted_buffer_size ;owerflow bufer
2667
		je @f
2685
		je @f
2668
 
2686
 
2669
		mov al,byte[edx]
2687
		mov al,byte[edx]
2670
		mov byte[ebx],al
2688
		mov byte[ebx],al
2671
		inc ebx
2689
		inc ebx
2672
		cmp al,13
2690
		cmp al,13
2673
		jne .no_13
2691
		jne .no_13
2674
			mov byte[ebx],10 ;¤¥« ¥¬ ª®­¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
2692
			mov byte[ebx],10 ;¤¥« ¥¬ ª®­¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
2675
			inc ebx
2693
			inc ebx
2676
			inc ecx
2694
			inc ecx
2677
		.no_13:
2695
		.no_13:
2678
		
2696
		
2679
		call ted_iterat_next
2697
		call ted_iterat_next
2680
		jmp @b
2698
		jmp @b
2681
	@@:
2699
	@@:
2682
	mov byte[ebx],0
2700
	mov byte[ebx],0
2683
 
2701
 
2684
	cmp ecx,12
2702
	cmp ecx,12
2685
	je .end_f
2703
	je .end_f
2686
		mov ebx,ted_buffer
2704
		mov ebx,ted_buffer
2687
		mov [ebx],ecx
2705
		mov [ebx],ecx
2688
		mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer
2706
		mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer
2689
		call ted_draw_buffer
2707
		call ted_draw_buffer
2690
		cmp ted_fun_draw_panel_buttons,0
2708
		cmp ted_fun_draw_panel_buttons,0
2691
		je .end_f
2709
		je .end_f
2692
			call ted_fun_draw_panel_buttons
2710
			call ted_fun_draw_panel_buttons
2693
	.end_f:
2711
	.end_f:
2694
	popad
2712
	popad
2695
	ret
2713
	ret
2696
endp
2714
endp
2697
 
2715
 
2698
 
2716
 
2699
align 16
2717
align 16
2700
proc ted_but_paste, edit:dword
2718
proc ted_but_paste, edit:dword
2701
	pushad
2719
	pushad
2702
	mov edi,[edit]
2720
	mov edi,[edit]
2703
 
2721
 
2704
	mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
2722
	mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
2705
	cmp eax,1
2723
	cmp eax,1
2706
	jl .no_buf_r
2724
	jl .no_buf_r
2707
 
2725
 
2708
	mov esi,eax
2726
	mov esi,eax
2709
	.cycle: ;®¡à â­ë© 横« ¯® ᫮⠬
2727
	.cycle: ;®¡à â­ë© 横« ¯® ᫮⠬
2710
	dec esi ;­®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â 
2728
	dec esi ;­®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â 
2711
	mcall SF_CLIPBOARD,SSF_READ_CB,esi
2729
	mcall SF_CLIPBOARD,SSF_READ_CB,esi
2712
	cmp eax,1
2730
	cmp eax,1
2713
	je .no_buf_r
2731
	je .no_buf_r
2714
	cmp eax,-1
2732
	cmp eax,-1
2715
	je .no_buf_r
2733
	je .no_buf_r
2716
		mov ecx,[eax]
2734
		mov ecx,[eax]
2717
		cmp ecx,1 ;size
2735
		cmp ecx,1 ;size
2718
		jl .no_buf_r
2736
		jl .no_buf_r
2719
		cmp dword[eax+4],0 ;text
2737
		cmp dword[eax+4],0 ;text
2720
		je @f
2738
		je @f
2721
			cmp esi,1
2739
			cmp esi,1
2722
			jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ­¥ ⥪áâ,   ᫮⮢ ¢ ¡ãä¥à¥ ­¥áª®«ìª®, ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
2740
			jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ­¥ ⥪áâ,   ᫮⮢ ¢ ¡ãä¥à¥ ­¥áª®«ìª®, ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
2723
			jmp .no_buf_r
2741
			jmp .no_buf_r
2724
		@@:
2742
		@@:
2725
		cmp dword[eax+8],1 ;866
2743
		cmp dword[eax+8],1 ;866
2726
		je @f
2744
		je @f
2727
			cmp esi,1
2745
			cmp esi,1
2728
			jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ⥪áâ ­¥ ¢ ª®¤¨à®¢ª¥ 866 ... ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
2746
			jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ⥪áâ ­¥ ¢ ª®¤¨à®¢ª¥ 866 ... ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
2729
			jmp .no_buf_r
2747
			jmp .no_buf_r
2730
		@@:
2748
		@@:
2731
		;ª®¯¨à®¢ ­¨¥ ⥪áâ  ¨§ á¨á⥬­®£® ¡ãä¥à  ¢® ¢­ãâ७­¨©
2749
		;ª®¯¨à®¢ ­¨¥ ⥪áâ  ¨§ á¨á⥬­®£® ¡ãä¥à  ¢® ¢­ãâ७­¨©
2732
		cmp ecx,ted_buffer_size
2750
		cmp ecx,ted_buffer_size
2733
		jle @f
2751
		jle @f
2734
			mov ecx,ted_buffer_size
2752
			mov ecx,ted_buffer_size
2735
		@@:
2753
		@@:
2736
		mov edi,ted_buffer
2754
		mov edi,ted_buffer
2737
		mov esi,eax
2755
		mov esi,eax
2738
		add	esi,4 ;12
2756
		add	esi,4 ;12
2739
		mov dword[edi],ecx
2757
		mov dword[edi],ecx
2740
		add edi,4 ;12
2758
		add edi,4 ;12
2741
		sub ecx,4 ;12
2759
		sub ecx,4 ;12
2742
		rep movsb
2760
		rep movsb
2743
		mov edi,[edit]
2761
		mov edi,[edit]
2744
 
2762
 
2745
		mov esi,eax
2763
		mov esi,eax
2746
		add	esi,12
2764
		add	esi,12
2747
		jmp .buf_r
2765
		jmp .buf_r
2748
	.no_buf_r:
2766
	.no_buf_r:
2749
		
2767
		
2750
	;¥á«¨ ­¥ 㤠«®áì ¯à®ç¨â âì ¤ ­­ë¥ ¨§ á¨á⥬­®£® ¡ãä¥à , ¯®¯ ¤ ¥¬ á
2768
	;¥á«¨ ­¥ 㤠«®áì ¯à®ç¨â âì ¤ ­­ë¥ ¨§ á¨á⥬­®£® ¡ãä¥à , ¯®¯ ¤ ¥¬ á
2751
	mov esi,ted_buffer
2769
	mov esi,ted_buffer
2752
	cmp dword[esi],1 ;¯à®¢¥à塞 ¥áâì «¨ ¤ ­­ë¥ ¢® ¢­ãâ७­¥¬ ¡ãä¥à¥
2770
	cmp dword[esi],1 ;¯à®¢¥à塞 ¥áâì «¨ ¤ ­­ë¥ ¢® ¢­ãâ७­¥¬ ¡ãä¥à¥
2753
	jl .no_paste ;¥á«¨ ¢®®¡é¥ ­¨ç¥£® ­¥ 㤠«®áì ¯à®ç¨â âì ¨¤¥¬ ­  ¢ë室
2771
	jl .no_paste ;¥á«¨ ¢®®¡é¥ ­¨ç¥£® ­¥ 㤠«®áì ¯à®ç¨â âì ¨¤¥¬ ­  ¢ë室
2754
	add esi,12 ;system buffer header size
2772
	add esi,12 ;system buffer header size
2755
	.buf_r:
2773
	.buf_r:
2756
	
2774
	
2757
	mov edx,esi
2775
	mov edx,esi
2758
	call tl_strlen
2776
	call tl_strlen
2759
	cmp eax,1
2777
	cmp eax,1
2760
	jl .no_paste
2778
	jl .no_paste
2761
		mov esi,eax
2779
		mov esi,eax
2762
		call ted_set_undo
2780
		call ted_set_undo
2763
		mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
2781
		mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
2764
		stdcall ted_sel_text_del,ebx
2782
		stdcall ted_sel_text_del,ebx
2765
		cmp al,1
2783
		cmp al,1
2766
		jne .del
2784
		jne .del
2767
			mov ebx,ted_opt_ed_move_cursor
2785
			mov ebx,ted_opt_ed_move_cursor
2768
		.del:
2786
		.del:
2769
		stdcall ted_text_add,edi,edx,esi,ebx
2787
		stdcall ted_text_add,edi,edx,esi,ebx
2770
		stdcall ted_draw,edi
2788
		stdcall ted_draw,edi
2771
		cmp ted_fun_draw_panel_buttons,0
2789
		cmp ted_fun_draw_panel_buttons,0
2772
		je .no_paste
2790
		je .no_paste
2773
			call ted_fun_draw_panel_buttons
2791
			call ted_fun_draw_panel_buttons
2774
	.no_paste:
2792
	.no_paste:
2775
	popad
2793
	popad
2776
	ret
2794
	ret
2777
endp
2795
endp
2778
 
2796
 
2779
align 16
2797
align 16
2780
proc ted_but_sumb_upper uses edi esi, edit:dword
2798
proc ted_but_sumb_upper uses edi esi, edit:dword
2781
	mov edi,[edit]
2799
	mov edi,[edit]
2782
 
2800
 
2783
	stdcall ted_convert_sel_text,fb_char_toupper
2801
	stdcall ted_convert_sel_text,fb_char_toupper
2784
	or esi,esi
2802
	or esi,esi
2785
	jz @f
2803
	jz @f
2786
		stdcall ted_draw,edi
2804
		stdcall ted_draw,edi
2787
	@@:
2805
	@@:
2788
	ret
2806
	ret
2789
endp
2807
endp
2790
 
2808
 
2791
align 16
2809
align 16
2792
proc ted_but_sumb_lover uses edi esi, edit:dword
2810
proc ted_but_sumb_lover uses edi esi, edit:dword
2793
	mov edi,[edit]
2811
	mov edi,[edit]
2794
 
2812
 
2795
	stdcall ted_convert_sel_text,fb_char_todown
2813
	stdcall ted_convert_sel_text,fb_char_todown
2796
	or esi,esi
2814
	or esi,esi
2797
	jz @f
2815
	jz @f
2798
		stdcall ted_draw,edi
2816
		stdcall ted_draw,edi
2799
	@@:
2817
	@@:
2800
	ret
2818
	ret
2801
endp
2819
endp
2802
 
2820
 
2803
align 16
2821
align 16
2804
proc ted_but_reverse uses eax ebx edi, edit:dword
2822
proc ted_but_reverse uses eax ebx edi, edit:dword
2805
	mov edi,[edit]
2823
	mov edi,[edit]
2806
 
2824
 
2807
	call ted_is_select
2825
	call ted_is_select
2808
	or al,al
2826
	or al,al
2809
	jz @f
2827
	jz @f
2810
		call ted_sel_normalize
2828
		call ted_sel_normalize
2811
		push esi ecx edx
2829
		push esi ecx edx
2812
			mov esi,ted_seln_x0
2830
			mov esi,ted_seln_x0
2813
			mov ecx,ted_seln_y0
2831
			mov ecx,ted_seln_y0
2814
			call ted_get_pos_by_coords
2832
			call ted_get_pos_by_coords
2815
			mov eax,edx
2833
			mov eax,edx
2816
			mov esi,ted_seln_x1
2834
			mov esi,ted_seln_x1
2817
			cmp esi,0
2835
			cmp esi,0
2818
			je .beg_str
2836
			je .beg_str
2819
				dec esi
2837
				dec esi
2820
			.beg_str:
2838
			.beg_str:
2821
			mov ecx,ted_seln_y1
2839
			mov ecx,ted_seln_y1
2822
			call ted_get_pos_by_coords
2840
			call ted_get_pos_by_coords
2823
			;call ted_get_text_perv_pos
2841
			;call ted_get_text_perv_pos
2824
			mov ebx,edx
2842
			mov ebx,edx
2825
		pop edx ecx esi
2843
		pop edx ecx esi
2826
		;cmp eax,...
2844
		;cmp eax,...
2827
		;je @f
2845
		;je @f
2828
		call ted_revers
2846
		call ted_revers
2829
	@@:
2847
	@@:
2830
	stdcall ted_draw,edi
2848
	stdcall ted_draw,edi
2831
	ret
2849
	ret
2832
endp
2850
endp
2833
 
2851
 
2834
align 16
2852
align 16
2835
proc ted_but_undo uses eax edi, edit:dword
2853
proc ted_but_undo uses eax edi, edit:dword
2836
	mov edi,[edit]
2854
	mov edi,[edit]
2837
 
2855
 
2838
	mov eax,ted_tim_undo
2856
	mov eax,ted_tim_undo
2839
	cmp ted_tim_ch,eax
2857
	cmp ted_tim_ch,eax
2840
	jbe @f
2858
	jbe @f
2841
		inc ted_tim_undo
2859
		inc ted_tim_undo
2842
		;call ted_text_colored
2860
		;call ted_text_colored
2843
		stdcall ted_draw,edi
2861
		stdcall ted_draw,edi
2844
		cmp ted_fun_draw_panel_buttons,0
2862
		cmp ted_fun_draw_panel_buttons,0
2845
		je @f
2863
		je @f
2846
			call ted_fun_draw_panel_buttons
2864
			call ted_fun_draw_panel_buttons
2847
	@@:
2865
	@@:
2848
	ret
2866
	ret
2849
endp
2867
endp
2850
 
2868
 
2851
align 16
2869
align 16
2852
proc ted_but_redo uses edi, edit:dword
2870
proc ted_but_redo uses edi, edit:dword
2853
	mov edi,[edit]
2871
	mov edi,[edit]
2854
 
2872
 
2855
	cmp ted_tim_undo,1
2873
	cmp ted_tim_undo,1
2856
	jb @f
2874
	jb @f
2857
		dec ted_tim_undo
2875
		dec ted_tim_undo
2858
		;call ted_text_colored
2876
		;call ted_text_colored
2859
		stdcall ted_draw,edi
2877
		stdcall ted_draw,edi
2860
		cmp ted_fun_draw_panel_buttons,0
2878
		cmp ted_fun_draw_panel_buttons,0
2861
		je @f
2879
		je @f
2862
			call ted_fun_draw_panel_buttons
2880
			call ted_fun_draw_panel_buttons
2863
	@@:
2881
	@@:
2864
	ret
2882
	ret
2865
endp
2883
endp
2866
 
2884
 
2867
;description:
2885
;description:
2868
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­  ª®â®àë© ãª §ë¢ ¥â ted_buffer_find
2886
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­  ª®â®àë© ãª §ë¢ ¥â ted_buffer_find
2869
;input:
2887
;input:
2870
; f_opt = ¯ à ¬¥âàë ¯®¨áª :
2888
; f_opt = ¯ à ¬¥âàë ¯®¨áª :
2871
;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
2889
;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
2872
;   ¥á«¨ ãáâ ­®¢«¥­ 31-© ¡¨â, â® ­¥ ®¡­®¢«ï¥âáï ®ª­®
2890
;   ¥á«¨ ãáâ ­®¢«¥­ 31-© ¡¨â, â® ­¥ ®¡­®¢«ï¥âáï ®ª­®
2873
;   ¥á«¨ ãáâ ­®¢«¥­ 30-© ¡¨â, â® ¯®¨áª ¨¤¥â ¡¥§ ãç¥â  ॣ¨áâà  á¨¬¢®«®¢
2891
;   ¥á«¨ ãáâ ­®¢«¥­ 30-© ¡¨â, â® ¯®¨áª ¨¤¥â ¡¥§ ãç¥â  ॣ¨áâà  á¨¬¢®«®¢
2874
;output:
2892
;output:
2875
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2893
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2876
align 16
2894
align 16
2877
proc ted_but_find uses ebx ecx edx edi esi, edit:dword, f_opt:dword
2895
proc ted_but_find uses ebx ecx edx edi esi, edit:dword, f_opt:dword
2878
	mov eax,[f_opt]
2896
	mov eax,[f_opt]
2879
	push eax
2897
	push eax
2880
	push [edit]
2898
	push [edit]
2881
	cmp al,2
2899
	cmp al,2
2882
	jne @f
2900
	jne @f
2883
		call _but_find_first
2901
		call _but_find_first
2884
		jmp .end0
2902
		jmp .end0
2885
	@@:
2903
	@@:
2886
	cmp al,0
2904
	cmp al,0
2887
	jne @f
2905
	jne @f
2888
		call _but_find_next
2906
		call _but_find_next
2889
		jmp .end0
2907
		jmp .end0
2890
	@@:
2908
	@@:
2891
	cmp al,1
2909
	cmp al,1
2892
	jne @f
2910
	jne @f
2893
		call _but_find_perv
2911
		call _but_find_perv
2894
		jmp .end0
2912
		jmp .end0
2895
	@@:
2913
	@@:
2896
	add esp,8
2914
	add esp,8
2897
	.end0:
2915
	.end0:
2898
 
2916
 
2899
	bt dword[f_opt],31
2917
	bt dword[f_opt],31
2900
	jc .end1
2918
	jc .end1
2901
	or eax,eax
2919
	or eax,eax
2902
	jz @f
2920
	jz @f
2903
		;⥪áâ ­ ©¤¥­, ®¡­®¢«ï¥¬ ®ª­®
2921
		;⥪áâ ­ ©¤¥­, ®¡­®¢«ï¥¬ ®ª­®
2904
		stdcall ted_draw,edi
2922
		stdcall ted_draw,edi
2905
		jmp .end1
2923
		jmp .end1
2906
	@@:
2924
	@@:
2907
		;⥪áâ ­¥ ­ ©¤¥­, ¯à®¡ã¥¬ ¢ë§¢ âì á®®¡é¥­¨¥
2925
		;⥪áâ ­¥ ­ ©¤¥­, ¯à®¡ã¥¬ ¢ë§¢ âì á®®¡é¥­¨¥
2908
		cmp ted_fun_find_err,0
2926
		cmp ted_fun_find_err,0
2909
		je .end1
2927
		je .end1
2910
			call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
2928
			call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
2911
	.end1:
2929
	.end1:
2912
	ret
2930
	ret
2913
endp
2931
endp
2914
 
2932
 
2915
;description:
2933
;description:
2916
; äã­ªæ¨ï ­ å®¤¨â ⥪á⠮⠭ ç «  ä ©« , ¨«¨ ®â ª®­æ  ⥪ã饣® ¢ë¤¥«¥­¨ï
2934
; äã­ªæ¨ï ­ å®¤¨â ⥪á⠮⠭ ç «  ä ©« , ¨«¨ ®â ª®­æ  ⥪ã饣® ¢ë¤¥«¥­¨ï
2917
;input:
2935
;input:
2918
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
2936
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
2919
;output:
2937
;output:
2920
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2938
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2921
; ebx, ecx, edx, edi, edi - ¯®àâïâáï
2939
; ebx, ecx, edx, edi, edi - ¯®àâïâáï
2922
align 16
2940
align 16
2923
proc _but_find_first, edit:dword, f_opt:dword
2941
proc _but_find_first, edit:dword, f_opt:dword
2924
	mov edi,[edit]
2942
	mov edi,[edit]
2925
 
2943
 
2926
	call ted_is_select
2944
	call ted_is_select
2927
	or al,al
2945
	or al,al
2928
	jz @f
2946
	jz @f
2929
		call ted_sel_normalize
2947
		call ted_sel_normalize
2930
		mov edx,ted_sel_y1
2948
		mov edx,ted_sel_y1
2931
		mov ecx,ted_sel_x1
2949
		mov ecx,ted_sel_x1
2932
		call ted_go_to_pos ;¯¥à¥å®¤ ­  ª®­¥æ ¢ë¤¥«¥­¨ï
2950
		call ted_go_to_pos ;¯¥à¥å®¤ ­  ª®­¥æ ¢ë¤¥«¥­¨ï
2933
		call ted_get_pos_by_cursor
2951
		call ted_get_pos_by_cursor
2934
		jmp .end0
2952
		jmp .end0
2935
	@@:
2953
	@@:
2936
		mov edx,ted_tex
2954
		mov edx,ted_tex
2937
		call ted_iterat_next
2955
		call ted_iterat_next
2938
	.end0:
2956
	.end0:
2939
	mov ebx,ted_buffer_find
2957
	mov ebx,ted_buffer_find
2940
	@@:
2958
	@@:
2941
		mov eax,[f_opt]
2959
		mov eax,[f_opt]
2942
		call ted_get_find_rezult
2960
		call ted_get_find_rezult
2943
		cmp ah,1
2961
		cmp ah,1
2944
		je @f ; find
2962
		je @f ; find
2945
			call ted_iterat_next
2963
			call ted_iterat_next
2946
			cmp edx,ted_tex_1
2964
			cmp edx,ted_tex_1
2947
			jle @f
2965
			jle @f
2948
			jmp @b
2966
			jmp @b
2949
	@@:
2967
	@@:
2950
	call _but_find_select
2968
	call _but_find_select
2951
	ret
2969
	ret
2952
endp
2970
endp
2953
 
2971
 
2954
;description:
2972
;description:
2955
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ¢ëè¥ ªãàá®à 
2973
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ¢ëè¥ ªãàá®à 
2956
;input:
2974
;input:
2957
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
2975
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
2958
;output:
2976
;output:
2959
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2977
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2960
; ebx, ecx, edx, edi, edi - ¯®àâïâáï
2978
; ebx, ecx, edx, edi, edi - ¯®àâïâáï
2961
align 16
2979
align 16
2962
proc _but_find_perv, edit:dword, f_opt:dword
2980
proc _but_find_perv, edit:dword, f_opt:dword
2963
	mov edi,[edit]
2981
	mov edi,[edit]
2964
 
2982
 
2965
	call ted_is_select
2983
	call ted_is_select
2966
	or al,al
2984
	or al,al
2967
	jz @f
2985
	jz @f
2968
		call ted_sel_normalize
2986
		call ted_sel_normalize
2969
		mov edx,ted_sel_y0
2987
		mov edx,ted_sel_y0
2970
		mov ecx,ted_sel_x0
2988
		mov ecx,ted_sel_x0
2971
		call ted_go_to_pos ;¯¥à¥å®¤ ­  ­ ç «® ¢ë¤¥«¥­¨ï
2989
		call ted_go_to_pos ;¯¥à¥å®¤ ­  ­ ç «® ¢ë¤¥«¥­¨ï
2972
		call ted_get_pos_by_cursor
2990
		call ted_get_pos_by_cursor
2973
		call ted_iterat_perv ;¯¥à¥å®¤ ­  1-© ᨬ¢®« ¯¥à¥¤ ¢ë¤¥«¥­¨¥¬
2991
		call ted_iterat_perv ;¯¥à¥å®¤ ­  1-© ᨬ¢®« ¯¥à¥¤ ¢ë¤¥«¥­¨¥¬
2974
		jmp .end0
2992
		jmp .end0
2975
	@@:
2993
	@@:
2976
	call ted_get_pos_by_cursor
2994
	call ted_get_pos_by_cursor
2977
	.end0:
2995
	.end0:
2978
	mov ebx,ted_buffer_find
2996
	mov ebx,ted_buffer_find
2979
	@@:
2997
	@@:
2980
		mov eax,[f_opt]
2998
		mov eax,[f_opt]
2981
		call ted_get_find_rezult
2999
		call ted_get_find_rezult
2982
		cmp ah,1
3000
		cmp ah,1
2983
		je @f ; find
3001
		je @f ; find
2984
			call ted_iterat_perv
3002
			call ted_iterat_perv
2985
			cmp edx,ted_tex_1
3003
			cmp edx,ted_tex_1
2986
			jle @f
3004
			jle @f
2987
			jmp @b
3005
			jmp @b
2988
	@@:
3006
	@@:
2989
	call _but_find_select
3007
	call _but_find_select
2990
	ret
3008
	ret
2991
endp
3009
endp
2992
 
3010
 
2993
;description:
3011
;description:
2994
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­¨¦¥ ªãàá®à 
3012
; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­¨¦¥ ªãàá®à 
2995
;input:
3013
;input:
2996
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
3014
; f_opt = ®¯æ¨¨ ¤«ï ¯®¨áª 
2997
;output:
3015
;output:
2998
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
3016
; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
2999
; ebx, ecx, edx, edi, esi - ¯®àâïâáï
3017
; ebx, ecx, edx, edi, esi - ¯®àâïâáï
3000
align 16
3018
align 16
3001
proc _but_find_next, edit:dword, f_opt:dword
3019
proc _but_find_next, edit:dword, f_opt:dword
3002
	mov edi,[edit]
3020
	mov edi,[edit]
3003
 
3021
 
3004
	call ted_get_pos_by_cursor
3022
	call ted_get_pos_by_cursor
3005
	mov ebx,ted_buffer_find
3023
	mov ebx,ted_buffer_find
3006
	@@:
3024
	@@:
3007
		mov eax,[f_opt]
3025
		mov eax,[f_opt]
3008
		call ted_get_find_rezult
3026
		call ted_get_find_rezult
3009
		cmp ah,1
3027
		cmp ah,1
3010
		je @f ; find
3028
		je @f ; find
3011
			call ted_iterat_next
3029
			call ted_iterat_next
3012
			cmp edx,ted_tex_1
3030
			cmp edx,ted_tex_1
3013
			jle @f
3031
			jle @f
3014
			jmp @b
3032
			jmp @b
3015
	@@:
3033
	@@:
3016
	call _but_find_select
3034
	call _but_find_select
3017
	ret
3035
	ret
3018
endp
3036
endp
3019
 
3037
 
3020
;description:
3038
;description:
3021
; ¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï, ¢ë¤¥«ï¥â ­ ©¤¥­­ë© ⥪áâ
3039
; ¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï, ¢ë¤¥«ï¥â ­ ©¤¥­­ë© ⥪áâ
3022
;input:
3040
;input:
3023
; ah = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
3041
; ah = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
3024
; esi = first symbol pointer
3042
; esi = first symbol pointer
3025
align 16
3043
align 16
3026
_but_find_select:
3044
_but_find_select:
3027
	or ah,ah
3045
	or ah,ah
3028
	jz @f
3046
	jz @f
3029
		call ted_get_text_coords
3047
		call ted_get_text_coords
3030
		inc ebx ;move cursor right
3048
		inc ebx ;move cursor right
3031
		mov ted_sel_x1,ebx
3049
		mov ted_sel_x1,ebx
3032
		mov ted_sel_y1,eax
3050
		mov ted_sel_y1,eax
3033
		mov edx,eax
3051
		mov edx,eax
3034
		mov ecx,ebx
3052
		mov ecx,ebx
3035
		call ted_go_to_pos
3053
		call ted_go_to_pos
3036
		mov edx,esi
3054
		mov edx,esi
3037
		call ted_get_text_coords
3055
		call ted_get_text_coords
3038
		mov ted_sel_x0,ebx
3056
		mov ted_sel_x0,ebx
3039
		mov ted_sel_y0,eax
3057
		mov ted_sel_y0,eax
3040
		xor eax,eax
3058
		xor eax,eax
3041
		inc eax
3059
		inc eax
3042
		jmp .end0
3060
		jmp .end0
3043
	@@:
3061
	@@:
3044
		xor eax,eax ;⥪áâ ­¥ ­ ©¤¥­
3062
		xor eax,eax ;⥪áâ ­¥ ­ ©¤¥­
3045
	.end0:
3063
	.end0:
3046
	ret
3064
	ret
3047
 
3065
 
3048
;input:
3066
;input:
3049
; rpl_text = ⥪áâ ¤«ï § ¬¥­ë
3067
; rpl_text = ⥪áâ ¤«ï § ¬¥­ë
3050
; r_opt = ¯ à ¬¥âàë ¯®¨áª :
3068
; r_opt = ¯ à ¬¥âàë ¯®¨áª :
3051
;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
3069
;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
3052
; n_tim = 䨪á¨à®¢ âì § ¬¥­ã ¢ ¨§¬¥­¥­¨ïå (0 - ­¥â, 1 - ¤ )
3070
; n_tim = 䨪á¨à®¢ âì § ¬¥­ã ¢ ¨§¬¥­¥­¨ïå (0 - ­¥â, 1 - ¤ )
3053
;output:
3071
;output:
3054
; eax = 0 - ­¥ 㤠筮, 1 - 㤠筮
3072
; eax = 0 - ­¥ 㤠筮, 1 - 㤠筮
3055
align 16
3073
align 16
3056
proc ted_but_replace uses edx edi esi, edit:dword, rpl_text:dword, r_opt:dword, n_tim:dword
3074
proc ted_but_replace uses edx edi esi, edit:dword, rpl_text:dword, r_opt:dword, n_tim:dword
3057
	mov edi,[edit]
3075
	mov edi,[edit]
3058
	mov eax,[r_opt]
3076
	mov eax,[r_opt]
3059
	bts eax,31
3077
	bts eax,31
3060
	stdcall ted_but_find, edi,eax
3078
	stdcall ted_but_find, edi,eax
3061
	or eax,eax
3079
	or eax,eax
3062
	jz .end0
3080
	jz .end0
3063
 
3081
 
3064
	xor edx,edx
3082
	xor edx,edx
3065
	cmp dword[n_tim],0
3083
	cmp dword[n_tim],0
3066
	je @f
3084
	je @f
3067
		call ted_set_undo
3085
		call ted_set_undo
3068
		mov edx,ted_opt_ed_change_time
3086
		mov edx,ted_opt_ed_change_time
3069
	@@:
3087
	@@:
3070
	stdcall ted_sel_text_del, edx
3088
	stdcall ted_sel_text_del, edx
3071
	or eax,0xff
3089
	or eax,0xff
3072
	jz .end0
3090
	jz .end0
3073
		mov esi,[rpl_text]
3091
		mov esi,[rpl_text]
3074
		stdcall tl_strlen
3092
		stdcall tl_strlen
3075
		or eax,eax
3093
		or eax,eax
3076
		jz .end0
3094
		jz .end0
3077
		stdcall ted_text_add, edi,esi,eax,ted_opt_ed_move_cursor
3095
		stdcall ted_text_add, edi,esi,eax,ted_opt_ed_move_cursor
3078
		xor eax,eax
3096
		xor eax,eax
3079
		inc eax
3097
		inc eax
3080
	.end0:
3098
	.end0:
3081
	ret
3099
	ret
3082
endp
3100
endp
3083
 
3101
 
3084
;description:
3102
;description:
3085
; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ ebx
3103
; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ ebx
3086
; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
3104
; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
3087
; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
3105
; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
3088
; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
3106
; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
3089
;input:
3107
;input:
3090
; eax - options to find
3108
; eax - options to find
3091
; ebx - text need find
3109
; ebx - text need find
3092
; edx - first symbol pointer
3110
; edx - first symbol pointer
3093
; edi - pointer to tedit struct
3111
; edi - pointer to tedit struct
3094
;output:
3112
;output:
3095
; ah - rezult
3113
; ah - rezult
3096
; edx - last text position (if find sucess)
3114
; edx - last text position (if find sucess)
3097
; esi - first symbol pointer
3115
; esi - first symbol pointer
3098
align 16
3116
align 16
3099
proc ted_get_find_rezult uses ebx
3117
proc ted_get_find_rezult uses ebx
3100
	mov al,byte[ebx]
3118
	mov al,byte[ebx]
3101
	bt eax,30
3119
	bt eax,30
3102
	jnc @f
3120
	jnc @f
3103
		call fb_char_toupper
3121
		call fb_char_toupper
3104
	@@:
3122
	@@:
3105
	mov ah,1
3123
	mov ah,1
3106
	mov esi,edx ;copy edx
3124
	mov esi,edx ;copy edx
3107
	.cycle0:
3125
	.cycle0:
3108
		mov cl,al
3126
		mov cl,al
3109
		mov al,byte[edx]
3127
		mov al,byte[edx]
3110
		bt eax,30
3128
		bt eax,30
3111
		jnc @f
3129
		jnc @f
3112
			call fb_char_toupper
3130
			call fb_char_toupper
3113
		@@:
3131
		@@:
3114
		cmp al,cl
3132
		cmp al,cl
3115
		jne .no_text
3133
		jne .no_text
3116
 
3134
 
3117
		inc ebx ;*** get next symbol (in find text) ***
3135
		inc ebx ;*** get next symbol (in find text) ***
3118
		mov al,byte[ebx]
3136
		mov al,byte[ebx]
3119
		or al,al
3137
		or al,al
3120
		jz .end_f ;end of find text
3138
		jz .end_f ;end of find text
3121
		bt eax,30
3139
		bt eax,30
3122
		jnc @f
3140
		jnc @f
3123
			call fb_char_toupper
3141
			call fb_char_toupper
3124
		@@:
3142
		@@:
3125
 
3143
 
3126
		call ted_iterat_next ;*** get next symbol (in editor text) ***
3144
		call ted_iterat_next ;*** get next symbol (in editor text) ***
3127
		cmp edx,ted_tex_1
3145
		cmp edx,ted_tex_1
3128
		jg .cycle0
3146
		jg .cycle0
3129
align 4
3147
align 4
3130
		.no_text:
3148
		.no_text:
3131
	xor ah,ah
3149
	xor ah,ah
3132
	mov edx,esi ;restore edx
3150
	mov edx,esi ;restore edx
3133
	.end_f:
3151
	.end_f:
3134
	ret
3152
	ret
3135
endp
3153
endp
3136
 
3154
 
3137
;input:
3155
;input:
3138
; edi = pointer to tedit struct
3156
; edi = pointer to tedit struct
3139
align 16
3157
align 16
3140
ted_key_ctrl_home:
3158
ted_key_ctrl_home:
3141
	mov ted_cur_x,0
3159
	mov ted_cur_x,0
3142
	mov ted_cur_y,0
3160
	mov ted_cur_y,0
3143
	push eax
3161
	push eax
3144
		mov eax,ted_scr_w
3162
		mov eax,ted_scr_w
3145
		mov dword[eax+sb_offs_position],0
3163
		mov dword[eax+sb_offs_position],0
3146
		mov eax,ted_scr_h
3164
		mov eax,ted_scr_h
3147
		mov dword[eax+sb_offs_position],0
3165
		mov dword[eax+sb_offs_position],0
3148
	pop eax
3166
	pop eax
3149
	stdcall ted_draw,edi
3167
	stdcall ted_draw,edi
3150
	cmp ted_fun_draw_panel_buttons,0
3168
	cmp ted_fun_draw_panel_buttons,0
3151
	je @f
3169
	je @f
3152
		call ted_fun_draw_panel_buttons
3170
		call ted_fun_draw_panel_buttons
3153
	@@:
3171
	@@:
3154
	ret
3172
	ret
3155
 
3173
 
3156
;input:
3174
;input:
3157
; edi = pointer to tedit struct
3175
; edi = pointer to tedit struct
3158
align 16
3176
align 16
3159
ted_key_ctrl_end:
3177
ted_key_ctrl_end:
3160
	push eax ebx
3178
	push eax ebx
3161
		call ted_get_num_lines
3179
		call ted_get_num_lines
3162
		mov ebx,ted_scr_w
3180
		mov ebx,ted_scr_w
3163
		mov [ebx+sb_offs_position],eax ;áâ ¢¨¬ ¯®«§ã­®ª ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
3181
		mov [ebx+sb_offs_position],eax ;áâ ¢¨¬ ¯®«§ã­®ª ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
3164
		cmp eax,[ebx+sb_offs_cur_area]
3182
		cmp eax,[ebx+sb_offs_cur_area]
3165
		jle @f
3183
		jle @f
3166
			mov eax,[ebx+sb_offs_cur_area] ;¯®«ãç ¥¬ ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­®
3184
			mov eax,[ebx+sb_offs_cur_area] ;¯®«ãç ¥¬ ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­®
3167
		@@:
3185
		@@:
3168
		sub [ebx+sb_offs_position],eax ;®â­¨¬ ¥¬ ®â ¯®«§ã­ª  ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­® (­® ­¥ ¡®«ìè¥ â¥å, çâ® ¥áâì ¢ ¤®ªã¬¥­â¥)
3186
		sub [ebx+sb_offs_position],eax ;®â­¨¬ ¥¬ ®â ¯®«§ã­ª  ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­® (­® ­¥ ¡®«ìè¥ â¥å, çâ® ¥áâì ¢ ¤®ªã¬¥­â¥)
3169
		dec eax
3187
		dec eax
3170
		mov ted_cur_y,eax ;áâ ¢¨¬ ªãàá®à ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
3188
		mov ted_cur_y,eax ;áâ ¢¨¬ ªãàá®à ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
3171
	pop ebx eax
3189
	pop ebx eax
3172
	call ted_cur_move_x_last_char
3190
	call ted_cur_move_x_last_char
3173
	stdcall ted_draw,edi
3191
	stdcall ted_draw,edi
3174
	cmp ted_fun_draw_panel_buttons,0
3192
	cmp ted_fun_draw_panel_buttons,0
3175
	je @f
3193
	je @f
3176
		call ted_fun_draw_panel_buttons
3194
		call ted_fun_draw_panel_buttons
3177
	@@:
3195
	@@:
3178
	ret
3196
	ret
3179
 
3197
 
3180
;input:
3198
;input:
3181
; edi = pointer to tedit struct
3199
; edi = pointer to tedit struct
3182
align 16
3200
align 16
3183
proc ted_sel_key_up
3201
proc ted_sel_key_up
3184
  cmp ted_drag_k,1
3202
  cmp ted_drag_k,1
3185
  je @f
3203
  je @f
3186
    call ted_sel_start
3204
    call ted_sel_start
3187
    mov ted_drag_k,1
3205
    mov ted_drag_k,1
3188
  @@:
3206
  @@:
3189
  push dx
3207
  push dx
3190
    call ted_cur_move_up
3208
    call ted_cur_move_up
3191
    cmp dl,8
3209
    cmp dl,8
3192
    jne @f
3210
    jne @f
3193
      call ted_scroll_set_redraw
3211
      call ted_scroll_set_redraw
3194
    @@:
3212
    @@:
3195
  pop dx
3213
  pop dx
3196
  call ted_sel_move
3214
  call ted_sel_move
3197
  stdcall ted_draw,edi
3215
  stdcall ted_draw,edi
3198
  ret
3216
  ret
3199
endp
3217
endp
3200
 
3218
 
3201
;input:
3219
;input:
3202
; edi = pointer to tedit struct
3220
; edi = pointer to tedit struct
3203
align 16
3221
align 16
3204
proc ted_sel_key_down
3222
proc ted_sel_key_down
3205
  cmp ted_drag_k,1
3223
  cmp ted_drag_k,1
3206
  je @f
3224
  je @f
3207
    call ted_sel_start
3225
    call ted_sel_start
3208
    mov ted_drag_k,1
3226
    mov ted_drag_k,1
3209
  @@:
3227
  @@:
3210
  push dx
3228
  push dx
3211
    call ted_cur_move_down
3229
    call ted_cur_move_down
3212
    cmp dl,8
3230
    cmp dl,8
3213
    jne @f
3231
    jne @f
3214
      call ted_scroll_set_redraw
3232
      call ted_scroll_set_redraw
3215
    @@:
3233
    @@:
3216
  pop dx
3234
  pop dx
3217
  call ted_sel_move
3235
  call ted_sel_move
3218
  stdcall ted_draw,edi
3236
  stdcall ted_draw,edi
3219
  ret
3237
  ret
3220
endp
3238
endp
3221
 
3239
 
3222
;input:
3240
;input:
3223
; edi = pointer to tedit struct
3241
; edi = pointer to tedit struct
3224
align 16
3242
align 16
3225
proc ted_sel_key_left
3243
proc ted_sel_key_left
3226
  cmp ted_drag_k,1
3244
	cmp ted_drag_k,1
3227
  je @f
3245
	je @f
3228
    call ted_sel_start
3246
		call ted_sel_start
3229
  @@:
3247
	@@:
3230
  push dx
3248
	push dx
3231
    call ted_cur_move_left
3249
		call ted_cur_move_left
3232
    call ted_sel_move
3250
		call ted_sel_move
3233
    cmp ted_drag_k,1
3251
		cmp ted_drag_k,1
3234
    je @f
3252
		je @f
3235
      mov ted_drag_k,1
3253
			mov ted_drag_k,1
3236
      mov dl,8
3254
			mov dl,8
3237
    @@:
3255
		@@:
3238
    cmp dl,8
3256
		cmp dl,8
3239
    jne @f
3257
		jne @f
3240
      call ted_scroll_set_redraw
3258
			call ted_scroll_set_redraw
3241
      stdcall ted_draw,edi
3259
			stdcall ted_draw,edi
3242
      jmp .end_f
3260
			jmp .end_f
3243
    @@:
3261
		@@:
3244
      stdcall ted_draw_cur_line,edi
3262
		stdcall ted_draw_cur_line,edi
3245
    .end_f:
3263
		.end_f:
3246
  pop dx
3264
	pop dx
3247
  ret
3265
	ret
3248
endp
3266
endp
3249
 
3267
 
3250
;input:
3268
;input:
3251
; edi = pointer to tedit struct
3269
; edi = pointer to tedit struct
3252
align 16
3270
align 16
3253
proc ted_sel_key_right
3271
proc ted_sel_key_right
3254
  cmp ted_drag_k,1
3272
	cmp ted_drag_k,1
3255
  je @f
3273
	je @f
3256
    call ted_sel_start
3274
		call ted_sel_start
3257
  @@:
3275
	@@:
3258
  push dx
3276
	push dx
3259
    call ted_cur_move_right
3277
		call ted_cur_move_right
3260
    call ted_sel_move
3278
		call ted_sel_move
3261
    cmp ted_drag_k,1
3279
		cmp ted_drag_k,1
3262
    je @f
3280
		je @f
3263
      mov ted_drag_k,1
3281
			mov ted_drag_k,1
3264
      mov dl,8
3282
			mov dl,8
3265
    @@:
3283
		@@:
3266
    cmp dl,8
3284
		cmp dl,8
3267
    jne @f
3285
		jne @f
3268
      call ted_scroll_set_redraw
3286
			call ted_scroll_set_redraw
3269
      stdcall ted_draw,edi
3287
			stdcall ted_draw,edi
3270
      jmp .end_f
3288
			jmp .end_f
3271
    @@:
3289
		@@:
3272
      stdcall ted_draw_cur_line,edi
3290
		stdcall ted_draw_cur_line,edi
3273
    .end_f:
3291
		.end_f:
3274
  pop dx
3292
	pop dx
3275
  ret
3293
	ret
3276
endp
3294
endp
3277
 
3295
 
3278
;input:
3296
;input:
3279
; edi = pointer to tedit struct
3297
; edi = pointer to tedit struct
3280
;description:
3298
;description:
3281
; this function need to optimize output
3299
; this function need to optimize output
3282
align 16
3300
align 16
3283
proc ted_draw_cursor_sumb
3301
proc ted_draw_cursor_sumb
3284
pushad
3302
pushad
3285
	mov ebx,ted_wnd_l
3303
	mov ebx,ted_wnd_l
3286
	add ebx,ted_rec_l
3304
	add ebx,ted_rec_l
3287
	mov edx,ted_cur_x
3305
	mov edx,ted_cur_x
3288
	imul edx,ted_rec_w
3306
	imul edx,ted_rec_w
3289
	add ebx,edx
3307
	add ebx,edx
3290
	shl ebx,16
3308
	shl ebx,16
3291
	add ebx,ted_rec_w
3309
	add ebx,ted_rec_w
3292
 
3310
 
3293
	mov ecx,ted_wnd_t ;calc rect -> y0,y1
3311
	mov ecx,ted_wnd_t ;calc rect -> y0,y1
3294
	add ecx,ted_rec_t
3312
	add ecx,ted_rec_t
3295
	mov edx,ted_cur_y
3313
	mov edx,ted_cur_y
3296
	imul edx,ted_rec_h
3314
	imul edx,ted_rec_h
3297
	add ecx,edx
3315
	add ecx,edx
3298
	shl ecx,16
3316
	shl ecx,16
3299
	add ecx,ted_rec_h
3317
	add ecx,ted_rec_h
3300
 
3318
 
3301
	mov edx,ted_color_wnd_work
3319
	mov edx,ted_color_wnd_work
3302
	call ted_sel_normalize
3320
	call ted_sel_normalize
3303
 
3321
 
3304
	mov esi,ted_scr_w
3322
	mov esi,ted_scr_w
3305
	mov eax,[esi+sb_offs_position]
3323
	mov eax,[esi+sb_offs_position]
3306
	sub ted_seln_y0,eax
3324
	sub ted_seln_y0,eax
3307
	sub ted_seln_y1,eax
3325
	sub ted_seln_y1,eax
3308
 
3326
 
3309
	mov eax,ted_cur_y
3327
	mov eax,ted_cur_y
3310
	cmp eax,ted_seln_y0
3328
	cmp eax,ted_seln_y0
3311
	jl .no_cur_sel
3329
	jl .no_cur_sel
3312
	cmp eax,ted_seln_y1
3330
	cmp eax,ted_seln_y1
3313
	jg .no_cur_sel
3331
	jg .no_cur_sel
3314
		mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
3332
		mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
3315
		mov esi,ted_scr_h
3333
		mov esi,ted_scr_h
3316
		cmp eax,ted_seln_y0
3334
		cmp eax,ted_seln_y0
3317
		jne @f
3335
		jne @f
3318
			mov eax,ted_cur_x
3336
			mov eax,ted_cur_x
3319
			add eax,[esi+sb_offs_position]
3337
			add eax,[esi+sb_offs_position]
3320
			cmp eax,ted_seln_x0
3338
			cmp eax,ted_seln_x0
3321
			jge @f
3339
			jge @f
3322
			mov edx,ted_color_wnd_work
3340
			mov edx,ted_color_wnd_work
3323
		@@:
3341
		@@:
3324
		mov eax,ted_cur_y
3342
		mov eax,ted_cur_y
3325
		cmp eax,ted_seln_y1
3343
		cmp eax,ted_seln_y1
3326
		jne .no_cur_sel
3344
		jne .no_cur_sel
3327
			mov eax,ted_cur_x
3345
			mov eax,ted_cur_x
3328
			add eax,[esi+sb_offs_position]
3346
			add eax,[esi+sb_offs_position]
3329
			cmp eax,ted_seln_x1
3347
			cmp eax,ted_seln_x1
3330
			jl .no_cur_sel
3348
			jl .no_cur_sel
3331
			mov edx,ted_color_wnd_work
3349
			mov edx,ted_color_wnd_work
3332
	.no_cur_sel:
3350
	.no_cur_sel:
3333
	mcall SF_DRAW_RECT
3351
	mcall SF_DRAW_RECT
3334
 
3352
 
3335
	call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
3353
	call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
3336
	cmp ted_gp_opt,2
3354
	cmp ted_gp_opt,2
3337
	jne @f
3355
	jne @f
3338
		mov esi,1
3356
		mov esi,1
3339
		ror ecx,16
3357
		ror ecx,16
3340
		mov bx,cx
3358
		mov bx,cx
3341
		add ebx,0x10001
3359
		add ebx,0x10001
3342
		call ted_get_symb_color
3360
		call ted_get_symb_color
3343
		call ted_convert_invis_symb
3361
		call ted_convert_invis_symb
3344
		mcall SF_DRAW_TEXT ;à¨á®¢ ­¨¥ ᨬ¢®« 
3362
		mcall SF_DRAW_TEXT ;à¨á®¢ ­¨¥ ᨬ¢®« 
3345
	@@:
3363
	@@:
3346
popad
3364
popad
3347
	ret
3365
	ret
3348
endp
3366
endp
3349
 
3367
 
3350
;input:
3368
;input:
3351
; edx -> pointer to text
3369
; edx -> pointer to text
3352
; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
3370
; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
3353
;output:
3371
;output:
3354
; ecx = color
3372
; ecx = color
3355
; if ted_mode_color=0 then ecx=ted_color_wnd_text
3373
; if ted_mode_color=0 then ecx=ted_color_wnd_text
3356
align 16
3374
align 16
3357
ted_get_symb_color:
3375
ted_get_symb_color:
3358
	mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
3376
	mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
3359
 
3377
 
3360
	push eax edx
3378
	push eax edx
3361
	cmp ted_mode_color,0
3379
	cmp ted_mode_color,0
3362
	je .exit
3380
	je .exit
3363
		jmp .on_first
3381
		jmp .on_first
3364
		@@:
3382
		@@:
3365
			call ted_iterat_perv
3383
			call ted_iterat_perv
3366
			cmp edx,ted_tex_1
3384
			cmp edx,ted_tex_1
3367
			jle .exit
3385
			jle .exit
3368
		.on_first:
3386
		.on_first:
3369
			xor eax,eax
3387
			xor eax,eax
3370
			mov al,byte[edx+1]
3388
			mov al,byte[edx+1]
3371
			or al,al ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
3389
			or al,al ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
3372
			jz @b
3390
			jz @b
3373
 
3391
 
3374
		cmp eax,ted_colors_text_count
3392
		cmp eax,ted_colors_text_count
3375
		jge .exit
3393
		jge .exit
3376
 
3394
 
3377
		shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
3395
		shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
3378
		mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
3396
		mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
3379
		add ecx,eax
3397
		add ecx,eax
3380
		mov ecx,[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
3398
		mov ecx,[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
3381
	.exit:
3399
	.exit:
3382
	or ecx,ted_font_size
3400
	or ecx,ted_font_size
3383
	pop edx eax
3401
	pop edx eax
3384
	ret
3402
	ret
3385
 
3403
 
3386
;input:
3404
;input:
3387
; edx = pointer to text
3405
; edx = pointer to text
3388
; edi = pointer to tedit struct
3406
; edi = pointer to tedit struct
3389
;description:
3407
;description:
3390
; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
3408
; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
3391
align 16
3409
align 16
3392
ted_convert_invis_symb:
3410
ted_convert_invis_symb:
3393
	cmp ted_mode_invis,1
3411
	cmp ted_mode_invis,1
3394
	jne .else
3412
	jne .else
3395
		cmp byte[edx],9
3413
		cmp byte[edx],9
3396
		jne @f
3414
		jne @f
3397
			lea edx,[ted_symbol_tab]
3415
			lea edx,[ted_symbol_tab]
3398
			jmp .end_f
3416
			jmp .end_f
3399
align 4
3417
align 4
3400
		@@:
3418
		@@:
3401
		cmp byte[edx],13
3419
		cmp byte[edx],13
3402
		jne @f
3420
		jne @f
3403
			mov edx,edi
3421
			mov edx,edi
3404
			add edx,ted_offs_symbol_new_line
3422
			add edx,ted_offs_symbol_new_line
3405
		@@:
3423
		@@:
3406
		jmp .end_f
3424
		jmp .end_f
3407
align 4
3425
align 4
3408
	.else:
3426
	.else:
3409
		cmp byte[edx],9
3427
		cmp byte[edx],9
3410
		je @f
3428
		je @f
3411
		cmp byte[edx],13
3429
		cmp byte[edx],13
3412
		je @f
3430
		je @f
3413
			jmp .end_f
3431
			jmp .end_f
3414
		@@:
3432
		@@:
3415
			lea edx,[ted_symbol_space]
3433
			lea edx,[ted_symbol_space]
3416
	.end_f:
3434
	.end_f:
3417
	ret
3435
	ret
3418
 
3436
 
3419
;input:
3437
;input:
3420
; edi = pointer to tedit struct
3438
; edi = pointer to tedit struct
3421
align 16
3439
align 16
3422
ted_scroll_set_redraw:
3440
ted_scroll_set_redraw:
3423
	push eax
3441
	push eax
3424
	mov eax,ted_scr_w
3442
	mov eax,ted_scr_w
3425
	mov dword[eax+sb_offs_redraw],1
3443
	mov dword[eax+sb_offs_redraw],1
3426
	mov eax,ted_scr_h
3444
	mov eax,ted_scr_h
3427
	mov dword[eax+sb_offs_redraw],1
3445
	mov dword[eax+sb_offs_redraw],1
3428
	pop eax
3446
	pop eax
3429
	ret
3447
	ret
3430
 
3448
 
3431
align 16
3449
align 16
3432
proc ted_draw, edit:dword
3450
proc ted_draw, edit:dword
3433
	locals
3451
	locals
3434
		line_num dd ?
3452
		line_num dd ?
3435
	endl
3453
	endl
3436
	pushad
3454
	pushad
3437
	mov edi,[edit]
3455
	mov edi,[edit]
3438
 
3456
 
3439
	mov eax,SF_DRAW_TEXT
3457
	mov eax,SF_DRAW_TEXT
3440
	mov ecx,ted_text_colors
3458
	mov ecx,ted_text_colors
3441
	mov ecx,[ecx]
3459
	mov ecx,[ecx]
3442
 
3460
 
3443
	mov ebx,ted_wnd_l
3461
	mov ebx,ted_wnd_l
3444
	add ebx,ted_rec_l
3462
	add ebx,ted_rec_l
3445
	shl ebx,16
3463
	shl ebx,16
3446
	add ebx,ted_wnd_t
3464
	add ebx,ted_wnd_t
3447
	add ebx,ted_rec_t
3465
	add ebx,ted_rec_t
3448
	add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3466
	add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3449
 
3467
 
3450
	call ted_sel_normalize ;need before draw select
3468
	call ted_sel_normalize ;need before draw select
3451
	mov esi,ted_scr_w
3469
	mov esi,ted_scr_w
3452
	mov esi,[esi+sb_offs_position]
3470
	mov esi,[esi+sb_offs_position]
3453
	mov [line_num],esi
3471
	mov [line_num],esi
3454
 
3472
 
3455
	stdcall ted_clear_line_before_draw, edi,ebx,1,esi
3473
	stdcall ted_clear_line_before_draw, edi,ebx,1,esi
3456
	call ted_get_first_visible_pos
3474
	call ted_get_first_visible_pos
3457
	cmp edx,0
3475
	cmp edx,0
3458
	je .no_draw_text
3476
	je .no_draw_text
3459
	mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
3477
	mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
3460
	@@:
3478
	@@:
3461
		call ted_iterat_next
3479
		call ted_iterat_next
3462
		cmp edx,ted_tex_1
3480
		cmp edx,ted_tex_1
3463
		jle .no_draw_text
3481
		jle .no_draw_text
3464
 
3482
 
3465
		; *** 梥⮢ ï à §¬¥âª 
3483
		; *** 梥⮢ ï à §¬¥âª 
3466
		cmp ted_mode_color,0
3484
		cmp ted_mode_color,0
3467
		je .no_col_change
3485
		je .no_col_change
3468
		cmp byte[edx+1],0
3486
		cmp byte[edx+1],0
3469
		je .no_col_change
3487
		je .no_col_change
3470
			call ted_get_symb_color
3488
			call ted_get_symb_color
3471
		.no_col_change:
3489
		.no_col_change:
3472
 
3490
 
3473
		cmp byte[edx],13
3491
		cmp byte[edx],13
3474
		jne .no_13
3492
		jne .no_13
3475
			cmp ted_mode_invis,1
3493
			cmp ted_mode_invis,1
3476
			jne .no_invis
3494
			jne .no_invis
3477
				push edx
3495
				push edx
3478
				mov edx,edi
3496
				mov edx,edi
3479
				add edx,ted_offs_symbol_new_line
3497
				add edx,ted_offs_symbol_new_line
3480
				int 0x40
3498
				int 0x40
3481
				pop edx
3499
				pop edx
3482
			.no_invis:
3500
			.no_invis:
3483
			add ebx,ted_rec_h
3501
			add ebx,ted_rec_h
3484
			;optimized output \/
3502
			;optimized output \/
3485
			mov eax,ted_wnd_h
3503
			mov eax,ted_wnd_h
3486
			add eax,ted_wnd_t
3504
			add eax,ted_wnd_t
3487
			cmp bx,ax
3505
			cmp bx,ax
3488
			jg .no_draw_text
3506
			jg .no_draw_text
3489
			mov eax,SF_DRAW_TEXT
3507
			mov eax,SF_DRAW_TEXT
3490
			;optimized output /\        
3508
			;optimized output /\        
3491
			and ebx,0xffff
3509
			and ebx,0xffff
3492
			ror ebx,16
3510
			ror ebx,16
3493
			add ebx,ted_wnd_l
3511
			add ebx,ted_wnd_l
3494
			add ebx,ted_rec_l
3512
			add ebx,ted_rec_l
3495
			inc ebx
3513
			inc ebx
3496
			ror ebx,16
3514
			ror ebx,16
3497
			inc dword[line_num] ;increment line number
3515
			inc dword[line_num] ;increment line number
3498
			stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
3516
			stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
3499
			call ted_opt_draw_line_left
3517
			call ted_opt_draw_line_left
3500
			jmp @b
3518
			jmp @b
3501
align 4
3519
align 4
3502
		.no_13:
3520
		.no_13:
3503
 
3521
 
3504
		int 0x40
3522
		int 0x40
3505
		ror ebx,16
3523
		ror ebx,16
3506
		add ebx,ted_rec_w
3524
		add ebx,ted_rec_w
3507
		mov esi,ted_wnd_l
3525
		mov esi,ted_wnd_l
3508
		add esi,ted_wnd_w
3526
		add esi,ted_wnd_w
3509
		cmp bx,si
3527
		cmp bx,si
3510
		jl .no_opt
3528
		jl .no_opt
3511
			call ted_opt_draw_line_right
3529
			call ted_opt_draw_line_right
3512
		.no_opt:
3530
		.no_opt:
3513
		mov si,1
3531
		mov si,1
3514
		ror ebx,16
3532
		ror ebx,16
3515
		jmp @b
3533
		jmp @b
3516
	.no_draw_text:
3534
	.no_draw_text:
3517
 
3535
 
3518
	inc dword[line_num]
3536
	inc dword[line_num]
3519
	stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
3537
	stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
3520
	call ted_draw_line_numbers
3538
	call ted_draw_line_numbers
3521
	call ted_draw_main_cursor
3539
	call ted_draw_main_cursor
3522
 
3540
 
3523
;---------------------------------------------
3541
;---------------------------------------------
3524
; set all_redraw flag for draw all ScrollBar
3542
; set all_redraw flag for draw all ScrollBar
3525
; In some cases it is necessity to draw only the area
3543
; In some cases it is necessity to draw only the area
3526
; of moving of a "runner", for acceleration of output - 
3544
; of moving of a "runner", for acceleration of output - 
3527
; in this case the flag needs to be reset to 0 (zero).
3545
; in this case the flag needs to be reset to 0 (zero).
3528
	mov eax,ted_scr_h
3546
	mov eax,ted_scr_h
3529
	mov esi,ted_scr_w
3547
	mov esi,ted_scr_w
3530
	mov dword[eax+sb_offs_all_redraw],1
3548
	mov dword[eax+sb_offs_all_redraw],1
3531
	mov dword[esi+sb_offs_all_redraw],1
3549
	mov dword[esi+sb_offs_all_redraw],1
3532
 
3550
 
3533
; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
3551
; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
3534
	stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
3552
	stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
3535
	stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
3553
	stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
3536
; reset all_redraw flag 
3554
; reset all_redraw flag 
3537
	mov dword[eax+sb_offs_all_redraw],0
3555
	mov dword[eax+sb_offs_all_redraw],0
3538
	mov dword[esi+sb_offs_all_redraw],0
3556
	mov dword[esi+sb_offs_all_redraw],0
3539
;---------------------------------------------
3557
;---------------------------------------------
3540
 
3558
 
3541
	;left-bottom square
3559
	;left-bottom square
3542
	mov ebx,ted_wnd_l
3560
	mov ebx,ted_wnd_l
3543
	shl ebx,16
3561
	shl ebx,16
3544
	add ebx,ted_rec_l
3562
	add ebx,ted_rec_l
3545
	mov ecx,ted_wnd_t
3563
	mov ecx,ted_wnd_t
3546
	add ecx,ted_wnd_h
3564
	add ecx,ted_wnd_h
3547
	shl ecx,16
3565
	shl ecx,16
3548
	mov cx,word[eax+sb_offs_size_y]
3566
	mov cx,word[eax+sb_offs_size_y]
3549
	inc cx
3567
	inc cx
3550
	mcall SF_DRAW_RECT,,,ted_color_wnd_capt ;[sc.work]
3568
	mcall SF_DRAW_RECT,,,ted_color_wnd_capt ;[sc.work]
3551
 
3569
 
3552
	;right-bottom square
3570
	;right-bottom square
3553
	mov ebx,ted_wnd_l
3571
	mov ebx,ted_wnd_l
3554
	add ebx,ted_wnd_w
3572
	add ebx,ted_wnd_w
3555
	shl ebx,16
3573
	shl ebx,16
3556
	mov bx,word[esi+sb_offs_size_x]
3574
	mov bx,word[esi+sb_offs_size_x]
3557
	inc bx
3575
	inc bx
3558
	int 0x40
3576
	int 0x40
3559
 
3577
 
3560
	cmp ted_fun_draw_panels,0
3578
	cmp ted_fun_draw_panels,0
3561
	je @f
3579
	je @f
3562
		stdcall ted_fun_draw_panels, edi
3580
		stdcall ted_fun_draw_panels, edi
3563
	@@:
3581
	@@:
3564
	popad
3582
	popad
3565
	ret
3583
	ret
3566
endp
3584
endp
3567
 
3585
 
3568
;input:
3586
;input:
3569
; edi = pointer to tedit struct
3587
; edi = pointer to tedit struct
3570
align 16
3588
align 16
3571
proc ted_draw_main_cursor
3589
proc ted_draw_main_cursor
3572
pushad
3590
pushad
3573
	mov eax,SF_DRAW_RECT ;draw cursor
3591
	mov eax,SF_DRAW_RECT ;draw cursor
3574
	mov ecx,ted_wnd_t ;calc rect -> y0,y1
3592
	mov ecx,ted_wnd_t ;calc rect -> y0,y1
3575
	add ecx,ted_rec_t
3593
	add ecx,ted_rec_t
3576
	mov edx,ted_cur_y
3594
	mov edx,ted_cur_y
3577
	imul edx,ted_rec_h
3595
	imul edx,ted_rec_h
3578
	add ecx,edx
3596
	add ecx,edx
3579
 
3597
 
3580
	cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
3598
	cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
3581
	jne @f
3599
	jne @f
3582
		mov edx,ted_rec_h
3600
		mov edx,ted_rec_h
3583
		inc edx   ;1->1, 3->2, 5->3, ...
3601
		inc edx   ;1->1, 3->2, 5->3, ...
3584
		shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
3602
		shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
3585
		add ecx,edx
3603
		add ecx,edx
3586
	@@:
3604
	@@:
3587
	shl ecx,16
3605
	shl ecx,16
3588
	add ecx,ted_rec_h
3606
	add ecx,ted_rec_h
3589
	cmp ted_cur_ins,1
3607
	cmp ted_cur_ins,1
3590
	jne @f
3608
	jne @f
3591
		shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
3609
		shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
3592
	@@:
3610
	@@:
3593
 
3611
 
3594
	mov ebx,ted_wnd_l ;calc rect -> x0,x1
3612
	mov ebx,ted_wnd_l ;calc rect -> x0,x1
3595
	add ebx,ted_rec_l
3613
	add ebx,ted_rec_l
3596
	mov edx,ted_cur_x
3614
	mov edx,ted_cur_x
3597
	imul edx,ted_rec_w
3615
	imul edx,ted_rec_w
3598
	add ebx,edx
3616
	add ebx,edx
3599
	shl ebx,16
3617
	shl ebx,16
3600
	add ebx,ted_rec_w
3618
	add ebx,ted_rec_w
3601
 
3619
 
3602
	mov edx,ted_color_cursor
3620
	mov edx,ted_color_cursor
3603
	int 0x40 ;¢ë¢®¤ ªãàá®à 
3621
	int 0x40 ;¢ë¢®¤ ªãàá®à 
3604
 
3622
 
3605
	call ted_get_pos_by_cursor
3623
	call ted_get_pos_by_cursor
3606
	cmp ted_gp_opt,2
3624
	cmp ted_gp_opt,2
3607
	jne @f
3625
	jne @f
3608
		mov esi,1
3626
		mov esi,1
3609
		ror ecx,16
3627
		ror ecx,16
3610
		mov bx,cx
3628
		mov bx,cx
3611
		add ebx,0x10001
3629
		add ebx,0x10001
3612
		cmp ted_cur_ins,1
3630
		cmp ted_cur_ins,1
3613
		jne .no_up_tetx
3631
		jne .no_up_tetx
3614
			mov ecx,ted_rec_h
3632
			mov ecx,ted_rec_h
3615
			inc cx ; 1->1, 3->2, 5->3, ...
3633
			inc cx ; 1->1, 3->2, 5->3, ...
3616
			shr cx,1
3634
			shr cx,1
3617
			sub bx,cx
3635
			sub bx,cx
3618
		.no_up_tetx:
3636
		.no_up_tetx:
3619
		mov ecx,ted_color_cur_text
3637
		mov ecx,ted_color_cur_text
3620
		or ecx,ted_font_size
3638
		or ecx,ted_font_size
3621
		call ted_convert_invis_symb
3639
		call ted_convert_invis_symb
3622
		mcall SF_DRAW_TEXT
3640
		mcall SF_DRAW_TEXT
3623
	@@:
3641
	@@:
3624
 
3642
 
3625
	mov ebx,ted_wnd_l
3643
	mov ebx,ted_wnd_l
3626
	add ebx,ted_rec_l
3644
	add ebx,ted_rec_l
3627
	shl ebx,16
3645
	shl ebx,16
3628
	add ebx,ted_wnd_t
3646
	add ebx,ted_wnd_t
3629
	add ebx,3
3647
	add ebx,3
3630
	mov ecx,ted_color_wnd_bord
3648
	mov ecx,ted_color_wnd_bord
3631
	or  ecx,0x80000000
3649
	or  ecx,0x80000000
3632
	lea edx,[txtRow]
3650
	lea edx,[txtRow]
3633
	mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
3651
	mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
3634
 
3652
 
3635
	add ebx,0x500000
3653
	add ebx,0x500000
3636
	lea edx,[txtCol]
3654
	lea edx,[txtCol]
3637
	int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
3655
	int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
3638
 
3656
 
3639
	cmp ted_tim_undo,0
3657
	cmp ted_tim_undo,0
3640
	je @f
3658
	je @f
3641
		add ebx,0x500000
3659
		add ebx,0x500000
3642
		lea edx,[txtOtm]
3660
		lea edx,[txtOtm]
3643
		int 0x40
3661
		int 0x40
3644
		sub ebx,0x500000
3662
		sub ebx,0x500000
3645
	@@:
3663
	@@:
3646
 
3664
 
3647
	call ted_draw_buffer
3665
	call ted_draw_buffer
3648
	call ted_draw_help_f1
3666
	call ted_draw_help_f1
3649
 
3667
 
3650
	mov eax,47 ;draw cursor coords
3668
	mov eax,47 ;draw cursor coords
3651
	mov esi,ted_color_wnd_bord
3669
	mov esi,ted_color_wnd_bord
3652
	or  esi,0x40000000
3670
	or  esi,0x40000000
3653
 
3671
 
3654
	mov edx,ebx
3672
	mov edx,ebx
3655
	ror edx,16
3673
	ror edx,16
3656
	sub edx,35
3674
	sub edx,35
3657
	ror edx,16
3675
	ror edx,16
3658
	;add edx,3
3676
	;add edx,3
3659
	mov ebx,0x40000 ;Row=...
3677
	mov ebx,0x40000 ;Row=...
3660
	mov ecx,ted_scr_w
3678
	mov ecx,ted_scr_w
3661
	mov ecx,[ecx+sb_offs_position]
3679
	mov ecx,[ecx+sb_offs_position]
3662
	add ecx,ted_cur_y
3680
	add ecx,ted_cur_y
3663
	inc ecx
3681
	inc ecx
3664
 
3682
 
3665
push edi
3683
push edi
3666
	mov edi,ted_color_wnd_work
3684
	mov edi,ted_color_wnd_work
3667
	int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
3685
	int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
3668
pop edi
3686
pop edi
3669
 
3687
 
3670
	;mov ebx,0x40000 ;Col=...
3688
	;mov ebx,0x40000 ;Col=...
3671
	mov ecx,ted_scr_h
3689
	mov ecx,ted_scr_h
3672
	mov ecx,[ecx+sb_offs_position]
3690
	mov ecx,[ecx+sb_offs_position]
3673
	add ecx,ted_cur_x
3691
	add ecx,ted_cur_x
3674
	inc ecx
3692
	inc ecx
3675
	add edx,0x500000
3693
	add edx,0x500000
3676
push edi
3694
push edi
3677
	mov edi,ted_color_wnd_work
3695
	mov edi,ted_color_wnd_work
3678
	int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
3696
	int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
3679
pop edi
3697
pop edi
3680
 
3698
 
3681
	cmp ted_tim_undo,0
3699
	cmp ted_tim_undo,0
3682
	je @f
3700
	je @f
3683
		mov ecx,ted_tim_undo
3701
		mov ecx,ted_tim_undo
3684
		add edx,0x500000
3702
		add edx,0x500000
3685
		mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
3703
		mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
3686
		int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
3704
		int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
3687
	@@:
3705
	@@:
3688
 
3706
 
3689
popad
3707
popad
3690
	ret
3708
	ret
3691
endp
3709
endp
3692
 
3710
 
3693
;input:
3711
;input:
3694
; edi = pointer to tedit struct
3712
; edi = pointer to tedit struct
3695
align 16
3713
align 16
3696
proc ted_draw_buffer
3714
proc ted_draw_buffer
3697
	pushad
3715
	pushad
3698
 
3716
 
3699
	mov eax,ted_buffer
3717
	mov eax,ted_buffer
3700
	cmp dword[eax],1 ;ᬮâਬ à §¬¥à ¡ãä¥à 
3718
	cmp dword[eax],1 ;ᬮâਬ à §¬¥à ¡ãä¥à 
3701
	jl @f
3719
	jl @f
3702
		mov ebx,ted_rec_l
3720
		mov ebx,ted_rec_l
3703
		add bx,300
3721
		add bx,300
3704
		cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
3722
		cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
3705
		jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
3723
		jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
3706
 
3724
 
3707
		add ebx,ted_wnd_l
3725
		add ebx,ted_wnd_l
3708
		shl ebx,16
3726
		shl ebx,16
3709
		add ebx,ted_wnd_t
3727
		add ebx,ted_wnd_t
3710
		add ebx,3
3728
		add ebx,3
3711
		mov ecx,ted_color_wnd_bord
3729
		mov ecx,ted_color_wnd_bord
3712
		or ecx,0x40000000
3730
		or ecx,0x40000000
3713
 
3731
 
3714
		mov edx,ted_buffer
3732
		mov edx,ted_buffer
3715
		add edx,12
3733
		add edx,12
3716
		mov esi,edx
3734
		mov esi,edx
3717
		mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
3735
		mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
3718
		call tl_strlen
3736
		call tl_strlen
3719
		;cmp eax,0 ;¡ãä¥à ¯ãáâ
3737
		;cmp eax,0 ;¡ãä¥à ¯ãáâ
3720
		;je @f
3738
		;je @f
3721
		cmp eax,20
3739
		cmp eax,20
3722
		jle .crop_buf
3740
		jle .crop_buf
3723
			mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
3741
			mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
3724
		.crop_buf:
3742
		.crop_buf:
3725
		mov esi,eax
3743
		mov esi,eax
3726
		mcall SF_DRAW_TEXT ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
3744
		mcall SF_DRAW_TEXT ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
3727
 
3745
 
3728
		sub ebx,50 shl 16
3746
		sub ebx,50 shl 16
3729
		lea edx,[txtBuf]
3747
		lea edx,[txtBuf]
3730
		mov esi,edx
3748
		mov esi,edx
3731
		call tl_strlen
3749
		call tl_strlen
3732
		mov esi,eax
3750
		mov esi,eax
3733
		xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
3751
		xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
3734
		mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
3752
		mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
3735
	@@:
3753
	@@:
3736
	popad
3754
	popad
3737
	ret
3755
	ret
3738
endp
3756
endp
3739
 
3757
 
3740
;input:
3758
;input:
3741
; edi = pointer to tedit struct
3759
; edi = pointer to tedit struct
3742
align 16
3760
align 16
3743
proc ted_draw_help_f1
3761
proc ted_draw_help_f1
3744
	pushad
3762
	pushad
3745
	cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
3763
	cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
3746
	jle @f
3764
	jle @f
3747
		;clear place before draw help
3765
		;clear place before draw help
3748
		mov ebx,ted_wnd_l
3766
		mov ebx,ted_wnd_l
3749
		add ebx,ted_rec_l
3767
		add ebx,ted_rec_l
3750
		shl ebx,16
3768
		shl ebx,16
3751
		add ebx,ted_wnd_w
3769
		add ebx,ted_wnd_w
3752
		sub ebx,ted_rec_l
3770
		sub ebx,ted_rec_l
3753
		mov ecx,ted_wnd_t
3771
		mov ecx,ted_wnd_t
3754
		add ecx,13
3772
		add ecx,13
3755
		shl ecx,16
3773
		shl ecx,16
3756
		add ecx,9 ;9 - ¢ëá®â  0-£® èà¨äâ , áâ ¢¨âì ted_rec_h ¯®ª  ¥é¥ à ­®
3774
		add ecx,9 ;9 - ¢ëá®â  0-£® èà¨äâ , áâ ¢¨âì ted_rec_h ¯®ª  ¥é¥ à ­®
3757
		mcall SF_DRAW_RECT,,,ted_color_wnd_capt
3775
		mcall SF_DRAW_RECT,,,ted_color_wnd_capt
3758
 
3776
 
3759
	cmp ted_help_id,-1
3777
	cmp ted_help_id,-1
3760
	je @f
3778
	je @f
3761
		mov eax,ted_help_id
3779
		mov eax,ted_help_id
3762
		ColToIndexOffset eax,edx
3780
		ColToIndexOffset eax,edx
3763
 
3781
 
3764
		;SetCoordinates
3782
		;SetCoordinates
3765
		mov ebx,ted_wnd_l
3783
		mov ebx,ted_wnd_l
3766
		add ebx,ted_rec_l
3784
		add ebx,ted_rec_l
3767
		shl ebx,16
3785
		shl ebx,16
3768
		add ebx,ted_wnd_t
3786
		add ebx,ted_wnd_t
3769
		add ebx,13 ;=3+10
3787
		add ebx,13 ;=3+10
3770
 
3788
 
3771
		;SetTextColor
3789
		;SetTextColor
3772
		xor eax,eax
3790
		xor eax,eax
3773
		mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
3791
		mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
3774
		shl ax,2
3792
		shl ax,2
3775
		mov ecx,ted_text_colors
3793
		mov ecx,ted_text_colors
3776
		add ecx,eax
3794
		add ecx,eax
3777
		mov ecx,[ecx]
3795
		mov ecx,[ecx]
3778
		or	ecx,0xc0000000 ;SetTextStyles
3796
		or	ecx,0xc0000000 ;SetTextStyles
3779
		mov esi,edi
3797
		mov esi,edi
3780
		mcall SF_DRAW_TEXT,,,,,ted_color_wnd_work
3798
		mcall SF_DRAW_TEXT,,,,,ted_color_wnd_work
3781
		mov edi,esi
3799
		mov edi,esi
3782
 
3800
 
3783
		mov esi,edx
3801
		mov esi,edx
3784
		call tl_strlen
3802
		call tl_strlen
3785
 
3803
 
3786
		;*** draw help string ***
3804
		;*** draw help string ***
3787
		mov ecx,ted_color_wnd_bord
3805
		mov ecx,ted_color_wnd_bord
3788
		or ecx,0x80000000
3806
		or ecx,0x80000000
3789
		mov edx,[edx+MAX_COLOR_WORD_LEN]
3807
		mov edx,[edx+MAX_COLOR_WORD_LEN]
3790
		or edx,edx
3808
		or edx,edx
3791
		jz @f
3809
		jz @f
3792
			add edx,ted_help_text_f1
3810
			add edx,ted_help_text_f1
3793
			inc eax
3811
			inc eax
3794
			imul eax,6 ;è¨à¨­  ᨬ¢®«  ¢ á¨áâ. èà¨äâ¥
3812
			imul eax,6 ;è¨à¨­  ᨬ¢®«  ¢ á¨áâ. èà¨äâ¥
3795
			shl eax,16			
3813
			shl eax,16			
3796
			add ebx,eax
3814
			add ebx,eax
3797
			mcall SF_DRAW_TEXT
3815
			mcall SF_DRAW_TEXT
3798
	@@:
3816
	@@:
3799
	popad
3817
	popad
3800
	ret
3818
	ret
3801
endp
3819
endp
3802
 
3820
 
3803
;input:
3821
;input:
3804
; edi = pointer to tedit struct
3822
; edi = pointer to tedit struct
3805
align 16
3823
align 16
3806
proc ted_draw_line_numbers
3824
proc ted_draw_line_numbers
3807
pushad
3825
pushad
3808
	;top panel with caption
3826
	;top panel with caption
3809
	mov ebx,ted_wnd_l
3827
	mov ebx,ted_wnd_l
3810
	;add ebx,ted_rec_l
3828
	;add ebx,ted_rec_l
3811
	shl ebx,16
3829
	shl ebx,16
3812
	add ebx,ted_wnd_w
3830
	add ebx,ted_wnd_w
3813
	;sub ebx,ted_rec_l
3831
	;sub ebx,ted_rec_l
3814
	mov edx,ted_color_wnd_work
3832
	mov edx,ted_color_wnd_work
3815
	mov ecx,ted_wnd_t
3833
	mov ecx,ted_wnd_t
3816
	shl ecx,16
3834
	shl ecx,16
3817
	add ecx,ted_rec_t
3835
	add ecx,ted_rec_t
3818
	mov edx,ted_color_wnd_capt
3836
	mov edx,ted_color_wnd_capt
3819
	mcall SF_DRAW_RECT
3837
	mcall SF_DRAW_RECT
3820
 
3838
 
3821
	;line numbers
3839
	;line numbers
3822
	mov ebx,0x40000 ;format
3840
	mov ebx,0x40000 ;format
3823
	mov ecx,ted_scr_w
3841
	mov ecx,ted_scr_w
3824
	mov ecx,[ecx+sb_offs_position]
3842
	mov ecx,[ecx+sb_offs_position]
3825
	inc ecx
3843
	inc ecx
3826
	mov edx,3
3844
	mov edx,3
3827
	add edx,ted_wnd_l
3845
	add edx,ted_wnd_l
3828
	rol edx,16
3846
	rol edx,16
3829
	add edx,ted_wnd_t
3847
	add edx,ted_wnd_t
3830
	add edx,ted_rec_t
3848
	add edx,ted_rec_t
3831
	@@:
3849
	@@:
3832
 
3850
 
3833
push ebx ecx edx
3851
push ebx ecx edx
3834
	;left panel with numbers
3852
	;left panel with numbers
3835
	mov ebx,ted_wnd_l
3853
	mov ebx,ted_wnd_l
3836
	shl ebx,16
3854
	shl ebx,16
3837
	add ebx,ted_rec_l
3855
	add ebx,ted_rec_l
3838
	mov ecx,ted_rec_h
3856
	mov ecx,ted_rec_h
3839
	rol ecx,16
3857
	rol ecx,16
3840
	mov cx,dx
3858
	mov cx,dx
3841
	rol ecx,16
3859
	rol ecx,16
3842
	mov edx,ted_color_wnd_capt
3860
	mov edx,ted_color_wnd_capt
3843
	mcall SF_DRAW_RECT ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
3861
	mcall SF_DRAW_RECT ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
3844
pop edx ecx ebx
3862
pop edx ecx ebx
3845
 
3863
 
3846
		mov esi,ted_color_wnd_bord
3864
		mov esi,ted_color_wnd_bord
3847
		mcall SF_DRAW_NUMBER ;à¨á㥬 ­®¬¥à áâப¨
3865
		mcall SF_DRAW_NUMBER ;à¨á㥬 ­®¬¥à áâப¨
3848
		inc ecx
3866
		inc ecx
3849
		add edx,ted_rec_h
3867
		add edx,ted_rec_h
3850
		sub edx,ted_wnd_t
3868
		sub edx,ted_wnd_t
3851
		mov esi,edx
3869
		mov esi,edx
3852
		and esi,0xffff
3870
		and esi,0xffff
3853
		cmp esi,ted_wnd_h
3871
		cmp esi,ted_wnd_h
3854
		jge @f
3872
		jge @f
3855
		add edx,ted_wnd_t
3873
		add edx,ted_wnd_t
3856
		jmp @b
3874
		jmp @b
3857
align 4
3875
align 4
3858
	@@:
3876
	@@:
3859
popad
3877
popad
3860
	ret
3878
	ret
3861
endp
3879
endp
3862
 
3880
 
3863
;output:
3881
;output:
3864
; ah = symbol
3882
; ah = symbol
3865
align 16
3883
align 16
3866
proc KeyConvertToASCII uses ebx, table:dword
3884
proc KeyConvertToASCII uses ebx, table:dword
3867
	mov ebx,[table] ;convert scan to ascii
3885
	mov ebx,[table] ;convert scan to ascii
3868
	shr ax,8
3886
	shr ax,8
3869
	add bx,ax ;? ebx,eax
3887
	add bx,ax ;? ebx,eax
3870
	mov ah,byte[ebx]
3888
	mov ah,byte[ebx]
3871
	ret
3889
	ret
3872
endp
3890
endp
3873
 
3891
 
3874
align 16
3892
align 16
3875
proc ted_draw_cur_line, edit:dword
3893
proc ted_draw_cur_line, edit:dword
3876
pushad
3894
pushad
3877
	mov edi,[edit]
3895
	mov edi,[edit]
3878
 
3896
 
3879
	mov ebx,ted_wnd_l
3897
	mov ebx,ted_wnd_l
3880
	add ebx,ted_rec_l
3898
	add ebx,ted_rec_l
3881
	shl ebx,16
3899
	shl ebx,16
3882
	mov eax,ted_cur_y
3900
	mov eax,ted_cur_y
3883
	imul eax,ted_rec_h
3901
	imul eax,ted_rec_h
3884
	mov bx,ax
3902
	mov bx,ax
3885
	add ebx,ted_wnd_t
3903
	add ebx,ted_wnd_t
3886
	add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
3904
	add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
3887
	add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3905
	add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3888
 
3906
 
3889
	call ted_sel_normalize ;need before draw select
3907
	call ted_sel_normalize ;need before draw select
3890
	mov ecx,ted_cur_y
3908
	mov ecx,ted_cur_y
3891
	mov eax,ted_scr_w
3909
	mov eax,ted_scr_w
3892
	add ecx,[eax+sb_offs_position]
3910
	add ecx,[eax+sb_offs_position]
3893
	stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
3911
	stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
3894
 
3912
 
3895
	mov eax,ted_scr_h
3913
	mov eax,ted_scr_h
3896
	mov esi,[eax+sb_offs_position]
3914
	mov esi,[eax+sb_offs_position]
3897
	call ted_get_pos_by_coords
3915
	call ted_get_pos_by_coords
3898
 
3916
 
3899
	cmp ted_gp_opt,2
3917
	cmp ted_gp_opt,2
3900
	jne .no_draw_text
3918
	jne .no_draw_text
3901
	call ted_get_symb_color
3919
	call ted_get_symb_color
3902
	mov esi,1 ;draw 1 symbol
3920
	mov esi,1 ;draw 1 symbol
3903
	@@:
3921
	@@:
3904
		;call ted_iterat_next
3922
		;call ted_iterat_next
3905
		cmp edx,ted_tex_1
3923
		cmp edx,ted_tex_1
3906
		jle .no_draw_text
3924
		jle .no_draw_text
3907
 
3925
 
3908
		; *** 梥⮢ ï à §¬¥âª 
3926
		; *** 梥⮢ ï à §¬¥âª 
3909
		cmp ted_mode_color,0
3927
		cmp ted_mode_color,0
3910
		je .no_col_change
3928
		je .no_col_change
3911
		cmp byte[edx+1],0
3929
		cmp byte[edx+1],0
3912
		je .no_col_change
3930
		je .no_col_change
3913
			call ted_get_symb_color
3931
			call ted_get_symb_color
3914
		.no_col_change:
3932
		.no_col_change:
3915
 
3933
 
3916
		mov eax,SF_DRAW_TEXT
3934
		mov eax,SF_DRAW_TEXT
3917
		cmp byte [edx],13
3935
		cmp byte [edx],13
3918
		jne .no_13
3936
		jne .no_13
3919
			cmp ted_mode_invis,1
3937
			cmp ted_mode_invis,1
3920
			jne .no_draw_text
3938
			jne .no_draw_text
3921
			push edx
3939
			push edx
3922
			mov edx,edi
3940
			mov edx,edi
3923
			add edx,ted_offs_symbol_new_line
3941
			add edx,ted_offs_symbol_new_line
3924
			int 0x40
3942
			int 0x40
3925
			pop edx
3943
			pop edx
3926
			jmp .no_draw_text
3944
			jmp .no_draw_text
3927
align 4
3945
align 4
3928
		.no_13:
3946
		.no_13:
3929
 
3947
 
3930
		int 0x40
3948
		int 0x40
3931
		ror ebx,16
3949
		ror ebx,16
3932
		add ebx,ted_rec_w
3950
		add ebx,ted_rec_w
3933
		mov eax,ted_wnd_w
3951
		mov eax,ted_wnd_w
3934
		add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
3952
		add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
3935
		cmp bx,ax
3953
		cmp bx,ax
3936
		jge .no_draw_text ;Opt
3954
		jge .no_draw_text ;Opt
3937
		ror ebx,16
3955
		ror ebx,16
3938
		call ted_iterat_next
3956
		call ted_iterat_next
3939
		jmp @b
3957
		jmp @b
3940
align 4
3958
align 4
3941
	.no_draw_text:
3959
	.no_draw_text:
3942
 
3960
 
3943
	call ted_draw_main_cursor
3961
	call ted_draw_main_cursor
3944
popad
3962
popad
3945
	ret
3963
	ret
3946
endp
3964
endp
3947
 
3965
 
3948
;input:
3966
;input:
3949
;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
3967
;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
3950
align 16
3968
align 16
3951
proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
3969
proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
3952
	pushad
3970
	pushad
3953
	mov edi,[edit]
3971
	mov edi,[edit]
3954
	mov ebx,[coords] ;ebx = x*2^16+y coords to left up point clear line
3972
	mov ebx,[coords] ;ebx = x*2^16+y coords to left up point clear line
3955
	mov esi,[numb_lin] ;esi - number text line
3973
	mov esi,[numb_lin] ;esi - number text line
3956
 
3974
 
3957
	sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3975
	sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
3958
	cmp dword[clear_o],0
3976
	cmp dword[clear_o],0
3959
	jne @f
3977
	jne @f
3960
		add ebx,ted_rec_h
3978
		add ebx,ted_rec_h
3961
		ror ebx,16
3979
		ror ebx,16
3962
		xor bx,bx
3980
		xor bx,bx
3963
		add ebx,ted_wnd_l
3981
		add ebx,ted_wnd_l
3964
		add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
3982
		add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
3965
		ror ebx,16
3983
		ror ebx,16
3966
	@@:
3984
	@@:
3967
 
3985
 
3968
	mov eax,ted_wnd_h
3986
	mov eax,ted_wnd_h
3969
	add eax,ted_wnd_t
3987
	add eax,ted_wnd_t
3970
	cmp ax,bx
3988
	cmp ax,bx
3971
	jl .no_clear
3989
	jl .no_clear
3972
	sub ax,bx
3990
	sub ax,bx
3973
 
3991
 
3974
	mov cx,bx
3992
	mov cx,bx
3975
	shl ecx,16
3993
	shl ecx,16
3976
 
3994
 
3977
	xor bx,bx
3995
	xor bx,bx
3978
	add ebx,ted_wnd_w
3996
	add ebx,ted_wnd_w
3979
	sub ebx,ted_rec_l
3997
	sub ebx,ted_rec_l
3980
	xor cx,cx
3998
	xor cx,cx
3981
	add ecx,ted_rec_h
3999
	add ecx,ted_rec_h
3982
	mov edx,ted_color_wnd_work
4000
	mov edx,ted_color_wnd_work
3983
 
4001
 
3984
	cmp dword[clear_o],0
4002
	cmp dword[clear_o],0
3985
	je .pusto
4003
	je .pusto
3986
	cmp ax,cx
4004
	cmp ax,cx
3987
	jge @f
4005
	jge @f
3988
	.pusto:
4006
	.pusto:
3989
		mov cx,ax
4007
		mov cx,ax
3990
		jmp .no_select ;¥á«¨ ®ç¨á⪠ ®ª­  ¤® ­¨§ã, â® ¢á¥£¤  ä®­®¢ë¬ 梥⮬
4008
		jmp .no_select ;¥á«¨ ®ç¨á⪠ ®ª­  ¤® ­¨§ã, â® ¢á¥£¤  ä®­®¢ë¬ 梥⮬
3991
	@@:
4009
	@@:
3992
 
4010
 
3993
	call ted_is_select
4011
	call ted_is_select
3994
	or al,al
4012
	or al,al
3995
	jz .no_select
4013
	jz .no_select
3996
	cmp ted_seln_y0,esi
4014
	cmp ted_seln_y0,esi
3997
	jg .no_select
4015
	jg .no_select
3998
	cmp ted_seln_y1,esi
4016
	cmp ted_seln_y1,esi
3999
	jl .no_select
4017
	jl .no_select
4000
		mov edx,ted_color_select ;draw selected line
4018
		mov edx,ted_color_select ;draw selected line
4001
	.no_select:
4019
	.no_select:
4002
 
4020
 
4003
	mcall SF_DRAW_RECT ;§ ªà áª  ¯®«­®© áâப¨ 梥⮬ ä®­  ¨«¨ 梥⮬ ¢ë¤¥«¥­¨ï
4021
	mcall SF_DRAW_RECT ;§ ªà áª  ¯®«­®© áâப¨ 梥⮬ ä®­  ¨«¨ 梥⮬ ¢ë¤¥«¥­¨ï
4004
 
4022
 
4005
	call ted_is_select
4023
	call ted_is_select
4006
	or al,al
4024
	or al,al
4007
	jz .no_clear
4025
	jz .no_clear
4008
 
4026
 
4009
	mov al,SF_DRAW_RECT
4027
	mov al,SF_DRAW_RECT
4010
	xor cx,cx
4028
	xor cx,cx
4011
	add ecx,ted_rec_h
4029
	add ecx,ted_rec_h
4012
	cmp ted_seln_y0,esi
4030
	cmp ted_seln_y0,esi
4013
	jne @f
4031
	jne @f
4014
		push bx esi
4032
		push bx esi
4015
		mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
4033
		mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
4016
		mov esi,ted_scr_h
4034
		mov esi,ted_scr_h
4017
		cmp edx,[esi+sb_offs_position]
4035
		cmp edx,[esi+sb_offs_position]
4018
		jle .in_wnd
4036
		jle .in_wnd
4019
			sub edx,[esi+sb_offs_position]
4037
			sub edx,[esi+sb_offs_position]
4020
			imul edx,ted_rec_w
4038
			imul edx,ted_rec_w
4021
			mov bx,dx
4039
			mov bx,dx
4022
			jmp .no_wnd
4040
			jmp .no_wnd
4023
		.in_wnd:
4041
		.in_wnd:
4024
		xor bx,bx
4042
		xor bx,bx
4025
		.no_wnd:
4043
		.no_wnd:
4026
		mov edx,ted_color_wnd_work
4044
		mov edx,ted_color_wnd_work
4027
		int 0x40
4045
		int 0x40
4028
		pop esi bx
4046
		pop esi bx
4029
	@@:
4047
	@@:
4030
	cmp ted_seln_y1,esi
4048
	cmp ted_seln_y1,esi
4031
	jne @f
4049
	jne @f
4032
		;push esi
4050
		;push esi
4033
		;¥á«¨ ¢ë¤¥«¥­ ¢¥áì ä ©« âãâ ¬®¦­® ᤥ« âì ¢ë室, ­® ⮣¤  ­ã¦­® ¢ëè¥ ã¡à âì jmp .no_select
4051
		;¥á«¨ ¢ë¤¥«¥­ ¢¥áì ä ©« âãâ ¬®¦­® ᤥ« âì ¢ë室, ­® ⮣¤  ­ã¦­® ¢ëè¥ ã¡à âì jmp .no_select
4034
		mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
4052
		mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
4035
		mov esi,ted_scr_h
4053
		mov esi,ted_scr_h
4036
		cmp edx,[esi+sb_offs_position]
4054
		cmp edx,[esi+sb_offs_position]
4037
		jle .in_wnd2
4055
		jle .in_wnd2
4038
			sub edx,[esi+sb_offs_position]
4056
			sub edx,[esi+sb_offs_position]
4039
			imul edx,ted_rec_w
4057
			imul edx,ted_rec_w
4040
			sub bx,dx
4058
			sub bx,dx
4041
			shl edx,16
4059
			shl edx,16
4042
			add ebx,edx
4060
			add ebx,edx
4043
		.in_wnd2:
4061
		.in_wnd2:
4044
		mov edx,ted_color_wnd_work
4062
		mov edx,ted_color_wnd_work
4045
		int 0x40
4063
		int 0x40
4046
		;pop esi
4064
		;pop esi
4047
	@@:
4065
	@@:
4048
 
4066
 
4049
	.no_clear:
4067
	.no_clear:
4050
	popad
4068
	popad
4051
	ret
4069
	ret
4052
endp
4070
endp
4053
 
4071
 
4054
;input:
4072
;input:
4055
; edi = pointer to tedit struct
4073
; edi = pointer to tedit struct
4056
;output:
4074
;output:
4057
; ecx = ­®¢ë© 梥â ᨬ¢®« 
4075
; ecx = ­®¢ë© 梥â ᨬ¢®« 
4058
; edx = pointer to symbol
4076
; edx = pointer to symbol
4059
; edx = 0 if text not in screen
4077
; edx = 0 if text not in screen
4060
align 16
4078
align 16
4061
ted_get_first_visible_pos:
4079
ted_get_first_visible_pos:
4062
	push eax ecx
4080
	push eax ecx
4063
	mov eax,ted_scr_w
4081
	mov eax,ted_scr_w
4064
	mov edx,ted_tex
4082
	mov edx,ted_tex
4065
	xor ecx,ecx
4083
	xor ecx,ecx
4066
	@@:
4084
	@@:
4067
		cmp ecx,[eax+sb_offs_position]
4085
		cmp ecx,[eax+sb_offs_position]
4068
		je @f
4086
		je @f
4069
		call ted_iterat_next
4087
		call ted_iterat_next
4070
		cmp edx,ted_tex_1
4088
		cmp edx,ted_tex_1
4071
		jle @f
4089
		jle @f
4072
		cmp byte[edx],13
4090
		cmp byte[edx],13
4073
		jne @b
4091
		jne @b
4074
		inc ecx
4092
		inc ecx
4075
		jmp @b
4093
		jmp @b
4076
align 4
4094
align 4
4077
	@@:
4095
	@@:
4078
 
4096
 
4079
	cmp ecx,[eax+sb_offs_position]
4097
	cmp ecx,[eax+sb_offs_position]
4080
	je @f
4098
	je @f
4081
		xor edx,edx
4099
		xor edx,edx
4082
	@@:
4100
	@@:
4083
	cmp ecx,[eax+sb_offs_max_area]
4101
	cmp ecx,[eax+sb_offs_max_area]
4084
	jle @f
4102
	jle @f
4085
		mov [eax+sb_offs_max_area],ecx
4103
		mov [eax+sb_offs_max_area],ecx
4086
	@@:
4104
	@@:
4087
	pop ecx eax
4105
	pop ecx eax
4088
	call ted_opt_draw_line_left
4106
	call ted_opt_draw_line_left
4089
	ret
4107
	ret
4090
 
4108
 
4091
;input:
4109
;input:
4092
; edx = pointer to symbol
4110
; edx = pointer to symbol
4093
; edi = pointer to tedit struct
4111
; edi = pointer to tedit struct
4094
;output:
4112
;output:
4095
; ecx = 梥â ᨬ¢®« 
4113
; ecx = 梥â ᨬ¢®« 
4096
; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
4114
; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
4097
;description:
4115
;description:
4098
; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
4116
; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
4099
align 16
4117
align 16
4100
proc ted_opt_draw_line_left uses ebx
4118
proc ted_opt_draw_line_left uses ebx
4101
	mov ebx,ted_scr_h
4119
	mov ebx,ted_scr_h
4102
	mov ebx,[ebx+sb_offs_position]
4120
	mov ebx,[ebx+sb_offs_position]
4103
	or ebx,ebx
4121
	or ebx,ebx
4104
	jz .ret_f
4122
	jz .ret_f
4105
	push eax
4123
	push eax
4106
	mov eax,edx
4124
	mov eax,edx
4107
 
4125
 
4108
	cmp edx,ted_tex
4126
	cmp edx,ted_tex
4109
	jne @f
4127
	jne @f
4110
		call ted_iterat_next
4128
		call ted_iterat_next
4111
		jmp .beg_cycle
4129
		jmp .beg_cycle
4112
	@@:
4130
	@@:
4113
 
4131
 
4114
	or ebx,ebx
4132
	or ebx,ebx
4115
	jz @f
4133
	jz @f
4116
 
4134
 
4117
	cmp byte[edx],13
4135
	cmp byte[edx],13
4118
	jne @f
4136
	jne @f
4119
		call ted_iterat_next
4137
		call ted_iterat_next
4120
		.beg_cycle:
4138
		.beg_cycle:
4121
	@@:
4139
	@@:
4122
		cmp edx,ted_tex_1
4140
		cmp edx,ted_tex_1
4123
		jle @f
4141
		jle @f
4124
		cmp byte[edx],13
4142
		cmp byte[edx],13
4125
		je @f
4143
		je @f
4126
		or ebx,ebx
4144
		or ebx,ebx
4127
		jz @f
4145
		jz @f
4128
;--------------------------------------
4146
;--------------------------------------
4129
xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
4147
xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
4130
mov al,byte[edx+1]
4148
mov al,byte[edx+1]
4131
or al,al
4149
or al,al
4132
jz .no_color
4150
jz .no_color
4133
cmp eax,ted_colors_text_count
4151
cmp eax,ted_colors_text_count
4134
jge .no_color
4152
jge .no_color
4135
	xor ecx,ecx
4153
	xor ecx,ecx
4136
	mov cl,byte[edx+1]
4154
	mov cl,byte[edx+1]
4137
	shl cx,2
4155
	shl cx,2
4138
	add ecx,ted_text_colors
4156
	add ecx,ted_text_colors
4139
	mov ecx,[ecx]
4157
	mov ecx,[ecx]
4140
.no_color:
4158
.no_color:
4141
;--------------------------------------
4159
;--------------------------------------
4142
		mov eax,edx
4160
		mov eax,edx
4143
		call ted_iterat_next
4161
		call ted_iterat_next
4144
		dec ebx
4162
		dec ebx
4145
		jmp @b
4163
		jmp @b
4146
align 4
4164
align 4
4147
	@@:
4165
	@@:
4148
		mov edx,eax
4166
		mov edx,eax
4149
	pop eax
4167
	pop eax
4150
	.ret_f:
4168
	.ret_f:
4151
	call ted_get_symb_color
4169
	call ted_get_symb_color
4152
	ret
4170
	ret
4153
endp
4171
endp
4154
 
4172
 
4155
;input:
4173
;input:
4156
; edx = pointer to symbol
4174
; edx = pointer to symbol
4157
; edi = pointer to tedit struct
4175
; edi = pointer to tedit struct
4158
;output:
4176
;output:
4159
; ecx = symbol color
4177
; ecx = symbol color
4160
; edx = pointer to 13 symbol
4178
; edx = pointer to 13 symbol
4161
;description:
4179
;description:
4162
; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
4180
; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
4163
align 16
4181
align 16
4164
proc ted_opt_draw_line_right uses eax
4182
proc ted_opt_draw_line_right uses eax
4165
	mov eax,edx
4183
	mov eax,edx
4166
	@@:
4184
	@@:
4167
		cmp edx,ted_tex_1
4185
		cmp edx,ted_tex_1
4168
		jle @f
4186
		jle @f
4169
		cmp byte[edx],13
4187
		cmp byte[edx],13
4170
		je @f
4188
		je @f
4171
		mov eax,edx
4189
		mov eax,edx
4172
		call ted_iterat_next
4190
		call ted_iterat_next
4173
		jmp @b
4191
		jmp @b
4174
	@@:
4192
	@@:
4175
	mov edx,eax ;perv sumbol
4193
	mov edx,eax ;perv sumbol
4176
	call ted_get_symb_color
4194
	call ted_get_symb_color
4177
	ret
4195
	ret
4178
endp
4196
endp
4179
 
4197
 
4180
align 16
4198
align 16
4181
proc ted_mouse, edit:dword
4199
proc ted_mouse, edit:dword
4182
	pushad
4200
	pushad
4183
	mov edi,[edit]
4201
	mov edi,[edit]
4184
 
4202
 
4185
	;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
4203
	;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
4186
	mov edx,ted_scr_h
4204
	mov edx,ted_scr_h
4187
	mov ecx,ted_scr_w
4205
	mov ecx,ted_scr_w
4188
 
4206
 
4189
	cmp word[edx+sb_offs_delta2],0
4207
	cmp word[edx+sb_offs_delta2],0
4190
	jne .horizontal
4208
	jne .horizontal
4191
 
4209
 
4192
	mov eax,[ecx+sb_offs_max_area]
4210
	mov eax,[ecx+sb_offs_max_area]
4193
	cmp eax,[ecx+sb_offs_cur_area]
4211
	cmp eax,[ecx+sb_offs_cur_area]
4194
	jbe .horizontal
4212
	jbe .horizontal
4195
	; mouse event for Vertical ScrollBar
4213
	; mouse event for Vertical ScrollBar
4196
	stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
4214
	stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
4197
	cmp dword[ecx+sb_offs_redraw],0
4215
	cmp dword[ecx+sb_offs_redraw],0
4198
	je @f
4216
	je @f
4199
		mov dword[ecx+sb_offs_redraw],0
4217
		mov dword[ecx+sb_offs_redraw],0
4200
		stdcall ted_draw,edi
4218
		stdcall ted_draw,edi
4201
		jmp .no_in_wnd
4219
		jmp .no_in_wnd
4202
	@@:
4220
	@@:
4203
	cmp word[ecx+sb_offs_delta2],0
4221
	cmp word[ecx+sb_offs_delta2],0
4204
	jne .no_in_wnd
4222
	jne .no_in_wnd
4205
	.horizontal:
4223
	.horizontal:
4206
	mov eax,[edx+sb_offs_max_area]
4224
	mov eax,[edx+sb_offs_max_area]
4207
	cmp eax,[edx+sb_offs_cur_area]
4225
	cmp eax,[edx+sb_offs_cur_area]
4208
	jbe .other
4226
	jbe .other
4209
	; mouse event for Horizontal ScrollBar
4227
	; mouse event for Horizontal ScrollBar
4210
	stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
4228
	stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
4211
	cmp dword[edx+sb_offs_redraw],0
4229
	cmp dword[edx+sb_offs_redraw],0
4212
	je .other
4230
	je .other
4213
		mov dword[edx+sb_offs_redraw],0
4231
		mov dword[edx+sb_offs_redraw],0
4214
		stdcall ted_draw,edi
4232
		stdcall ted_draw,edi
4215
		jmp .no_in_wnd
4233
		jmp .no_in_wnd
4216
	.other:
4234
	.other:
4217
	cmp word[ecx+sb_offs_delta2],0
4235
	cmp word[ecx+sb_offs_delta2],0
4218
	jne .no_in_wnd
4236
	jne .no_in_wnd
4219
	cmp word[edx+sb_offs_delta2],0
4237
	cmp word[edx+sb_offs_delta2],0
4220
	jne .no_in_wnd
4238
	jne .no_in_wnd
4221
 
4239
 
4222
	;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
4240
	;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
4223
	mcall SF_MOUSE_GET,SSF_BUTTON
4241
	mcall SF_MOUSE_GET,SSF_BUTTON
4224
	cmp al,1
4242
	cmp al,1
4225
	jne @f
4243
	jne @f
4226
		mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
4244
		mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
4227
		mov ebx,ted_wnd_t
4245
		mov ebx,ted_wnd_t
4228
		add ebx,ted_rec_t
4246
		add ebx,ted_rec_t
4229
		cmp ax,bx
4247
		cmp ax,bx
4230
		jl @f ;y_mouse
4248
		jl @f ;y_mouse
4231
 
4249
 
4232
		sub ebx,ted_rec_t
4250
		sub ebx,ted_rec_t
4233
		add ebx,ted_wnd_h
4251
		add ebx,ted_wnd_h
4234
		cmp bx,ax
4252
		cmp bx,ax
4235
		jl @f ;y_mouse>y_wnd
4253
		jl @f ;y_mouse>y_wnd
4236
 
4254
 
4237
		mov ebx,ted_wnd_l
4255
		mov ebx,ted_wnd_l
4238
		add ebx,ted_rec_l
4256
		add ebx,ted_rec_l
4239
		mov ecx,eax
4257
		mov ecx,eax
4240
		shr ecx,16
4258
		shr ecx,16
4241
		cmp cx,bx
4259
		cmp cx,bx
4242
		jl @f ;x_mouse
4260
		jl @f ;x_mouse
4243
 
4261
 
4244
		sub ebx,ted_rec_l
4262
		sub ebx,ted_rec_l
4245
		add ebx,ted_wnd_w
4263
		add ebx,ted_wnd_w
4246
		cmp bx,cx
4264
		cmp bx,cx
4247
		jl @f ;x_mouse>x_wnd
4265
		jl @f ;x_mouse>x_wnd
4248
 
4266
 
4249
		call ted_draw_cursor_sumb
4267
		call ted_draw_cursor_sumb
4250
		call ted_wnd_main_click
4268
		call ted_wnd_main_click
4251
		jmp .no_in_wnd
4269
		jmp .no_in_wnd
4252
	@@:
4270
	@@:
4253
	mov edx,ted_el_focus
4271
	mov edx,ted_el_focus
4254
	cmp [edx],edi
4272
	cmp [edx],edi
4255
	jne @f
4273
	jne @f
4256
		call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
4274
		call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
4257
	@@:
4275
	@@:
4258
	cmp ted_drag_m,0
4276
	cmp ted_drag_m,0
4259
	je .no_in_wnd
4277
	je .no_in_wnd
4260
		mov ted_drag_m,0
4278
		mov ted_drag_m,0
4261
		stdcall ted_draw,edi
4279
		stdcall ted_draw,edi
4262
		cmp ted_fun_draw_panel_buttons,0
4280
		cmp ted_fun_draw_panel_buttons,0
4263
		je .no_in_wnd
4281
		je .no_in_wnd
4264
			call ted_fun_draw_panel_buttons
4282
			call ted_fun_draw_panel_buttons
4265
	.no_in_wnd:
4283
	.no_in_wnd:
4266
	popad
4284
	popad
4267
	ret
4285
	ret
4268
endp
4286
endp
4269
 
4287
 
4270
;input:
4288
;input:
4271
; eax -> (x,y)
4289
; eax -> (x,y)
4272
; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
4290
; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
4273
;description:
4291
;description:
4274
; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
4292
; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
4275
align 16
4293
align 16
4276
ted_wnd_main_click:
4294
ted_wnd_main_click:
4277
	push ebx ecx edx
4295
	push ebx ecx edx
4278
	mov ebx,ted_el_focus
4296
	mov ebx,ted_el_focus
4279
	mov [ebx],edi ;áâ ¢¨¬ 䮪ãá
4297
	mov [ebx],edi ;áâ ¢¨¬ 䮪ãá
4280
 
4298
 
4281
	push eax
4299
	push eax
4282
		shr eax,16
4300
		shr eax,16
4283
		sub eax,ted_wnd_l
4301
		sub eax,ted_wnd_l
4284
		sub eax,ted_rec_l
4302
		sub eax,ted_rec_l
4285
 
4303
 
4286
		xor edx,edx
4304
		xor edx,edx
4287
		mov ecx,ted_rec_w
4305
		mov ecx,ted_rec_w
4288
		div cx
4306
		div cx
4289
		;inc eax
4307
		;inc eax
4290
		mov ebx,ted_scr_h
4308
		mov ebx,ted_scr_h
4291
		cmp eax,[ebx+sb_offs_cur_area]
4309
		cmp eax,[ebx+sb_offs_cur_area]
4292
		jle @f
4310
		jle @f
4293
			mov eax,[ebx+sb_offs_cur_area]
4311
			mov eax,[ebx+sb_offs_cur_area]
4294
		@@:
4312
		@@:
4295
		;dec eax
4313
		;dec eax
4296
		mov ted_cur_x,eax
4314
		mov ted_cur_x,eax
4297
	pop eax
4315
	pop eax
4298
 
4316
 
4299
	push eax
4317
	push eax
4300
		and eax,0xffff
4318
		and eax,0xffff
4301
		sub eax,ted_wnd_t
4319
		sub eax,ted_wnd_t
4302
		sub eax,ted_rec_t
4320
		sub eax,ted_rec_t
4303
 
4321
 
4304
		xor edx,edx
4322
		xor edx,edx
4305
		mov ecx,ted_rec_h
4323
		mov ecx,ted_rec_h
4306
		div cx
4324
		div cx
4307
		inc eax
4325
		inc eax
4308
		mov ebx,ted_scr_w
4326
		mov ebx,ted_scr_w
4309
		cmp eax,[ebx+sb_offs_cur_area]
4327
		cmp eax,[ebx+sb_offs_cur_area]
4310
		jle @f
4328
		jle @f
4311
			mov eax,[ebx+sb_offs_cur_area]
4329
			mov eax,[ebx+sb_offs_cur_area]
4312
		@@:
4330
		@@:
4313
		dec eax
4331
		dec eax
4314
		mov ted_cur_y,eax
4332
		mov ted_cur_y,eax
4315
	pop eax
4333
	pop eax
4316
 
4334
 
4317
	cmp ted_drag_m,0
4335
	cmp ted_drag_m,0
4318
	je @f
4336
	je @f
4319
		call ted_sel_move
4337
		call ted_sel_move
4320
		jmp .sel_move
4338
		jmp .sel_move
4321
	@@:
4339
	@@:
4322
		mov ted_drag_m,1
4340
		mov ted_drag_m,1
4323
		call ted_sel_start
4341
		call ted_sel_start
4324
	.sel_move:
4342
	.sel_move:
4325
	pop edx ecx ebx
4343
	pop edx ecx ebx
4326
	ret
4344
	ret
4327
 
4345
 
4328
;input:
4346
;input:
4329
; edi = pointer to tedit struct
4347
; edi = pointer to tedit struct
4330
align 16
4348
align 16
4331
ted_wnd_main_mouse_scroll:
4349
ted_wnd_main_mouse_scroll:
4332
	push eax ebx ecx
4350
	push eax ebx ecx
4333
	mcall SF_MOUSE_GET,SSF_SCROLL_DATA
4351
	mcall SF_MOUSE_GET,SSF_SCROLL_DATA
4334
	or ax,ax
4352
	or ax,ax
4335
	jz .no_scroll
4353
	jz .no_scroll
4336
		mov ecx,ted_scr_w
4354
		mov ecx,ted_scr_w
4337
		movsx eax,ax
4355
		movsx eax,ax
4338
		lea eax,[eax+eax*2] ;㬭®¦ ¥¬ ­  3 (ç¨á«® áâப ¯à®ªàã⪨ §  ®¤­® ¤¢¨¦¥­¨¥ ª®«¥á  ¬ëè¨)
4356
		lea eax,[eax+eax*2] ;㬭®¦ ¥¬ ­  3 (ç¨á«® áâப ¯à®ªàã⪨ §  ®¤­® ¤¢¨¦¥­¨¥ ª®«¥á  ¬ëè¨)
4339
		add eax,[ecx+sb_offs_position]
4357
		add eax,[ecx+sb_offs_position]
4340
		mov ebx,[ecx+sb_offs_max_area]
4358
		mov ebx,[ecx+sb_offs_max_area]
4341
		shl ebx,1
4359
		shl ebx,1
4342
		sub ebx,[ecx+sb_offs_cur_area] ;®â­¨¬ ¥¬ ¯®«®¢¨­ã ¢ëá®âë ®ª­ 
4360
		sub ebx,[ecx+sb_offs_cur_area] ;®â­¨¬ ¥¬ ¯®«®¢¨­ã ¢ëá®âë ®ª­ 
4343
		shr ebx,1
4361
		shr ebx,1
4344
		cmp eax,ebx
4362
		cmp eax,ebx
4345
		jae .no_scroll
4363
		jae .no_scroll
4346
		mov [ecx+sb_offs_position],eax
4364
		mov [ecx+sb_offs_position],eax
4347
		stdcall ted_draw,edi
4365
		stdcall ted_draw,edi
4348
	.no_scroll:
4366
	.no_scroll:
4349
	pop ecx ebx eax
4367
	pop ecx ebx eax
4350
	ret
4368
	ret
4351
 
4369
 
4352
align 16
4370
align 16
4353
proc ted_save_file, edit:dword, file:dword, f_name:dword
4371
proc ted_save_file, edit:dword, file:dword, f_name:dword
4354
pushad
4372
pushad
4355
	mov edi,[edit]
4373
	mov edi,[edit]
4356
 
4374
 
4357
	stdcall ted_can_save,edi
4375
	stdcall ted_can_save,edi
4358
	;or al,al
4376
	;or al,al
4359
	;jz .no_save
4377
	;jz .no_save
4360
 
4378
 
4361
	mov ecx,ted_max_chars
4379
	mov ecx,ted_max_chars
4362
	invoke mem.alloc,ecx
4380
	invoke mem.alloc,ecx
4363
	push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4381
	push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4364
 
4382
 
4365
	mov edx,ted_tex
4383
	mov edx,ted_tex
4366
	xor ecx,ecx
4384
	xor ecx,ecx
4367
	@@:
4385
	@@:
4368
		call ted_iterat_next
4386
		call ted_iterat_next
4369
		cmp edx,ted_tex_1
4387
		cmp edx,ted_tex_1
4370
		jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
4388
		jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
4371
		mov bl,[edx]
4389
		mov bl,[edx]
4372
		mov byte[eax],bl
4390
		mov byte[eax],bl
4373
		inc eax
4391
		inc eax
4374
		inc ecx
4392
		inc ecx
4375
		jmp @b
4393
		jmp @b
4376
align 4
4394
align 4
4377
	@@:
4395
	@@:
4378
 
4396
 
4379
	or ecx,ecx
4397
	or ecx,ecx
4380
	jz @f
4398
	jz @f
4381
		mov ebx,[file]
4399
		mov ebx,[file]
4382
		pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4400
		pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4383
		mov [ebx+16],eax
4401
		mov [ebx+16],eax
4384
		push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4402
		push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4385
		mov dword[ebx], SSF_CREATE_FILE
4403
		mov dword[ebx], SSF_CREATE_FILE
4386
		mov dword[ebx+4], 0
4404
		mov dword[ebx+4], 0
4387
		mov dword[ebx+8], 0
4405
		mov dword[ebx+8], 0
4388
		mov [ebx+12], ecx
4406
		mov [ebx+12], ecx
4389
		mov  byte[ebx+20], 0
4407
		mov  byte[ebx+20], 0
4390
		push dword[f_name]
4408
		push dword[f_name]
4391
		pop dword[ebx+21]
4409
		pop dword[ebx+21]
4392
		mcall SF_FILE
4410
		mcall SF_FILE
4393
 
4411
 
4394
		mov ted_err_save,al
4412
		mov ted_err_save,al
4395
 
4413
 
4396
		or eax,eax
4414
		or eax,eax
4397
		jz .no_msg
4415
		jz .no_msg
4398
		cmp ax,10
4416
		cmp ax,10
4399
		jl .zifra_0_9
4417
		jl .zifra_0_9
4400
			mov al,'?'
4418
			mov al,'?'
4401
			sub ax,48
4419
			sub ax,48
4402
		.zifra_0_9:
4420
		.zifra_0_9:
4403
		add ax,48
4421
		add ax,48
4404
		cmp ted_fun_save_err,0
4422
		cmp ted_fun_save_err,0
4405
		je @f
4423
		je @f
4406
		call ted_fun_save_err
4424
		call ted_fun_save_err
4407
		jmp @f
4425
		jmp @f
4408
		.no_msg:
4426
		.no_msg:
4409
		m2m ted_tim_ls,ted_tim_ch
4427
		m2m ted_tim_ls,ted_tim_ch
4410
	@@:
4428
	@@:
4411
 
4429
 
4412
	pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4430
	pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
4413
	invoke mem.free,ecx
4431
	invoke mem.free,ecx
4414
	.no_save:
4432
	.no_save:
4415
popad
4433
popad
4416
	ret
4434
	ret
4417
endp
4435
endp
4418
 
4436
 
4419
>
4437
>
4420
 
4438
 
4421
>
4439
>
4422
>
4440
>
4423
>
4441
>
4424
>
4442
>
4425
>
4443
>