diff --git a/programs/develop/libraries/box_lib/trunk/box_lib.asm b/programs/develop/libraries/box_lib/trunk/box_lib.asm index 207871afe6..01ae74af44 100644 --- a/programs/develop/libraries/box_lib/trunk/box_lib.asm +++ b/programs/develop/libraries/box_lib/trunk/box_lib.asm @@ -311,9 +311,9 @@ dd sz_PathShow_prepare, path_show.prepare dd sz_PathShow_draw, path_show.draw dd szVersion_path_show, 0x00010001 -dd sz_ted_but_save_file, ted_but_save_file dd sz_ted_but_sumb_upper, ted_but_sumb_upper dd sz_ted_but_sumb_lover, ted_but_sumb_lover +dd sz_ted_but_convert_by_table, ted_but_convert_by_table dd sz_ted_can_save, ted_can_save dd sz_ted_clear, ted_clear dd sz_ted_delete, ted_delete @@ -325,6 +325,7 @@ dd sz_ted_is_select, ted_is_select dd sz_ted_key, ted_key dd sz_ted_mouse, ted_mouse dd sz_ted_open_file, ted_open_file +dd sz_ted_save_file, ted_save_file dd sz_ted_text_add, ted_text_add dd sz_ted_but_select_word, ted_but_select_word dd sz_ted_but_cut, ted_but_cut @@ -335,7 +336,7 @@ dd sz_ted_but_redo, ted_but_redo dd sz_ted_but_reverse, ted_but_reverse dd sz_ted_but_find_next, ted_but_find_next dd sz_ted_text_colored, ted_text_colored -dd sz_ted_version, 0x00000003 +dd sz_ted_version, 0x00000004 dd sz_Frame_draw, frame.draw dd szVersion_frame, 0x00010001 @@ -416,9 +417,9 @@ sz_PathShow_prepare db 'PathShow_prepare',0 sz_PathShow_draw db 'PathShow_draw',0 szVersion_path_show db 'version_PathShow',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_but_convert_by_table db 'ted_but_convert_by_table',0 sz_ted_can_save db 'ted_can_save',0 sz_ted_clear db 'ted_clear',0 sz_ted_delete db 'ted_delete',0 @@ -430,6 +431,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 diff --git a/programs/develop/libraries/box_lib/trunk/t_edit.mac b/programs/develop/libraries/box_lib/trunk/t_edit.mac index 2fff4b47ed..06e7246da5 100644 --- a/programs/develop/libraries/box_lib/trunk/t_edit.mac +++ b/programs/develop/libraries/box_lib/trunk/t_edit.mac @@ -1,6 +1,6 @@ ; макрос для системной библиотеки box_lib.obj ; элемент TextEditor для Kolibri OS -; файл последний раз изменялся 18.11.2013 IgorA +; файл последний раз изменялся 27.11.2013 IgorA ; на код применена GPL2 лицензия ;input: @@ -1264,6 +1264,38 @@ ted_char_add: call ted_text_colored ret +;description: +; функция для смены кодировок +;input: +; table - таблица для перекодировки +align 4 +proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword + mov edi,dword[edit] + mov esi,dword[table] + mov edx,ted_tex + .cycle: + ;переходим на следующий символ + mov edx,dword[edx+6] + cmp edx,1 + jle .end_text + imul edx,sizeof.symbol + add edx,ted_tex + + movzx eax,byte[edx] + add eax,esi + mov al,byte[eax] + cmp al,0 + je @f + mov byte[edx],al ;меняем кодировку символа + @@: + jmp .cycle + .end_text: + ;cmp esi,0 + ;je @f + stdcall ted_draw,edi ;обновляем окно + ;@@: + ret +endp ;input: ; edi = pointer to tedit struct @@ -4038,7 +4070,7 @@ ted_wnd_main_mouse_scroll: ret align 4 -proc ted_but_save_file, edit:dword, file:dword, f_name:dword +proc ted_save_file, edit:dword, file:dword, f_name:dword pushad mov edi,dword[edit] diff --git a/programs/other/t_edit/t_button.inc b/programs/other/t_edit/t_button.inc index 6b2da27c1a..6c3f1544dc 100644 --- a/programs/other/t_edit/t_button.inc +++ b/programs/other/t_edit/t_button.inc @@ -63,7 +63,7 @@ On_SaveAndNewFile: push edi mov edi, tedit0 - stdcall [ted_but_save_file],edi,run_file_70,[edit1.text] + call ted_but_save_file cmp ted_err_save,0 jne @f call On_NewFile @@ -76,7 +76,7 @@ On_SaveAndNewFile: align 4 but_no_msg_OpenFile: push eax ebx - stdcall [ted_open_file], tedit0,run_file_70,[edit1.text] + stdcall [ted_open_file], tedit0,run_file_70,openfile_path call ted_messages_after_open_file pop ebx eax ret @@ -115,20 +115,19 @@ ted_but_open_file: @@: cmp [OpenDialog_data.status],1 jne .ret_f - mov esi,[OpenDialog_data.openfile_path] - call strlen - mov [edit1.size],eax - mov [edit1.pos],eax - stdcall [edit_box_draw], edit1 + stdcall [PathShow_prepare], PathShow_data_1 + stdcall [PathShow_draw], PathShow_data_1 ;ищем есть ли файл подсветки для открываемого текстового файла - mov edx,[edit1.text] + mov esi,[OpenDialog_data.openfile_path] + call strlen + mov edx,openfile_path add edx,eax .f_beg: cmp byte[edx],'.' je .found dec edx - cmp edx,[edit1.text] + cmp edx,openfile_path jg .f_beg .found: inc edx ;edx - указатель на расширение открытого файла @@ -150,13 +149,29 @@ ted_but_open_file: call open_unpac_synt_file .end_0: - stdcall [ted_open_file], tedit0,run_file_70,[edit1.text] + stdcall [ted_open_file], tedit0,run_file_70,openfile_path call ted_messages_after_open_file .ret_f: popad ret +;description: +; функция сохранения файла с вызовом окна диалога +align 4 +proc ted_but_save_file + ;*** вызов диалогового окна для сохранения файла + copy_path open_dialog_name,communication_area_default_path,file_name,0 + mov [OpenDialog_data.type],1 + stdcall [OpenDialog_Start],OpenDialog_data + cmp [OpenDialog_data.status],1 ;if status==1 then save + jne .end_save_file + stdcall [PathShow_prepare], PathShow_data_1 + stdcall [ted_save_file],tedit0,run_file_70,openfile_path + .end_save_file: + ret +endp + ;description: ; копирование памяти align 4 @@ -216,6 +231,7 @@ ted_messages_after_open_file: jl .ret_f stdcall [mb_create],msgbox_1,thread .ret_f: + stdcall [PathShow_prepare], PathShow_data_1 pop edi ecx ret @@ -265,8 +281,8 @@ push eax edi esi cld rep movsb - copy_path ebx,fn_syntax_dir,file_name_rez,0 - copy_path file_name_rez,sys_path,file_name,0 + copy_path ebx,fn_syntax_dir,syntax_path,0 + copy_path syntax_path,sys_path,file_name,0 mov edi, tedit0 mov [run_file_70.Function], 0 mov [run_file_70.Position], 0 @@ -308,25 +324,47 @@ pop esi edi eax ;description: ; вызов/скрытие панели поиска align 4 -proc ted_but_find - push edi - mov edi,tedit0 +proc ted_but_find uses edi + mov edi,tedit0 - cmp ted_panel_id,TED_PANEL_NULL - je @f - mov ted_panel_id,TED_PANEL_NULL - mov ted_wnd_l,0 - jmp .e_if - @@: - mov ted_panel_id,TED_PANEL_FIND - mov ted_wnd_l,TED_PANEL_WIDTH - .e_if: - call EvSize - stdcall [ted_draw],edi - pop edi - ret + cmp ted_panel_id,TED_PANEL_NULL + je @f + mov ted_panel_id,TED_PANEL_NULL + mov ted_wnd_l,0 + jmp .e_if + @@: + mov ted_panel_id,TED_PANEL_FIND + mov ted_wnd_l,TED_PANEL_WIDTH + .e_if: + call EvSize + stdcall [ted_draw],edi + ret endp +align 4 +tbl_1251_866: +rb 128 +db 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0 ;128 +db 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0 ;144 +db 0, 0, 0, 0, 0, 0, 0, 0,240,0,0,0,0,0,0,0 ;160 +db 0, 0, 0, 0, 0, 0, 0, 0,241,0,0,0,0,0,0,0 ;176 +db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143 ;192 +db 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159 ;208 +db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175 ;224 +db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239 ;240 + +align 4 +tbl_866_1251: +rb 128 +db 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207 ;128 +db 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223 ;144 +db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239 ;160 +db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;176 +db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;192 +db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;208 +db 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 ;224 +db 168,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;240 + align 4 ted_on_find_err: stdcall [mb_create],msgbox_7,thread ;message: Can not find text diff --git a/programs/other/t_edit/t_data.inc b/programs/other/t_edit/t_data.inc index 9a16941a68..d68f45c5a0 100644 --- a/programs/other/t_edit/t_data.inc +++ b/programs/other/t_edit/t_data.inc @@ -95,9 +95,9 @@ import_box_lib: tl_node_lev_inc dd sz_tl_node_lev_inc tl_node_lev_dec dd sz_tl_node_lev_dec - 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_but_convert_by_table dd sz_ted_but_convert_by_table ted_can_save dd sz_ted_can_save ted_clear dd sz_ted_clear ted_delete dd sz_ted_delete @@ -109,6 +109,7 @@ import_box_lib: 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 @@ -121,6 +122,9 @@ import_box_lib: 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 + dd 0,0 alib_init0 db 'lib_init',0 @@ -163,9 +167,9 @@ dd 0,0 sz_tl_node_lev_inc db 'tl_node_lev_inc',0 sz_tl_node_lev_dec db 'tl_node_lev_dec',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_but_convert_by_table db 'ted_but_convert_by_table',0 sz_ted_can_save db 'ted_can_save',0 sz_ted_clear db 'ted_clear',0 sz_ted_delete db 'ted_delete',0 @@ -177,6 +181,7 @@ dd 0,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 @@ -189,6 +194,9 @@ dd 0,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 + align 4 import_proclib: OpenDialog_Init dd aOpenDialog_Init @@ -486,7 +494,7 @@ tree_file_struct: if lang eq ru -hed db 'Текстовый редактор 14.11.13',0 ;подпись окна +hed db 'Текстовый редактор 28.11.13',0 ;подпись окна menu_text_area: db 'Файл',0 @@ -580,14 +588,6 @@ msgbox_9: db 0 db 'Закрыть',0 db 0 -msgbox_10: - db 1,0 - db 'Внимание',0 - db 'Вы используете старую версию библиотеки ',39,'box_lib.obj',39,'.',13,\ - 'Попробуйте найти библиотеку в которой',13,\ - 'элемент ',39,'t_edit',39,' имеет версию 3.',0 - db 'Закрыть',0 - db 0 txtFile db 'Файл:',0 txtFindCapt db 'Поиск',0 @@ -597,7 +597,7 @@ txtFormatApply db ' else -hed db 'Text editor 14.11.13',0 +hed db 'Text editor 28.11.13',0 menu_text_area: db 'File',0 @@ -691,14 +691,6 @@ msgbox_9: db 0 db 'Close',0 db 0 -msgbox_10: - db 1,0 - db 'Warning',0 - db 'You are using an older version of the library ',39,'box_lib.obj',39,'.',13,\ - 'Try to find a library in which the element',13,\ - 39,'t_edit',39,' has a version 3.',13,0 - db 'Close',0 - db 0 txtFile db 'File:',0 txtFindCapt db 'Search',0 diff --git a/programs/other/t_edit/t_draw.inc b/programs/other/t_edit/t_draw.inc index 95469bd64a..1279f117b1 100644 --- a/programs/other/t_edit/t_draw.inc +++ b/programs/other/t_edit/t_draw.inc @@ -94,20 +94,28 @@ and ecx,0xffff call draw_but_icon or ecx,0x40000000 - inc cx - mov edx,400*65536+25 - call draw_but_icon + inc cx + mov edx,400*65536+25 + call draw_but_icon - inc cx - mov edx,425*65536+25 - call draw_but_icon + inc cx + mov edx,425*65536+25 + call draw_but_icon - mov cx,17 - mov edx,450*65536+25 - call draw_but_icon + mov cx,17 ;т√сюЁ Їрщыр яюфётхЄъш + mov edx,450*65536+25 + call draw_but_icon - popad - ret + mov cx,18 ;cp 1251 -> 866 + mov edx,425*65536+2 + call draw_but_icon + + mov cx,19 ;cp 866 -> 1251 + mov edx,450*65536+2 + call draw_but_icon + + popad + ret ;txtBUp db 24 ;txtBDn db 25 @@ -332,7 +340,7 @@ draw_but_icon: cmp eax,7 jne @f ;ъэюяър эх тыхчыр т юъэю mov ebx,[bmp_icon] - bt ecx,30 ;if (ecx or 0x40000000) + bt ecx,30 ;if (ecx & 0x40000000) jc .gray add ebx,TOOLBAR_ICONS_SIZE ;яхЁхьх∙рхьё  эр ёхЁ√х ъэюяъш .gray: diff --git a/programs/other/t_edit/t_edit.asm b/programs/other/t_edit/t_edit.asm index 5c3d112c31..4ebd92ff4b 100644 --- a/programs/other/t_edit/t_edit.asm +++ b/programs/other/t_edit/t_edit.asm @@ -1,7 +1,4 @@ -;Огромная благодарность Maxxxx32, Diamond, Heavyiron -;и другим программистам, а также -;Теплову Алексею ( www.lrz.land.ru) - +;Огромная благодарность всем, кто помогал: кодом/советом/дизайном ... use32 org 0x0 @@ -18,7 +15,7 @@ MAX_COLOR_WORD_LEN equ 40 maxChars equ 100002 ;(...+2) BUF_SIZE equ 4096 ;buffer for copy|paste maxSyntaxFileSize equ 410000 -TOOLBAR_ICONS_SIZE equ 1200*18 +TOOLBAR_ICONS_SIZE equ 1200*20 include '../../proc32.inc' ;include '../../config.inc' @@ -88,41 +85,34 @@ icon_tl_sys dd 0 ;ука align 4 start: - mcall 48,3,sc,sizeof.system_colors + mcall 48,3,sc,sizeof.system_colors - mcall 68,11 - or eax,eax - jz button.exit + mcall 68,11 + or eax,eax + jz button.exit - mcall 66,1,1 ;scan code - mcall 40,0xC0000027 + mcall 66,1,1 ;scan code + mcall 40,0xC0000027 - mov esi,file_name - call strlen - mov ecx,eax - mov edi,openfile_path - cld - rep movsb ;копируем имя файла в буфер edit1 + mov esi,file_name + call strlen + mov ecx,eax + mov edi,openfile_path + cld + rep movsb ;копируем имя файла в буфер openfile_path load_libraries l_libs_start,load_lib_end ;проверка на сколько удачно загузились библиотеки - mov ebp,lib0 +mov ebp,lib0 +.test_lib_open: cmp dword [ebp+ll_struc_size-4],0 jz @f mcall -1 ;exit not correct @@: - mov ebp,lib1 ; - cmp dword [ebp+ll_struc_size-4],0 - jz @f - mcall -1 ;exit not correct -@@: - - cmp dword[version_text_edit],3 - jge @f - stdcall [mb_create],msgbox_10,thread - mcall -1 - @@: + add ebp,ll_struc_size + cmp ebp,load_lib_end + jl .test_lib_open ;--------------------------------------------------------------------- stdcall [ted_init], tedit0 @@ -130,6 +120,10 @@ load_libraries l_libs_start,load_lib_end ; OpenDialog initialisation stdcall [OpenDialog_Init],OpenDialog_data + mov eax,[sc.work_button_text] + mov [PathShow_data_1.font_color],eax + mov eax,[sc.work_button] + mov [PathShow_data_1.background_color],eax ; init toolbar file load_image_file 'te_icon.png', bmp_icon,TOOLBAR_ICONS_SIZE*2 ;умножение на 2 для серых кнопок @@ -223,7 +217,6 @@ mov ecx,ebx je @f ;if file names exist mov esi,openfile_path call strlen ;eax=strlen - mov [edit1.size],eax call but_no_msg_OpenFile @@: @@ -276,23 +269,18 @@ draw_window: mov edx,txtFile int 0x40 - stdcall [edit_box_draw], dword edit1 - stdcall [menu_bar_draw], dword menu_data_1 + stdcall [PathShow_draw], dword PathShow_data_1 + stdcall [menu_bar_draw], dword menu_data_1 - call draw_but_toolbar + call draw_but_toolbar - stdcall [ted_draw], tedit0 + stdcall [ted_draw], tedit0 - mcall 12,2 - ret + mcall 12,2 + ret align 4 mouse: - stdcall [edit_box_mouse], dword edit1 - - test word [edit1.flags],10b ;ed_focus ;если не в фокусе, выходим - jne still - stdcall [ted_mouse], tedit0 cmp byte[tedit0.panel_id],TED_PANEL_FIND ;if not panel @@ -313,7 +301,7 @@ mouse: je button.exit cmp dword[menu_data_1.cursor_out],3 jne @f - stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text] + call ted_but_save_file @@: cmp dword[menu_data_1.cursor_out],2 jne @f @@ -369,26 +357,6 @@ key: mcall 2 ;получаем код нажатой клавиши stdcall [tl_key], tree1 - test word [edit1.flags],10b;ed_focus ; если не в фокусе, выходим - je @f - cmp ah,0x80 ;if key up - ja still - cmp ah,42 ;[Shift] (left) - je still - cmp ah,54 ;[Shift] (right) - je still - cmp ah,56 ;[Alt] - je still - cmp ah,29 ;[Ctrl] - je still - cmp ah,69 ;[Pause Break] - je still - - stdcall KeyConvertToASCII, dword conv_tabl - stdcall [edit_box_key], dword edit1 - jmp still - @@: - test word [edit2.flags],10b;ed_focus ; если не в фокусе, выходим je @f cmp ah,0x80 ;if key up @@ -431,7 +399,7 @@ button: @@: cmp ah,5 jne @f - stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text] + call ted_but_save_file @@: cmp ah,6 jne @f @@ -493,6 +461,14 @@ button: jne @f stdcall but_synt_show, tedit0 @@: + cmp ah,21 + jne @f + stdcall [ted_but_convert_by_table],tedit0,tbl_1251_866 + @@: + cmp ah,22 + jne @f + stdcall [ted_but_convert_by_table],tedit0,tbl_866_1251 + @@: cmp ah,200 jne @f @@ -522,8 +498,20 @@ button: stdcall dword[tl_data_clear], tree1 mcall -1 ;выход из программы +PathShow_data_1: +.type dd 0 ;+0 +.start_y dw 9 ;+4 +.start_x dw 222 ;+6 +.font_size_x dw 6 ;+8 ; 6 - for font 0, 8 - for font 1 +.area_size_x dw 200 ;+10 +.font_number dd 0 ;+12 ; 0 - monospace, 1 - variable +.background_flag dd 1 ;+16 +.font_color dd 0x0 ;+20 +.background_color dd 0xffffff ;+24 +.text_pointer dd openfile_path ;+28 +.work_area_pointer dd text_work_area ;+32 +.temp_text_length dd 0 ;+36 -edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 4090, openfile_path, mouse_dd, 0 edit2 edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0 unpac_mem dd 0 @@ -587,17 +575,19 @@ IncludeUGlobals thread_coords: rb 1024 stacktop: - sys_path: + sys_path: ;путь откуда запустился исполняемый файл rb 4096 - file_name: + file_name: ;параметры запуска rb 4096 - file_name_rez: + syntax_path: ;имя подключаемого файла синтаксиса rb 4096 plugin_path: rb 4096 - openfile_path: + openfile_path: ;полный путь к файлу с которым идет работа rb 4096 - filename_area: + text_work_area: ;путь к файлу, который показывается в окне + rb 4096 + filename_area: ;имя файла для диалога открытия/закрытия rb 256 file_info: rb 40 diff --git a/programs/other/t_edit/te_icon.png b/programs/other/t_edit/te_icon.png index 30afc6fe49..c5c894bc24 100644 Binary files a/programs/other/t_edit/te_icon.png and b/programs/other/t_edit/te_icon.png differ