diff --git a/programs/other/t_edit/build.bat b/programs/other/t_edit/build.bat new file mode 100644 index 0000000000..bf5b11b5d4 --- /dev/null +++ b/programs/other/t_edit/build.bat @@ -0,0 +1,13 @@ +if not exist bin mkdir bin +@fasm.exe -m 16384 ..\..\develop\libraries\box_lib\trunk\box_lib.asm bin\box_lib.obj +@kpack bin\box_lib.obj + +@fasm.exe -m 16384 t_edit.asm bin\t_edit.kex +@kpack bin\t_edit.kex +@copy ..\..\develop\libraries\box_lib\trunk\tl_sys_16.bmp bin\tl_sys_16.bmp +@copy ..\..\develop\libraries\box_lib\trunk\tl_nod_16.bmp bin\tl_nod_16.bmp +@copy msgbox.obj bin\msgbox.obj +@copy te_icon.bmp bin\te_icon.bmp +if not exist bin\info mkdir bin\info +copy info\* bin\info\* +pause \ No newline at end of file diff --git a/programs/other/t_edit/info/asm.syn b/programs/other/t_edit/info/asm.syn new file mode 100644 index 0000000000..a9e91a26a8 Binary files /dev/null and b/programs/other/t_edit/info/asm.syn differ diff --git a/programs/other/t_edit/info/cpp_kol_cla.syn b/programs/other/t_edit/info/cpp_kol_cla.syn new file mode 100644 index 0000000000..bd6f13d21e Binary files /dev/null and b/programs/other/t_edit/info/cpp_kol_cla.syn differ diff --git a/programs/other/t_edit/info/cpp_kol_dar.syn b/programs/other/t_edit/info/cpp_kol_dar.syn new file mode 100644 index 0000000000..5acfef7fe8 Binary files /dev/null and b/programs/other/t_edit/info/cpp_kol_dar.syn differ diff --git a/programs/other/t_edit/info/cpp_kol_def.syn b/programs/other/t_edit/info/cpp_kol_def.syn new file mode 100644 index 0000000000..5bca205e57 Binary files /dev/null and b/programs/other/t_edit/info/cpp_kol_def.syn differ diff --git a/programs/other/t_edit/info/cpp_win_dar.syn b/programs/other/t_edit/info/cpp_win_dar.syn new file mode 100644 index 0000000000..f7a2e46385 Binary files /dev/null and b/programs/other/t_edit/info/cpp_win_dar.syn differ diff --git a/programs/other/t_edit/info/default.syn b/programs/other/t_edit/info/default.syn new file mode 100644 index 0000000000..b391ed74c7 Binary files /dev/null and b/programs/other/t_edit/info/default.syn differ diff --git a/programs/other/t_edit/info/html.syn b/programs/other/t_edit/info/html.syn new file mode 100644 index 0000000000..afa705483c Binary files /dev/null and b/programs/other/t_edit/info/html.syn differ diff --git a/programs/other/t_edit/info/voc_eng_rus.syn b/programs/other/t_edit/info/voc_eng_rus.syn new file mode 100644 index 0000000000..0a8c50d337 Binary files /dev/null and b/programs/other/t_edit/info/voc_eng_rus.syn differ diff --git a/programs/other/t_edit/info/win_const.syn b/programs/other/t_edit/info/win_const.syn new file mode 100644 index 0000000000..d66f53e5a5 Binary files /dev/null and b/programs/other/t_edit/info/win_const.syn differ diff --git a/programs/other/t_edit/load_lib.mac b/programs/other/t_edit/load_lib.mac new file mode 100644 index 0000000000..bda5c92e2e --- /dev/null +++ b/programs/other/t_edit/load_lib.mac @@ -0,0 +1,634 @@ +;08.05.2009 - bugfix +;14.04.2009 - a macros for code load library the box_lib.obj from '/sys/lib/' or current dirrectory. +; The macros for load any library/libraries: +; Copyright (c) 2009, +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions are met: +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; * Neither the name of the nor the +; names of its contributors may be used to endorse or promote products +; derived from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka ''AS IS'' AND ANY +; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;***************************************************************************** +; This macros based on source code: +; - Alexey Teplov / Алексей Теплов +; Mario79, Mario - Marat Zakiyanov / Марат Закиянов +; Diamondz - Evgeny Grechnikov / Евгений Гречников +;------------------------ +; DESCRIPTION +; Macro load_library +; Logick of work. +; A first time we must to check system path, where I belive find a system library. System path is "/sys/lib/". +; If I cannot found my library, i must to check second way. Second way is current dirrectory. +; If we cannot load library, we must show the error message: +; "I'm sorry,the programm cannot found system library box_lib.obj." +; "The find was make on 2 ways: /sys/lib/ and current dirrectory." +; +; +;--------------------------------------------------------------------- +; Macro sys_load_library +; A first time we must to check own path in current dirrectory the program, where I belive find a system library. +; If I cannot found my library, i must to check second way. Second way is system path a "/sys/lib/". +; If we cannot load library, we must show the error message: +; "I'm sorry,the programm cannot found system library box_lib.obj." +; "The find was make on 2 ways: /sys/lib/ and current dirrectory." +; +;--------------------------------------------------------------------- +; How can I use it? +;--------------------------------------------------------------------- +;-Example using single load library +;-universal load library/librarys +;load_library library_name__, cur_dir_path__, library_path__, system_path__, \ +;err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__ +;-if return code =-1 then exit, else normally work +; cmp eax,-1 +; jz exit +;- Well, if you get +; +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +;DATA данные +;Всегда соблюдать последовательность в имени. +;system_path__ db '/sys/lib/' +;library_name__ db 'box_lib.obj',0 +; Если есть желание разъединить, то нужно использовать следующию конструкцию +;system_path__ db '/sys/lib/box_lib.obj',0 +;... любая последовательность других команд и определений. +;library_name__ db 'box_lib.obj',0 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;err_message_found_lib__ db 'Sorry I cannot found library box_lib.obj',0 +;head_f_i__: +;head_f_l__ db 'System error',0 +;err_message_import__ db 'Error on load import library box_lib.obj',0 + +;myimport: +; +;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 +; +;check_box_draw dd aCheck_box_draw +;check_box_mouse dd aCheck_box_mouse +;version_ch dd aVersion_ch +; +;option_box_draw dd aOption_box_draw +;option_box_mouse dd aOption_box_mouse +;version_op dd aVersion_op + +; dd 0 +; dd 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 + +;aCheck_box_draw db 'check_box_draw',0 +;aCheck_box_mouse db 'check_box_mouse',0 +;aVersion_ch db 'version_ch',0 + +;aOption_box_draw db 'option_box_draw',0 +;aOption_box_mouse db 'option_box_mouse',0 +;aVersion_op db 'version_op',0 + +;--------------------------------------------------------------------- +macro @use_library +{ + +local __sc +local lp +local lp1 +local correction +;local end_tr +local exit_ +;/equ +err_message1 equ dword [esp+8] +head1 equ dword [esp+4] + + +__sc.frame equ dword [__sc+0] +__sc.grab equ dword [__sc+4] +__sc.grab_button equ dword [__sc+8] +__sc.grab_button_text equ dword [__sc+12] +__sc.grab_text equ dword [__sc+16] +__sc.work equ dword [__sc+20] +__sc.work_button equ dword [__sc+24] +__sc.work_button_text equ dword [__sc+28] +__sc.work_text equ dword [__sc+32] +__sc.work_graph equ dword [__sc+36] + +;;;;;;;;;;;CALC WIDTH & HIGHT WINDOW & CENTER MONITOR POSITION;;;;;;;;;; +show_err_: +;check memory + push dword [arrea_xx] + pop eax + test eax,eax + jnz @f + + mcall 68,11 + mcall 68,12,4096 + push eax + pop dword [arrea_xx] + + push head1 + pop dword[eax] + + push 0x0 + pop dword[eax+4] + +@@: + mov eax,48 ;get system color + mov ebx,3 + mov ecx,__sc + mov edx,sizeof.system_colors + mcall +;----------------------------------- + xor eax,eax + mov esi,err_message1 + mov ecx,30 +align 4 +lp: add ecx,7 + lodsb + test eax,eax + jnz lp + + push dword [arrea_xx] + pop ebp + +align 4 +@@: add ebp,4 + mov eax,dword [ebp] + + test eax,eax + jnz @b + + push err_message1 + pop dword[ebp] + + mov dword [ebp+4],eax + + mcall 48,5 ;get system window + cmp word[on_x],cx + jae @f; не нужно обновлять + + sub eax,ecx + shl eax,15 + mov ax,cx + mov dword [on_x],eax + +@@: + add word [on_y],12 + sub bx,word [on_y] + shl ebx,15 + mov bx,word [on_y] + mov dword [on_y],ebx + + ret + + +;;;;;;;;;;;DRAW WINDOW;;;;;;;;;;;;;; +align 4 +start__: + mcall 40,0x5 ;set mask on events rewraw window and get id button. +.red_win: +;draw_window: + mcall 12,1 + + xor eax,eax + mov ebp,dword [arrea_xx] ; set point + mov ebx,dword [on_x] + mov ecx,dword [on_y] + mov edx,__sc.work + or edx,0x33000000 + mov esi,__sc.grab_text + xor edi,edi + mov edi,dword [ebp] ;head1 + mcall + + mov ebx,(10*65536+25-12) + add ebp,4 ;inc index + +@@: + mov eax,4 + add bx,12 + mov ecx,__sc.grab_text + or ecx,0x90000000 + mov edx,dword [ebp] ;err_message1 + mcall + + add ebp,4 ;inc index + + mov eax,dword [ebp] + test eax,eax + jnz @b + + mcall 12,2 +align 4 + +.still: ;main loop + mcall 10 ;wait event + dec eax + jz .red_win + sub eax,2 + jnz .still ;go to main loop +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +.button: + mcall 17 ;get id button + test ah,ah ;if in ah 0, then go to still + jz .still + mcall -1 + ret + +align 4 +__sc system_colors +on_x dd 0x0 +on_y dd 0x0000004E +arrea_xx dd 0x0 +rb 0x50 +end_tr: + +;--------------------------------------------------------------------- +@library_name equ dword [esp+12] +@cur_dir_path equ dword [esp+8] +@library_path equ dword [esp+4] + +align 4 +@copy_path: + mov ebx,@library_name + mov esi,@cur_dir_path + mov edi,@library_path + + xor eax,eax + cld +.lp1: + lodsb + stosb + test eax,eax + jnz .lp1 + mov esi,edi + + std +.lp2: + lodsb + cmp al,'/' + jnz .lp2 + mov edi,esi + mov esi,ebx + add edi,2 + + + cld +.lp3: + lodsb + stosb + test eax,eax + jnz .lp3 +;--------------------------------------------------------------------- + ret +} + + + +macro sys_load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__ +{ +local end_steep +local exit +;--------------------------------------------------------------------- +; loading Box_Lib library + + mcall 68,19,system_path__ ; load of sys directory + test eax,eax + jnz end_steep + + copy_path library_name__, cur_dir_path__, library_path__ ;the macros making way /current pach a program/+ name system library + + mcall 68,19,library_path__ ; load of alternative + test eax,eax + jnz end_steep + show_error_window err_message_found_lib__, head_f_l__ ;show error message /create window + jmp exit + + +align 4 +end_steep: + + import_boxlib myimport, err_message_import__, head_f_i__ ;import +exit: + test eax,eax + jz @f + + mcall 51,1,start__,end_tr ; создаем новый поток по шаблону + or eax,-1 +@@: + +;--------------------------------------------------------------------- +} + + +macro load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__ +{ +local end_steep +local exit +;--------------------------------------------------------------------- +; loading Box_Lib library + + copy_path library_name__, cur_dir_path__, library_path__ ;the macros making way /current pach a program/+ name system library + + mcall 68,19,library_path__ ; load of alternative + test eax,eax + jnz end_steep + + mcall 68,19,system_path__ ; load of sys directory + test eax,eax + jnz end_steep + + show_error_window err_message_found_lib__, head_f_l__ ;show error message /create window + jmp exit + +align 4 +end_steep: + + import_boxlib myimport, err_message_import__, head_f_i__ ;import +exit: + test eax,eax + jz @f + + mcall 51,1,start__,end_tr ; создаем новый поток по шаблону + or eax,-1 +@@: + +;--------------------------------------------------------------------- +} +macro sys_load_libraries _start,_end +{ +local exit_lp2 +local lp2 +local lp +local end_steep +local next +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +library_name__ equ [ebp] +cur_dir_path__ equ [ebp+4] +library_path__ equ [ebp+8] +system_path__ equ [ebp+12] +err_message_found_lib__ equ [ebp+16] +head_f_l__ equ [ebp+20] +my_import equ [ebp+24] +err_message_import__ equ [ebp+28] +head_f_i__ equ [ebp+32] +adr_load_lib equ dword [ebp+36] +status_lib equ dword [ebp+40] + + mov ebp,_start + mov ecx,((_end-_start)/ll_struc_size) + +align 4 +lp: push ecx + mcall 68,19,system_path__ ; load of sys directory + test eax,eax + jnz end_steep + + copy_path library_name__, cur_dir_path__, library_path__ ;the macros making way /current pach a program/+ name system library + + mcall 68,19,library_path__ ; load of alternative + test eax,eax + jnz end_steep + + or status_lib,0x1 ; status of code - enable error - not found library + + show_error_window err_message_found_lib__, head_f_l__ ;show error message /create window + jmp next + +align 4 +end_steep: + mov adr_load_lib,eax ;save adr lib in memory + import_boxlib my_import, err_message_import__, head_f_i__ ;import + + test eax,eax + jz next + + or status_lib,0x2 ; status of code - enable error - import error + +next: + pop ecx + add ebp,ll_struc_size + dec ecx + jnz lp + +;---------------------------------- + mov ebp,_start + mov ecx,((_end-_start)/ll_struc_size) + +align 4 +lp2: + mov eax,status_lib + test eax,eax + jz @f + + mcall 51,1,start__,end_tr ; создаем новый поток по шаблону + or eax,-1 + jmp exit_lp2 + +@@: + add ebp,ll_struc_size + dec ecx + jnz lp2 +exit_lp2: +} + +macro load_libraries _start,_end +{ +local lp2 +local exit_lp2 +local lp +local end_steep +local next +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +library_name__ equ [ebp] +cur_dir_path__ equ [ebp+4] +library_path__ equ [ebp+8] +system_path__ equ [ebp+12] +err_message_found_lib__ equ [ebp+16] +head_f_l__ equ [ebp+20] +my_import equ [ebp+24] +err_message_import__ equ [ebp+28] +head_f_i__ equ [ebp+32] +adr_load_lib equ dword [ebp+36] +status_lib equ dword [ebp+40] + + mov ebp,_start + mov ecx,((_end-_start)/ll_struc_size) + +align 4 +lp: push ecx + + copy_path library_name__, cur_dir_path__, library_path__ ;the macros making way /current pach a program/+ name system library + + mcall 68,19,library_path__ ; load of alternative + test eax,eax + jnz end_steep + + mcall 68,19,system_path__ ; load of sys directory + test eax,eax + jnz end_steep + + or status_lib,0x1 ; status of code - enable error - not found library + + show_error_window err_message_found_lib__, head_f_l__ ;show error message /create window + jmp next + +align 4 +end_steep: + mov adr_load_lib,eax ;save adr lib in memory + + import_boxlib my_import, err_message_import__, head_f_i__ ;import + + test eax,eax + jz next + + or status_lib,0x2 ; status of code - enable error - import error + +next: + pop ecx + add ebp,ll_struc_size + dec ecx + jnz lp + +;----------------------------------------------- + mov ebp,_start + mov ecx,((_end-_start)/ll_struc_size) + +align 4 +lp2: + mov eax,status_lib + test eax,eax + jz @f + + mcall 51,1,start__,end_tr ; создаем новый поток по шаблону + or eax,-1 + jmp exit_lp2 + +@@: + add ebp,ll_struc_size + dec ecx + jnz lp2 +exit_lp2: + +} + + +macro copy_path lib_name,dir_path,lib_path +{ + pushad ;save all registers + push dword lib_name + push dword dir_path + push dword lib_path + + call @copy_path + + add esp,12 + popad ;restore all registers +} + +macro show_error_window err_message, head +{ pushad ;save all registers + push dword err_message + push dword head + + call show_err_ + + add esp,8 + popad ;restore all registers + or eax,-1 ;увы +} + + +macro import_boxlib myimport, err_message_import__, head_f_i__ +{ +local import_loop +local import_find +local lp +local import_find_next +local import_found +local import_done +local exit +local e.exit +local import_not_found +; initialize import + + mov edx, eax + mov esi,myimport +import_loop: + lodsd + test eax, eax + jz import_done + push edx +import_find: + mov ebx, [ds:edx] + test ebx, ebx + jz import_not_found + push eax +lp: + mov cl, [ds:eax] + cmp cl, [ds:ebx] + jnz import_find_next + test cl, cl + jz import_found + inc eax + inc ebx + jmp lp +import_find_next: + pop eax + add edx, 8 + jmp import_find +import_found: + pop eax + mov eax, [ds:edx+4] + mov [esi-4], eax + pop edx + jmp import_loop +import_not_found: + add esp,4 + show_error_window err_message_import__, head_f_i__ ;show error message /create window + jmp e.exit +import_done: + xor eax,eax +e.exit: +;--------------------------------------------------------------------- +} +ll_struc_size = 44;($-library_name__) ; constant size of struct +struc l_libs library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, my_import, err_message_import__, head_f_i__; struct for loading libraries +{ +.library_name__ dd library_name__ ; имя загружаемой библиотеки +.cur_dir_path__ dd cur_dir_path__ ; указатель на буфер в котором содержиться путь от куда была запущена программа + +.library_path__ dd library_path__ ; указатель на буфер в котором будет софоримирован путь к библиотеки, если нужно вычислить путь до либы с места запуска программы, обычно нужно, в случаях, если либа расположена в той же папке +.complete_path dd system_path__ ; путь который четко содержит путь + +.err_message_found_lib__ dd err_message_found_lib__ +.head_f_l__ dd head_f_l__ +.my_import dd my_import +.err_message_import__ dd err_message_import__ +.head_f_i__ dd head_f_i__ + +.adr_load_lib dd 0x0 +.status_lib dd 0x0 ;status of load library +; +} diff --git a/programs/other/t_edit/msgbox.obj b/programs/other/t_edit/msgbox.obj new file mode 100644 index 0000000000..b1db8e31fb Binary files /dev/null and b/programs/other/t_edit/msgbox.obj differ diff --git a/programs/other/t_edit/readme.htm b/programs/other/t_edit/readme.htm new file mode 100644 index 0000000000..8fef36c7e9 --- /dev/null +++ b/programs/other/t_edit/readme.htm @@ -0,0 +1,170 @@ + + +Оглавление + + + + + +

TextEditor версия от 29.12.2009

+

О программе

+

Программа для работы с текстовыми файлами. + Лицензия свободная.

+

+

Внешний вид программы, с открытым текстовым файлом.

+

Обсуждение программы здесь: http://board.kolibrios.org/viewtopic.php?f=9&t=1222

+ +

Возможности

+
    +
  • Открытие (Ctrl+O)/Сохранение файла.
  • +
  • Редактирование: Повтор/Отмена действия (Ctrl+Z), Вырезать/Копировать (Ctrl+C)/Вставить (Ctrl+V), Поиск (Ctrl+F, F3).
  • +
  • Выделение цветом слов, заданных в файле синтаксиса. Вывод справки по ним, если она есть (нажатием F1 когда курсор на слове).
  • +
+ +

После создания программы TextEditor в Kolibri стало 2 программы для работы с текстом, + у каждой из них есть свои сильные и слабые стороны. + Проведу (не полное) сравнение программ TinyPad и TextEditor:

+ + + + + + + + + + + + +
ДействияTinyPadTextEditorКомментарий
Работа с несколькими документамиестьнетпока не планирую сделать
Поддержка кодировок KOI8M, OEMестьнетхотелось-бы сделать
Подсветка синтаксисаподсветка заранее зашита в программуподсветка берется из файлов, которые может указать пользователь. Также есть возможность получать справку по подсвечиваемым словам (если она есть в файлах подсветки, навести курсор на слово и нажать F1).
Многократная отмена/повтор действийнетесть
Ограничения на размер файловнетесть
+ +

Некоторые недоработки

+
    +
  • Если открыть большой файл, размер которого больше чем: + maxChars equ 100002 ;(...+2) + он откроется не весь, а первые maxChars-2 символов из файла + (о чем выдается сообщение).
  • +
  • При сохранении программа не спрашивает о замене существ. файла.
  • +
  • Срабатывали кнопки под меню, потому я их сдвинул влево.
  • +
+ +

О работе программы

+

Раздел для программистов (и интересующихся людей), в котором расказаны + некоторые идеи, на которых построена данная программа.

+ +

Для работы с текстом программа использует структуры:

+
struct symbol
+  c db ?	;  +0 символ
+  col db ?	;  +1 цвет
+  perv dd ? ;  +2
+  next dd ? ;  +6 указатели
+  tc dd ?	; +10 врем. создания
+  td dd ?	; +14 врем. удаления
+ends
+

Каждая из таких структур сохраняет один символ в переменной 'c'. Переменные + 'perv' и 'next' хранят индексы первого и следующего символов. Благодаря чему + текст создается в виде цепочки символов (двунаправленный список).

+

'tc' - время создания символа, при отмене действия текстовый редактор "знает" + какие символы отображать, а какие нет (хотя все символы "висят" в памяти).

+

'td' - время удаления символа, заполняется при удалении, при отмене действия + удаления символов, текст может быть восстановлен.

+

'col' - используется для цветовой разметки.

+ +

Теперь немного о функциях:

+

GetTexPervPos - переход на предыдущий символ в цепи (через указатель 'perv')

+

GetTexNextPos - переход на следующий символ в цепи (через указатель 'next')

+

SymbNotVis - определяет видимый ли указанный символ на экране (в зависимости + от значений 'tc' и 'td')

+

IteratNext - переход на следующий видимый символ в цепи. Использует для + работы функции GetTexNextPos и SymbNotVis.

+

IteratPerv - переход на предедущий видимый символ в цепи.

+ +

ItPoNextUc - найти следующую позицию указанного символа (edx-поз. начала + поиска, bl->код искомого символа)

+

GetPosByParam - берет позицию символа по координатам (esi->коорд. x, знак; + ecx->коорд. y, строка)

+

GoToPos - переставляет курсор в указанную позицию, если указанная позиция + находится вне экрана, то также переставляются скролинги (ecx->коорд. x, знак; edx->коорд. y, строка)

+ +

Формат файла подсветки *.syn

+ + + + + + + + + + + + + + + + +
ЭлементРазмер (байт)
Количество цветов текста
4
Количество подсвечиваемых слов
4
Цвета интерфейса
4*6
Цвета для текста
4*(кол. цв. текста)
Структуры со свойствами и описаниями слов
sizeof(TexColViv)*(кол. слов)
Разделительный символ, означающий начало описаний слов (всегда равен 0)
1 байт
Описания слов (строки текста с 0-ми в конце)
(длинна справочного текста + 1)
+

Замечания.

+
    +
  • Все слова должны быть расположены в порядке следования их ASCII кодов. + Возможно в будущих версиях формат файлов подсветки будет изменен.
  • +
+ +
+

Автор

+

Игорь А. (IgorA) - разработка программы.

+ +

Спасибо

+
    +
  • Евтихов Максим (Maxxxx32) - элемент EditBox.
  • +
  • Алексей Теплов (Lrz) - элемент EditBox, макрос load_library.
  • +
  • Mario79 - элемент скроллинг.
  • +
  • Diamond - за программу KlbrInWin, и помощь при написании программы.
  • +
  • Insolor - за тестирование программы на ошибки.
  • +
  • Leency и другим, кто помогал на форуме советами.
  • +
+ + + \ No newline at end of file diff --git a/programs/other/t_edit/strlen.inc b/programs/other/t_edit/strlen.inc new file mode 100644 index 0000000000..f7564b93ad --- /dev/null +++ b/programs/other/t_edit/strlen.inc @@ -0,0 +1,71 @@ +; strlen function +; +; Copyright (c) 2003 Thomas Mathys +; killer@vantage.ch +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; +;%ifndef _STRLEN_INC +;%define _STRLEN_INC + + +;******************************************************************** +; returns the length of an asciiz string +; input : esi = pointer to string +; output : eax = string length +; destroys : nothing +;******************************************************************** +strlen: + push ecx + push edi + pushfd + cld ; ! + mov ecx,-1 + mov edi,esi ; find terminating zero + xor al,al + repne scasb + mov eax,edi ; calculate string length + sub eax,esi + dec eax + popfd + pop edi + pop ecx + ret + + + +; linlen function +; +; Copyright (c) 2009 Igor Afanasiev + +linlen: + push ecx + push edi + pushfd + cld ; ! + mov ecx,eax + inc ecx + mov edi,esi ; find terminating zero + mov al,13 + repne scasb + mov eax,edi ; calculate string length + sub eax,esi + dec eax + popfd + pop edi + pop ecx + ret +;%endif + diff --git a/programs/other/t_edit/t_button.inc b/programs/other/t_edit/t_button.inc new file mode 100644 index 0000000000..bdf1890fbd --- /dev/null +++ b/programs/other/t_edit/t_button.inc @@ -0,0 +1,601 @@ +but_NewFile: + push eax ebx + call CanSave + cmp al,1 + jne @f + push thread + push msgbox_2 + call [mb_create] ;message: save changes in file? + ;mov eax,5 + ;mov ebx,50 + ;int 0x40 + push msgbox_2_funct + call [mb_setfunctions] + jmp .ret_f + @@: + call On_NewFile + .ret_f: + pop ebx eax + ret + +On_NewFile: + push eax + mov al,1 + call Clear + call draw_but_toolbar + call draw_main_win + pop eax + ret + +On_SaveAndNewFile: + call but_SaveFile + cmp byte[err_sav],0 + jne @f + call On_NewFile + @@: + ret + +but_OpenFile: + push eax + call CanSave + cmp al,1 + jne @f + push thread + push msgbox_5 + call [mb_create] ;message: save changes in file? + push msgbox_5_funct + call [mb_setfunctions] + jmp .ret_f + @@: + call On_OpenFile + .ret_f: + pop eax + ret + +On_OpenFile: + push eax ebx + mov eax,70 + mov [run_file_70.func_n], 0 + mov [run_file_70.param1], 0 + mov [run_file_70.param2], 0 + mov [run_file_70.param3], maxChars-2 ;sizeof.symbol + m2m [run_file_70.param4], [tex] + mov [run_file_70.rezerv], 0 + push dword[edit1.text] + pop dword[run_file_70.name] + mov ebx,run_file_70 + int 0x40 + + cmp eax,0 + je @f + cmp eax,6 + je @f + cmp ax,10 + jl .zifra_0_9 + mov al,'?' + sub ax,48 + .zifra_0_9: + add ax,48 + + mov byte[msgbox_4.err],al + push thread + push msgbox_4 + call [mb_create] ;message: Can-t open text file! + jmp .ret_f + @@: + mov [err_opn],1 + cmp ebx,-1 + je .ret_f + ;if open file + call OpenFile + call draw_but_toolbar + call draw_main_win + cmp ebx,maxChars-2 + jl .ret_f + push thread + push msgbox_1 + call [mb_create] + .ret_f: + pop ebx eax + ret + +but_SaveFile: + push eax ebx ecx edx + call CanSave + cmp al,0 + je .no_save + + mov ecx,maxChars + call mem_Alloc + push eax + + mov edx,[tex] + xor ecx,ecx + @@: + call IteratNext + cmp edx,[tex_1] + jle @f ;edx = [tex] or edx = [tex]+sizeof.symbol + mov bl,[edx] + mov byte[eax],bl + inc eax + inc ecx + jmp @b + @@: + + cmp ecx,0 + je @f + pop eax + mov [run_file_70.param4],eax + push eax + mov eax,70 + mov [run_file_70.func_n], 2 + mov [run_file_70.param1], 0 + mov [run_file_70.param2], 0 + mov [run_file_70.param3], ecx + mov [run_file_70.rezerv], 0 + push [edit1.text] + pop [run_file_70.name] + mov ebx,run_file_70 + int 0x40 + + mov [err_sav],al + + cmp eax,0 + je .no_msg +; cmp eax,6 +; je @f + cmp ax,10 + jl .zifra_0_9 + mov al,'?' + sub ax,48 + .zifra_0_9: + add ax,48 + + mov byte[msgbox_6.err],al + push thread + push msgbox_6 + call [mb_create] ;message: Can-t save text file! + jmp @f + .no_msg: + m2m [ls_tim],[ch_tim] + @@: + + pop ecx + call mem_Free + .no_save: + pop edx ecx ebx eax + ret + +but_FindText: + push eax ebx ecx edx edi + call GetPos + mov eax,[edit2.text] + mov bl,byte[eax] + @@: + call GetFindRezult + cmp bh,1 + je @f ; find + + call IteratNext + cmp edx,[tex_1] + jle @f + jmp @b + @@: + cmp bh,0 + je @f + call GetTexCoords + inc ebx ;move cursor right + mov [sel.x1],ebx + mov [sel.y1],eax + mov edx,eax + mov ecx,ebx + call GoToPos + mov edx,edi + call GetTexCoords + mov [sel.x0],ebx + mov [sel.y0],eax + call draw_main_win + jmp .end_find + @@: + push thread + push msgbox_7 + call [mb_create] ;message: Can not find text + .end_find: + pop edi edx ecx ebx eax + ret + +;input: +; eax - text need find +; bl - first symbol to find +; edx - first symbol pointer +;output: +; bh - rezult +; edx - last text position (if find sucess) +; edi - first symbol pointer +GetFindRezult: + push eax + mov bh,1 + mov edi,edx ;copy edx + @@: + cmp byte[edx],bl + jne .no_text + + inc eax ;*** get next symbol (in find text) *** + mov bl,byte[eax] + cmp bl,0 + je @f ;end of find text + + call IteratNext ;*** get next symbol (in editor text) *** + cmp edx,[tex_1] + jle @f ;end of editor text + + jmp @b + .no_text: + xor bh,bh + mov edx,edi ;restore edx + @@: + pop eax + mov bl,byte[eax] ;restore bl + ret + +but_OpenSyntax: + cmp byte[panel_id],TE_PANEL_SYNTAX + jne @f + push dword tree1 + call dword [tl_node_get_data] + pop dword [fn_col_option] + call InitColText + call CmColored + call draw_main_win + @@: + ret + +but_select_word: + push eax ebx ecx edx + + call GetPos + push edx + call ItPervColorTag + cmp edx,[tex_1] + jle @f + call GetTexCoords + mov [sel.x0],ebx + mov [sel.y0],eax + @@: + pop edx + call ItNextColorTag + cmp edx,[tex_1] + jle @f + call GetTexCoords + mov [sel.x1],ebx + mov [sel.y1],eax + @@: + pop edx ecx ebx eax + call draw_but_toolbar + call draw_main_win + jmp still + +but_cut: + call but_Copy + call SetUndo + push bx + mov bl,1 + call SelTextDel + pop bx + cmp al,1 + jne @f + call draw_but_toolbar + call draw_main_win + @@: + jmp still + +;output: +; al = 1 if copy text +but_Copy: + push ax + call IsSel + cmp al,0 + jne @f + pop ax + ret ;if not selected text + @@: + call SelNormalize + + push ebx ecx edx esi + mov esi,[seln.x1] + mov ecx,[seln.y1] + call GetPosByParam + mov ebx,edx + mov esi,[seln.x0] + mov ecx,[seln.y0] + call GetPosByParam + mov esi,ebx + + xor ecx,ecx + mov ebx,buf + ;mov edx,[tex] + @@: + cmp edx,[tex_1] ;end of file + jle @f + cmp edx,esi ;end of select + je @f + inc ecx + cmp ecx,BUF_SIZE ;owerflow bufer + je @f + + mov al,byte[edx] + mov byte[ebx],al + inc ebx + + call IteratNext + jmp @b + @@: + add ecx,buf + mov byte[ebx],0 + + cmp ecx,0 + je @f + call draw_but_toolbar + call draw_bufer + @@: + pop esi edx ecx ebx ax + ret + +but_paste: + push eax bx esi edi + mov esi,buf + call strlen + cmp eax,1 + jl @f + call SetUndo + mov esi,eax + mov bx,0x0101 + call SelTextDel + mov edi,buf + call TextAdd + call draw_but_toolbar + call draw_main_win + @@: + pop edi esi bx eax + jmp still + +but_find: + cmp byte[panel_id],TE_PANEL_NULL + je @f + mov byte[panel_id],TE_PANEL_NULL + mov word[wndMain.left],0 + jmp .e_if + @@: + mov byte[panel_id],TE_PANEL_FIND + mov word[wndMain.left],TE_PANEL_WIDTH + .e_if: + call EvSize + call draw_main_win + jmp still + +but_replace: + jmp still + +but_find_key_w: + jmp still + +but_sumb_upper: + push edi + mov [conv_table],EvUpper + call ConvertSelText + cmp edi,0 + je @f + call draw_main_win + @@: + pop edi + jmp still + +but_sumb_lover: + push edi + mov [conv_table],EvLover + call ConvertSelText + cmp edi,0 + je @f + call draw_main_win + @@: + pop edi + jmp still + +but_reverse: + push eax ebx + call IsSel + cmp al,0 + je @f + call SelNormalize + push esi ecx edx + mov esi,[seln.x0] + mov ecx,[seln.y0] + call GetPosByParam + mov eax,edx + mov esi,[seln.x1] + cmp esi,0 + je .beg_str + dec esi + .beg_str: + mov ecx,[seln.y1] + call GetPosByParam + ;call GetTexPervPos + mov ebx,edx + pop edx ecx esi + ;cmp eax,... + ;je @f + call Revers + @@: + pop ebx eax + call draw_main_win + jmp still + +but_undo: + mov eax,[tim_Undo] + cmp [ch_tim],eax + jbe still + inc [tim_Undo] + ;call CmColored + jmp red_win + +but_redo: + cmp [tim_Undo],1 + jb still + dec [tim_Undo] + ;call CmColored + jmp red_win + + +but_sumb_invis: + xor [invis],1 + jmp red_win + +but_k_words_show: + xor byte[mode_colored],1 + cmp byte[mode_colored],0 + je red_win + call CmColored + +; push eax ebx ecx esi edi +; mov eax,dword[cur_x] +; ColToIndexOffset eax,edx +; mov eax,4 +; mov ebx,50*65536+75 +; mov ecx,0x40ffffff +; mov edi,0x404040 +; mov esi,10 +; int 0x40 +; +; mov eax,47 +; mov ecx,250 +; mov esi,0xffff80 +; mov edx,50*65536+80 +; mov esi,FkPos;[keyW] +; @@: +; mov ebx,0x30001 +; cmp dx,300 +; jl .no_br +; mov dx,80 +; add edx,0x200000 +; .no_br: +; add dx,10 +; push ecx esi +; mov ecx,esi +; cmp dword[ecx],-1 +; jne .no_minus +; mov ebx,0x10000 +; mov ecx,1 +; .no_minus: +; mov esi,0xffff00 +; int 0x40 +; pop esi ecx +; add esi,4 +; loop @b +; pop edi esi ecx ebx eax + jmp red_win + +but_CtrlHome: + mov [cur_x],0 + mov [cur_y],0 + mov [wScr.position],0 + mov [hScr.position],0 + + call draw_but_toolbar + call draw_main_win + ret + +but_synt_show: + cmp byte[panel_id],TE_PANEL_NULL + je @f + mov byte[panel_id],TE_PANEL_NULL + mov word[wndMain.left],0 + jmp .e_if + @@: + mov byte[panel_id],TE_PANEL_SYNTAX + mov word[wndMain.left],TE_PANEL_WIDTH + .e_if: + call EvSize + call draw_main_win + jmp still + +sel_KeyUp: + cmp [dragk],1 + je @f + call SelStart + mov [dragk],1 + @@: + push dx + call CurMoveUp + cmp dl,8 + jne @f + call OnInitialUpdate + @@: + pop dx + call SelMove + call draw_main_win + ret + +sel_KeyDown: + cmp [dragk],1 + je @f + call SelStart + mov [dragk],1 + @@: + push dx + call CurMoveDown + cmp dl,8 + jne @f + call OnInitialUpdate + @@: + pop dx + call SelMove + call draw_main_win + ret + +sel_KeyLeft: + cmp [dragk],1 + je @f + call SelStart + @@: + push dx + call CurMoveLeft + call SelMove + cmp [dragk],1 + je @f + mov [dragk],1 + mov dl,8 + @@: + cmp dl,8 + jne @f + call OnInitialUpdate + call draw_main_win + jmp .end_f + @@: + call draw_cur_line + .end_f: + pop dx + ret + +sel_KeyRight: + cmp [dragk],1 + je @f + call SelStart + @@: + push dx + call CurMoveRight + call SelMove + cmp [dragk],1 + je @f + mov [dragk],1 + mov dl,8 + @@: + cmp dl,8 + jne @f + call OnInitialUpdate + call draw_main_win + jmp .end_f + @@: + call draw_cur_line + .end_f: + pop dx + ret \ No newline at end of file diff --git a/programs/other/t_edit/t_data.inc b/programs/other/t_edit/t_data.inc new file mode 100644 index 0000000000..ee02e109c8 --- /dev/null +++ b/programs/other/t_edit/t_data.inc @@ -0,0 +1,461 @@ +;--- данные программы ---------------------------------------------- +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_dir1 db '/sys/lib/' +msgbox_name db 'msgbox.obj',0 + +fn_icon_tl_sys db 'tl_sys_16.bmp',0 +fn_icon_tl_nod db 'tl_nod_16.bmp',0 +;--------------------------------------------------------------------- +fileinfo: + dd 5 + dd 0 + dd 0 + dd 0 + dd file_info +string: + db 0 + dd file_name + +;plugin dd 0 + +;--------------------------------------------------------------------- +align 4 +myimport: +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 + +check_box_draw dd aCheck_box_draw +check_box_mouse dd aCheck_box_mouse +version_ch dd aVersion_ch + +option_box_draw dd aOption_box_draw +option_box_mouse dd aOption_box_mouse +version_op dd aVersion_op + +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 + +dinamic_button_draw dd aDbutton_draw +dinamic_button_mouse dd aDbutton_mouse +version_dbutton dd aVersion_dbutton + +menu_bar_draw dd aMenu_bar_draw +menu_bar_mouse dd aMenu_bar_mouse +version_menu_bar dd aVersion_menu_bar + + tl_data_init dd sz_tl_data_init + tl_data_clear dd sz_tl_data_clear + tl_info_clear dd sz_tl_info_clear + tl_key dd sz_tl_key + tl_mouse dd sz_tl_mouse + tl_draw dd sz_tl_draw + tl_info_undo dd sz_tl_info_undo + tl_info_redo dd sz_tl_info_redo + tl_node_add dd sz_tl_node_add + tl_node_set_data dd sz_tl_node_set_data + tl_node_get_data dd sz_tl_node_get_data + tl_node_delete dd sz_tl_node_delete + tl_cur_beg dd sz_tl_cur_beg + tl_cur_next dd sz_tl_cur_next + tl_cur_perv dd sz_tl_cur_perv + tl_node_close_open dd sz_tl_node_close_open + tl_node_lev_inc dd sz_tl_node_lev_inc + tl_node_lev_dec dd sz_tl_node_lev_dec +dd 0,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 + +aCheck_box_draw db 'check_box_draw',0 +aCheck_box_mouse db 'check_box_mouse',0 +aVersion_ch db 'version_ch',0 + +aOption_box_draw db 'option_box_draw',0 +aOption_box_mouse db 'option_box_mouse',0 +aVersion_op db 'version_op',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 + +aDbutton_draw db 'dbutton_draw',0 +aDbutton_mouse db 'dbutton_mouse',0 +aVersion_dbutton db 'version_dbutton',0 + +aMenu_bar_draw db 'menu_bar_draw',0 +aMenu_bar_mouse db 'menu_bar_mouse',0 +aVersion_menu_bar db 'version_menu_bar',0 + + sz_tl_data_init db 'tl_data_init',0 + sz_tl_data_clear db 'tl_data_clear',0 + sz_tl_info_clear db 'tl_info_clear',0 + sz_tl_key db 'tl_key',0 + sz_tl_mouse db 'tl_mouse',0 + sz_tl_draw db 'tl_draw',0 + sz_tl_info_undo db 'tl_info_undo',0 + sz_tl_info_redo db 'tl_info_redo',0 + sz_tl_node_add db 'tl_node_add',0 + sz_tl_node_set_data db 'tl_node_set_data',0 + sz_tl_node_get_data db 'tl_node_get_data',0 + sz_tl_node_delete db 'tl_node_delete',0 + sz_tl_cur_beg db 'tl_cur_beg',0 + sz_tl_cur_next db 'tl_cur_next',0 + sz_tl_cur_perv db 'tl_cur_perv',0 + sz_tl_node_close_open db 'tl_node_close_open',0 + sz_tl_node_lev_inc db 'tl_node_lev_inc',0 + sz_tl_node_lev_dec db 'tl_node_lev_dec',0 +;-------------------------------------------------- +align 4 +msgbox_lib_import: + mb_create dd amb_create + mb_reinit dd amb_reinit + mb_setfunctions dd amb_setfunctions + dd 0,0 + amb_create db 'mb_create',0 + amb_reinit db 'mb_reinit',0 + amb_setfunctions db 'mb_setfunctions',0 +;--------------------------------------------------------------------- +align 4 +wScr: +.x: +.size_x dw 16 ;+0 +.start_x dw 50 ;+2 +.y: +.size_y dw 300 ;+4 +.start_y dw 50 ;+6 +.btn_high dd 15 ;+8 +.type dd 1 ;+12 +.max_area dd 100 ;+16 +.cur_area dd 30 ;+20 +.position dd 0 ;+24 +.bckg_col dd 0xeeeeee ;+28 +.frnt_col dd 0xbbddff ;+32 +.line_col dd 0 ;+36 +.redraw dd 0 ;+40 +.delta dw 0 ;+44 +.delta2 dw 0 ;+46 +.run_x: +.r_size_x dw 0 ;+48 +.r_start_x dw 0 ;+50 +.run_y: +.r_size_y dw 0 ;+52 +.r_start_y dw 0 ;+54 +.m_pos dd 0 ;+56 +.m_pos_2 dd 0 ;+60 +.m_keys dd 0 ;+64 +.run_size dd 0 ;+68 +.position2 dd 0 ;+72 +.work_size dd 0 ;+76 +.all_redraw dd 0 ;+80 +.ar_offset dd 1 ;+84 +;--------------------------------------------------------------------- +align 4 +hScr: +.x: +.size_x dw 150 ;+0 +.start_x dw 0 ;+2 +.y: +.size_y dw 16 ;+4 +.start_y dw 50 ;+6 +.btn_high dd 15 ;+8 +.type dd 1 ;+12 +.max_area dd 100 ;+16 +.cur_area dd 30 ;+20 +.position dd 0 ;+24 +.bckg_col dd 0xeeeeee ;+28 +.frnt_col dd 0xbbddff ;+32 +.line_col dd 0 ;+36 +.redraw dd 0 ;+40 +.delta dw 0 ;+44 +.delta2 dw 0 ;+46 +.run_x: +.r_size_x dw 0 ;+48 +.r_start_x dw 0 ;+50 +.run_y: +.r_size_y dw 0 ;+52 +.r_start_y dw 0 ;+54 +.m_pos dd 0 ;+56 +.m_pos_2 dd 0 ;+60 +.m_keys dd 0 ;+64 +.run_size dd 0 ;+68 +.position2 dd 0 ;+72 +.work_size dd 0 ;+76 +.all_redraw dd 0 ;+80 +.ar_offset dd 1 ;+84 +;--------------------------------------------------------------------- +align 4 +ws_dir_lbox: ;дочерний скроллинг для элемента ListBox +.x: +.size_x dw 16 ;+0 +.start_x dw 0 ;+2 +.y: +.size_y dw 30 ;+4 +.start_y dw 70 ;+6 +.btn_high dd 15 ;+8 +.type dd 1 ;+12 +.max_area dd 100 ;+16 +.cur_area dd 30 ;+20 +.position dd 0 ;+24 +.bckg_col dd 0xeeeeee ;+28 +.frnt_col dd 0xbbddff ;+32 +.line_col dd 0 ;+36 +.redraw dd 0 ;+40 +.delta dw 0 ;+44 +.delta2 dw 0 ;+46 +.run_x: +.r_size_x dw 0 ;+48 +.r_start_x dw 0 ;+50 +.run_y: +.r_size_y dw 0 ;+52 +.r_start_y dw 0 ;+54 +.m_pos dd 0 ;+56 +.m_pos_2 dd 0 ;+60 +.m_keys dd 0 ;+64 +.run_size dd 0 ;+68 +.position2 dd 0 ;+72 +.work_size dd 0 ;+76 +.all_redraw dd 0 ;+80 +.ar_offset dd 1 ;+84;--------------------------------------------------------------------- + +align 4 +menu_data_1: +.type: dd 0 ;+0 +.x: +.size_x dw 35 ;+4 +.start_x dw 5 ;+6 +.y: +.size_y dw 15 ;+8 +.start_y dw 5 ;+10 +.text_pointer: dd menu_text_area ;0 ;+12 +.pos_pointer: dd menu_text_area.1 ;0 ;+16 +.text_end dd menu_text_area.end ;0 ;+20 +.mouse_pos dd 0 ;+24 +.mouse_keys dd 0 ;+28 +.x1: +.size_x1 dw 70 ;+32 +.start_x1 dw 5 ;+34 +.y1: +.size_y1 dw 15 ;+36 +.start_y1 dw 20 ;+38 +.bckg_col dd 0xeeeeee ;+40 +.frnt_col dd 0xff ;+44 +.menu_col dd 0xffffff ;+48 +.select dd 0 ;+52 +.out_select dd 0 ;+56 +.buf_adress dd 0 ;+60 +.procinfo dd procinfo ;0 ;+64 +.click dd 0 ;+68 +.cursor dd 0 ;+72 +.cursor_old dd 0 ;+76 +.interval dd 16 ;+80 +.cursor_max dd 0 ;+84 +.extended_key dd 0 ;+88 +.menu_sel_col dd 0x00cc00 ;+92 +.bckg_text_col dd 0 ; +96 +.frnt_text_col dd 0xffffff ;+100 +.mouse_keys_old dd 0 ;+104 +.font_height dd 8 ;+108 +.cursor_out dd 0 ;+112 +.get_mouse_flag dd 0 ;+116 +;------------------------- + +TE_PANEL_NULL equ 0 +TE_PANEL_FIND equ 1 +TE_PANEL_SYNTAX equ 2 +TE_PANEL_WIDTH equ 150 ;ширина панели + +count_of_dir_list_files equ 15 + +el_focus dd 0 +mouse_dd dd 0 +tree1 tree_list 264,count_of_dir_list_files+2, tl_key_no_edit+tl_draw_par_line+tl_list_box_mode,\ + 16,16, 0x8080ff,0x0000ff,0xffffff, 0,70,TE_PANEL_WIDTH-17,120, 0,0,0, el_focus,\ + ws_dir_lbox,0 + +;dir_list memory +tree_file_struct: + dd 1 + dd 0,0,count_of_dir_list_files + dd dir_mem + db 0 + dd file_name ;sys_path + +dir_mem rb 32+304*count_of_dir_list_files + + +menu_text_area: +db '” ©«',0 +.1: +db '‘®§¤ вм',0 +db 'ЋвЄалвм',0 +db '‘®еа ­Ёвм',0 +db '‚л室',0 +.end: +db 0 + +;-------- +msgbox_1: + dw 0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db '” ©« Ў®«ми®©, Ї®в®¬г ®вЄалв ­Ґ ўҐбм.',13 + db ' 1. ЏаЁ ҐЈ® б®еа ­Ґ­ЁЁ Ўг¤гв Ї®вҐап­л "­Ґ ®вЄалўиЁҐбп" бЁ¬ў®«л.',13 + db ' 2. ‚ ¤®Єг¬Ґ­в ­Ґ«м§п ¤®Ў ў«пвм ⥪бв, в. Є. Ї ¬пвм § ­пв .',0 + db 'џ Ї®­п«( )',0 ;button1 + db 0 +msgbox_2: + db 3,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db '‘®еа ­Ёвм Ё§¬Ґ­Ґ­Ёп ў д ©«Ґ?',0 + db '‘®еа ­Ёвм',0 + db 'ЌҐ б®еа ­пвм',0 + db 'Ћв¬Ґ­ ',0 + db 0 +msgbox_2_funct: + dd On_SaveAndNewFile + dd On_NewFile + dd 0 + +msgbox_3: + db 1,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db 'ЋиЁЎЄ  ЇаЁ ®вЄалвЁЁ д ©«  б 梥⮢묨 ­ бва®©Є ¬Ё!',13,\ + 'Џ®в®¬г ўл¤Ґ«Ґ­ЁҐ б«®ў 梥⮬ ­Ґ ў®§¬®¦­®.',13,\ + ' (Є®¤ ®иЁЎЄЁ=' + .err: db '?' + db ')',0 + db '‡ Єалвм',0 + db 0 + +msgbox_4: + db 1,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db 'ЋиЁЎЄ  ЇаЁ ®вЄалвЁЁ д ©« !',13,\ + '‚®§¬®¦­® Ё¬п д ©«  ўўҐ¤Ґ­® ­Ґ Їа ўЁ«м­®.',13,\ + ' (Є®¤ ®иЁЎЄЁ=' + .err: db '?' + db ')',0 + db '‡ Єалвм',0 + db 0 + +msgbox_5: + db 3,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db '‘®еа ­Ёвм Ё§¬Ґ­Ґ­Ёп ў д ©«Ґ?',0 + db 'ЌҐ б®еа ­пвм',0 + db 'Ћв¬Ґ­ ',0 + db 0 +msgbox_5_funct: +; dd but_SaveFile + dd On_OpenFile + dd 0 + +msgbox_6: + db 1,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db 'ЋиЁЎЄ  ЇаЁ б®еа ­Ґ­ЁЁ д ©« !',13,\ + '‚®§¬®¦­® Ё¬п д ©«  ўўҐ¤Ґ­® ­Ґ Їа ўЁ«м­®.',13,\ + ' (Є®¤ ®иЁЎЄЁ=' + .err: db '?' + db ')',0 + db '‡ Єалвм',0 + db 0 +msgbox_7: + db 1,0 + db '’ҐЄбв ­Ґ ­ ©¤Ґ­',0 ;+2 = +MB_TEXT_OFFSET + db '„®бвЁЈ­гв Є®­Ґж ¤®Єг¬Ґ­в .',13,\ + 'Џ®Їа®Ўг©вҐ ЇҐаҐ©вЁ ў ­ з «® ¤®Єг¬Ґ­в ',13,\ + 'Ё«Ё Ё§¬Ґ­Ёвм § Їа®б Ё Ї®ўв®аЁвм Ї®ЁбЄ.',0 + db '‡ Єалвм',0 + db 0 +msgbox_8: + db 3,0 + db '‚­Ё¬ ­ЁҐ',0 ;+2 = +MB_TEXT_OFFSET + db '„«п ўл室  § ўҐаиЁвҐ а Ў®вг б д ©«®¬.',13,\ + 'Џ®Їа®Ўг©вҐ б®еа ­Ёвм Ё§¬Ґ­Ґ­Ёп ў д ©«Ґ',13,\ + 'Ё«Ё ­ з вм ­®ўл© Їгбв®©.',0 + db 'Ћв¬Ґ­ ',0 + db 0 + +txtFindCapt db 'Џ®ЁбЄ',0 +txtFindNext db 'Ќ ©вЁ ¤ «ҐҐ',0 +txtFormatCapt db '”®а¬ в',0 +txtFormatApply db 'ЏаЁ¬Ґ­Ёвм',0 +;------ +align 4 +EvChar db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + +EvUpper db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 + db 80,81,82,83,84,85,86,87,88,89,90,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +EvLover db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111 + db 112,113,114,115,116,117,118,119,120,121,122,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +conv_table dd 0 + + +KM_SHIFT equ 0x00010000 +KM_CTRL equ 0x00020000 +KM_ALT equ 0x00040000 +KM_NUMLOCK equ 0x00080000 + +; KEY CODES +KEY_F1 equ 0x0000003B +KEY_F2 equ 0x0000003C +KEY_F3 equ 0x0000003D + diff --git a/programs/other/t_edit/t_draw.inc b/programs/other/t_edit/t_draw.inc new file mode 100644 index 0000000000..485c6bd981 --- /dev/null +++ b/programs/other/t_edit/t_draw.inc @@ -0,0 +1,1291 @@ +mouse_wnd_main: + push eax ebx ecx + mcall 37,2 ;get mouse buttons + + cmp al,1 + jne @f + mcall 37,1 ;get mouse coords + mov ebx,[wndMain.top] + add ebx,[recMain.top] + cmp ax,bx + jl @f ;y_mousey_wnd + + mov ebx,[wndMain.left] + add ebx,[recMain.left] + mov ecx,eax + shr ecx,16 + cmp cx,bx + jl @f ;x_mousex_wnd + + call draw_cursor_sumb + call wnd_main_click + ;call draw_main_cursor ;??? + jmp .no_in_wnd + @@: + call wnd_main_mouse_scroll + cmp [dragm],0 + je .no_in_wnd + mov [dragm],0 + call draw_but_toolbar + call draw_main_win + .no_in_wnd: + pop ecx ebx eax + ret + +; input: +; eax->(x,y) +wnd_main_click: + push ecx edx + + push eax + shr eax,16 + and eax,0xffff + sub eax,[wndMain.left] + sub eax,[recMain.left] + + xor edx,edx + mov ecx,[recMain.width] + div cx + ;inc eax + cmp eax,[hScr.cur_area] + jle @f + mov eax,[hScr.cur_area] + @@: + ;dec eax + mov [cur_x],eax + pop eax + + push eax + and eax,0xffff + sub eax,[wndMain.top] + sub eax,[recMain.top] + + xor edx,edx + mov ecx,[recMain.height] + div cx + inc eax + cmp eax,[wScr.cur_area] + jle @f + mov eax,[wScr.cur_area] + @@: + dec eax + mov [cur_y],eax + pop eax + + cmp [dragm],0 + je @f + call SelMove + jmp .sel_move + @@: + mov [dragm],1 + call SelStart + .sel_move: + pop edx ecx + ret + +wnd_main_mouse_scroll: + push eax ebx + mcall 37,7 + cmp ax,0 + je .no_scroll + mov ebx,dword[wScr.position] ;copy old scroll position + and eax,0xffff + btr ax,15 + jae @f + or eax,0xffff8000 + @@: + add dword[wScr.position],eax + + mov eax,[wScr.position] + cmp eax,[wScr.max_area] + jb @f + mov dword[wScr.position],ebx ;if scroll position out of range + jmp .no_scroll + @@: + call draw_main_win + .no_scroll: + pop ebx eax + ret + +draw_but_toolbar: + + push ebx ecx edx + mov ecx,0x40000000 +; mov edx,5*65536+25 + mov edx,85*65536+2 + call draw_but_icon + + inc cx +; mov edx,30*65536+25 + mov edx,110*65536+2 + call draw_but_icon + +call CanSave +cmp al,1 +je @f +and ecx,0xffff +@@: + inc cx +; mov edx,55*65536+25 + mov edx,135*65536+2 + call draw_but_icon +or ecx,0x40000000 + + inc cx + mov edx,85*65536+25 + call draw_but_icon + +call IsSel +cmp al,0 +jne @f +and ecx,0xffff +@@: + inc cx ; Cut + mov edx,110*65536+25 + call draw_but_icon + + inc cx ; Copy + mov edx,135*65536+25 + call draw_but_icon + + mov cx,10 ; Upper + mov edx,265*65536+25 + call draw_but_icon + + inc cx ; Lower + mov edx,290*65536+25 + call draw_but_icon + + inc cx ; Reverse + mov edx,315*65536+25 + call draw_but_icon +or ecx,0x40000000 + +cmp byte[buf],0 +jne @f +and ecx,0xffff +@@: + mov cx,6 ; Paste + mov edx,160*65536+25 + call draw_but_icon +or ecx,0x40000000 + + inc cx + mov edx,185*65536+25 + call draw_but_icon + + inc cx + mov edx,210*65536+25 + call draw_but_icon + + inc cx + mov edx,235*65536+25 + call draw_but_icon + +mov ebx,[tim_Undo] +cmp [ch_tim],ebx +jg @f +and ecx,0xffff +@@: + mov cx,13 + mov edx,345*65536+25 + call draw_but_icon +or ecx,0x40000000 + +cmp [tim_Undo],1 +jge @f +and ecx,0xffff +@@: + inc cx + mov edx,370*65536+25 + call draw_but_icon +or ecx,0x40000000 + + inc cx + mov edx,400*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 + + pop edx ecx ebx + ret + + +;input: +; ebx = x*2^16+y coords to left up point clear line +; esi = 0 clear all rows +; edi - number text line +clear_line_before_draw: + push eax ebx ecx edx + sub ebx,0x10001 ;отнимаем отступы для выравнивания буквы по центру + cmp esi,0 + jne @f + add bx,word[recMain.height] + inc edi ; ??? + ror ebx,16 + mov bx,word[wndMain.left] + add bx,word[recMain.left] + ror ebx,16 + @@: + + mov ax,word[wndMain.height] + add ax,word[wndMain.top] + cmp ax,bx + jl .no_clear + sub ax,bx + + mov cx,bx + shl ecx,16 + + mov bx,word[wndMain.width] + sub bx,word[recMain.left] + mov cx,word[recMain.height] + mov edx,[WND_WORK_COLOR] + + cmp esi,0 + je .pusto + cmp ax,cx + jge @f + .pusto: + mov cx,ax + @@: + + call IsSel + cmp al,0 + je @f + cmp [seln.y0],edi + jg @f + cmp [seln.y1],edi + jl @f + mov edx,[SELECT_COLOR] ;draw selected line + @@: + + mov eax,13 ;rect + int 0x40 + + call IsSel + cmp al,0 + je .no_clear + + mov al,13 ;rect + mov cx,word[recMain.height] + cmp [seln.y0],edi + jne @f + push bx + mov edx,[seln.x0] ; верхняя полоса (затирает слева) + cmp edx,[hScr.position] + jle .in_wnd + sub edx,[hScr.position] + imul edx,[recMain.width] + mov bx,dx + jmp .no_wnd + .in_wnd: + mov bx,0 + .no_wnd: + mov edx,[WND_WORK_COLOR] + int 0x40 + pop bx + @@: + cmp [seln.y1],edi + jne @f + mov edx,[seln.x1] ; нижняя полоса (затирает справа) + cmp edx,[hScr.position] + jle .in_wnd2 + sub edx,[hScr.position] + imul edx,[recMain.width] + sub bx,dx + shl edx,16 + add ebx,edx + .in_wnd2: + + mov edx,[WND_WORK_COLOR] + int 0x40 + @@: + + .no_clear: + pop edx ecx ebx eax + ret + +;include 't_debug.inc' +draw_main_win: + push eax ebx ecx edx edi esi +;---debug--- +;mov ecx,0 +;@@: +;call DebugSymb +;inc ecx +;cmp ecx,10 +;jge @f +;jmp @b +;@@: +;ret +;---debug--- + + mov eax,4 ;draw text + mov esi,1 + mov ecx,[tex_colors] + push dword[ecx] + pop ecx + + mov ebx,[wndMain.left] + add ebx,[recMain.left] + inc ebx + shl ebx,16 + add ebx,[wndMain.top] + add ebx,[recMain.top] + inc ebx + + call SelNormalize ;need before draw select + mov edi,[wScr.position] + + call clear_line_before_draw + call GetFirstVisiblePos + cmp edx,0 + je .no_draw_text + @@: + call IteratNext + cmp edx,[tex_1] + jle .no_draw_text + +;--- debug +;cmp dword[edx+6],maxChars +;jge .no_draw_text +;--- debug + + ; *** цветовая разметка + cmp byte[mode_colored],0 + je .no_col_change + cmp byte[edx+1],0 + je .no_col_change + call GetSymbColor + .no_col_change: + + cmp byte [edx],13 + jne .no_13 + cmp [invis],1 + jne .no_invis + push edx + mov edx,symbol_new_line + int 0x40 + pop edx + .no_invis: + add bx,word [recMain.height] + ;optimized output \/ + mov ax,word [wndMain.height] + add ax,word [wndMain.top] + cmp bx,ax + jg .no_draw_text + mov ax,4 + ;optimized output /\ + ror ebx,16 + mov bx,word [wndMain.left] + add bx,word [recMain.left] + inc ebx + ror ebx,16 + inc edi ;increment line number + call clear_line_before_draw + call OptDrawLineLeft + jmp @b + .no_13: + + int 0x40 + ror ebx,16 + add bx,word [recMain.width] + mov si,word [wndMain.left] + add si,word [wndMain.width] + cmp bx,si + jl .no_opt + call OptDrawLineRight + .no_opt: + mov si,1 + ror ebx,16 + jmp @b + .no_draw_text: + xor esi,esi + call clear_line_before_draw + + + mov eax,13 + ;top panel with caption + mov ebx,[wndMain.left] +; add ebx,[recMain.left] + shl ebx,16 + add ebx,[wndMain.width] +; sub ebx,[recMain.left] + mov edx,[WND_WORK_COLOR] + mov ecx,[wndMain.top] ;draw caption + shl ecx,16 + add ecx,[recMain.top] + mov edx,[WND_CAPT_COLOR] + int 0x40 + ;left panel with numbers +; mov ebx,[wndMain.left] +; shl ebx,16 +; add ebx,[recMain.left] + ;mov cx,word[wndMain.height] +; mov cx,word[recMain.top] +; int 0x40 + + call draw_line_numbers + call draw_main_cursor + +;--------------------------------------------- +; set all_redraw flag for draw all ScrollBar +; In some cases it is necessity to draw only the area +; of moving of a "runner", for acceleration of output - +; in this case the flag needs to be reset to 0 (zero). + xor eax,eax + inc eax + mov [wScr.all_redraw],eax + mov [hScr.all_redraw],eax + +; draw for Vertical ScrollBar + push dword wScr + call [scrollbar_ver_draw] + push dword hScr + call [scrollbar_hor_draw] +; reset all_redraw flag + xor eax,eax + mov [wScr.all_redraw],eax + mov [hScr.all_redraw],eax +;--------------------------------------------- + + mov eax,13 + ;left-bottom square + mov bx,word[wndMain.left] + shl ebx,16 + mov bx,word[recMain.left] + mov ecx,[wndMain.top] + add ecx,[wndMain.height] + shl ecx,16 + mov cx,word[hScr.size_y] + inc cx + mov edx,[sc.work] + int 0x40 + + ;right-bottom square + mov ebx,[wndMain.left] + add ebx,[wndMain.width] + shl ebx,16 + mov bx,word[wScr.size_x] + inc bx + int 0x40 + + pop esi edi edx ecx ebx eax + call draw_panel_find + call draw_panel_syntax + ret + +;txtBUp db 24 +;txtBDn db 25 +;txtBRi db 26 +;txtBLe db 27 +draw_panel_find: + cmp byte[panel_id],TE_PANEL_FIND ;if not panel + jne @f + push eax ebx ecx edx + + mov eax,13 ;рисование прямоугольника + mov ebx,TE_PANEL_WIDTH + mov cx,word[wndMain.top] + shl ecx,16 + mov cx,20 + mov edx,[sc.work] + int 0x40 + + mov eax,4 ;рисование текста + mov ebx,30*65536+5 + add bx,word[wndMain.top] + mov ecx,[sc.work_text] + or ecx,0x80000000 + mov edx,txtFindCapt + int 0x40 + + push dword edit2 + call [edit_box_draw] + + mov eax,13 ;рисование прямоугольника + mov ebx,TE_PANEL_WIDTH + mov cx,word[wndMain.top] + add cx,20+15 ; 15 - height text box + shl ecx,16 + mov cx,word[wndMain.height] + add cx,word[hScr.size_y] + sub cx,20+15-1 ; 15 - height text box + mov edx,[sc.work] + int 0x40 + + mov eax,8 ;кнопка + mov ebx,5*65536+85 + mov cx,word[wndMain.top] + add cx,20+15+5 + shl ecx,16 + mov cx,20 + mov edx,201 ;button id + mov esi,[sc.work_button] + int 0x40 + + mov eax,4 ;рисование текста + mov ebx,15*65536+(20+15+10) + add bx,word[wndMain.top] + mov ecx,[sc.work_text] + or ecx,0x80000000 + mov edx,txtFindNext + int 0x40 + + pop edx ecx ebx eax + ret + @@: + push eax edx + mov eax,8 + mov edx,201 + or edx,0x80000000 + int 0x40 + pop edx eax + ret + +draw_panel_syntax: + cmp byte[panel_id],TE_PANEL_SYNTAX ;if not panel + jne @f + push eax ebx ecx edx + + mov eax,13 ;рисование прямоугольника + mov ebx,TE_PANEL_WIDTH + mov cx,word[wndMain.top] + shl ecx,16 + mov cx,20 + mov edx,[sc.work] + int 0x40 + + push dword tree1 + call dword[tl_draw] + + mov [ws_dir_lbox.all_redraw],1 + push dword ws_dir_lbox + call dword[scrollbar_ver_draw] + + ror ecx,16 + add ecx,dword[tree1.box_height] + add ecx,20 + ror ecx,16 + mov cx,word[wndMain.height] + add cx,word[hScr.size_y] + sub cx,20 + sub ecx,dword[tree1.box_height] + inc cx + int 0x40 + + mov eax,8 ;кнопка + mov ebx,5*65536+65 + mov cx,word[wndMain.top] + add cx,25 + add ecx,dword[tree1.box_height] + shl ecx,16 + mov cx,20 + mov edx,200 ;button id + mov esi,[sc.work_button] + int 0x40 + + mov eax,4 ;рисование текста + mov ebx,30*65536+5 + add bx,word[wndMain.top] + mov ecx,[sc.work_text] + or ecx,0x80000000 + mov edx,txtFormatCapt + int 0x40 + + mov ebx,10*65536+30 + add ebx,dword[tree1.box_height] + add bx,word[wndMain.top] + mov edx,txtFormatApply + int 0x40 + + pop edx ecx ebx eax + ret + @@: + push eax edx + mov eax,8 + mov edx,200 + or edx,0x80000000 + int 0x40 + pop edx eax + ret + +draw_cur_line: + push eax ebx ecx edx esi edi + + mov edi,[cur_y] + + mov ebx,[wndMain.left] + add ebx,[recMain.left] + inc ebx + shl ebx,16 + add ebx,edi + imul bx,word[recMain.height] + add ebx,[wndMain.top] + add ebx,[recMain.top] + inc ebx + + add edi,[wScr.position] + mov esi,1 + call SelNormalize ;need before draw select + call clear_line_before_draw + + mov esi,[hScr.position] + mov ecx,edi + call GetPosByParam + + cmp [gpOpt],2 + jne .no_draw_text +; mov eax,4 ;draw text + call GetSymbColor + mov esi,1 ;draw 1 symbol + @@: + ;call IteratNext + cmp edx,[tex_1] + jle .no_draw_text + + ; *** цветовая разметка + cmp byte[mode_colored],0 + je .no_col_change + cmp byte[edx+1],0 + je .no_col_change + call GetSymbColor + .no_col_change: + + mov eax,4 ;draw text + cmp byte [edx],13 + jne .no_13 + cmp [invis],1 + jne .no_draw_text + push edx + mov edx,symbol_new_line + int 0x40 + pop edx + jmp .no_draw_text + .no_13: + + int 0x40 + ror ebx,16 + add bx,word[recMain.width] +; cmp bx,word[wndMain.width] + mov ax,word[wndMain.width] + add ax,word[wndMain.left] ;ax = отступ по оси x + cmp bx,ax + jge .no_draw_text ;Opt + ror ebx,16 + call IteratNext + jmp @b + .no_draw_text: + + pop edi esi edx ecx ebx eax + call draw_main_cursor + ret + +MIN_M_WND_H equ 100 +MIN_W_SCRL_ARE equ 3 +MIN_H_SCRL_ARE equ 3 +EvSize: + push eax ecx edx edi + m2m [wndMain.width],[procinfo.client_box.width] + mov ax,word[wndMain.left] + sub word[wndMain.width],ax + mov eax,[wScr] ;+0 size_x + sub word[wndMain.width],ax + + m2m [wndMain.height],[procinfo.client_box.height] + cmp [wndMain.height],MIN_M_WND_H + jg @f + mov [wndMain.height],MIN_M_WND_H + @@: + + mov ax,word[hScr.size_y] + sub word[wndMain.height],ax + mov eax,[wndMain.height] ;.height = .top+.height + mov word[hScr.start_y],ax + mov eax,[wndMain.top] + sub word[wndMain.height],ax + + m2m word[wScr.start_x],word[wndMain.width] + mov ax,word[wndMain.left] + add [wScr.start_x],ax + m2m word[wScr.size_y],word[wndMain.height] + + m2m word[hScr.start_x],word[recMain.left] + add [hScr.start_x],ax ;ax=[wndMain.left] + mov eax,[wndMain.width] + sub ax,word[recMain.left] + mov word[hScr.size_x],ax + + mov eax,[wndMain.height] ;calculate lines in page + sub eax,[recMain.top] + xor edx,edx + mov ecx,[recMain.height] + div ecx + cmp eax,MIN_W_SCRL_ARE + jg @f + mov eax,MIN_W_SCRL_ARE + @@: + mov [wScr.cur_area],eax + + mov eax,[wndMain.width] ;calculate cols in page + sub eax,[recMain.left] + xor edx,edx + mov ecx,[recMain.width] + div ecx + cmp eax,MIN_H_SCRL_ARE + jg @f + mov eax,MIN_H_SCRL_ARE + @@: + dec eax ; ??? + mov [hScr.cur_area],eax + + mov edi,dword tree1 + m2m tl_box_top,dword[wndMain.top] + add tl_box_top,20 + + m2m dword[edit2.top],dword[wndMain.top] + add dword[edit2.top],20 + + pop edi edx ecx eax + call OnInitialUpdate + ret + +OnInitialUpdate: + mov [wScr.redraw],1 + mov [hScr.redraw],1 + ret + +;output: +; edx = pointer to symbol +; edx = 0 if text not in screen +GetFirstVisiblePos: + push ecx + mov edx,[tex] + xor ecx,ecx + @@: + cmp ecx,[wScr.position] + je @f + call IteratNext + cmp edx,[tex_1] + jle @f + cmp byte [edx],13 + jne @b + inc ecx + jmp @b + @@: + + cmp ecx,[wScr.position] + je @f + xor edx,edx + @@: + cmp ecx,[wScr.max_area] + jle @f + mov [wScr.max_area],ecx + @@: + pop ecx + call OptDrawLineLeft + ret + + + +;input: +; edx = pointer to symbol +;output: +; edx = pointer to first left symbol +OptDrawLineLeft: + push ecx + mov ecx,[hScr.position] + cmp ecx,0 + je .ret_f + push eax + mov eax,edx + + cmp edx,[tex] + jne @f + call IteratNext + jmp .beg_cycle + @@: + + cmp ecx,0 + je @f + + cmp byte[edx],13 + jne @f + call IteratNext + .beg_cycle: + @@: + cmp edx,[tex_1] + jle @f + cmp byte[edx],13 + je @f + cmp ecx,0 + je @f + mov eax,edx + call IteratNext + dec ecx + jmp @b + @@: + mov edx,eax + pop eax + .ret_f: + pop ecx + call GetSymbColor + ret + +;input: +; edx = pointer to symbol +;output: +; edx = pointer to 13 symbol +OptDrawLineRight: + push eax + mov eax,edx + @@: + cmp edx,[tex_1] + jle @f + cmp byte[edx],13 + je @f + mov eax,edx + call IteratNext + jmp @b + @@: + mov edx,eax ;perv sumbol + pop eax + call GetSymbColor + ret + +txtRow db '‘ва®Є ',0 +txtCol db '‡­ Є',0 +txtOtm db 'Ћв¬Ґ­л',0 + +draw_main_cursor: + push eax ebx ecx edx edi esi + + mov eax,13 ;draw cursor + mov ecx,[wndMain.top] ;calc rect -> y0,y1 + add ecx,[recMain.top] + mov edx,[cur_y] + imul edx,[recMain.height] + add ecx,edx + + cmp [curMod],1 + jne @f + mov edx,[recMain.height] + inc edx ; 1->1, 3->2, 5->3, ... + shr edx,1 + add ecx,edx + @@: + shl ecx,16 + add ecx,[recMain.height] + cmp [curMod],1 + jne @f + shr cx,1 + @@: + + mov ebx,[wndMain.left] ;calc rect -> x0,x1 + add ebx,[recMain.left] + mov edx,[cur_x] + imul edx,[recMain.width] + add ebx,edx + shl ebx,16 + add ebx,[recMain.width] + + mov edx,[CURSOR_COLOR] + int 0x40 + + call GetPos + cmp [gpOpt],2 + jne @f + mov eax,4 ;draw text + mov esi,1 + ror ecx,16 + mov bx,cx + add ebx,0x10001 + cmp [curMod],1 + jne .no_up_tetx + mov cx,word[recMain.height] + inc cx ; 1->1, 3->2, 5->3, ... + shr cx,1 + sub bx,cx + .no_up_tetx: + mov ecx,[CUR_TEXT_COLOR] + call ConvertInvisSymb + int 0x40 + @@: + + + + mov eax,4 + mov ebx,[wndMain.left] + add ebx,[recMain.left] + shl ebx,16 + add ebx,[wndMain.top] + add ebx,3 + mov ecx,[WND_BORD_COLOR] + or ecx,0x80000000 + mov edx,txtRow + int 0x40 + + add ebx,0x500000 + mov edx,txtCol + int 0x40 + + cmp [tim_Undo],0 + je @f + add ebx,0x500000 + mov edx,txtOtm + int 0x40 + sub ebx,0x500000 + @@: + + call draw_bufer + call draw_help_f1 + + mov eax,47 ;draw cursor coords + mov esi,[WND_BORD_COLOR] + or esi,0x40000000 + mov edi,[WND_WORK_COLOR] + + mov edx,ebx + ror edx,16 + sub edx,35 + ror edx,16 + ;add edx,3 + mov ebx,0x40000 ;Row=... + mov ecx,[cur_y] + inc ecx + add ecx,[wScr.position] + int 0x40 + + ;mov ebx,0x40000 ;Col=... + mov ecx,[cur_x] + inc ecx + add ecx,[hScr.position] + add edx,0x500000 + int 0x40 + + cmp [tim_Undo],0 + je @f + mov ecx,[tim_Undo] + add edx,0x500000 + int 0x40 + @@: + + pop esi edi edx ecx ebx eax + ret + + +draw_bufer: + push eax ebx ecx edx esi edi + cmp byte[buf],0 + je @f + mov ebx,[wndMain.left] + add ebx,[recMain.left] + add bx,250 + shl ebx,16 + add ebx,[wndMain.top] + add ebx,3 + mov ecx,[WND_BORD_COLOR] + or ecx,0x40000000 + mov edi,[WND_WORK_COLOR] + + mov edx,txtBuf + mov esi,buf + call strlen + cmp eax,15 + jle .crop_buf + mov eax,15 + .crop_buf: + mov esi,7 + add esi,eax + + mov eax,4 + int 0x40 + @@: + pop edi esi edx ecx ebx eax + ret + +draw_help_f1: + push eax ebx ecx edx edi + mov eax,13 ;clear place before draw help + mov ebx,[wndMain.left] + add ebx,[recMain.left] + shl ebx,16 + add ebx,[wndMain.width] + sub ebx,[recMain.left] + mov ecx,[wndMain.top] + add ecx,13 + shl ecx,16 + add ecx,[recMain.height] + mov edx,[WND_CAPT_COLOR] + int 0x40 + + cmp [help_id],-1 + je @f;.no_help + mov eax,[help_id] + ColToIndexOffset eax,edx + + ;SetCoordinates + mov ebx,[wndMain.left] + add ebx,[recMain.left] + shl ebx,16 + add ebx,[wndMain.top] + add ebx,13 ;=3+10 + + ;SetTextColor + xor eax,eax + mov al,byte[edx+MAX_COLOR_WORD_LEN+6] + shl ax,2 + mov ecx,[tex_colors] + add ecx,eax + push dword[ecx] + pop ecx + or ecx,0xc0000000 ;SetTextStyles + mov edi,[WND_WORK_COLOR] + + mov eax,4 + int 0x40 + + ;*** draw help string *** + mov ecx,[WND_BORD_COLOR] + or ecx,0x80000000 + mov edi,dword[edx+MAX_COLOR_WORD_LEN] + cmp edi,0 + je @f + add edi,dword[tex_help_f1] + mov edx,edi + add ebx,0x500000 + int 0x40 + @@: + ;.no_help: + pop edi edx ecx ebx eax + ret + +draw_line_numbers: + push eax ebx ecx edx esi ;edi + ;line numbers + mov eax,47 + mov esi,[WND_BORD_COLOR] + ;or esi,0x40000000 + ;mov edi,[WND_WORK_COLOR] + mov ebx,0x40000 ;format + + mov ecx,[wScr.position] + inc ecx + mov dx,3 + add dx,word[wndMain.left] + shl edx,16 + mov dx,word[wndMain.top] + add dx,word[recMain.top] + @@: + +push eax ebx ecx edx + mov eax,13 + ;left panel with numbers + mov ebx,[wndMain.left] + shl ebx,16 + add ebx,[recMain.left] + mov cx,dx +; mov ecx,[wndMain.top] ;draw caption +; add ecx,[recMain.top] + shl ecx,16 + mov cx,word [recMain.height] + mov edx,[WND_CAPT_COLOR] + int 0x40 +pop edx ecx ebx eax + + int 0x40 + inc ecx + add dx,word[recMain.height] + sub dx,word[wndMain.top] + cmp dx,word[wndMain.height] + jge @f + add dx,word[wndMain.top] + jmp @b + @@: + + pop esi edx ecx ebx eax + ret + + +draw_cursor_sumb: ;this function need to optimize output + push eax ecx edx + mov eax,13 ;rect + mov ebx,[wndMain.left] + add ebx,[recMain.left] + mov edx,[cur_x] + imul edx,[recMain.width] + add ebx,edx + shl ebx,16 + add ebx,[recMain.width] + + mov ecx,[wndMain.top] ;calc rect -> y0,y1 + add ecx,[recMain.top] + mov edx,[cur_y] + imul edx,[recMain.height] + add ecx,edx + shl ecx,16 + add ecx,[recMain.height] + + mov edx,[WND_WORK_COLOR] + push ecx + call SelNormalize + + mov ecx,[wScr.position] + sub [seln.y0],ecx + sub [seln.y1],ecx + + mov ecx,[cur_y] + cmp ecx,[seln.y0] + jl .no_cur_sel + cmp ecx,[seln.y1] + jg .no_cur_sel + mov edx,[SELECT_COLOR] + + cmp ecx,[seln.y0] + jne @f + mov ecx,[cur_x] + add ecx,[hScr.position] + cmp ecx,[seln.x0] + jge @f + mov edx,[WND_WORK_COLOR] + @@: + + mov ecx,[cur_y] + cmp ecx,[seln.y1] + jne .no_cur_sel + mov ecx,[cur_x] + add ecx,[hScr.position] + cmp ecx,[seln.x1] + jl .no_cur_sel + mov edx,[WND_WORK_COLOR] + + .no_cur_sel: + pop ecx + int 0x40 + + call GetPos + cmp [gpOpt],2 + jne @f + push esi + mov eax,4 ;draw text + mov esi,1 + ror ecx,16 + mov bx,cx + add ebx,0x10001 + ;mov ecx,[WND_TEXT_COLOR] + call GetSymbColor + call ConvertInvisSymb + int 0x40 + pop esi + @@: + + pop edx ecx eax + ret + + + +;input: +; edx = pointer to text +;output: +; ecx = color +; if mode_colored=0 then ecx=WND_TEXT_COLOR +GetSymbColor: + mov ecx,[WND_TEXT_COLOR] + + push eax edx + cmp byte[mode_colored],0 + je .exit + jmp .on_first + @@: + call IteratPerv + cmp edx,[tex_1] + jle .exit + .on_first: + xor eax,eax + mov al,byte[edx+1] + cmp al,0 + je @b + + ;cmp al,0xff + ;je .exit + cmp eax,[ColColor] + jge .exit + + shl ax,2 ;*4 + mov ecx,[tex_colors] + add ecx,eax + push dword[ecx] + pop ecx + .exit: + pop edx eax + ret + +;input: +; edx = pointer to text +ConvertInvisSymb: + cmp [invis],1 + jne @f + cmp byte [edx],13 + jne @f + mov edx,symbol_new_line + @@: + ret + +;input: +; ecx = 0x4000____ +; cx = icon index +; edx = x*2^16+y +draw_but_icon: + push eax ebx + + mov eax,8 ;кнопка + push ecx edx esi + mov ebx,edx + mov edx,ecx + add edx,3 + mov cx,bx + shl ecx,16 + mov cx,19 ;=20-1 + mov bx,19 ;=20-1 + mov esi,[sc.work_button] + int 0x40 + pop esi edx ecx + + mov ebx,ecx + ror ebx,16 + cmp bx,0x4000 + jne @f + + mov eax,7 ;bmp + mov ebx,[bmp_icon] + push ecx + and ecx,0xffff + imul ecx,1200 + add ebx,ecx + mov ecx,20 + shl ecx,16 + add ecx,20 + int 0x40 + pop ecx + + @@: + pop ebx eax + ret + diff --git a/programs/other/t_edit/t_edit.asm b/programs/other/t_edit/t_edit.asm new file mode 100644 index 0000000000..82678bef1d --- /dev/null +++ b/programs/other/t_edit/t_edit.asm @@ -0,0 +1,875 @@ +;Огромная благодарность Maxxxx32, Diamond, Heavyiron +;и другим программистам, а также +;Теплову Алексею ( www.lrz.land.ru) + + +use32 + org 0x0 + db 'MENUET01' ;идентиф. исполняемого файла всегда 8 байт + dd 0x01 + dd start + dd i_end ; размер приложения + dd mem + dd stacktop + dd file_name;buf_cmd_lin + dd sys_path + +MAX_COLOR_WORD_LEN equ 40 +maxChars equ 100002 ;(...+2) +BUF_SIZE equ 1000 ;bufer for copy|paste +maxColWords equ 10000 + + +include '../../macros.inc' +;include '../../develop/libraries/box_lib/load_lib.mac' +include 'load_lib.mac' ;include old file +include '../../develop/libraries/box_lib/trunk/tree_list.mac' +include '../../develop/libraries/box_lib/trunk/editbox_ex.mac' + +include 't_data.inc' +include 'strlen.inc' +include 't_work.inc' ;text work functions +include 't_draw.inc' ;draw main window functions +include 't_button.inc' + +@use_library + +start: + mov eax,48 + mov ebx,3 + mov ecx,sc + mov edx,sizeof.system_colors + mcall + + m2m [wScr.bckg_col],[sc.work] + m2m [wScr.frnt_col],[sc.work_button] + m2m [wScr.line_col],[sc.work_button_text] + + m2m [hScr.bckg_col],[sc.work] + m2m [hScr.frnt_col],[sc.work_button] + m2m [hScr.line_col],[sc.work_button_text] + + + mcall 68,11 + or eax,eax + jz button.exit + + mcall 66,1,1 ;scan code + ;mcall 26,2,1,conv_tabl + + mov ecx,sizeof.symbol*maxChars + call mem_Alloc + mov [tex],eax + mov [tex_1],eax + add [tex_1],sizeof.symbol + mov [tex_end],eax + add [tex_end],sizeof.symbol*maxChars + + mcall 40,0x27 + + call Clear + +;------------------------------------------------- + mov ecx,maxColWords*sizeof.TexColViv + add ecx,40 + call mem_Alloc + mov [options_file],eax + mov [options_file_end],eax + add [options_file_end],maxColWords*sizeof.TexColViv + add [options_file_end],40 + +;------------------------------------------------- +; init bmp file + mov ecx,1200*18 + call mem_Alloc + mov [bmp_icon],eax + + mov esi,file_name + call strlen + mov ecx,eax + mov edi,buf_cmd_lin + rep movsb + + copy_path fn_icon,sys_path,file_name + + mov eax,70 ;load icon file + mov [run_file_70.func_n], 0 + mov [run_file_70.param1], 54 + mov [run_file_70.param2], 0 + mov [run_file_70.param3], 1200*18 + m2m [run_file_70.param4], [bmp_icon] + mov [run_file_70.rezerv], 0 + mov [run_file_70.name], file_name + mov ebx,run_file_70 + int 0x40 + + cmp ebx,-1 + mov [err_ini0],1 + je @f ;if open file + mov [err_ini0],0 + @@: + +load_libraries l_libs_start,load_lib_end + +;Їа®ўҐаЄ  ­  бЄ®«мЄ® г¤ з­® § Јг§Ё« бм ­ и  «ЁЎ  + mov ebp,lib0 + 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 +@@: + + +;--------------------------------------------------------------------- + push dword tree1 + call dword[tl_data_init] +;--------------------------------------------------------------------- +; читаем bmp файл с курсорами и линиями + copy_path fn_icon_tl_sys,sys_path,file_name + + mov ecx,3*256*13 + call mem_Alloc + mov dword[tree1.data_img_sys],eax + + mov [run_file_70.func_n], 0 + mov [run_file_70.param1], 54 + mov [run_file_70.param2], 0 + mov [run_file_70.param3], 3*256*13 + mov [run_file_70.param4], eax + mov [run_file_70.rezerv], 0 + mov [run_file_70.name], 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 + @@: +;--------------------------------------------------------------------- +; читаем bmp файл с иконками узлов + copy_path fn_icon_tl_nod,sys_path,file_name + + mov ecx,3*256*2 + call mem_Alloc + mov dword[tree1.data_img],eax + +; mov [run_file_70.func_n], 0 +; mov [run_file_70.param1], 54 +; mov [run_file_70.param2], 0 + mov [run_file_70.param3], 3*256*2 + mov [run_file_70.param4], eax +; mov [run_file_70.rezerv], 0 +; mov [run_file_70.name], 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 + @@: +;------------------------------------------------------------------------------ + copy_path fn_syntax_dir,sys_path,file_name ;берем путь к папке с файлами синтаксиса + mov eax,70 + mov ebx,tree_file_struct + int 0x40 + +cmp ebx,-1 +je .end_dir_init + + mov eax,dir_mem + add eax,32+4+1+3+4*6+8 +mov ecx,ebx +@@: + cmp byte[eax],'.' ;фильтруем файлы с именами '.' и '..' + je .filter + push dword tree1 + push dword 0x10000 ;1*2^16 - где 1 номер иконки с книгой + push dword eax + call dword[tl_node_add] + + push dword tree1 + call dword[tl_cur_next] + .filter: + add eax,304 + loop @b +.end_dir_init: + +; push dword tree1 +; push dword 0 +; push dword file_name +; call dword[tl_node_add] + + +;--- load color option file --- + call InitColText + +;--- get cmd line --- + cmp byte[buf_cmd_lin+3],0 ;buf_cmd_lin + je @f ;if file names exist + mov esi,buf_cmd_lin + call strlen ;eax=strlen + mov [edit1.size],eax + call but_OpenFile + @@: + + +red_win: + mov eax,12 + mov ebx,1 + mcall + + xor eax,eax + mov ebx,10*65536+485 + mov ecx,10*65536+280 + mov edx,[sc.work] + or edx,0x73000000 + mov edi,hed + mcall + + mcall 9,procinfo,-1 + call EvSize + + mov eax,13 ;rect + xor ebx,ebx + xor ecx,ecx + mov bx,word [procinfo.client_box.width] + inc bx + mov cx,word [wndMain.top] + mcall + + push dword edit1 + call [edit_box_draw] + +; draw for Menu 1 + push dword menu_data_1 + call [menu_bar_draw] + + call draw_but_toolbar + + cmp [err_ini0],1 + jne @f + mov eax,4 + mov ebx,[wndMain.left] + add ebx,[recMain.left] + shl ebx,16 + add ebx,[wndMain.top] + add ebx,[recMain.top] + mov ecx,0x80ff0000 + mov edx,txtErrIni0 + int 0x40 + + add ebx,10 ;move <--y--> + mov ecx,0x80ff0080 + mov edx,file_name + int 0x40 + @@: + + cmp [err_ini0],1 + je @f + call draw_main_win + @@: + + cmp [err_opn],1 + jne @f + ;mov eax,4 + mov ebx,10*65536+35 + mov ecx,0x80ff0000 + mov edx,txtErrOpen + mcall + @@: + + mov eax,12 + mov ebx,2 + mcall + +still: + mov eax,10 + mcall + + cmp al,1 ;изм. положение окна + jz red_win + cmp al,2 + jz key + cmp al,3 + jz button + cmp al,6 + jz mouse + + jmp still + + + +mouse: + push dword edit1 + call [edit_box_mouse] + + test word [edit1.flags],10b;ed_focus ; Ґб«Ё ­Ґ ў д®ЄгбҐ, ўл室Ё¬ + jne still + +;----------------------------------------------- + cmp [hScr.delta2],0 + jne .horizontal +.vertical: + mov eax,[wScr.max_area] + cmp eax,[wScr.cur_area] + jbe .horizontal +; mouse event for Vertical ScrollBar + push dword wScr + call [scrollbar_ver_mouse] + mov eax,wScr.redraw + xor ebx,ebx + cmp [eax],ebx + je @f + mov [eax],ebx + + call draw_main_win + ;call mouse_wnd_main + jmp still +@@: + cmp [wScr.delta2],0 + jne still +.horizontal: + mov eax,[hScr.max_area] + cmp eax,[hScr.cur_area] + jbe .other +; mouse event for Horizontal ScrollBar + push dword hScr + call [scrollbar_hor_mouse] + mov eax,hScr.redraw + xor ebx,ebx + cmp [eax],ebx + je .other + mov [eax],ebx + call draw_main_win + jmp still +.other: + cmp [wScr.delta2],0 + jne still + cmp [hScr.delta2],0 + jne still + + call mouse_wnd_main + + cmp byte[panel_id],TE_PANEL_FIND ;if not panel + jne @f + push dword edit2 + call [edit_box_mouse] + @@: + cmp byte[panel_id],TE_PANEL_SYNTAX ;if not panel + jne .menu_bar_1 ;@f + push dword tree1 + call [tl_mouse] +;----------------------------------------------- +.menu_bar_1: + mov [menu_data_1.get_mouse_flag],1 +; mouse event for Menu 1 + push dword menu_data_1 + call [menu_bar_mouse] + cmp [menu_data_1.click],dword 1 + jne .mnu_1 + cmp [menu_data_1.cursor_out],dword 4 + je button.exit + cmp [menu_data_1.cursor_out],dword 3 + jne @f + call but_SaveFile + @@: + cmp [menu_data_1.cursor_out],dword 2 + jne @f + call but_OpenFile + @@: + cmp [menu_data_1.cursor_out],dword 1 + jne @f + call but_NewFile + @@: + ;cmp [menu_data_1.cursor_out],dword 0 + ;jne @f +.mnu_1: + jmp still +;--------------------------------------------------------------------- + +KeyConvertToASCII: + mov ebx,conv_tabl ;convert scan to ascii + ror ax,8 + xor ah,ah + add bx,ax + mov ah,byte[ebx] + ret + +key: + mov ecx,1 + mcall 66,3 + xor ebx,ebx + test al,0x03 ;[Shift] + jz @f + inc cl + or ebx,KM_SHIFT + @@: + test al,0x0c ;[Ctrl] + jz @f + or ebx,KM_CTRL + @@: + test al,0x30 ;[Alt] + jz @f + or ebx,KM_ALT + @@: + test al,0x80 ;[NumLock] + jz @f + or ebx,KM_NUMLOCK + @@: + + mov [keyUpr],ebx + mcall 26,2,,conv_tabl + mcall 2 + +; push dword tree1 ;??? +; call [tl_key] ;??? + + 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 +; cmp [keyUpr],0 +; jne still + + call KeyConvertToASCII + + push dword edit1 + call [edit_box_key] + jmp still + @@: + + test word [edit2.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 +; cmp [keyUpr],0 +; jne still + + call KeyConvertToASCII + push dword edit2 + call [edit_box_key] + jmp still + @@: + + cmp ah,KEY_F1 ;[F1] + jne @f + call ShowHelpF1 + jmp still + @@: + cmp ah,KEY_F3 ;[F3] + jne @f + call but_FindText + jmp still + @@: + + test [keyUpr],KM_CTRL ;Ctrl+... + jz .key_Ctrl + + cmp ah,24 ;Ctrl+O + jne @f + call but_OpenFile + @@: + cmp ah,33 ;Ctrl+F + jne @f + cmp byte[panel_id],TE_PANEL_FIND + je @f + call but_find + @@: + cmp ah,44 ;Ctrl+Z + je but_undo + cmp ah,46 ;Ctrl+C + jne @f + call but_Copy + @@: + cmp ah,47 ;Ctrl+V + je but_paste + cmp ah,49 ;Ctrl+N + jne @f + call but_NewFile + @@: + cmp ah,199 ;Ctrl+Home + jne @f + call but_CtrlHome + @@: + ;jmp still + .key_Ctrl: + + test [keyUpr],KM_SHIFT ;Shift+... + jz .key_Shift + cmp ah,72 ;Shift+Up + jne @f + call sel_KeyUp + @@: + cmp ah,75 ;Shift+Left + jne @f + call sel_KeyLeft + @@: + cmp ah,77 ;Shift+Right + jne @f + call sel_KeyRight + @@: + cmp ah,80 ;Shift+Down + jne @f + call sel_KeyDown + @@: + ;mov [dragk],1 ;начинаем выделение от клавиатуры + jmp .key_MoveCur + .key_Shift: +;------------------------------------------------- + cmp ah,72 ;178 ;Up + jne @f + push dx + call draw_cursor_sumb + call CurMoveUp + cmp dl,8 + jne .no_red_0 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_0: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,80 ;177 ;Down + jne @f + push dx + call draw_cursor_sumb + call CurMoveDown + cmp dl,8 + jne .no_red_1 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_1: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,75 ;176 ;Left + jne @f + push dx + call draw_cursor_sumb + call CurMoveLeft + cmp dl,8 + jne .no_red_2 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_2: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,77 ;179 ;Right + jne @f + push dx + call draw_cursor_sumb + call CurMoveRight + cmp dl,8 + jne .no_red_3 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_3: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,71 ;180 ;Home + jne @f + push dx + call draw_cursor_sumb + call CurMoveX_FirstChar + cmp dl,8 + jne .no_red_4 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_4: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,79 ;181 ;End + jne @f + push dx + call draw_cursor_sumb + call CurMoveX_LastChar + cmp dl,8 + jne .no_red_5 + call OnInitialUpdate + call draw_main_win + pop dx + jmp @f + .no_red_5: + call draw_main_cursor + pop dx + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: + cmp ah,73 ;184 ;PageUp + jne @f + push dx + call CurMovePageUp + cmp dl,0 + pop dx + je @f + call OnInitialUpdate + call draw_main_win + @@: + cmp ah,81 ;183 ;PageDown + jne @f + push dx + call CurMovePageDown + cmp dl,0 + pop dx + je @f + call OnInitialUpdate + call draw_main_win + mov [dragk],0 ;заканчиваем выделение от клавиатуры + @@: +;------------------------------------------------- + cmp [keyUpr],0 + jne still + .key_MoveCur: + + cmp ah,69 ;[Pause Break] + je still + cmp ah,120 ;[Fn] + je still + cmp ah,0x80 ;if key up + ja still + call KeyConvertToASCII + + ;mov [dragk],0 ;заканчиваем выделение от клавиатуры + + push ebx + xor ebx,ebx + mov bl,ah + add ebx,EvChar ;add char to text + cmp byte [ebx],1 + jne @f + push esi edi + call SetUndo + mov bx,0x0101 + call SelTextDel + mov esi,1 + mov byte [key_new],ah + mov edi,dword key_new + cmp [curMod],1 + je .no_ins_mod + call TextDel + xor bl,1 + .no_ins_mod: + call TextAdd + call draw_but_toolbar + cmp byte [key_new],13 + jne .dr_m_win + call draw_main_win + jmp .dr_cur_l + .dr_m_win: + call draw_cur_line + .dr_cur_l: + pop edi esi + @@: + pop ebx + + cmp ah,8 ;[<-] + jne @f + push ax bx + call SetUndo + + mov bx,0x0001 + call SelTextDel + cmp al,1 + je .del_one_b + call TextDel + .del_one_b: + call draw_but_toolbar + call draw_main_win + pop bx ax + @@: + + cmp ah,182 ;Delete + jne @f + push ax bx + call SetUndo + + mov bx,0x0101 + call SelTextDel + cmp al,1 + je .del_one_d + call TextDel + .del_one_d: + call draw_but_toolbar + call draw_main_win + pop bx ax + @@: + + cmp ah,185 ;Ins + jne @f + call draw_cursor_sumb + xor [curMod],1 + call draw_main_cursor + @@: + + jmp still + +button: +; cmp [menu_active],1 ;если нажали меню, то сначала реакция на меню +; jne @f ;mouse.menu_bar_1 +; mov [menu_active],0 +; jmp still +; @@: + + mcall 17 ;получить код нажатой кнопки + cmp ah,3 + jne @f + call but_NewFile + @@: + cmp ah,4 + jne @f + call but_OpenFile + @@: + cmp ah,5 + jne @f + call but_SaveFile + @@: + cmp ah,6 + jz but_select_word + cmp ah,7 + jz but_cut + cmp ah,8 + jne @f + call but_Copy + @@: + cmp ah,9 + jz but_paste + cmp ah,10 + jz but_find + cmp ah,11 + jz but_replace + cmp ah,12 + jz but_find_key_w + cmp ah,13 + jz but_sumb_upper + cmp ah,14 + jz but_sumb_lover + cmp ah,15 + jz but_reverse + cmp ah,16 + jz but_undo + cmp ah,17 + jz but_redo + cmp ah,18 + jz but_sumb_invis + cmp ah,19 + jz but_k_words_show + cmp ah,20 + jz but_synt_show + + cmp ah,200 + jne @f + call but_OpenSyntax + @@: + cmp ah,201 + jne @f + call but_FindText + @@: + + cmp ah,1 + jne still +.exit: + ;push eax + call CanSave + cmp al,1 + jne @f + push thread + push msgbox_8 + call [mb_create] ;message: save changes in file? + jmp still + @@: + mov ecx,[tex] + call mem_Free + mov ecx,[bmp_icon] + call mem_Free + mov ecx,[options_file] + call mem_Free + push dword tree1 + call dword[tl_data_clear] + mcall -1 ;выход из программы + + + +txtErrOpen db 'ЌҐ ­ ©¤Ґ­ д ©«, Їа®ўҐам⥠Їа ўЁ«м­®бвм Ё¬Ґ­Ё',0 +txtErrIni0 db 'ЌҐ ®вЄал«бп д ©« б ЁЄ®­Є ¬Ё',0 +err_ini0 db 0 + +edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_cmd_lin, mouse_dd, 0 +edit2 edit_box TE_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0 + +buf_cmd_lin db 302 dup(0) +buf_find db 302 dup(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 +;head_f_i1: +;head_f_l1 db 'System error',0 +err_message_import1 db 'Error on load import library msgbox.obj',0 + +;library structures +l_libs_start: + lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, myimport,err_message_import0, head_f_i0 + lib1 l_libs msgbox_name, sys_path, file_name, system_dir1, err_message_found_lib1, head_f_l0, msgbox_lib_import, err_message_import1, head_f_i0 +load_lib_end: + + +i_end: + align 16 + procinfo process_information + thread: + rb 1024 +stacktop: + sys_path: + rb 4096 + file_name: + rb 4096 + file_name_rez: + rb 4096 + file_info: + rb 40 +mem: diff --git a/programs/other/t_edit/t_edit.png b/programs/other/t_edit/t_edit.png new file mode 100644 index 0000000000..e8c2fdb807 Binary files /dev/null and b/programs/other/t_edit/t_edit.png differ diff --git a/programs/other/t_edit/t_work.inc b/programs/other/t_edit/t_work.inc new file mode 100644 index 0000000000..b15cb4adf1 --- /dev/null +++ b/programs/other/t_edit/t_work.inc @@ -0,0 +1,1759 @@ +struct f70 + func_n dd ? + param1 dd ? + param2 dd ? + param3 dd ? + param4 dd ? + rezerv db ? + name dd ? +ends + +struct TexSelect + x0 dd ? + y0 dd ? + x1 dd ? + y1 dd ? +ends + +struct TexColViv + Text rb MAX_COLOR_WORD_LEN; // слово + f1 dd 0 + wwo db ? ; whole words only + endc db ? ; символ конца выделения (wwo&4) + color db ? ; номер цвета +ends + +struct symbol + c db ? ; +0 символ + col db ? ; +1 цвет + perv dd ? ; +2 + next dd ? ; +6 указатели + tc dd ? ; +10 врем. создания + td dd ? ; +14 врем. удаления +ends + +ColColor dd 1 +ColWords dd 0 +CURSOR_COLOR dd 0x808080 +WND_CAPT_COLOR dd 0x80 +WND_WORK_COLOR dd 0x0 +WND_BORD_COLOR dd 0xd0d0d0 +SELECT_COLOR dd 0x208080 +CUR_TEXT_COLOR dd 0xff0000 +WND_TEXT_COLOR dd 0xffff00 + +options_file dd 0 +options_file_end dd 0 +tex_colors dd 0 +tex_help_f1 dd 0 + +FkPos: rd 256 +Col dd 0 ;указатель на структуры ключевых слов TexColViv + +conv_tabl rb 128 ; таблица для конвертирования scan-кода в ascii-код +keyUpr dd 0 +err_opn db 0 ;ошибка открытия файла +err_sav db 0 ;ошибка сохранения файла +panel_id db 0 ;номер открытой панели + +ch_tim dd ? ; количество изменений в файле +ls_tim dd ? ; время последнего сохранения +co_tim dd ? ; время последней цветовой разметки +tim_Undo dd ? ; количество отмененных действий +gpOpt db 0 +mode_colored db 1 ; режим выделения слов цветом (0-выкл. 1-вкл.) + +txtBuf db 'ЃгдҐа: ' +buf db BUF_SIZE dup(0) +key_new db 0 ; символ, который будет добавлятся с клавиатуры +tex dd 0 +tex_1 dd 0 +tex_end dd 0 + +hed db 'TextEditor 29.12.09',0 ;подпись окна +sc system_colors + +wndMain BOX 0,50,440,150 +recMain BOX 30,23,7,10 + +curMod db 1 +cur_x dd 0 +cur_y dd 0 +invis db 0 ;режим показа непечатаемых символов +symbol_new_line db 20 ;символ завершения строки +dragm db 0 ;выделение от мыши +dragk db 0 ;выделение от клавиатуры +sel TexSelect 0,0,0,0 ;структура выделения +seln TexSelect ;дополнительная структура выделения +help_id dd -1 ;идентификатор для справки + +fn_icon db 'te_icon.bmp',0 +bmp_icon dd 0 +run_file_70 f70 + + +;input: +; reg = index +;output: +; reg = pointer to 'tex' struct +macro ConvertIndexToPointer reg { + imul reg,sizeof.symbol + add reg,[tex] +} + + +;output: +; al = 1 - can save +CanSave: + push ecx + mov ecx,[ch_tim] + sub ecx,[tim_Undo] + mov al,1 + cmp [ls_tim],ecx + jne @f + dec al + @@: + pop ecx + ret + + +;output: +; al = 1 - selected +IsSel: + push ebx + xor al,al + cmp [dragm],1 + je @f + mov al,1 + mov ebx,[sel.x0] + cmp ebx,[sel.x1] + jne @f + mov ebx,[sel.y0] + cmp ebx,[sel.y1] + jne @f + xor al,al + @@: + pop ebx + ret + +SelNormalize: + push ecx esi edi + mov esi,sel + mov edi,seln + mov ecx,sizeof.TexSelect + rep movsb + + jmp @f + .swp_f: + mov ecx,[seln.x0] + m2m [seln.x0],[seln.x1] + mov [seln.x1],ecx + + mov ecx,[seln.y0] + cmp ecx,[seln.y1] ;(sel.y0>sel.y1) + jle .end_f + m2m [seln.y0],[seln.y1] + mov [seln.y1],ecx + + jmp .end_f + @@: + + mov ecx,[seln.y0] + cmp ecx,[seln.y1] ;(sel.y0>sel.y1) + jg .swp_f + + cmp ecx,[seln.y1] ;(sel.y0==sel.y1) + jne .end_f + mov ecx,[seln.x0] + cmp ecx,[seln.x1] ;(sel.x0>sel.x1) + jg .swp_f + + .end_f: + pop edi esi ecx + ret + +SelStart: + push ecx + mov ecx,[cur_x] + add ecx,[hScr.position] + mov [sel.x0],ecx + mov [sel.x1],ecx + + mov ecx,[cur_y] + add ecx,[wScr.position] + mov [sel.y0],ecx + mov [sel.y1],ecx + pop ecx + ret + +SelMove: + push ecx + mov ecx,[cur_x] + add ecx,[hScr.position] + mov [sel.x1],ecx + + mov ecx,[cur_y] + add ecx,[wScr.position] + mov [sel.y1],ecx + pop ecx + ret + +;input: +; al = 1 - clear all memory +Clear: + mov [cur_x],0 + mov [cur_y],0 + mov [ch_tim],0 + mov [ls_tim],0 + mov [co_tim],0 + mov [tim_Undo],0 + mov [help_id],-1 + + mov [wScr.position],0 + mov [wScr.max_area],100 + mov [wScr.redraw],1 + mov [hScr.position],0 + mov [hScr.max_area],100 + + mov [sel.x0],0 + mov [sel.y0],0 + mov [sel.x1],0 + mov [sel.y1],0 + + cmp al,0 + je .exit + + push ecx edx + mov ecx,sizeof.symbol*maxChars + mov edx,[tex] + @@: + mov byte [edx],0 + inc edx + loop @b + mov edx,[tex] + mov dword [edx+6],1 + pop edx ecx + + .exit: + ret + + +;--- out_reg = Col[keyw[ind_reg]].Text[0] --- +macro ColToIndexOffset ind_reg,out_reg { + mov out_reg,ind_reg + imul out_reg,sizeof.TexColViv + add out_reg,[Col] +} + + + +InitColText: + push eax ebx ecx esi edi + +; mov ebx,fn_col_option +; mov esi,sys_path +; mov edi,file_name + mov ebx,dword[fn_col_option] + copy_path ebx,fn_syntax_dir,file_name_rez + copy_path file_name_rez,sys_path,file_name + + mov eax,70 + mov [run_file_70.func_n], 0 + mov [run_file_70.param1], 0 + mov [run_file_70.param2], 0 + mov ebx,[options_file_end] + sub ebx,[options_file] + mov [run_file_70.param3], ebx + m2m [run_file_70.param4], [options_file] + mov [run_file_70.rezerv], 0 + mov [run_file_70.name], file_name + mov ebx,run_file_70 + int 0x40 + + mov ecx,0x100 + mov edi,FkPos + @@: + mov dword[edi],-1 + add edi,4 + loop @b + + + ;init: ColColor, ColWords, ... + mov dword[ColColor],1 + mov dword[ColWords],0 + mov dword[tex_help_f1],0 + mov [help_id],-1 ;идентификатор слова для справки + + cmp eax,6 + je @f + cmp eax,0 + je @f + cmp ax,10 + jl .zifra_0_9 + mov al,'?' + sub ax,48 + .zifra_0_9: + add ax,48 + + mov byte[msgbox_3.err],al + push thread + push msgbox_3 + call [mb_create] ;message: Can-t open color options file! + jmp .no_colors + @@: + + mov esi,[options_file] + mov edi,ColColor + mov ecx,9*4 + rep movsb + + mov eax,[options_file] + add eax,32 + mov dword[tex_colors],eax + + mov eax,dword[ColColor] ;init: Col (offset to key words) + add eax,8 + shl eax,2 + add eax,[options_file] + mov dword[Col],eax + + mov ecx,dword[ColWords] ;init: FkPos (first key positions) + xor eax,eax + @@: + ColToIndexOffset eax,edi + xor ebx,ebx + mov bl,byte[edi] + shl bx,2 + mov esi,FkPos + add esi,ebx + cmp dword[esi],-1 + jne .no_ch_key + mov dword[esi],eax + .no_ch_key: + inc eax + loop @b + + ;init: tex_help_f1 + mov ecx,dword[ColWords] + imul ecx,sizeof.TexColViv + add ecx,dword[Col] + mov dword[tex_help_f1],ecx + + ;copy new colors in dir_list +; m2m dword[eax+28],dword[WND_WORK_COLOR] +; m2m dword[eax+32],dword[SELECT_COLOR] +; m2m dword[eax+36],dword[WND_CAPT_COLOR] +; m2m dword[eax+40],dword[WND_TEXT_COLOR] +; m2m dword[eax+44],dword[CUR_TEXT_COLOR] + + .no_colors: + pop edi esi ecx ebx eax + ret + + +;input: +; ebx = file size +OpenFile: + mov [err_opn],0 + push eax ;destination + push ecx ;for cycle + push edx ;source + + xor al,al + call Clear + mov eax,ebx + mov ecx,ebx + add eax,2 + ConvertIndexToPointer eax + mov edx,[tex] + add edx,ebx + push ebx + @@: + mov ebx,[edx] + mov byte [eax],bl + mov dword [eax+2],ecx + inc dword [eax+2] + mov dword [eax+6],ecx + add dword [eax+6],3 + ;mov byte[eax+1],0 ;col=0 + mov dword [eax+10],-1 ;tc=-1 + mov dword [eax+14],0 ;td=0 + + cmp ecx,0 + je @f + dec ecx + dec edx + sub eax,sizeof.symbol + jmp @b + @@: + pop ebx + add eax,2 + mov dword [eax],0 ; first sumbol 'perv=0' + + mov edx,[tex] + ; begining sumbol 'perv=0' 'next=2' + mov dword [edx+2],0 + mov dword [edx+6],2 + + add edx,sizeof.symbol + mov dword [edx+6],0 ; last sumbol 'next=0' + mov dword [edx+2],ebx ; last sumbol 'perv=last' + inc dword [edx+2] + + mov edx,ebx + inc edx ;2 = rezerv sumbols + imul edx,sizeof.symbol + add edx,[tex] + mov dword [edx+6],1 ; last sumbol 'next=1' + + @@: ;clear memory, need if before was open big file + add edx,sizeof.symbol + cmp edx,[tex_end] + jge @f + mov dword[edx+10],0 + mov dword[edx+14],0 + jmp @b + @@: + + call GetNumLines + cmp eax,100 + jge @f + mov eax,100 + @@: + mov [wScr.max_area],eax +; mov [wScr.redraw],1 + pop edx ecx eax + call CmColored + ret + +;input: +; edx = pointer to symbol struct +;output: +; edx = pointer to 'perv' visible symbol struct +IteratPerv: + cmp [tim_Undo],0 + je .else + push ebx + @@: + call GetTexPervPos + cmp edx,[tex] + je @f + call SymbNotVis + cmp bl,1 + je @b + cmp byte[edx],10 ;пропуск символа с кодом 10 + je @b + @@: + pop ebx + ret + .else: + call GetTexPervPos + cmp edx,[tex] + je .endif + cmp dword [edx+14],0 + jne .else + cmp byte[edx],10 ;пропуск символа с кодом 10 + je .else + .endif: + ret + + +;input: +; edx = pointer to symbol struct +;output: +; edx = pointer to 'next' visible symbol struct +IteratNext: + cmp [tim_Undo],0 + je .else + push ebx + @@: + call GetTexNextPos + cmp edx,[tex_1] + jle @f + call SymbNotVis + cmp bl,1 + je @b + cmp byte[edx],10 ;пропуск символа с кодом 10 + je @b + @@: + pop ebx + ret + .else: + call GetTexNextPos + cmp edx,[tex_1] + jle .endif + cmp dword [edx+14],0 + jne .else + cmp byte[edx],10 ;пропуск символа с кодом 10 + je .else + .endif: + ret + +;input: +; edx = pointer to symbol struct +; bl = symbol end of select +ItPoNextUc: + @@: + cmp bl,byte[edx] + je @f + cmp edx,[tex_1] + jle @f + call IteratNext + jmp @b + @@: + call IteratNext + ret + +;input: +; edx = pointer to symbol struct +ItPervColorTag: + @@: + cmp byte[edx+1],0 + jne @f + call IteratPerv + cmp edx,[tex_1] + jle @f + jmp @b + @@: + ret + +;input: +; edx = pointer to symbol struct +ItNextColorTag: + @@: + call IteratNext + cmp byte[edx+1],0 + jne @f + cmp edx,[tex_1] + jle @f + jmp @b + @@: + ;call IteratNext + ret + +;input: +; edx = pointer to symbol struct +;output: +; bl = 1 if sumbol not visible +; (tex[i].td+tim_Undo<=ch_tim && tex[i].td) || (tex[i].tc>ch_tim-tim_Undo) +SymbNotVis: + push eax + + xor bl,bl + + cmp dword [edx+14],0 + je @f + mov eax,[edx+14] ;eax=tex[i].td + add eax,[tim_Undo] + cmp eax,[ch_tim] + jg @f + mov bl,1 + pop eax + ret + @@: + + mov eax,[ch_tim] + sub eax,[tim_Undo] + cmp [edx+10],eax + jle @f + or bl,1 + @@: + + pop eax + ret + + +;input: +; bh = 1 - move cursor after text add +; bl = 1 - change time when text add +; esi = add text len +; edi = pointer to text string +TextAdd: + push ebp + mov ebp,esp + sub esp,4*2 + + push eax ;po_t + push ecx edx edi + + call GetPos + call GetTexPervPos + call GetTexArrIndex ;eax=po_t + + mov dword[ebp-4],0 ;count new spaces + cmp [gpOpt],2 + je @f + push eax ebx ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos); + mov eax,[cur_x] + add eax,[hScr.position] + mov dword[ebp-4],eax + + mov eax,[cur_y] + add eax,[wScr.position] + call StrLen + sub dword[ebp-4],ebx + pop ebx eax + @@: + + mov dword[ebp-8],0 ;count new lines + cmp [gpOpt],0 + jne @f + push eax + mov eax,[cur_y] + add eax,[wScr.position] + inc eax + mov dword[ebp-8],eax + + call GetNumLines + sub dword[ebp-8],eax + pop eax + @@: + + mov edx,sizeof.symbol + shl edx,1 + add edx,[tex] + @@: ;for(i=2;i cur_x + mov [gpOpt],1 + cmp eax,ecx + jge @f ; Row >= cur_y + .u1_0: + mov [gpOpt],0 + inc ebx + cmp byte [edx],13 + jne @b + cmp eax,ecx + jge @f ; Row >= cur_y + inc eax + xor ebx,ebx + jmp @b + @@: + cmp eax,ecx + jne @f ; Row = cur_y + inc [gpOpt] + @@: + cmp [gpOpt],0 + jne @f + mov edx,[tex_1] + ;call GetTexPervPos + @@: + pop ebx eax + ret + + +;input: +; eax = Row +;output: +; ebx = str len +StrLen: + push edx ecx + ;ecx = Row, from cycle + + xor ebx,ebx + xor ecx,ecx + mov edx,[tex] + @@: + call IteratNext + cmp edx,[tex_1] + jle @f + inc ebx + cmp byte [edx],13 + jne @b + dec ebx ;lenght minus 1 sumbol to paragraph + cmp eax,ecx + je @f + xor ebx,ebx + inc ecx + jmp @b + @@: + + cmp eax,ecx + je @f + xor ebx,ebx + @@: + + pop ecx edx + ret + + +;output: +; edx = symbol position +;output: +; eax = number of line +; ebx = symbol position in line +GetTexCoords: + push edx + xor eax,eax + xor ebx,ebx + @@: + call IteratPerv + + cmp eax,0 + jne .no_col_mov + inc ebx + .no_col_mov: + + cmp edx,[tex_1] + jle @f + cmp byte [edx],13 + jne @b + inc eax + jmp @b + @@: + dec ebx + pop edx + ret + +;output: +; eax = num lines +GetNumLines: + push edx + mov eax,1 + mov edx,[tex] + @@: + call IteratNext + cmp edx,[tex_1] + jle @f + cmp byte [edx],13 + jne @b + inc eax + jmp @b + @@: +;... +;dec eax + pop edx + ret + +SetUndo: + mov [dragk],0 ;заканчиваем выделение от клавиатуры + cmp [tim_Undo],1 + jl .no_work + + push eax ebx edx + mov edx,[tex] + call GetTexNextPos ;long i=tex[0].next; + mov eax,[tim_Undo] + sub [ch_tim],eax ;ch_tim-=tim_Undo; + mov eax,[ch_tim] + cmp [ls_tim],eax ;if(ls_tim>ch_tim) + jle @f + mov dword [ls_tim],0 + @@: + cmp edx,[tex] + je @f + + ;if(tex[i].tc>ch_tim){ // если создание символа было отменено + cmp [edx+10],eax + jle .no_u1 + mov dword [edx+10],0 + mov dword [edx+14],0 + + mov ebx,[edx+2] + imul ebx,sizeof.symbol + add ebx,[tex];.next + m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next; + + mov ebx,[edx+6] + imul ebx,sizeof.symbol + add ebx,[tex];.perv + m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv; + + .no_u1: + + ;else if(tex[i].td>ch_tim) tex[i].td=0; // если удаление символа было отменено + cmp [edx+14],eax + jle .no_u2 + mov dword [edx+14],0 + .no_u2: + + call GetTexNextPos + jmp @b + @@: + mov dword [tim_Undo],0 + mov eax,[co_tim] + cmp [ch_tim],eax + jge @f + mov [co_tim],0 + @@: + pop edx ebx eax + .no_work: + ret + +;input: +; ecx = Col +; edx = Row +GoToPos: + mov [cur_x],ecx + sub edx,[wScr.position] + + cmp edx,[wScr.cur_area] ;[cur_y] > [.cur_area] + jl @f + push ebx + mov ebx,edx + sub ebx,[wScr.cur_area] + inc ebx + add [wScr.position],ebx + sub edx,ebx + pop ebx + ; ??? redrav + @@: + mov [cur_y],edx + ret + +;input: +; bl = 1 change time when delete text +;output: +; al = 1 if delete +SelTextDel: + call IsSel + cmp al,0 + jne @f + ret + @@: + ;call SelEnd + call SelNormalize + push esi edi ecx edx + mov esi,[seln.x1] + mov ecx,[seln.y1] + call GetPosByParam + mov edi,edx + + mov esi,[seln.x0] + mov ecx,[seln.y0] + call GetPosByParam + + cmp bl,0 + je @f + inc [ch_tim] + + @@: + cmp edx,[tex] + je @f + cmp edx,edi ;if(i==te)break; + je @f + m2m dword[edx+14],dword[ch_tim] + xor bl,bl ;n_tim=false; + call IteratNext + jmp @b + @@: + cmp bl,0 + je @f + dec [ch_tim] + xor al,al + @@: + cmp bl,0 + jne @f + mov ecx,[seln.x0] + mov edx,[seln.y0] + call GoToPos + mov [sel.x0],0 + mov [sel.y0],0 + mov [sel.x1],0 + mov [sel.y1],0 + @@: + pop edx ecx edi esi + + ret + + +CmColored: + push eax edx + mov eax,[ch_tim] + sub eax,[tim_Undo] + mov dword[co_tim],eax + mov edx,[tex] + @@: + call IteratNext + cmp edx,[tex_1] + jle @f + mov byte[edx+1],0 + jmp @b + @@: + + cmp dword[ColWords],1 + jl .no_colors + mov edx,[tex] + @@: + call TextFSColor + cmp edx,[tex_1] + jle .no_colors + jmp @b + .no_colors: + pop edx eax + ret + + + +;input: +; edx = pointer to start symbol +;output: +; edx = pointer to next symbol +TextFSColor: + ;eax = word_n + ;ecx = l_pos + push ebp + mov ebp,esp + sub esp,10 ;2*4+2*1 + ;bP = dword[ebp-4] + ;eP = dword[ebp-8] + ;fnd = byte[ebp-12] + ;f_color = byte[ebp-13] + + push eax ebx ecx esi edi + mov dword[ebp-4],1 + mov dword[ebp-4],1 + mov byte[ebp-12],0 + mov byte[ebp-13],1 + @@: + call IteratNext + cmp edx,[tex_1] + jle @f + + xor ebx,ebx + mov bl,byte[edx] +;mov byte[buf],bl +;mov byte[buf+1],0 + shl bx,2 ;ebx*=4 + add ebx,FkPos + mov eax,dword[ebx] + cmp eax,0 + jl @b ;if( (word_n=FkPos[(unsigned char)tex[i].c])>-1 ){ + + mov ecx,eax + ;while(l_posword_n && Col[keyw[l_pos-1]].Text[pos]!=tex[i].c) + .wh_3b: + cmp ecx,eax + jle .wh_3e + dec ecx + ColToIndexOffset ecx,ebx + inc ecx + ;cmp byte[ebx+edi],byte[edx] + push ax + mov al,byte[ebx+edi] + mov bl,al + pop ax + cmp bl,byte[edx] + je .wh_3e + dec ecx + jmp .wh_3b + .wh_3e: + + ColToIndexOffset eax,ebx + cmp byte[ebx+edi],0 + jne .if_0 ;if(Col[keyw[word_n]].Text[pos]==0){ + mov dword[ebp-8],edx ;eP=i; + ColToIndexOffset eax,esi + mov bl,byte[esi+MAX_COLOR_WORD_LEN+6] + mov byte[ebp-13],bl ;f_color=Col[keyw[word_n]].color; + +mov byte[ebp-12],1 +;... esi = Col[keyw[word_n]] + mov bl,byte[esi+MAX_COLOR_WORD_LEN+4] + cmp bl,0 ;if(Col[keyw[word_n]].wwo) + je .if_2n + push edx + mov edx,dword[ebp-4] + call IteratPerv +; mov bh,bl + + btr bx,0 ;1-1 + jae .if_3e ;if(Col[keyw[word_n]].wwo&1) + ;u1= !(isalnum(cont_s)||cont_s=='_') + call isalnum + jae .if_3e + mov byte[ebp-12],0 + .if_3e: + + btr bx,3 ;4-1 + jae .if_4e ;if(Col[keyw[word_n]].wwo&8) + ;u1= !isalpha(cont_s); + call isalpha + jae .if_4e + mov byte[ebp-12],0 + .if_4e: + + + mov edx,dword[ebp-8] +; call IteratNext + + btr bx,1 ;2-1 + jae .if_5e ;if(Col[keyw[word_n]].wwo&2) + ;u1= !(isalnum(cont_s)||cont_s=='_') + call isalnum + jae .if_5e + mov byte[ebp-12],0 + .if_5e: + + btr bx,4 ;5-1 + jae .if_6e ;if(Col[keyw[word_n]].wwo&16) + ;u1= !isalpha(cont_s); + call isalpha + jae .if_6e + mov byte[ebp-12],0 + .if_6e: + + btr bx,2 ;3-1 + jae .if_7e ;if(Col[keyw[word_n]].wwo&4) + mov bl,byte[esi+MAX_COLOR_WORD_LEN+5] + call ItPoNextUc + cmp edx,[tex_1] + jle .if_7e + mov dword[ebp-8],edx + .if_7e: + + pop edx + .if_2n: +; if(i!=1){ // не конец документа +; cont_s=tex[eP].c; +; if(Col[keyw[word_n]].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_'); // не букв.-числ. символ +; if(u2 && Col[keyw[word_n]].wwo&16) u2= !isalpha(cont_s); // не числ. символ +; if(Col[keyw[word_n]].wwo&4) eP=ItPoNextUc(eP,Col[keyw[word_n]].endc); + + cmp eax,ecx + je .wh_2e ;if(word_n==l_pos) break; // do double - если слово точно последнее + .if_0: + + cmp edx,[tex_1] + jle .wh_2e ;if(i==1) break; + + ;while(l_pos>word_n && Col[keyw[word_n]].Text[pos]!=tex[i].c) + .wh_4b: + cmp ecx,eax + jle .wh_4e + ColToIndexOffset eax,ebx + ;cmp byte[ebx+edi],byte[edx] + push ax + mov al,byte[ebx+edi] + mov bl,al + pop ax + cmp bl,byte[edx] + je .wh_4e + inc eax + jmp .wh_4b + .wh_4e: + + cmp eax,ecx + je .wh_2e;if(word_n==l_pos) break; + inc edi ;pos++; + jmp .wh_2b + .wh_2e: + + cmp byte[ebp-12],1 ;if(fnd)break; + je @f + mov edx,dword[ebp-4];i=bP; + jmp @b + @@: + + cmp byte[ebp-12],1 + jne .if_1e ;if(fnd){ // выделение найденого текста +; if(!mode_sf1 || (mode_sf1 && strlen(Col[keyw[word_n]].f1->c_str())>0)){ + mov eax,dword[ebp-4] + mov bl,byte[ebp-13] + mov byte[eax+1],bl ;tex[bP].col=f_color; + mov eax,dword[ebp-8] + mov byte[eax+1],0xff ;tex[eP].col=255; +; return ItPoPerv(eP); // возвращаем позицию конца вхождения + mov edx,dword[ebp-8] + call GetTexPervPos + jmp @f + .if_1e: + mov edx,[tex] + @@: + + pop edi esi ecx ebx eax + mov esp,ebp + pop ebp + ret + + +;input: +; edx = pointer to char (byte) +;output: +; cf=1 if symbol is... +tab_all_num db 0,0,0,0,0,0,11111111b,11b,11111110b,0xff,0xff,111b,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 +tab_alpha db 0,0,0,0,0,0,0,0,11111110b,0xff,0xff,111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ;db 0,0,0,0,0,0,11111111b,11b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +isalnum: + push eax ebx + mov al,byte[edx] ;al=offset + shr al,3 + and eax,11111b + mov ebx,tab_all_num + add ebx,eax + mov ah,byte[ebx] + mov al,byte[edx] ;al=bit + and ax,111b + m2m bx,word[ebx] + btr bx,ax + pop ebx eax + ret +isalpha: + push eax ebx + mov al,byte[edx] ;al=offset + shr al,3 + and eax,11111b + mov ebx,tab_alpha + add ebx,eax + mov ah,byte[ebx] + mov al,byte[edx] ;al=bit + and ax,111b + m2m bx,word[ebx] + btr bx,ax + pop ebx eax + ret + + +ShowHelpF1: + push eax edx + + call GetPos + push edx + call ItNextColorTag + mov eax,edx + pop edx + call ItPervColorTag + + cmp eax,[tex] + jle @f + cmp edx,[tex_1] + jle @f + call FindHelpId + @@: + pop edx eax + ;call draw_main_cursor + call draw_help_f1 + ret + +;input: +; edx = position begin 'symbol' struct +; eax = position end 'symbol' struct +FindHelpId: +; ecx = word_n +; ebx = l_pos + mov [help_id],-1 + + push ebx ecx + xor ebx,ebx + mov bl,byte[edx] + shl bx,2 ;ebx*=4 + add ebx,FkPos + mov ecx,dword[ebx] + cmp ecx,0 + jl .if_0e ;if( (word_n=FkPos[(unsigned char)tf[0]])>-1 ){ + push esi edi + mov ebx,ecx ;l_pos=word_n; + ColToIndexOffset ecx,esi + push cx + mov cl,byte[esi] + @@: + cmp ebx,dword[ColWords] ;while(l_posword_n + jle .wh_0e + dec ebx + ColToIndexOffset ebx,edi + inc ebx + cmp byte[edi+esi],dl ;&& Col[keyw[l_pos-1]].Text[pos]!=tf[i]) + je .wh_0e + dec ebx ;l_pos--; + jmp .wh_0b + .wh_0e: + + .wh_1b: + cmp ebx,ecx ;while(l_pos>word_n + jle .wh_1e + ColToIndexOffset ecx,edi + cmp byte[edi+esi],dl + je .wh_1e + inc ecx ;word_n++; + jmp .wh_1b + .wh_1e: + pop dx + + cmp ecx,ebx ;if(word_n==l_pos) break; + je @f + call IteratNext ;pos++; + cmp edx,eax ;for(...;i