Rev 5911 | Rev 7577 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1476 | IgorA | 1 | use32 |
7575 | IgorA | 2 | org 0 |
1476 | IgorA | 3 | db 'MENUET01' ;идентиф. исполняемого файла всегда 8 байт |
7575 | IgorA | 4 | dd 1, start, i_end, mem, stacktop, file_name, sys_path |
1476 | IgorA | 5 | |
6 | MAX_COLOR_WORD_LEN equ 40 |
||
2819 | IgorA | 7 | BUF_SIZE equ 4096 ;buffer for copy|paste |
2086 | IgorA | 8 | CAPT_PATH_WIDTH equ 50 ;ширина подписи перед текстовым полем |
1476 | IgorA | 9 | |
10 | include '../../macros.inc' |
||
11 | include '../../proc32.inc' |
||
7575 | IgorA | 12 | include '../../KOSfuncs.inc' |
13 | include '../../load_img.inc' |
||
1476 | IgorA | 14 | include '../../develop/libraries/box_lib/trunk/box_lib.mac' |
7575 | IgorA | 15 | include '../../system/skincfg/trunk/kglobals.inc' |
16 | include '../../system/skincfg/trunk/unpacker.inc' |
||
1476 | IgorA | 17 | include 'te_data.inc' |
18 | include 'te_work.inc' ;text work functions |
||
19 | |||
4990 | IgorA | 20 | @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load |
1476 | IgorA | 21 | |
4990 | IgorA | 22 | icon_tl_sys dd 0 ;указатель на память для хранения системных иконок |
23 | |||
1476 | IgorA | 24 | align 4 |
25 | start: |
||
7575 | IgorA | 26 | mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors |
1476 | IgorA | 27 | |
7575 | IgorA | 28 | mcall SF_SYS_MISC,SSF_HEAP_INIT |
2819 | IgorA | 29 | or eax,eax |
30 | jz button.exit |
||
1476 | IgorA | 31 | |
7575 | IgorA | 32 | mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1 ;scan code |
33 | mcall SF_SET_EVENTS_MASK,0xC0000027 |
||
1476 | IgorA | 34 | |
7575 | IgorA | 35 | load_libraries l_libs_start,load_lib_end |
1476 | IgorA | 36 | |
7575 | IgorA | 37 | ;проверка на сколько удачно загузилась библиотека |
38 | cmp dword[lib0+ll_struc_size-4],0 |
||
5911 | IgorA | 39 | jz @f |
40 | mcall -1 ;exit not correct |
||
41 | @@: |
||
1476 | IgorA | 42 | |
43 | ;--------------------------------------------------------------------- |
||
7575 | IgorA | 44 | stdcall [tl_data_init], tree1 |
1476 | IgorA | 45 | |
4990 | IgorA | 46 | ; читаем файл с курсорами и линиями |
7575 | IgorA | 47 | include_image_file '..\..\media\log_el\trunk\tl_sys_16.png', icon_tl_sys |
48 | mov eax,[icon_tl_sys] |
||
49 | mov [tree1.data_img_sys],eax |
||
1476 | IgorA | 50 | ;--------------------------------------------------------------------- |
51 | ; читаем bmp файл с иконками узлов |
||
7575 | IgorA | 52 | include_image_file '..\t_edit\tl_nod_16.png', icon_tl_sys |
53 | mov eax,[icon_tl_sys] |
||
54 | mov [tree1.data_img],eax |
||
1476 | IgorA | 55 | ;------------------------------------------------------------------------------ |
7575 | IgorA | 56 | copy_path fn_syntax_dir,sys_path,file_name,0 ;берем путь к папке с файлами синтаксиса |
57 | mcall SF_FILE,tree_file_struct |
||
1476 | IgorA | 58 | |
7575 | IgorA | 59 | cmp ebx,-1 |
60 | je .end_dir_init |
||
61 | mov eax,dir_mem |
||
62 | add eax,32+4+1+3+4*6+8 |
||
63 | mov ecx,ebx |
||
64 | @@: |
||
65 | cmp byte[eax],'.' ;фильтруем файлы с именами '.' и '..' |
||
66 | je .filter |
||
67 | stdcall [tl_node_add],tree1,0x10000,eax ;1*2^16 - где 1 номер иконки с книгой |
||
68 | stdcall [tl_cur_next],tree1 |
||
69 | .filter: |
||
70 | add eax,304 |
||
71 | loop @b |
||
72 | stdcall [tl_cur_beg],tree1 ;ставим курсор на начало списка |
||
73 | or dword[tree1.style], tl_cursor_pos_limited ;ограничиваем движение курсора в пределах списка |
||
74 | .end_dir_init: |
||
1476 | IgorA | 75 | |
76 | ;--- load color option file --- |
||
77 | stdcall [ted_init], tedit0 |
||
2086 | IgorA | 78 | mov byte[file_name],0 |
1476 | IgorA | 79 | |
80 | align 4 |
||
81 | red_win: |
||
2086 | IgorA | 82 | call draw_window |
1476 | IgorA | 83 | |
84 | align 4 |
||
85 | still: |
||
7575 | IgorA | 86 | mcall SF_WAIT_EVENT |
1476 | IgorA | 87 | |
88 | cmp al,1 ;изм. положение окна |
||
89 | jz red_win |
||
90 | cmp al,2 |
||
91 | jz key |
||
92 | cmp al,3 |
||
93 | jz button |
||
94 | cmp al,6 |
||
95 | jz mouse |
||
96 | |||
97 | jmp still |
||
98 | |||
99 | |||
100 | align 4 |
||
2086 | IgorA | 101 | draw_window: |
102 | pushad |
||
7575 | IgorA | 103 | mcall SF_REDRAW,SSF_BEGIN_DRAW |
2086 | IgorA | 104 | |
105 | mov edx,[sc.work] |
||
106 | or edx,0x33000000 |
||
107 | mov edi,hed |
||
7575 | IgorA | 108 | mcall SF_CREATE_WINDOW,<10,555>,<10,333> |
2086 | IgorA | 109 | |
7575 | IgorA | 110 | mcall SF_THREAD_INFO,procinfo,-1 |
111 | mov edi,tedit0 ;значение edi нужно для EvSize и ted_wnd_t |
||
112 | call EvSize |
||
2086 | IgorA | 113 | |
114 | mov esi,[sc.work_button];0xd0 |
||
7575 | IgorA | 115 | mcall SF_DEFINE_BUTTON,5*65536+90,195*65536+20,200 |
2086 | IgorA | 116 | |
117 | mov ebx,100*65536+85 |
||
118 | mov ecx,195*65536+20 |
||
119 | mov edx,201 |
||
120 | mov esi,0xd00000 |
||
121 | mcall |
||
122 | |||
123 | mov ecx,[sc.work_button_text] |
||
124 | or ecx,0x80000000 |
||
7575 | IgorA | 125 | mcall SF_DRAW_TEXT,10*65536+200,,txt_load_f |
2086 | IgorA | 126 | |
127 | mov ecx,0xffff00 |
||
128 | or ecx,0x80000000 |
||
7575 | IgorA | 129 | mcall ,105*65536+200,,txt_save_f |
2086 | IgorA | 130 | |
131 | mov ecx,[sc.work_text] |
||
132 | or ecx,0x80000000 |
||
7575 | IgorA | 133 | mcall ,195*65536+10,,txt_inp_file |
2086 | IgorA | 134 | |
135 | add ebx,20 |
||
136 | mov edx,txt_out_file |
||
137 | int 0x40 |
||
138 | |||
2125 | IgorA | 139 | push dword PathShow_data_1 |
140 | call [PathShow_draw] |
||
141 | |||
2086 | IgorA | 142 | stdcall [edit_box_draw],dword edit1 |
143 | stdcall [tl_draw],dword tree1 |
||
144 | |||
145 | ;scroll 1 |
||
146 | mov [ws_dir_lbox.all_redraw],1 |
||
147 | stdcall [scrollbar_ver_draw],dword ws_dir_lbox |
||
148 | stdcall [ted_draw], tedit0 |
||
149 | |||
7575 | IgorA | 150 | mcall SF_REDRAW,SSF_END_DRAW |
2086 | IgorA | 151 | popad |
152 | ret |
||
153 | |||
7575 | IgorA | 154 | MIN_M_WND_H equ 100 ;минимальная высота главного окна |
155 | ;input: |
||
156 | ; edi = pointer to tedit struct |
||
2086 | IgorA | 157 | align 4 |
7575 | IgorA | 158 | EvSize: |
159 | pushad |
||
160 | mov ebx,ted_scr_h |
||
161 | mov esi,ted_scr_w |
||
162 | |||
163 | m2m ted_wnd_w,[procinfo.client_box.width] ;ставим ширину окна редактора равной ширине всего окна |
||
164 | mov eax,ted_wnd_l |
||
165 | sub ted_wnd_w,eax ;отнимаем отступ слева |
||
166 | movzx eax,word[esi+sb_offs_size_x] |
||
167 | sub ted_wnd_w,eax ;отнимаем ширину верт. скроллинга |
||
168 | |||
169 | m2m ted_wnd_h,[procinfo.client_box.height] ;ставим высоту окна редактора равной высоте всего окна |
||
170 | cmp ted_wnd_h,MIN_M_WND_H |
||
171 | jg @f |
||
172 | mov ted_wnd_h,MIN_M_WND_H |
||
173 | @@: |
||
174 | |||
175 | movzx eax,word[ebx+sb_offs_size_y] |
||
176 | sub ted_wnd_h,eax ;отнимаем высоту гориз. скроллинга |
||
177 | mov eax,ted_wnd_t |
||
178 | sub ted_wnd_h,eax ;отнимаем отступ сверху |
||
179 | |||
180 | stdcall [ted_init_scroll_bars], tedit0,2 |
||
181 | popad |
||
182 | ret |
||
183 | |||
184 | align 4 |
||
1476 | IgorA | 185 | mouse: |
186 | stdcall [tl_mouse],tree1 |
||
187 | stdcall [edit_box_mouse],edit1 |
||
188 | stdcall [ted_mouse], tedit0 |
||
189 | jmp still |
||
190 | |||
2819 | IgorA | 191 | ;output: |
192 | ; ah = symbol |
||
193 | align 4 |
||
194 | proc KeyConvertToASCII, table:dword |
||
195 | push ebx |
||
196 | mov ebx,dword[table] ;convert scan to ascii |
||
197 | ror ax,8 |
||
198 | xor ah,ah |
||
199 | add bx,ax |
||
200 | mov ah,byte[ebx] |
||
201 | pop ebx |
||
202 | ret |
||
203 | endp |
||
1476 | IgorA | 204 | |
205 | align 4 |
||
206 | key: |
||
7575 | IgorA | 207 | mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS ;66.3 получить состояние управляющих клавиш |
2819 | IgorA | 208 | xor esi,esi |
209 | mov ecx,1 |
||
7575 | IgorA | 210 | test al,3 ;[Shift] |
2819 | IgorA | 211 | jz @f |
212 | mov cl,2 |
||
213 | or esi,KM_SHIFT |
||
214 | @@: |
||
215 | test al,0x0c ;[Ctrl] |
||
216 | jz @f |
||
217 | or esi,KM_CTRL |
||
218 | @@: |
||
219 | test al,0x30 ;[Alt] |
||
220 | jz @f |
||
221 | mov cl,3 |
||
222 | or esi,KM_ALT |
||
223 | @@: |
||
224 | test al,0x80 ;[NumLock] |
||
225 | jz @f |
||
226 | or esi,KM_NUMLOCK |
||
227 | @@: |
||
228 | |||
7575 | IgorA | 229 | mcall SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT,,conv_tabl ;26.2 получить раскладку клавиатуры |
230 | mcall SF_GET_KEY |
||
1476 | IgorA | 231 | stdcall [tl_key],tree1 |
2819 | IgorA | 232 | |
233 | test word [edit1.flags],10b;ed_focus ; если не в фокусе, выходим |
||
234 | je @f |
||
235 | cmp ah,0x80 ;if key up |
||
236 | ja still |
||
237 | cmp ah,42 ;[Shift] (left) |
||
238 | je still |
||
239 | cmp ah,54 ;[Shift] (right) |
||
240 | je still |
||
241 | cmp ah,56 ;[Alt] |
||
242 | je still |
||
243 | cmp ah,29 ;[Ctrl] |
||
244 | je still |
||
245 | cmp ah,69 ;[Pause Break] |
||
246 | je still |
||
247 | |||
7575 | IgorA | 248 | stdcall KeyConvertToASCII, conv_tabl |
2819 | IgorA | 249 | stdcall [edit_box_key],edit1 |
250 | jmp still |
||
251 | @@: |
||
252 | |||
253 | stdcall [ted_key], tedit0, conv_tabl,esi |
||
1476 | IgorA | 254 | jmp still |
255 | |||
256 | align 4 |
||
257 | button: |
||
7575 | IgorA | 258 | mcall SF_GET_BUTTON |
1476 | IgorA | 259 | |
7575 | IgorA | 260 | cmp ah,200 |
261 | jne @f |
||
262 | call but_OpenSyntax |
||
263 | @@: |
||
264 | cmp ah,201 |
||
265 | jne @f |
||
266 | call but_SaveSyntax |
||
267 | @@: |
||
1476 | IgorA | 268 | |
7575 | IgorA | 269 | cmp ah,1 |
270 | jne still |
||
1476 | IgorA | 271 | .exit: |
7575 | IgorA | 272 | stdcall mem.Free,[options_file] |
273 | stdcall mem.Free,[unpac_mem] |
||
1476 | IgorA | 274 | |
7575 | IgorA | 275 | stdcall [tl_data_clear], tree1 |
276 | stdcall [ted_delete], tedit0 |
||
277 | mcall SF_TERMINATE_PROCESS ;выход из программы |
||
1476 | IgorA | 278 | |
279 | align 4 |
||
280 | but_OpenSyntax: |
||
5911 | IgorA | 281 | push eax |
282 | stdcall [tl_node_get_data],tree1 |
||
283 | mov [fn_col_option],eax |
||
284 | call InitColText |
||
285 | pop eax |
||
286 | ret |
||
1476 | IgorA | 287 | |
288 | align 4 |
||
289 | but_SaveSyntax: |
||
4990 | IgorA | 290 | stdcall [ted_save_file], tedit0,run_file_70,[edit1.text] |
1476 | IgorA | 291 | ret |
292 | |||
293 | align 4 |
||
294 | but_ctrl_o: |
||
295 | push eax |
||
296 | call get_wnd_in_focus |
||
297 | cmp eax,0 |
||
298 | je @f |
||
299 | stdcall [ted_open_file], eax,str_file_70,[edit1.text] |
||
300 | @@: |
||
301 | pop eax |
||
302 | ret |
||
303 | |||
304 | ;создание нового файла |
||
305 | align 4 |
||
306 | but_ctrl_n: |
||
307 | push eax |
||
308 | call get_wnd_in_focus |
||
309 | cmp eax,0 |
||
310 | je @f |
||
311 | stdcall [ted_clear], eax,1 |
||
312 | stdcall [ted_draw], eax |
||
313 | @@: |
||
314 | pop eax |
||
315 | ret |
||
316 | |||
317 | ;определяем какое из окон редактора в фокусе |
||
318 | align 4 |
||
319 | get_wnd_in_focus: |
||
320 | xor eax,eax |
||
321 | cmp dword[el_focus],tedit0 |
||
322 | jne @f |
||
323 | mov eax,tedit0 |
||
324 | @@: |
||
325 | ;cmp dword[el_focus],tedit1 |
||
326 | ;jne @f |
||
327 | ; mov eax,tedit1 |
||
328 | ;@@: |
||
329 | ret |
||
330 | |||
7575 | IgorA | 331 | hed db 'TextEditor syntax file converter 15.01.19',0 ;подпись окна |
2819 | IgorA | 332 | conv_tabl rb 128 ; таблица для конвертирования scan-кода в ascii-код |
1476 | IgorA | 333 | |
7575 | IgorA | 334 | txt_load_f db 'Загр. файл',0 |
335 | txt_save_f db 'Сохр. файл',0 |
||
2086 | IgorA | 336 | txt_inp_file db 'Исх. файл:',0 |
1476 | IgorA | 337 | txt_out_file db 'Вых. файл:',0 |
338 | |||
4990 | IgorA | 339 | head_f_i: |
340 | head_f_l db 'System error',0 |
||
341 | err_message_found_lib_0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0 |
||
342 | err_message_import_0 db 'Error on load import library ',39,'box_lib.obj',39,0 |
||
343 | err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,0 |
||
344 | err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,0 |
||
345 | |||
1476 | IgorA | 346 | ;library structures |
347 | l_libs_start: |
||
4990 | IgorA | 348 | lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0, err_message_found_lib_0, head_f_l, import_box_lib,err_message_import_0, head_f_i |
349 | lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1, err_message_found_lib_1, head_f_l, import_libimg,err_message_import_1, head_f_i |
||
1476 | IgorA | 350 | load_lib_end: |
351 | |||
7575 | IgorA | 352 | IncludeIGlobals |
1476 | IgorA | 353 | |
5911 | IgorA | 354 | align 16 |
1476 | IgorA | 355 | i_end: |
7575 | IgorA | 356 | IncludeUGlobals |
1476 | IgorA | 357 | procinfo process_information |
5911 | IgorA | 358 | rb 1024 |
1476 | IgorA | 359 | thread: |
360 | rb 1024 |
||
361 | stacktop: |
||
362 | sys_path: |
||
363 | rb 4096 |
||
364 | file_name: |
||
365 | rb 4096 |
||
366 | file_name_rez: |
||
367 | rb 4096 |
||
368 | mem:10,333>10,555> |