Subversion Repositories Kolibri OS

Rev

Rev 8932 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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