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