From 664313ede7861aeb5e3d0cc3cd1e0c84eeabc2c0 Mon Sep 17 00:00:00 2001 From: IgorA Date: Tue, 1 Jul 2014 13:46:54 +0000 Subject: [PATCH] update 'te_syntax': use *.png icons and other changes git-svn-id: svn://kolibrios.org@4990 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/other/t_edit_synt/build.bat | 9 +- programs/other/t_edit_synt/te_data.inc | 36 ++++--- programs/other/t_edit_synt/te_syntax.asm | 121 +++++++++++++---------- programs/other/t_edit_synt/te_work.inc | 29 +++--- 4 files changed, 108 insertions(+), 87 deletions(-) diff --git a/programs/other/t_edit_synt/build.bat b/programs/other/t_edit_synt/build.bat index 3642a5da74..dd980033e6 100644 --- a/programs/other/t_edit_synt/build.bat +++ b/programs/other/t_edit_synt/build.bat @@ -1,13 +1,8 @@ if not exist bin mkdir bin -if not exist bin\tl_sys_16.bmp @copy ..\..\develop\libraries\box_lib\trunk\tl_sys_16.bmp bin\tl_sys_16.bmp -if not exist bin\tl_nod_16.bmp @copy ..\..\develop\libraries\box_lib\trunk\tl_nod_16.bmp bin\tl_nod_16.bmp -if not exist bin\info mkdir bin\info - -if not exist bin\box_lib.obj @fasm.exe -m 16384 ..\..\develop\libraries\box_lib\trunk\box_lib.asm bin\box_lib.obj -@kpack bin\box_lib.obj +if not exist bin\tl_sys_16.png @copy ..\..\media\log_el\trunk\tl_sys_16.png bin\tl_sys_16.png +if not exist bin\tl_nod_16.png @copy ..\t_edit\tl_nod_16.png bin\tl_nod_16.png @fasm.exe -m 16384 te_syntax.asm bin\te_syntax.kex @kpack bin\te_syntax.kex -..\t_edit\info\build.bat ..\t_edit\info\ bin\info\ pause \ No newline at end of file diff --git a/programs/other/t_edit_synt/te_data.inc b/programs/other/t_edit_synt/te_data.inc index 00128f22bf..cdb4a0ee7d 100644 --- a/programs/other/t_edit_synt/te_data.inc +++ b/programs/other/t_edit_synt/te_data.inc @@ -2,27 +2,25 @@ fn_col_option dd def_col_file fn_syntax_dir db 'info/',0 def_col_file db 'default.syn',0 -system_dir0 db '/sys/lib/' -boxlib_name db 'box_lib.obj',0 +system_dir_0 db '/sys/lib/' +lib_name_0 db 'box_lib.obj',0 -fn_icon_tl_sys db 'tl_sys_16.bmp',0 -fn_icon_tl_nod db 'tl_nod_16.bmp',0 +system_dir_1 db '/sys/lib/' +lib_name_1 db 'libimg.obj',0 ;--------------------------------------------------------------------- align 4 -boxlib_import: +import_box_lib: dd alib_init2 ;функция запускается макросом 1 раз при подключении бибилиотеки, потому в программе метка на нее не нужна edit_box_draw dd aEdit_box_draw edit_box_key dd aEdit_box_key edit_box_mouse dd aEdit_box_mouse -version_ed dd aVersion_ed scrollbar_ver_draw dd aScrollbar_ver_draw scrollbar_ver_mouse dd aScrollbar_ver_mouse scrollbar_hor_draw dd aScrollbar_hor_draw scrollbar_hor_mouse dd aScrollbar_hor_mouse -version_scrollbar dd aVersion_scrollbar tl_data_init dd sz_tl_data_init tl_data_clear dd sz_tl_data_clear @@ -46,7 +44,6 @@ tl_node_move_down dd sz_tl_node_move_down tl_save_mem dd sz_tl_save_mem tl_load_mem dd sz_tl_load_mem -ted_but_save_file dd sz_ted_but_save_file ted_but_sumb_upper dd sz_ted_but_sumb_upper ted_but_sumb_lover dd sz_ted_but_sumb_lover ted_can_save dd sz_ted_can_save @@ -60,6 +57,7 @@ ted_is_select dd sz_ted_is_select ted_key dd sz_ted_key ted_mouse dd sz_ted_mouse ted_open_file dd sz_ted_open_file +ted_save_file dd sz_ted_save_file ted_text_add dd sz_ted_text_add ted_but_select_word dd sz_ted_but_select_word ted_but_cut dd sz_ted_but_cut @@ -70,11 +68,9 @@ ted_but_redo dd sz_ted_but_redo ted_but_reverse dd sz_ted_but_reverse ted_but_find_next dd sz_ted_but_find_next ted_text_colored dd sz_ted_text_colored -;version_text_edit dd sz_ted_version PathShow_prepare dd sz_PathShow_prepare PathShow_draw dd sz_PathShow_draw -;Version_path_show dd szVersion_path_show dd 0,0 alib_init2 db 'lib_init',0 @@ -82,13 +78,11 @@ alib_init2 db 'lib_init',0 aEdit_box_draw db 'edit_box',0 aEdit_box_key db 'edit_box_key',0 aEdit_box_mouse db 'edit_box_mouse',0 -aVersion_ed db 'version_ed',0 aScrollbar_ver_draw db 'scrollbar_v_draw',0 aScrollbar_ver_mouse db 'scrollbar_v_mouse',0 aScrollbar_hor_draw db 'scrollbar_h_draw',0 aScrollbar_hor_mouse db 'scrollbar_h_mouse',0 -aVersion_scrollbar db 'version_scrollbar',0 sz_tl_data_init db 'tl_data_init',0 sz_tl_data_clear db 'tl_data_clear',0 @@ -112,7 +106,6 @@ sz_tl_node_move_down db 'tl_node_move_down',0 sz_tl_save_mem db 'tl_save_mem',0 sz_tl_load_mem db 'tl_load_mem',0 -sz_ted_but_save_file db 'ted_but_save_file',0 sz_ted_but_sumb_upper db 'ted_but_sumb_upper',0 sz_ted_but_sumb_lover db 'ted_but_sumb_lover',0 sz_ted_can_save db 'ted_can_save',0 @@ -126,6 +119,7 @@ sz_ted_is_select db 'ted_is_select',0 sz_ted_key db 'ted_key',0 sz_ted_mouse db 'ted_mouse',0 sz_ted_open_file db 'ted_open_file',0 +sz_ted_save_file db 'ted_save_file',0 sz_ted_text_add db 'ted_text_add',0 sz_ted_but_select_word db 'ted_but_select_word',0 sz_ted_but_cut db 'ted_but_cut',0 @@ -136,12 +130,22 @@ sz_ted_but_redo db 'ted_but_redo',0 sz_ted_but_reverse db 'ted_but_reverse',0 sz_ted_but_find_next db 'ted_but_find_next',0 sz_ted_text_colored db 'ted_text_colored',0 -;sz_ted_version db 'version_text_edit',0 sz_PathShow_prepare db 'PathShow_prepare',0 sz_PathShow_draw db 'PathShow_draw',0 -;szVersion_path_show db 'version_PathShow',0 -;--------------------------------------------------------------------- + +align 4 +import_libimg: + dd alib_init1 + img_to_rgb2 dd aimg_to_rgb2 + img_decode dd aimg_decode + img_destroy dd aimg_destroy +dd 0,0 + alib_init1 db 'lib_init',0 + aimg_to_rgb2 db 'img_to_rgb2',0 + aimg_decode db 'img_decode',0 ;автоматически определяет формат графических данных + aimg_destroy db 'img_destroy',0 + ;--------------------------------------------------------------------- align 4 ws_dir_lbox: ;дочерний скроллинг для элемента ListBox .x: diff --git a/programs/other/t_edit_synt/te_syntax.asm b/programs/other/t_edit_synt/te_syntax.asm index 5e49fa2b2f..e1302f548d 100644 --- a/programs/other/t_edit_synt/te_syntax.asm +++ b/programs/other/t_edit_synt/te_syntax.asm @@ -18,11 +18,58 @@ include '../../macros.inc' include '../../proc32.inc' include '../../develop/libraries/box_lib/load_lib.mac' include '../../develop/libraries/box_lib/trunk/box_lib.mac' -include '../t_edit/mem.inc' +include '../../dll.inc' include 'te_data.inc' include 'te_work.inc' ;text work functions -@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,0 +@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load + +;Макрос для загрузки изображений с использованием библиотеки libimg.obj +;для использования макроса нужны переменные: +; - run_file_70 FileInfoBlock +; - image_data dd 0 +macro load_image_file path,buf,size +{ + ;path - может быть переменной или строковым параметром + if path eqtype '' ;проверяем задан ли строкой параметр path + jmp @f + local .path_str + .path_str db path ;формируем локальную переменную + db 0 + @@: + ;32 - стандартный адрес по которому должен быть буфер с системным путем + copy_path .path_str,[32],file_name,0x0 + else + copy_path path,[32],file_name,0x0 ;формируем полный путь к файлу изображения, подразумеваем что он в одной папке с программой + end if + + stdcall mem.Alloc, dword size ;выделяем память для изображения + mov [buf],eax + + mov eax,70 ;70-я функция работа с файлами + mov [run_file_70.Function], 0 + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + mov [run_file_70.Count], dword size + m2m [run_file_70.Buffer], [buf] + mov byte[run_file_70+20], 0 + mov [run_file_70.FileName], file_name + mov ebx,run_file_70 + int 0x40 ;загружаем файл изображения + cmp ebx,0xffffffff + je @f + ;определяем вид изображения и переводим его во временный буфер image_data + stdcall dword[img_decode], dword[buf],ebx,0 + mov dword[image_data],eax + ;преобразуем изображение к формату rgb + stdcall dword[img_to_rgb2], dword[image_data],dword[buf] + ;удаляем временный буфер image_data + stdcall dword[img_destroy], dword[image_data] + @@: +} + +image_data dd 0 ;указатель на временную память. для нужен преобразования изображения +icon_tl_sys dd 0 ;указатель на память для хранения системных иконок align 4 start: @@ -53,51 +100,17 @@ load_libraries l_libs_start,load_lib_end @@: ;--------------------------------------------------------------------- - stdcall dword[tl_data_init],dword tree1 - copy_path fn_icon_tl_sys,sys_path,file_name,0 + stdcall dword[tl_data_init],dword tree1 - mov ecx,3*256*13 - stdcall mem.Alloc,ecx - mov dword[tree1.data_img_sys],eax - - mov [run_file_70.Function], 0 - mov [run_file_70.Position], 54 - mov [run_file_70.Flags], 0 - mov [run_file_70.Count], ecx - mov [run_file_70.Buffer], eax - mov byte[run_file_70+20], 0 - mov [run_file_70.FileName], file_name - - mov eax,70 ;load icon file - mov ebx,run_file_70 - int 0x40 - cmp ebx,0 - jg @f - mov dword[tree1.data_img_sys],0 - @@: +; читаем файл с курсорами и линиями + load_image_file 'tl_sys_16.png', icon_tl_sys,54+3*256*13 + mov eax,dword[icon_tl_sys] + mov dword[tree1.data_img_sys],eax ;--------------------------------------------------------------------- ; читаем bmp файл с иконками узлов - copy_path fn_icon_tl_nod,sys_path,file_name,0 - - mov ecx,3*256*2 - stdcall mem.Alloc,ecx - mov dword[tree1.data_img],eax - -; mov [run_file_70.Function], 0 -; mov [run_file_70.Position], 54 -; mov [run_file_70.Flags], 0 - mov [run_file_70.Count], ecx - mov [run_file_70.Buffer], eax -; mov byte[run_file_70+20], 0 -; mov [run_file_70.FileName], file_name - - mov eax,70 ;load icon file - mov ebx,run_file_70 - int 0x40 - cmp ebx,0 - jg @f - mov dword[tree1.data_img],0 - @@: + load_image_file 'tl_nod_16.png', icon_tl_sys,54+3*256*2 + mov eax,dword[icon_tl_sys] + mov dword[tree1.data_img],eax ;------------------------------------------------------------------------------ copy_path fn_syntax_dir,sys_path,file_name,0 ;берем путь к папке с файлами синтаксиса mov eax,70 @@ -324,7 +337,7 @@ but_OpenSyntax: align 4 but_SaveSyntax: - stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text] + stdcall [ted_save_file], tedit0,run_file_70,[edit1.text] ret align 4 @@ -365,7 +378,7 @@ get_wnd_in_focus: ;@@: ret -hed db 'TextEditor syntax file converter 23.06.12',0 ;подпись окна +hed db 'TextEditor syntax file converter 01.07.14',0 ;подпись окна conv_tabl rb 128 ; таблица для конвертирования scan-кода в ascii-код txt122 db 'Загр. файл',0 @@ -373,15 +386,19 @@ txt148 db ' txt_inp_file db 'Исх. файл:',0 txt_out_file db 'Вых. файл:',0 -err_message_found_lib0 db 'Sorry I cannot found library box_lib.obj',0 -head_f_i0: -head_f_l0 db 'System error',0 -err_message_import0 db 'Error on load import library box_lib.obj',0 -err_message_found_lib1 db 'Sorry I cannot found library msgbox.obj',0 +txt_no_kpack db 'Открываемый файл сжат Kpack-ом.',13,10,'Для работы с файлом распакуйте его используя системную программу Kpack.',13,10,'Работа со сжатыми файлами пока не поддерживается.',0 + +head_f_i: +head_f_l db 'System error',0 +err_message_found_lib_0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0 +err_message_import_0 db 'Error on load import library ',39,'box_lib.obj',39,0 +err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,0 +err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,0 ;library structures l_libs_start: - lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, boxlib_import,err_message_import0, head_f_i0 + 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 + 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 load_lib_end: diff --git a/programs/other/t_edit_synt/te_work.inc b/programs/other/t_edit_synt/te_work.inc index d411a29b26..8244fb04d7 100644 --- a/programs/other/t_edit_synt/te_work.inc +++ b/programs/other/t_edit_synt/te_work.inc @@ -50,18 +50,18 @@ InitColText: copy_path ebx,fn_syntax_dir,file_name_rez,0 copy_path file_name_rez,sys_path,file_name,0 - mov eax,70 - mov [run_file_70.Function], 0 - mov [run_file_70.Position], 0 - mov [run_file_70.Flags], 0 - mov ebx,[options_file_end] - sub ebx,[options_file] - mov [run_file_70.Count], ebx - m2m [run_file_70.Buffer], [options_file] - mov byte[run_file_70+20], 0 - mov [run_file_70.FileName], file_name - mov ebx,run_file_70 - int 0x40 + mov eax,70 + mov [run_file_70.Function], 0 + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + mov ebx,[options_file_end] + sub ebx,[options_file] + mov [run_file_70.Count], ebx + m2m [run_file_70.Buffer], [options_file] + mov byte[run_file_70+20], 0 + mov [run_file_70.FileName], file_name + mov ebx,run_file_70 + int 0x40 ;init: count_colors_text, ColWords, ... @@ -83,6 +83,11 @@ InitColText: @@: mov esi,[options_file] + cmp dword[esi],'KPCK' + jne @f + notify_window_run txt_no_kpack ; ёючфрхь юъэю @notify + jmp .no_colors + @@: mov edi,count_colors_text mov ecx,9*4 rep movsb