Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 4273 → Rev 4274

/programs/develop/fasm/trunk/fasm.asm
132,6 → 132,10
jne @f
mov [_run_outfile],1
@@:
cmp [esi], dword ',dbg'
jne @f
mov [_run_outfile],2
@@:
mov [_mode],CONSOLE_MODE
jmp start
;---------------------------------------------------------------------
662,6 → 666,12
mov edx,outfile
call make_fullpaths
xor ecx,ecx
 
cmp [_run_outfile],2 ; param is ',dbg'
jne run
mcall 70,file_info_debug
jmp @f
run:
mcall 70,file_info_start
@@:
jmp exit_program
/programs/develop/fasm/trunk/version.inc
33,7 → 33,7
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
 
VERSION_STRING equ "1.71.13"
VERSION_STRING equ "1.71.14"
 
VERSION_MAJOR = 1
VERSION_MINOR = 71
/programs/develop/tinypad/trunk/data/tp-defines.inc
18,6 → 18,7
define mm.Search.Replace key.ctrl_h
 
define mm.Run.Run key.f9
define mm.Run.Debug key.f10
define mm.Run.Compile key.ctrl_f9
define mm.Run.DbgBoard open_debug_board
define mm.Run.SysFuncs open_sysfuncs_txt
/programs/develop/tinypad/trunk/data/tp-locale.inc
58,13 → 58,13
et,'-' ,'' , ,\
et,'Välju' ,'Alt+X' ,Exit,\
\
sp,'Nuevo' ,'Ctrl+N' ,New ,\
sp,'Nuevo' ,'Ctrl+N' ,New ,\
sp,'Abrir...' ,'Ctrl+O' ,Open ,\
sp,'Guardar' ,'Ctrl+S' ,Save ,\
sp,'Guardar' ,'Ctrl+S' ,Save ,\
sp,'Guardar como...','Ctrl+Shift+S',SaveAs,\
sp,'-' ,'' , ,\
sp,'Cerrar' ,'Ctrl+F4' ,Close ,\
sp,'-' ,'' , ,\
sp,'-' ,'' , ,\
sp,'Cerrar' ,'Ctrl+F4' ,Close ,\
sp,'-' ,'' , ,\
sp,'Salir' ,'Alt+X' ,Exit
 
popup_res mm.Edit,\
89,11 → 89,11
et,'-' ,'' , ,\
et,'Vali kõik' ,'Ctrl+A',SelAll,\
\
sp,'Cortar' ,'Ctrl+X',Cut ,\
sp,'Cortar' ,'Ctrl+X',Cut ,\
sp,'Copiar' ,'Ctrl+C',Copy ,\
sp,'Pegar' ,'Ctrl+V',Insert,\
sp,'Eliminar' ,'' ,Delete,\
sp,'-' ,'' , ,\
sp,'Eliminar' ,'' ,Delete,\
sp,'-' ,'' , ,\
sp,'Seleccionar todo','Ctrl+A',SelAll
 
popup_res mm.Search,\
116,13 → 116,14
et,'Asenda...' ,'Ctrl+H',Replace ,\
\
sp,'Posición...','Ctrl+G',Position,\
sp,'-' ,'' , ,\
sp,'-' ,'' , ,\
sp,'Buscar...' ,'Ctrl+F',Find ,\
sp,'Buscar siguiente' ,'F3' ,FindNext,\
sp,'Buscar siguiente' ,'F3' ,FindNext,\
sp,'Reemplazar...' ,'Ctrl+H',Replace
 
popup_res mm.Run,\
ru,'‡ ¯ãáâ¨âì' ,'F9' ,Run ,\
ru,'‡ ¯ãáâ¨âì ¢ ¤¥¡ ££¥à¥','F10',Debug ,\
ru,'Š®¬¯¨«¨à®¢ âì' ,'Ctrl+F9',Compile ,\
ru,'-' ,'' , ,\
ru,'„®áª  ®â« ¤ª¨' ,'' ,DbgBoard,\
129,6 → 130,7
ru,'‘¨á⥬­ë¥ ä㭪樨','' ,SysFuncs,\
\
en,'Run' ,'F9' ,Run ,\
en,'Run in debugger' ,'F10' ,Debug ,\
en,'Compile' ,'Ctrl+F9',Compile ,\
en,'-' ,'' , ,\
en,'Debug board' ,'' ,DbgBoard,\
135,6 → 137,7
en,'System functions' ,'' ,SysFuncs,\
\
et,'Käivita' ,'F9' ,Run ,\
et,'Käivita aastal siluri' ,'F10' ,Debug ,\
et,'Kompileeri' ,'Ctrl+F9',Compile ,\
et,'-' ,'' , ,\
et,'Silumis paneel' ,'' ,DbgBoard,\
141,9 → 144,10
et,'Süsteemi funktsioonid' ,'' ,SysFuncs,\
\
sp,'Ejecutar' ,'F9' ,Run ,\
sp,'Ejecutar en el depurador' ,'F10' ,Debug ,\
sp,'Compilar' ,'Ctrl+F9',Compile ,\
sp,'-' ,'' , ,\
sp,'Depuración' ,'' ,DbgBoard,\
sp,'Depuración' ,'' ,DbgBoard,\
sp,'Funciones del sistema' ,'' ,SysFuncs
 
popup_res mm.Encoding,\
187,14 → 191,14
et,'-' ,'', ,\
et,'Rea numbrid' ,'',LineNumbers ,\
\
sp,'Apariencia...' ,'',Appearance ,\
sp,'-' ,'', ,\
sp,'Apariencia...' ,'',Appearance ,\
sp,'-' ,'', ,\
sp,'Selección segura' ,'',SecureSel ,\
sp,'Paréntesis automáticos' ,'',AutoBrackets,\
sp,'Identación automática' ,'',AutoIndents ,\
sp,'Tabulación inteligente' ,'',SmartTabs ,\
sp,'Paréntesis automáticos' ,'',AutoBrackets,\
sp,'Identación automática' ,'',AutoIndents ,\
sp,'Tabulación inteligente' ,'',SmartTabs ,\
sp,'Llenado óptimo al guardar','',OptimalFill ,\
sp,'-' ,'', ,\
sp,'-' ,'', ,\
sp,'Números en líneas' ,'',LineNumbers
 
lsz s_defname,\
/programs/develop/tinypad/trunk/data/tp-tables.inc
62,6 → 62,7
0x0000001C,key.return ,\ ; Return
0x0000003D,key.f3 ,\ ; F3
0x00000043,key.f9 ,\ ; F9
0x00000044,key.f10 ,\ ; F10
0x00000147,key.home ,\ ; Home
0x00000148,key.up ,\ ; Up
0x00000149,key.pgup ,\ ; PageUp
/programs/develop/tinypad/trunk/history.txt
1,171 → 1,175
 
HISTORY:
 
4.0.6 (26/09/2010, Marat Zakiyanov aka Mario79, aka Mario)
new features:
- Select file path with OpenDialog for Load and Save.
 
4.0.5 (Rus, mike.dld)
bug-fixes:
- new tab is created when opening a file from Tinypad's home folder
(was opening in current tab if there was a new file, even modified)
- show "save file" dialog for new files or files from Tinypad's home folder
- line is redrawn after lining up a single char and then deleting it
(pressing Del twice) [#1]
- update tab/window title and highlighting mode after file save
- allocate 1024 bytes in case file not found (avoid crash)
changes:
- max line length changed back to 4GB, each line overhead is 6 bytes now
- settings are stored in INI file (using libini), allowing binary to be compressed
new features:
- prompt to save modified file before closing (+fixes)
- button to close current tab (+fixes)
- mouse scroll wheel support
- numpad support
 
4.0.4 (mike.dld)
bug-fixes:
- statusbar contained hint after dialog operation cancelled
- small drawing fix for gutter and line saved/modified markers
(incorrect calculations)
- incorrect lines marking on Ctrl+V
- put filename of current tab into open/save dialog (noticed by Maxxxx32)
changes:
- editor and other modifications to ease parts placement changing,
including changes in look
- modified/saved colors now match those in MSVS
- function 70 for *all* file operations (including diamond's fixes)
- use memory manager instead of statically allocated region
- case-insensitive filenames input, to be able to open/save files with
non-latin chars in name (russian etc.)
- reduced flickering (changes checker)
- overall code cleanup
new features:
- recode tables between CP866, CP1251 and KOI8-R (suggested by Victor)
- tabbed interface, ability to open several files in one app instance
(thanks IRC guys for ideas and testing)
- make any tab default to compile it disregarding currently active tab
- configuration dialog (colors, tabs positioning)
 
4.0.3 (mike.dld)
bug-fixes:
- 1-char selection if pressing <BS> out of real line length
- fault in `writepos`, added call to function 9
- main menu items weren't highlighted if popup opened and cursor
isn't in main menu item's area
- statusbar and textboxes drawing fixes (wrong colors)
- perform no redraw while pressing Shift, Ctrl, Alt keys
- data length from DOCPAK in string representation (fixed by diamond)
- compare file extension case-insensitively (fixed by diamond)
changes:
- function 70 instead of 58 for files loading/saving
- clientarea-relative drawing (less code)
- every line's dword is now splitted into 2 words;
low word - line block length, so max line length is 64KB now
high word - various flags. for now, only 2 of 16 bits are used:
if bit #0 is set, line was modified since file open
if bit #1 is set, line was saved after last modification
high word could also be further used for code collapsing and different
line marking features (breakpoints, errors, bookmarks, etc.)
new features:
- line markers for modified and saved lines
- status messages for various actions
 
4.0.2 (mike.dld)
bug-fixes:
- program terminates if started with parameters (fine for DOCPAK)
 
4.0.1 (mike.dld)
bug-fixes:
- unable to run program after exiting from main menu (Alt+X)
new features:
- integration with DOCPAK
 
4.0 (mike.dld)
bug-fixes:
- main menu popups' "on show" was called only for first shown popup
- clear selection on left/right arrow keys
new features:
- "replace" dialog (w/o "skip", "replace all")
- line numbers display
- options (except "appearance" and "smart tabulation")
- options saving (colors, window position, "Options" popup triggers)
 
4.0 beta 2 (mike.dld)
bug-fixes:
- unable to start if /rd/1/example.asm is missing (from Halyavin)
- clicking on menu items draws main window in popup (from Rohan)
- passed parameters aren't taken into account (from Mario79)
- background isn't erased if text lines < screen lines after
selection deletion (from Rohan)
 
4.0 beta 1 (mike.dld)
menu bar and popup menu;
removed buttons from the top and input fields from the bottom since
now they're accesible through main/popup menu;
improved keyboard handling (using 66th function);
support for almost all FASMW keyboard shourtcuts;
added text selection ability, standard selection operations
(copy,cut,paste);
new integrated dialogs (open, save, find)
fix to collapse SPACEs into TABs only for *.asm and *.inc files
 
3.78a (mike.dld)
fixed termination while typing in x positions higher than (line_length+10);
improved drawing on small heights
don't draw window while its height = 0 (Kolibri "minimize" support)
 
3.78 (mike.dld)
now lines may be of ANY length;
optimized memory usage (less memory for internal file representation)
after loading file, it's internal size equals to its real size
plus 14 bytes for each line (4 bytes for line length
and 10 spaced to the end - to reduce data relocations count);
completely rewritten keyboard handling;
added horizontal scrollbar;
all line feed formats are supported: WIN(CRLF),*NIX(LF),MAC(CR);
etc.
 
3.77 (mike.dld)
changed save_string to collapse SPACEs into TABs;
rewrote drawfile from scratch (speed++)
through some drawing improvements needed
(some checkups to reduce flickering);
writepos (size--);
fixed drawing window while height < 100px, and for non-asm files;
several small fixes; speed/size optimizations
 
3.76 (mike.dld)
changed loadfile/loadhdfile to expand TABs into SPACEs;
changed TAB,ENTER,DELETE,BSPACE keys behaviour (rewritten from scratch);
vertical scrollbar;
extra window resizing capabilities (added a couple of constants);
completely new text cursor management & moving text cursor with mouse;
improved search function, moving cursor to beginning of text found;
adjustable max line width (change LINE_WIDTH & recompile) // (obsolet)
 
3.75a
fixed converting char to upper case in read_string
 
3.75
rewrote save_file from scratch; bugfix in loadfile;
 
3.74
optimisation
 
3.73
completly new load_file function
 
3.72
speed++
 
3.71
error beep
 
3.6,3.7:
many bugs fixed
simple toolbar
compile, run applications from TINYPAD, all fasm output is in debug board
TAB button
auto-indent
Ctrl+L - insert comment string
 
HISTORY:
 
4.0.7 (21/11/2013, Sergey Tyrnov aka tserj)
new feature:
- Run in debugger by F10
 
4.0.6 (26/09/2010, Marat Zakiyanov aka Mario79, aka Mario)
new features:
- Select file path with OpenDialog for Load and Save.
 
4.0.5 (Rus, mike.dld)
bug-fixes:
- new tab is created when opening a file from Tinypad's home folder
(was opening in current tab if there was a new file, even modified)
- show "save file" dialog for new files or files from Tinypad's home folder
- line is redrawn after lining up a single char and then deleting it
(pressing Del twice) [#1]
- update tab/window title and highlighting mode after file save
- allocate 1024 bytes in case file not found (avoid crash)
changes:
- max line length changed back to 4GB, each line overhead is 6 bytes now
- settings are stored in INI file (using libini), allowing binary to be compressed
new features:
- prompt to save modified file before closing (+fixes)
- button to close current tab (+fixes)
- mouse scroll wheel support
- numpad support
 
4.0.4 (mike.dld)
bug-fixes:
- statusbar contained hint after dialog operation cancelled
- small drawing fix for gutter and line saved/modified markers
(incorrect calculations)
- incorrect lines marking on Ctrl+V
- put filename of current tab into open/save dialog (noticed by Maxxxx32)
changes:
- editor and other modifications to ease parts placement changing,
including changes in look
- modified/saved colors now match those in MSVS
- function 70 for *all* file operations (including diamond's fixes)
- use memory manager instead of statically allocated region
- case-insensitive filenames input, to be able to open/save files with
non-latin chars in name (russian etc.)
- reduced flickering (changes checker)
- overall code cleanup
new features:
- recode tables between CP866, CP1251 and KOI8-R (suggested by Victor)
- tabbed interface, ability to open several files in one app instance
(thanks IRC guys for ideas and testing)
- make any tab default to compile it disregarding currently active tab
- configuration dialog (colors, tabs positioning)
 
4.0.3 (mike.dld)
bug-fixes:
- 1-char selection if pressing <BS> out of real line length
- fault in `writepos`, added call to function 9
- main menu items weren't highlighted if popup opened and cursor
isn't in main menu item's area
- statusbar and textboxes drawing fixes (wrong colors)
- perform no redraw while pressing Shift, Ctrl, Alt keys
- data length from DOCPAK in string representation (fixed by diamond)
- compare file extension case-insensitively (fixed by diamond)
changes:
- function 70 instead of 58 for files loading/saving
- clientarea-relative drawing (less code)
- every line's dword is now splitted into 2 words;
low word - line block length, so max line length is 64KB now
high word - various flags. for now, only 2 of 16 bits are used:
if bit #0 is set, line was modified since file open
if bit #1 is set, line was saved after last modification
high word could also be further used for code collapsing and different
line marking features (breakpoints, errors, bookmarks, etc.)
new features:
- line markers for modified and saved lines
- status messages for various actions
 
4.0.2 (mike.dld)
bug-fixes:
- program terminates if started with parameters (fine for DOCPAK)
 
4.0.1 (mike.dld)
bug-fixes:
- unable to run program after exiting from main menu (Alt+X)
new features:
- integration with DOCPAK
 
4.0 (mike.dld)
bug-fixes:
- main menu popups' "on show" was called only for first shown popup
- clear selection on left/right arrow keys
new features:
- "replace" dialog (w/o "skip", "replace all")
- line numbers display
- options (except "appearance" and "smart tabulation")
- options saving (colors, window position, "Options" popup triggers)
 
4.0 beta 2 (mike.dld)
bug-fixes:
- unable to start if /rd/1/example.asm is missing (from Halyavin)
- clicking on menu items draws main window in popup (from Rohan)
- passed parameters aren't taken into account (from Mario79)
- background isn't erased if text lines < screen lines after
selection deletion (from Rohan)
 
4.0 beta 1 (mike.dld)
menu bar and popup menu;
removed buttons from the top and input fields from the bottom since
now they're accesible through main/popup menu;
improved keyboard handling (using 66th function);
support for almost all FASMW keyboard shourtcuts;
added text selection ability, standard selection operations
(copy,cut,paste);
new integrated dialogs (open, save, find)
fix to collapse SPACEs into TABs only for *.asm and *.inc files
 
3.78a (mike.dld)
fixed termination while typing in x positions higher than (line_length+10);
improved drawing on small heights
don't draw window while its height = 0 (Kolibri "minimize" support)
 
3.78 (mike.dld)
now lines may be of ANY length;
optimized memory usage (less memory for internal file representation)
after loading file, it's internal size equals to its real size
plus 14 bytes for each line (4 bytes for line length
and 10 spaced to the end - to reduce data relocations count);
completely rewritten keyboard handling;
added horizontal scrollbar;
all line feed formats are supported: WIN(CRLF),*NIX(LF),MAC(CR);
etc.
 
3.77 (mike.dld)
changed save_string to collapse SPACEs into TABs;
rewrote drawfile from scratch (speed++)
through some drawing improvements needed
(some checkups to reduce flickering);
writepos (size--);
fixed drawing window while height < 100px, and for non-asm files;
several small fixes; speed/size optimizations
 
3.76 (mike.dld)
changed loadfile/loadhdfile to expand TABs into SPACEs;
changed TAB,ENTER,DELETE,BSPACE keys behaviour (rewritten from scratch);
vertical scrollbar;
extra window resizing capabilities (added a couple of constants);
completely new text cursor management & moving text cursor with mouse;
improved search function, moving cursor to beginning of text found;
adjustable max line width (change LINE_WIDTH & recompile) // (obsolet)
 
3.75a
fixed converting char to upper case in read_string
 
3.75
rewrote save_file from scratch; bugfix in loadfile;
 
3.74
optimisation
 
3.73
completly new load_file function
 
3.72
speed++
 
3.71
error beep
 
3.6,3.7:
many bugs fixed
simple toolbar
compile, run applications from TINYPAD, all fasm output is in debug board
TAB button
auto-indent
Ctrl+L - insert comment string
/programs/develop/tinypad/trunk/tinypad.asm
2,8 → 2,8
; project name: TINYPAD
; compiler: flat assembler 1.67.21
; memory to compile: 3.0/9.0 MBytes (without/with size optimizations)
; version: SVN (4.0.5)
; last update: 2008-07-18 (Jul 18, 2008)
; version: SVN (4.0.7)
; last update: 2013-11-21 (Nov 21, 2013)
; minimal kernel: revision #823 (svn://kolibrios.org/kernel/trunk)
;-----------------------------------------------------------------------------
; originally by: Ville Michael Turjanmaa >> villemt@aton.co.jyu.fi
35,7 → 35,7
 
header '01',1,@CODE,TINYPAD_END,STATIC_MEM_END,MAIN_STACK,@PARAMS,ini_path
 
APP_VERSION equ 'SVN (4.0.6)'
APP_VERSION equ 'SVN (4.0.7)'
 
TRUE = 1
FALSE = 0
193,9 → 193,9
xor eax,eax
mov [edi],al
;---------------------------------------------------------------------
;OpenDialog initialisation
push dword OpenDialog_data
call [OpenDialog_Init]
;OpenDialog initialisation
push dword OpenDialog_data
call [OpenDialog_Init]
;---------------------------------------------------------------------
 
 
242,8 → 242,8
mov [OpenDialog_data.type],eax
popa
; invoke OpenDialog
push dword OpenDialog_data
call [OpenDialog_Start]
push dword OpenDialog_data
call [OpenDialog_Start]
 
cmp [OpenDialog_data.status],1
jne .3
257,7 → 257,7
mov eax,edi
mov [tb_opensave.length],al
popa
 
cmp [bot_mode2],0
je .2
call save_file
293,7 → 293,7
xor eax,eax
mov [esi],al
inc esi
mov edi,edx ; edi filename_area
mov edi,edx ; edi filename_area
call copy_str_1
ret
;-----------------------------------------------------------------------------
466,7 → 466,9
;-----------------------------------------------------------------------------
proc start_fasm ;/////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; BL = run after compile
; BL = 0 - compile
; BL = 1 - run after compile
; BL = 2 - run under mtdbg after compile
;-----------------------------------------------------------------------------
; FASM infile,outfile,/path/to/files[,run]
;-----------------------------------------------------------------------------
516,11 → 518,15
sub ecx,esi
rep movsb
 
cmp bl,0 ; run outfile ?
cmp bl,0 ; compile outfile ?
je @f
mov dword[edi],',run'
cmp bl,1 ; run outfile ?
je do_run
mov dword[edi],',dbg'
do_run:
add edi,4
@@:
@@:
mov al,0
stosb
 
696,7 → 702,7
rb 4096
;---------------------------------------------------------------------
fname_Info:
rb 4096 ; filename
rb 4096 ; filename
;---------------------------------------------------------------------
filename_area:
rb 256
/programs/develop/tinypad/trunk/tp-key.asm
1,1661 → 1,1669
diff16 'tp-key.asm',0,$
 
key:
mov ecx,1
mcall 66,3 ; Get status of the control keys
mov [shi],eax
xor ebx,ebx
test al,0x03 ; Left or right shift
jz @f
or ebx,KM_SHIFT
@@: test al,0x0C ; Left or right control
jz @f
or ebx,KM_CTRL
@@: test al,0x10 ; Left alt
jz @f
or ebx,KM_ALT
@@: mov edx,ebx
test al,0x03
jz @f
inc cl
@@:
mcall 2
cmp al,0
jne still.skip_write
shr eax,8
;--------------------------------------
; this code for Win-keys, works with
; kernel SVN r.3356 or later
test [shi],0x200 ; LWin
jnz still.skip_write
test [shi],0x400 ; RWin
jnz still.skip_write
;--------------------------------------
cmp al,224
jne @f
mov [ext],0x01
jmp still.skip_write
@@: cmp al,225
jne @f
mov [ext],0x02
jmp still.skip_write
@@:
mov ah,[ext]
mov [ext],0
 
mov esi,numpad_table_off
test [shi], 0x00000080 ; NumLock is on?
jz .num
mov esi,numpad_table_on
.num: cmp eax,[esi]
jne @f
mov eax,[esi+4]
mov ebx,eax
or eax,edx
shr ebx,8
or ebx,0x0000FFFF
and eax,ebx
mov ecx,eax
shr ecx,16
and cl,1
inc cl
jmp .lp0
@@: add esi,8
cmp dword[esi],0
jne .num
 
or eax,edx
 
.lp0: test al,0x80
jnz still.skip_write
;--------------------------------------
; it is CAPS LOCK correct processing for chars
test [shi], 0x00000040 ; CAPS LOCK is on?
jz .no_caps_lock
cmp ecx,1
jnz @f
inc ecx
jmp .no_caps_lock
@@:
cmp ecx,2
jnz .no_caps_lock
dec ecx
.no_caps_lock:
;--------------------------------------
; alt gr pressed?
test [shi], 0x00000020
jz .no_alt_gr
mov ecx, 3
.no_alt_gr:
;--------------------------------------
push eax
mcall 26,2,,key1
pop eax
 
mov [chr],eax
 
cmp [bot_mode],0
je @f
mov ebx,eax
mov al,2
call [bot_dlg_handler]
jmp still.skip_write
@@:
 
mov esi,accel_table_main
.acc: cmp eax,[esi]
jne @f
test [secure_sel],1
jz .lp1
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
.lp1: mov [s_status],0
call dword[esi+4]
call editor_check_for_changes
jmp still
@@: add esi,8
cmp dword[esi],0
jne .acc
 
test [chr],KM_CTRLALT
jnz still.skip_write
 
mov [s_status],0
 
movzx eax,byte[chr]
movzx eax,[eax+key0]
or al,al
jz still.skip_write
movzx eax,[eax+key1]
push eax
 
test [secure_sel],1
jz .lp2
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
jmp .put
.lp2: call delete_selection
 
test [auto_braces],1
jz .put
cmp al,'['
jne @f
mov al,']'
call .lp3
dec [cur_editor.Caret.X]
jmp .put
@@: cmp al,'('
jne @f
mov al,')'
call .lp3
dec [cur_editor.Caret.X]
jmp .put
@@: cmp al,'{'
jne .put
mov al,'}'
call .lp3
dec [cur_editor.Caret.X]
 
.put: pop eax
push still editor_check_for_changes
inc [cur_editor.SelStart.X]
.lp3: push [cur_editor.Caret.X] eax
inc dword[esp+4]
mov eax,1
jmp key.tab.direct
 
;-----------------------------------------------------------------------------
proc key.ctrl_a ;///// SELECT ALL DOCUMENT ///////////////////////////////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [cur_editor.SelStart.X],eax
mov [cur_editor.SelStart.Y],eax
mov ecx,[cur_editor.Lines.Count]
dec ecx
mov [cur_editor.Caret.Y],ecx
call get_line_offset
call get_real_length
mov [cur_editor.Caret.X],eax
call draw_editor
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_o ;///// ENTER OPEN FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_mode2],0
 
.direct:
cmp [bot_mode2], 2
je .ask
mov [s_status],s_enter_filename
jmp .ask1
 
.ask:
mov [s_status],s_ask_save
.ask1:
mov [bot_mode],1
mov [bot_dlg_height],16*2+4*2-1
mov [bot_dlg_handler],osdlg_handler
mov [focused_tb],tb_opensave
 
@@: mov al,[tb_opensave.length]
mov [tb_opensave.pos.x],al
mov [tb_opensave.sel.x],0
mov [tb_casesen],0;1
call drawwindow
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_s ;///// ENTER SAVE FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
cmp [cur_editor.FilePath], 0
je key.shift_ctrl_s
cmp [cur_editor.Modified],0
je .exit
call save_file
call drawwindow
.exit:
ret
 
key.shift_ctrl_s:
mov [bot_mode2],1
jmp key.ctrl_o.direct
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_n ;///// CREATE NEW FILE (TAB) /////////////////////////////////
;-----------------------------------------------------------------------------
call create_tab
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f ;///// ENTER KEYWORD TO FIND /////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_mode2],0
mov [bot_dlg_height],16*2+4*2-1
 
mov [s_status],s_enter_text_to_find
 
.direct:
mov [bot_mode],1
mov [bot_dlg_handler],finddlg_handler
mov [focused_tb],tb_find
 
mov ecx,[s_search.size]
mov [tb_find.length],cl
jecxz @f
mov esi,s_search
mov edi,tb_find.text
cld
rep movsb
 
@@: mov al,[tb_find.length]
mov [tb_find.pos.x],al
mov [tb_find.sel.x],0
mov [tb_casesen],0
call drawwindow
ret
endp
 
proc key.ctrl_h
mov [bot_mode2],1
mov [bot_dlg_height],16*3+4*2+1
 
mov [s_status],s_enter_text_to_replace
 
jmp key.ctrl_f.direct
endp
 
proc key.ctrl_g
ret
@^
mov [bot_mode2],0
mov [bot_dlg_height],16*2+4*2-1
 
mov [bot_mode],1
mov [bot_dlg_handler],gotodlg_handler
mov [focused_tb],tb_gotorow
 
mov al,[tb_gotorow.length]
mov [tb_gotorow.pos.x],al
mov [tb_gotorow.sel.x],0
mov [tb_casesen],0
call drawwindow
ret
^@
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_left ;///// GO TO PREVIOUS WORD ////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_left: ;///// GO TO PREVIOUS WORD, WITH SELECTION /////////
;-----------------------------------------------------------------------------
mov ebx,[cur_editor.Caret.Y]
mov edx,[cur_editor.Caret.X]
cld
mov ecx,ebx
call get_line_offset
.lp1: cmp edx,[esi+EDITOR_LINE_DATA.Size]
jle @f
mov edx,[esi+EDITOR_LINE_DATA.Size]
@@: dec edx
jl .nx1
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
mov ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
mov al,[esi]
dec esi
repne scasb
pop ecx
jne @f
dec edx
dec ecx
jnz @b
.nx1: dec ebx
js .exit.2
mov ecx,ebx
call get_line_offset
mov edx,[esi+EDITOR_LINE_DATA.Size]
dec edx
jmp .lp1
@@:
mov ecx,ebx
call get_line_offset
.lp2: cmp edx,[esi+EDITOR_LINE_DATA.Size]
jle @f
mov edx,[esi+EDITOR_LINE_DATA.Size]
@@: or edx,edx
jl .nx2
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
@@: mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
mov al,[esi]
dec esi
repne scasb
je @f
dec edx
jns @b
jmp @f
.nx2: dec ebx
js .exit.2
mov ecx,ebx
call get_line_offset
mov edx,[esi+EDITOR_LINE_DATA.Size]
dec edx
jmp .lp2
@@:
inc edx
mov [cur_editor.Caret.Y],ebx
mov [cur_editor.Caret.X],edx
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],ebx
mov [cur_editor.SelStart.X],edx
@@: sub ebx,[cur_editor.TopLeft.Y]
jge @f
add [cur_editor.TopLeft.Y],ebx
@@: mov eax,edx
sub eax,[cur_editor.TopLeft.X]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [cur_editor.TopLeft.X],eax
jmp .exit
@@: cmp edx,[cur_editor.TopLeft.X]
jge .exit
mov [cur_editor.TopLeft.X],edx
.exit:
call editor_check_for_changes
.exit.2:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_right ;///// GO TO NEXT WORD ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_right: ;///// GO TO NEXT WORD, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov ebx,[cur_editor.Caret.Y]
mov edx,[cur_editor.Caret.X]
cld
.lp1: mov ecx,ebx
call get_line_offset
mov ecx,[esi+EDITOR_LINE_DATA.Size]
cmp edx,ecx
jge .nx1
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
sub ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
lodsb
repne scasb
pop ecx
je @f
inc edx
dec ecx
jnz @b
.nx1: inc ebx
cmp ebx,[cur_editor.Lines.Count]
jge .exit.2
xor edx,edx
jmp .lp1
@@:
 
.lp2: mov ecx,ebx
call get_line_offset
mov ecx,[esi+EDITOR_LINE_DATA.Size]
cmp edx,ecx
jge .nx2
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
sub ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
lodsb
repne scasb
pop ecx
jne @f
inc edx
dec ecx
jnz @b
.nx2: inc ebx
cmp ebx,[cur_editor.Lines.Count]
jge .exit.2
xor edx,edx
jmp .lp2
@@:
mov [cur_editor.Caret.Y],ebx
mov [cur_editor.Caret.X],edx
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],ebx
mov [cur_editor.SelStart.X],edx
@@: sub ebx,[cur_editor.TopLeft.Y]
cmp ebx,[lines.scr]
jl @f
sub ebx,[lines.scr]
inc ebx
add [cur_editor.TopLeft.Y],ebx
@@: mov eax,edx
sub eax,[cur_editor.TopLeft.X]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [cur_editor.TopLeft.X],eax
jmp .exit
@@: cmp edx,[cur_editor.TopLeft.X]
jge .exit
mov [cur_editor.TopLeft.X],edx
.exit:
call editor_check_for_changes
.exit.2:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_x
cmp [sel.selected],0
je @f
call key.ctrl_c
call key.del
mov [cur_editor.Modified],1
@@: ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_c
mov [copy_size],0
cmp [sel.selected],0
je .exit
 
call get_selection_size
stdcall mem.ReAlloc,[copy_buf],eax
mov [copy_buf],eax
 
cld
mov eax,[sel.begin.y]
cmp eax,[sel.end.y]
je .single_line
mov ecx,[sel.begin.y]
call get_line_offset
inc ecx
push ecx
mov edi,[copy_buf]
call get_real_length
sub eax,[sel.begin.x]
jge @f
xor eax,eax
@@: add esi,[sel.begin.x]
add esi,sizeof.EDITOR_LINE_DATA
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,eax
jecxz @f
rep movsb
@@: mov ecx,[sel.end.y]
call get_line_offset
pop ecx
cmp ecx,[sel.end.y]
je @f
mov eax,esi
call get_line_offset
sub eax,esi
mov ecx,eax
rep movsb
mov ecx,[sel.end.y]
@@: call get_line_offset
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
cmp eax,[sel.end.x]
jle @f
mov eax,[sel.end.x]
@@: mov ebx,edi
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,eax
jecxz @f
rep movsb
sub eax,[sel.end.x]
jz @f
neg eax
mov ecx,eax
add [ebx],eax
mov al,' '
rep stosb
@@: sub edi,[copy_buf]
mov [copy_size],edi
mov eax,[sel.end.y]
sub eax,[sel.begin.y]
inc eax
mov [copy_count],eax
.exit:
ret
 
.single_line:
mov eax,[sel.end.x]
sub eax,[sel.begin.x]
mov edi,[copy_buf]
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,[sel.begin.y]
call get_line_offset
mov ebx,[sel.begin.x]
mov ecx,[sel.end.x]
cmp ebx,[esi+EDITOR_LINE_DATA.Size]
jge .add_spaces
cmp ecx,[esi+EDITOR_LINE_DATA.Size]
jle .lp1
mov ecx,[esi+EDITOR_LINE_DATA.Size]
.lp1: sub ecx,[sel.begin.x]
sub eax,ecx
lea esi,[esi+ebx+sizeof.EDITOR_LINE_DATA]
rep movsb
 
.add_spaces:
mov ecx,eax
mov al,' '
jecxz @b
rep stosb
jmp @b
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_v
cmp [copy_size],0
je .exit
 
call delete_selection
 
mov eax,[copy_size]
call editor_realloc_lines
 
mov ebx,[cur_editor.Lines.Size]
add ebx,[copy_size]
mov [cur_editor.Lines.Size],ebx
stdcall mem.ReAlloc,[cur_editor.Lines],ebx
mov [cur_editor.Lines],eax
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
pushd [esi+EDITOR_LINE_DATA.Size] esi
mov ecx,[cur_editor.Caret.X]
call line_add_spaces
add [esp],eax
add esi,eax
mov ecx,[copy_size]
sub ecx,sizeof.EDITOR_LINE_DATA
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
mov eax,esi
mov esi,edi
sub esi,ecx
lea ecx,[eax+sizeof.EDITOR_LINE_DATA]
add ecx,[cur_editor.Caret.X]
neg ecx
lea ecx,[esi+ecx+1]
std
rep movsb
 
mov ecx,[copy_count]
dec ecx
jz .single_line
 
cld
pop edi
add edi,sizeof.EDITOR_LINE_DATA
mov esi,[copy_buf]
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
 
mov ebx,[cur_editor.Caret.X]
add eax,ebx
mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],eax
mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
sub eax,ebx
call .check_columns
add edi,ebx
@@: push ecx
mov ecx,eax
rep movsb
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
mov [edi+EDITOR_LINE_DATA.Size],eax
mov [edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
add edi,sizeof.EDITOR_LINE_DATA
pop ecx
loop @b
 
pop ecx
sub ecx,ebx
add [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],ecx
call .check_columns
mov ecx,eax
rep movsb
 
mov [cur_editor.Caret.X],eax
mov [cur_editor.SelStart.X],eax
mov eax,[copy_count]
dec eax
add [cur_editor.Caret.Y],eax
add [cur_editor.SelStart.Y],eax
add [cur_editor.Lines.Count],eax
 
mov [cur_editor.Modified],1
jmp .exit
 
.single_line:
cld
pop edi
add edi,sizeof.EDITOR_LINE_DATA
mov esi,[copy_buf]
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
add [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],eax
and [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
call .check_columns
add edi,[cur_editor.Caret.X]
add esp,4
mov ecx,eax
rep movsb
 
add [cur_editor.Caret.X],eax
add [cur_editor.SelStart.X],eax
 
mov [cur_editor.Modified],1
 
.exit:
ret
 
.check_columns:
push eax
mov eax,[edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@: pop eax
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_d ;///// INSERT SEPARATOR //////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,90+sizeof.EDITOR_LINE_DATA
call editor_realloc_lines
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
mov ebx,esi
 
mov ecx,[cur_editor.Lines.Count]
call get_line_offset
lea edi,[esi+90+sizeof.EDITOR_LINE_DATA]
lea ecx,[esi+sizeof.EDITOR_LINE_DATA]
sub ecx,ebx
std
rep movsb
 
lea edi,[ebx+sizeof.EDITOR_LINE_DATA+1]
mov [ebx+EDITOR_LINE_DATA.Size],90
mov al,ASEPC
mov ecx,79
cld
rep stosb
mov al,' '
mov ecx,10
rep stosb
mov byte[ebx+sizeof.EDITOR_LINE_DATA],';'
 
inc [cur_editor.Lines.Count]
inc [cur_editor.Caret.Y]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_y ;///// DELETE CURRENT LINE ///////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.Y]
inc eax
cmp eax,[cur_editor.Lines.Count]
jge .exit
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
mov edi,esi
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
push eax
 
dec [cur_editor.Lines.Count]
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
shr ecx,2
cld
rep movsd
 
pop eax
add eax,sizeof.EDITOR_LINE_DATA
neg eax
call editor_realloc_lines
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.up ;///// GO TO PREVIOUS LINE ///////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_up: ;///// GO TO PREVIOUS LINE, WITH SELECTION ////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.Y]
dec eax
jns @f
xor eax,eax
@@: mov ecx,[cur_editor.TopLeft.Y]
cmp eax,ecx
jae @f
dec ecx
jns @f
xor ecx,ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.down ;///// GO TO NEXT LINE /////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_down: ;///// GO TO NEXT LINE, WITH SELECTION //////////////////
;-----------------------------------------------------------------------------
 
mov eax,[cur_editor.Caret.Y]
inc eax
cmp eax,[cur_editor.Lines.Count]
jb @f
dec eax
@@: mov ecx,[cur_editor.TopLeft.Y]
mov edx,eax
sub edx,ecx
cmp edx,[lines.scr]
jb @f
inc ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.left ;///// GO TO PREVIOUS CHAR /////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_left: ;///// GO TO PREVIOUS CHAR, WITH SELECTION //////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.X]
dec eax
jns @f
inc eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@: mov [cur_editor.Caret.X],eax
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.right ;///// GO TO NEXT CHAR ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_right: ;///// GO TO NEXT CHAR, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.X]
inc eax
cmp eax,[cur_editor.Columns.Count]
jbe @f
dec eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@: mov [cur_editor.Caret.X],eax
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.pgup ;///// GO TO PREVIOUS PAGE /////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_pgup: ;///// GO TO PREVIOUS PAGE, WITH SELECTION //////////////
;-----------------------------------------------------------------------------
mov edx,[lines.scr]
dec edx
mov eax,[cur_editor.Caret.Y]
mov ecx,[cur_editor.TopLeft.Y]
sub eax,edx
jns @f
xor eax,eax
@@: sub ecx,edx
jns @f
xor ecx,ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.pgdn ;///// GO TO NEXT PAGE /////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_pgdn: ;///// GO TO NEXT PAGE, WITH SELECTION //////////////////
;-----------------------------------------------------------------------------
mov edx,[lines.scr]
dec edx
mov eax,[cur_editor.Caret.Y]
mov ecx,[cur_editor.TopLeft.Y]
add eax,edx
add ecx,edx
cmp eax,[cur_editor.Lines.Count]
jb @f
mov eax,[cur_editor.Lines.Count]
dec eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.home ;///// GO TO LINE START ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_home: ;///// GO TO LINE START, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov [cur_editor.Caret.X],0
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],0
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.end ;///// GO TO LINE END ///////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_end: ;///// GO TO LINE END, WITH SELECTION ////////////////////
;-----------------------------------------------------------------------------
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
call get_real_length
mov [cur_editor.Caret.X],eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_home ;///// GO TO PAGE START ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_home: ;///// GO TO PAGE START, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.TopLeft.Y]
mov ecx,eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_end ;///// GO TO PAGE END //////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_end: ;///// GO TO PAGE END, WITH SELECTION ///////////////
;-----------------------------------------------------------------------------
mov ecx,[cur_editor.TopLeft.Y]
mov eax,[lines.scr]
cmp eax,[cur_editor.Lines.Count]
jle @f
mov eax,[cur_editor.Lines.Count]
@@: add eax,ecx
dec eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_pgup ;///// GO TO DOCUMENT START ///////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgup: ;///// GO TO DOCUMENT START, WITH SELECTION ////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [cur_editor.TopLeft.Y],eax
mov [cur_editor.Caret.Y],eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_pgdn ;///// GO TO DOCUMENT END /////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgdn: ;///// GO TO DOCUMENT END, WITH SELECTION //////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Lines.Count]
mov [cur_editor.Caret.Y],eax
sub eax,[lines.scr]
jns @f
xor eax,eax
@@: mov [cur_editor.TopLeft.Y],eax
dec [cur_editor.Caret.Y]
test [chr],KM_SHIFT
jnz @f
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc .exit
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
mov ebp,esi
 
call get_real_length
or eax,eax
je .line_up
 
mov ecx,[cur_editor.Caret.X]
cmp ecx,eax
jae .line_up
lea edi,[ebx+ecx]
neg ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add ecx,eax;[ebp]
repe scasb
je .line_up
 
mov edi,ebx
mov ecx,[cur_editor.Caret.X]
add edi,ecx
lea esi,[edi+1]
neg ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add ecx,eax;[ebp]
dec ecx
rep movsb
mov byte[edi],' '
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
ret
 
.line_up:
mov eax,[cur_editor.Lines.Count]
dec eax
cmp eax,[cur_editor.Caret.Y]
je .exit
mov edi,[temp_buf]
add edi,sizeof.EDITOR_LINE_DATA
mov esi,ebx
mov ecx,[cur_editor.Caret.X]
rep movsb
mov ecx,[cur_editor.Caret.X]
mov eax,[temp_buf]
mov [eax+EDITOR_LINE_DATA.Size],ecx
cmp ecx,[ebp+EDITOR_LINE_DATA.Size]
jbe @f
mov eax,[ebp+EDITOR_LINE_DATA.Size]
sub ecx,eax
sub edi,ecx
mov al,' '
rep stosb
@@: lea esi,[ebx+sizeof.EDITOR_LINE_DATA]
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add esi,eax
mov ecx,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
mov eax,[temp_buf]
add [eax+EDITOR_LINE_DATA.Size],ecx
or [eax+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
rep movsb
 
mov ecx,edi
sub ecx,[temp_buf]
 
mov esi,[temp_buf]
call get_real_length
cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@:
push ecx
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
sub esi,ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add esi,eax
mov eax,[ebp+eax+sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
add esi,eax
lea ecx,[esi-sizeof.EDITOR_LINE_DATA]
sub ecx,ebp
std
cmp esi,edi
jb @f
jz .lp1
mov edi,ebp
add edi,[esp]
lea esi,[ebp+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
mov eax,[esi-sizeof.EDITOR_LINE_DATA*2+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
add esi,eax
mov eax,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
add esi,eax
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb
.lp1: pop ecx
mov esi,[temp_buf]
mov edi,ebp
cld
rep movsb
 
.ok.dec.lines:
dec [cur_editor.Lines.Count]
mov eax,[cur_editor.Lines.Count]
cmp [cur_editor.Caret.Y],eax
jb @f
dec eax
mov [cur_editor.Caret.Y],eax
@@: m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov ecx,[cur_editor.Lines.Count]
call get_line_offset
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
mov eax,[cur_editor.Lines]
add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
sub esi,eax
lea eax,[esi+4096]
call editor_realloc_lines
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ins ;///// TOGGLE INSERT/OVERWRITE MODE /////////////////////////////
;-----------------------------------------------------------------------------
xor [ins_mode],1
mov eax,[cur_editor.Caret.Y]
mov ebx,eax
call draw_editor_text.part
call draw_editor_caret
ret
endp
 
;-----------------------------------------------------------------------------
proc key.bkspace ;///// DELETE PREVIOUS CHAR OR SELECTION ////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc key.del.exit
 
mov eax,[cur_editor.Caret.X]
dec eax
js .line_up
 
dec [cur_editor.Caret.X]
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ebx,eax
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
mov [cur_editor.Modified],1
ret
 
@@: lea edi,[esi+sizeof.EDITOR_LINE_DATA+ebx]
mov ecx,ebx
neg ecx
mov eax,[esi+EDITOR_LINE_DATA.Size]
add ecx,eax
dec ecx
lea esi,[edi+1]
cld
rep movsb
mov byte[edi],' '
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
ret
 
.line_up:
cmp [cur_editor.Caret.Y],0
jne @f
ret
@@: mov ecx,[cur_editor.Caret.Y]
dec ecx
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ebp,esi
lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
@@: cmp byte[ebx+ecx-1],' '
jne @f
dec ecx
jg @b
@@: mov [cur_editor.Caret.X],ecx
dec [cur_editor.Caret.Y]
cld
jmp key.del.line_up
endp
 
;-----------------------------------------------------------------------------
proc key.tab ;///// TABULATE /////////////////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
mov eax,[cur_editor.Caret.X]
 
mov ecx,eax
add eax,ATABW
and eax,not(ATABW-1)
push eax ' '
sub eax,ecx
.direct:
push eax
call editor_realloc_lines
pop eax
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
xchg eax,ecx
 
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
mov eax,[cur_editor.Caret.X]
@@: mov edx,[esi+EDITOR_LINE_DATA.Size]
sub edx,eax
cmp ecx,edx
jl @f
push eax
mov eax,10
call editor_realloc_lines
add esi,eax
pop eax
pushad
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
dec ecx
mov edi,ecx
add ecx,-10+1
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea eax,[esi+eax+sizeof.EDITOR_LINE_DATA]
sub ecx,eax
lea esi,[edi-10]
std
rep movsb
mov ecx,10
mov al,' '
rep stosb
popad
add [esi+EDITOR_LINE_DATA.Size],10
jmp @b
@@: lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
push ecx
mov edi,[esi+EDITOR_LINE_DATA.Size]
lea edi,[ebx+edi-1]
mov esi,edi
sub esi,ecx
lea ecx,[esi+1]
sub ecx,ebx
sub ecx,[cur_editor.Caret.X]
std
rep movsb
.ok: pop ecx
pop eax
rep stosb
cld
pop [cur_editor.Caret.X]
lea esi,[ebx-sizeof.EDITOR_LINE_DATA]
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
mov eax,[cur_editor.Caret.X]
@@: cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@: m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
 
mov eax,14
call editor_realloc_lines
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
 
mov ebx,[cur_editor.Caret.X]
cmp ebx,[esi+EDITOR_LINE_DATA.Size]
jb @f
mov ebx,[esi+EDITOR_LINE_DATA.Size]
dec ebx
jns @f
xor ebx,ebx
@@:
cld
 
mov edi,[temp_buf]
mov ebp,esi
lea ecx,[ebx+1]
@@: dec ecx
jz @f
cmp byte[esi+ecx+sizeof.EDITOR_LINE_DATA-1],' '
je @b
@@: lea eax,[ecx+10]
mov [edi+EDITOR_LINE_DATA.Size],eax
mov [edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
add edi,sizeof.EDITOR_LINE_DATA
jecxz @f
push esi
add esi,sizeof.EDITOR_LINE_DATA
rep movsb
pop esi
@@: mov al,' '
mov ecx,10
rep stosb
 
mov ecx,[esi+EDITOR_LINE_DATA.Size]
sub ecx,ebx
add esi,ebx
add esi,sizeof.EDITOR_LINE_DATA
inc ecx
@@: dec ecx
jz @f
cmp byte[esi+ecx-1],' '
je @b
@@: jz .lp1
@@: cmp byte[esi],' '
jne .lp1
inc esi
loop @b
.lp1: test [auto_indent],1
jz .lp2
push edi ecx
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
lea edi,[ebp+sizeof.EDITOR_LINE_DATA]
mov al,' '
repe scasb
mov eax,ecx
pop ecx edi
je .lp2
neg eax
mov edx,[ebp+EDITOR_LINE_DATA.Size]
add eax,edx;[ebp]
dec eax
jmp @f
.lp2: xor eax,eax
@@: mov edx,edi
add edi,sizeof.EDITOR_LINE_DATA
mov [cur_editor.Caret.X],eax
jecxz @f
push ecx
mov ecx,eax
mov al,' '
rep stosb
pop ecx
@@: jecxz @f
rep movsb
@@: mov ecx,10
mov al,' '
rep stosb
 
lea eax,[edi-sizeof.EDITOR_LINE_DATA]
sub eax,edx
mov [edx+EDITOR_LINE_DATA.Size],eax
mov [edx+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ecx,edi
sub ecx,[temp_buf]
 
push ecx
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+sizeof.EDITOR_LINE_DATA]
sub esi,ecx
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
add esi,ecx
lea ecx,[esi-sizeof.EDITOR_LINE_DATA]
sub ecx,ebp
std
cmp esi,edi
jb @f
je .lp3
lea esi,[ebp+sizeof.EDITOR_LINE_DATA]
mov eax,[esp]
lea edi,[esi+eax-sizeof.EDITOR_LINE_DATA]
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
add esi,ecx
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb
.lp3: pop ecx
mov esi,[temp_buf]
mov edi,ebp
cld
rep movsb
 
inc [cur_editor.Caret.Y]
inc [cur_editor.SelStart.Y]
inc [cur_editor.Lines.Count]
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_tab ;///// SWITCH TO NEXT TAB //////////////////////////////////
;-----------------------------------------------------------------------------
cmp [tab_bar.Items.Count],1
je .exit
xor eax,eax
mov ebp,[tab_bar.Items]
@@: cmp ebp,[tab_bar.Current.Ptr]
je @f
inc eax
add ebp,sizeof.TABITEM
jmp @b
@@: add ebp,sizeof.TABITEM
inc eax
cmp eax,[tab_bar.Items.Count]
jb @f
mov ebp,[tab_bar.Items]
@@: call set_cur_tab
call make_tab_visible
call align_editor_in_tab
call draw_editor
call draw_tabctl
call update_caption
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.shift_ctrl_tab ;///// SWITCH TO PREVIOUS TAB ////////////////////////
;-----------------------------------------------------------------------------
cmp [tab_bar.Items.Count],1
je .exit
xor eax,eax
mov ebp,[tab_bar.Items]
@@: cmp ebp,[tab_bar.Current.Ptr]
je @f
inc eax
add ebp,sizeof.TABITEM
jmp @b
@@: add ebp,-sizeof.TABITEM
dec eax
jge @f
imul eax,[tab_bar.Items.Count],sizeof.TABITEM
add eax,[tab_bar.Items]
lea ebp,[eax-sizeof.TABITEM]
@@: call set_cur_tab
call make_tab_visible
call align_editor_in_tab
call draw_editor
call draw_tabctl
call update_caption
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f4 ;///// CLOSE CURRENT TAB ////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [cur_editor.Modified],0
je .close
mov [bot_mode2],2
jmp key.ctrl_o.direct
.close:
mov [do_not_draw],1
push [tab_bar.Current.Ptr]
cmp [tab_bar.Items.Count],1
jne @f
;call create_tab
jmp key.alt_x.close ; close program
@@: pop ebp
call delete_tab
dec [do_not_draw]
call align_editor_in_tab
call draw_editor
call draw_tabctl
call draw_statusbar
ret
endp
 
;-----------------------------------------------------------------------------
proc key.shift_f9 ;///// SET DEFAULT TAB /////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[tab_bar.Current.Ptr]
cmp eax,[tab_bar.Default.Ptr]
jne @f
xor eax,eax
@@: mov [tab_bar.Default.Ptr],eax
mov ebp,[tab_bar.Current.Ptr]
call make_tab_visible
cmp [tab_bar.Style],2
jbe @f
call align_editor_in_tab
call draw_editor
@@: call draw_tabctl
ret
endp
 
;-----------------------------------------------------------------------------
proc key.f3 ;///// FIND NEXT MATCH ///////////////////////////////////////////
;-----------------------------------------------------------------------------
call search
jc @f
@@: ret
endp
 
;-----------------------------------------------------------------------------
proc key.f9 ;///// COMPILE AND RUN ///////////////////////////////////////////
;-----------------------------------------------------------------------------
mov bl,1
call start_fasm
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f9 ;///// COMPILE //////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov bl,0
call start_fasm
ret
endp
 
;-----------------------------------------------------------------------------
proc key.alt_x ;///// EXIT PROGRAM ///////////////////////////////////////////
;-----------------------------------------------------------------------------
mov [main_closing],1
mov eax,[tab_bar.Items]
mov [exit_tab_item],eax
mov eax,[tab_bar.Items.Count]
mov [exit_tab_num],eax
.direct:
call try_to_close_tabs
or eax,eax
jz @f
mov [bot_mode2],2
jmp key.ctrl_o.direct
 
@@: stdcall save_settings
 
.close:
mov [main_closed],1
mcall -1
endp
 
;-----------------------------------------------------------------------------
proc try_to_close_tabs ;///// FIND TABS TO BE SAVED BEFORE CLOSE /////////////
;-----------------------------------------------------------------------------
push ecx ebp
call flush_cur_tab
mov ebp,[exit_tab_item] ; [tab_bar.Items]
add ebp,-sizeof.TABITEM
@@: dec [exit_tab_num]
js .ok
add ebp,sizeof.TABITEM
mov al,[ebp+TABITEM.Editor.Modified]
cmp [ebp+TABITEM.Editor.Modified],0
je @b
mov [exit_tab_item],ebp
call set_cur_tab
call make_tab_visible
xor eax,eax
inc eax
@@: pop ebp ecx
ret
.ok: xor eax,eax
jmp @b
endp
diff16 'tp-key.asm',0,$
 
key:
mov ecx,1
mcall 66,3 ; Get status of the control keys
mov [shi],eax
xor ebx,ebx
test al,0x03 ; Left or right shift
jz @f
or ebx,KM_SHIFT
@@: test al,0x0C ; Left or right control
jz @f
or ebx,KM_CTRL
@@: test al,0x10 ; Left alt
jz @f
or ebx,KM_ALT
@@: mov edx,ebx
test al,0x03
jz @f
inc cl
@@:
mcall 2
cmp al,0
jne still.skip_write
shr eax,8
;--------------------------------------
; this code for Win-keys, works with
; kernel SVN r.3356 or later
test [shi],0x200 ; LWin
jnz still.skip_write
test [shi],0x400 ; RWin
jnz still.skip_write
;--------------------------------------
cmp al,224
jne @f
mov [ext],0x01
jmp still.skip_write
@@: cmp al,225
jne @f
mov [ext],0x02
jmp still.skip_write
@@:
mov ah,[ext]
mov [ext],0
 
mov esi,numpad_table_off
test [shi], 0x00000080 ; NumLock is on?
jz .num
mov esi,numpad_table_on
.num: cmp eax,[esi]
jne @f
mov eax,[esi+4]
mov ebx,eax
or eax,edx
shr ebx,8
or ebx,0x0000FFFF
and eax,ebx
mov ecx,eax
shr ecx,16
and cl,1
inc cl
jmp .lp0
@@: add esi,8
cmp dword[esi],0
jne .num
 
or eax,edx
 
.lp0: test al,0x80
jnz still.skip_write
;--------------------------------------
; it is CAPS LOCK correct processing for chars
test [shi], 0x00000040 ; CAPS LOCK is on?
jz .no_caps_lock
cmp ecx,1
jnz @f
inc ecx
jmp .no_caps_lock
@@:
cmp ecx,2
jnz .no_caps_lock
dec ecx
.no_caps_lock:
;--------------------------------------
; alt gr pressed?
test [shi], 0x00000020
jz .no_alt_gr
mov ecx, 3
.no_alt_gr:
;--------------------------------------
push eax
mcall 26,2,,key1
pop eax
 
mov [chr],eax
 
cmp [bot_mode],0
je @f
mov ebx,eax
mov al,2
call [bot_dlg_handler]
jmp still.skip_write
@@:
 
mov esi,accel_table_main
.acc: cmp eax,[esi]
jne @f
test [secure_sel],1
jz .lp1
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
.lp1: mov [s_status],0
call dword[esi+4]
call editor_check_for_changes
jmp still
@@: add esi,8
cmp dword[esi],0
jne .acc
 
test [chr],KM_CTRLALT
jnz still.skip_write
 
mov [s_status],0
 
movzx eax,byte[chr]
movzx eax,[eax+key0]
or al,al
jz still.skip_write
movzx eax,[eax+key1]
push eax
 
test [secure_sel],1
jz .lp2
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
jmp .put
.lp2: call delete_selection
 
test [auto_braces],1
jz .put
cmp al,'['
jne @f
mov al,']'
call .lp3
dec [cur_editor.Caret.X]
jmp .put
@@: cmp al,'('
jne @f
mov al,')'
call .lp3
dec [cur_editor.Caret.X]
jmp .put
@@: cmp al,'{'
jne .put
mov al,'}'
call .lp3
dec [cur_editor.Caret.X]
 
.put: pop eax
push still editor_check_for_changes
inc [cur_editor.SelStart.X]
.lp3: push [cur_editor.Caret.X] eax
inc dword[esp+4]
mov eax,1
jmp key.tab.direct
 
;-----------------------------------------------------------------------------
proc key.ctrl_a ;///// SELECT ALL DOCUMENT ///////////////////////////////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [cur_editor.SelStart.X],eax
mov [cur_editor.SelStart.Y],eax
mov ecx,[cur_editor.Lines.Count]
dec ecx
mov [cur_editor.Caret.Y],ecx
call get_line_offset
call get_real_length
mov [cur_editor.Caret.X],eax
call draw_editor
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_o ;///// ENTER OPEN FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_mode2],0
 
.direct:
cmp [bot_mode2], 2
je .ask
mov [s_status],s_enter_filename
jmp .ask1
 
.ask:
mov [s_status],s_ask_save
.ask1:
mov [bot_mode],1
mov [bot_dlg_height],16*2+4*2-1
mov [bot_dlg_handler],osdlg_handler
mov [focused_tb],tb_opensave
 
@@: mov al,[tb_opensave.length]
mov [tb_opensave.pos.x],al
mov [tb_opensave.sel.x],0
mov [tb_casesen],0;1
call drawwindow
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_s ;///// ENTER SAVE FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
cmp [cur_editor.FilePath], 0
je key.shift_ctrl_s
cmp [cur_editor.Modified],0
je .exit
call save_file
call drawwindow
.exit:
ret
 
key.shift_ctrl_s:
mov [bot_mode2],1
jmp key.ctrl_o.direct
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_n ;///// CREATE NEW FILE (TAB) /////////////////////////////////
;-----------------------------------------------------------------------------
call create_tab
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f ;///// ENTER KEYWORD TO FIND /////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_mode2],0
mov [bot_dlg_height],16*2+4*2-1
 
mov [s_status],s_enter_text_to_find
 
.direct:
mov [bot_mode],1
mov [bot_dlg_handler],finddlg_handler
mov [focused_tb],tb_find
 
mov ecx,[s_search.size]
mov [tb_find.length],cl
jecxz @f
mov esi,s_search
mov edi,tb_find.text
cld
rep movsb
 
@@: mov al,[tb_find.length]
mov [tb_find.pos.x],al
mov [tb_find.sel.x],0
mov [tb_casesen],0
call drawwindow
ret
endp
 
proc key.ctrl_h
mov [bot_mode2],1
mov [bot_dlg_height],16*3+4*2+1
 
mov [s_status],s_enter_text_to_replace
 
jmp key.ctrl_f.direct
endp
 
proc key.ctrl_g
ret
@^
mov [bot_mode2],0
mov [bot_dlg_height],16*2+4*2-1
 
mov [bot_mode],1
mov [bot_dlg_handler],gotodlg_handler
mov [focused_tb],tb_gotorow
 
mov al,[tb_gotorow.length]
mov [tb_gotorow.pos.x],al
mov [tb_gotorow.sel.x],0
mov [tb_casesen],0
call drawwindow
ret
^@
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_left ;///// GO TO PREVIOUS WORD ////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_left: ;///// GO TO PREVIOUS WORD, WITH SELECTION /////////
;-----------------------------------------------------------------------------
mov ebx,[cur_editor.Caret.Y]
mov edx,[cur_editor.Caret.X]
cld
mov ecx,ebx
call get_line_offset
.lp1: cmp edx,[esi+EDITOR_LINE_DATA.Size]
jle @f
mov edx,[esi+EDITOR_LINE_DATA.Size]
@@: dec edx
jl .nx1
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
mov ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
mov al,[esi]
dec esi
repne scasb
pop ecx
jne @f
dec edx
dec ecx
jnz @b
.nx1: dec ebx
js .exit.2
mov ecx,ebx
call get_line_offset
mov edx,[esi+EDITOR_LINE_DATA.Size]
dec edx
jmp .lp1
@@:
mov ecx,ebx
call get_line_offset
.lp2: cmp edx,[esi+EDITOR_LINE_DATA.Size]
jle @f
mov edx,[esi+EDITOR_LINE_DATA.Size]
@@: or edx,edx
jl .nx2
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
@@: mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
mov al,[esi]
dec esi
repne scasb
je @f
dec edx
jns @b
jmp @f
.nx2: dec ebx
js .exit.2
mov ecx,ebx
call get_line_offset
mov edx,[esi+EDITOR_LINE_DATA.Size]
dec edx
jmp .lp2
@@:
inc edx
mov [cur_editor.Caret.Y],ebx
mov [cur_editor.Caret.X],edx
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],ebx
mov [cur_editor.SelStart.X],edx
@@: sub ebx,[cur_editor.TopLeft.Y]
jge @f
add [cur_editor.TopLeft.Y],ebx
@@: mov eax,edx
sub eax,[cur_editor.TopLeft.X]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [cur_editor.TopLeft.X],eax
jmp .exit
@@: cmp edx,[cur_editor.TopLeft.X]
jge .exit
mov [cur_editor.TopLeft.X],edx
.exit:
call editor_check_for_changes
.exit.2:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_right ;///// GO TO NEXT WORD ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_right: ;///// GO TO NEXT WORD, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov ebx,[cur_editor.Caret.Y]
mov edx,[cur_editor.Caret.X]
cld
.lp1: mov ecx,ebx
call get_line_offset
mov ecx,[esi+EDITOR_LINE_DATA.Size]
cmp edx,ecx
jge .nx1
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
sub ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
lodsb
repne scasb
pop ecx
je @f
inc edx
dec ecx
jnz @b
.nx1: inc ebx
cmp ebx,[cur_editor.Lines.Count]
jge .exit.2
xor edx,edx
jmp .lp1
@@:
 
.lp2: mov ecx,ebx
call get_line_offset
mov ecx,[esi+EDITOR_LINE_DATA.Size]
cmp edx,ecx
jge .nx2
add esi,sizeof.EDITOR_LINE_DATA
add esi,edx
sub ecx,edx
@@: push ecx
mov edi,symbols_ex
mov ecx,symbols_ex.size+symbols.size
lodsb
repne scasb
pop ecx
jne @f
inc edx
dec ecx
jnz @b
.nx2: inc ebx
cmp ebx,[cur_editor.Lines.Count]
jge .exit.2
xor edx,edx
jmp .lp2
@@:
mov [cur_editor.Caret.Y],ebx
mov [cur_editor.Caret.X],edx
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],ebx
mov [cur_editor.SelStart.X],edx
@@: sub ebx,[cur_editor.TopLeft.Y]
cmp ebx,[lines.scr]
jl @f
sub ebx,[lines.scr]
inc ebx
add [cur_editor.TopLeft.Y],ebx
@@: mov eax,edx
sub eax,[cur_editor.TopLeft.X]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [cur_editor.TopLeft.X],eax
jmp .exit
@@: cmp edx,[cur_editor.TopLeft.X]
jge .exit
mov [cur_editor.TopLeft.X],edx
.exit:
call editor_check_for_changes
.exit.2:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_x
cmp [sel.selected],0
je @f
call key.ctrl_c
call key.del
mov [cur_editor.Modified],1
@@: ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_c
mov [copy_size],0
cmp [sel.selected],0
je .exit
 
call get_selection_size
stdcall mem.ReAlloc,[copy_buf],eax
mov [copy_buf],eax
 
cld
mov eax,[sel.begin.y]
cmp eax,[sel.end.y]
je .single_line
mov ecx,[sel.begin.y]
call get_line_offset
inc ecx
push ecx
mov edi,[copy_buf]
call get_real_length
sub eax,[sel.begin.x]
jge @f
xor eax,eax
@@: add esi,[sel.begin.x]
add esi,sizeof.EDITOR_LINE_DATA
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,eax
jecxz @f
rep movsb
@@: mov ecx,[sel.end.y]
call get_line_offset
pop ecx
cmp ecx,[sel.end.y]
je @f
mov eax,esi
call get_line_offset
sub eax,esi
mov ecx,eax
rep movsb
mov ecx,[sel.end.y]
@@: call get_line_offset
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
cmp eax,[sel.end.x]
jle @f
mov eax,[sel.end.x]
@@: mov ebx,edi
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,eax
jecxz @f
rep movsb
sub eax,[sel.end.x]
jz @f
neg eax
mov ecx,eax
add [ebx],eax
mov al,' '
rep stosb
@@: sub edi,[copy_buf]
mov [copy_size],edi
mov eax,[sel.end.y]
sub eax,[sel.begin.y]
inc eax
mov [copy_count],eax
.exit:
ret
 
.single_line:
mov eax,[sel.end.x]
sub eax,[sel.begin.x]
mov edi,[copy_buf]
mov [edi+EDITOR_LINE_DATA.Size],eax
add edi,sizeof.EDITOR_LINE_DATA
mov ecx,[sel.begin.y]
call get_line_offset
mov ebx,[sel.begin.x]
mov ecx,[sel.end.x]
cmp ebx,[esi+EDITOR_LINE_DATA.Size]
jge .add_spaces
cmp ecx,[esi+EDITOR_LINE_DATA.Size]
jle .lp1
mov ecx,[esi+EDITOR_LINE_DATA.Size]
.lp1: sub ecx,[sel.begin.x]
sub eax,ecx
lea esi,[esi+ebx+sizeof.EDITOR_LINE_DATA]
rep movsb
 
.add_spaces:
mov ecx,eax
mov al,' '
jecxz @b
rep stosb
jmp @b
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_v
cmp [copy_size],0
je .exit
 
call delete_selection
 
mov eax,[copy_size]
call editor_realloc_lines
 
mov ebx,[cur_editor.Lines.Size]
add ebx,[copy_size]
mov [cur_editor.Lines.Size],ebx
stdcall mem.ReAlloc,[cur_editor.Lines],ebx
mov [cur_editor.Lines],eax
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
pushd [esi+EDITOR_LINE_DATA.Size] esi
mov ecx,[cur_editor.Caret.X]
call line_add_spaces
add [esp],eax
add esi,eax
mov ecx,[copy_size]
sub ecx,sizeof.EDITOR_LINE_DATA
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
mov eax,esi
mov esi,edi
sub esi,ecx
lea ecx,[eax+sizeof.EDITOR_LINE_DATA]
add ecx,[cur_editor.Caret.X]
neg ecx
lea ecx,[esi+ecx+1]
std
rep movsb
 
mov ecx,[copy_count]
dec ecx
jz .single_line
 
cld
pop edi
add edi,sizeof.EDITOR_LINE_DATA
mov esi,[copy_buf]
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
 
mov ebx,[cur_editor.Caret.X]
add eax,ebx
mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],eax
mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
sub eax,ebx
call .check_columns
add edi,ebx
@@: push ecx
mov ecx,eax
rep movsb
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
mov [edi+EDITOR_LINE_DATA.Size],eax
mov [edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
add edi,sizeof.EDITOR_LINE_DATA
pop ecx
loop @b
 
pop ecx
sub ecx,ebx
add [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],ecx
call .check_columns
mov ecx,eax
rep movsb
 
mov [cur_editor.Caret.X],eax
mov [cur_editor.SelStart.X],eax
mov eax,[copy_count]
dec eax
add [cur_editor.Caret.Y],eax
add [cur_editor.SelStart.Y],eax
add [cur_editor.Lines.Count],eax
 
mov [cur_editor.Modified],1
jmp .exit
 
.single_line:
cld
pop edi
add edi,sizeof.EDITOR_LINE_DATA
mov esi,[copy_buf]
mov eax,[esi+EDITOR_LINE_DATA.Size]
add esi,sizeof.EDITOR_LINE_DATA
add [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],eax
and [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
call .check_columns
add edi,[cur_editor.Caret.X]
add esp,4
mov ecx,eax
rep movsb
 
add [cur_editor.Caret.X],eax
add [cur_editor.SelStart.X],eax
 
mov [cur_editor.Modified],1
 
.exit:
ret
 
.check_columns:
push eax
mov eax,[edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@: pop eax
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_d ;///// INSERT SEPARATOR //////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,90+sizeof.EDITOR_LINE_DATA
call editor_realloc_lines
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
mov ebx,esi
 
mov ecx,[cur_editor.Lines.Count]
call get_line_offset
lea edi,[esi+90+sizeof.EDITOR_LINE_DATA]
lea ecx,[esi+sizeof.EDITOR_LINE_DATA]
sub ecx,ebx
std
rep movsb
 
lea edi,[ebx+sizeof.EDITOR_LINE_DATA+1]
mov [ebx+EDITOR_LINE_DATA.Size],90
mov al,ASEPC
mov ecx,79
cld
rep stosb
mov al,' '
mov ecx,10
rep stosb
mov byte[ebx+sizeof.EDITOR_LINE_DATA],';'
 
inc [cur_editor.Lines.Count]
inc [cur_editor.Caret.Y]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_y ;///// DELETE CURRENT LINE ///////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.Y]
inc eax
cmp eax,[cur_editor.Lines.Count]
jge .exit
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
mov edi,esi
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
push eax
 
dec [cur_editor.Lines.Count]
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
shr ecx,2
cld
rep movsd
 
pop eax
add eax,sizeof.EDITOR_LINE_DATA
neg eax
call editor_realloc_lines
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.up ;///// GO TO PREVIOUS LINE ///////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_up: ;///// GO TO PREVIOUS LINE, WITH SELECTION ////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.Y]
dec eax
jns @f
xor eax,eax
@@: mov ecx,[cur_editor.TopLeft.Y]
cmp eax,ecx
jae @f
dec ecx
jns @f
xor ecx,ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.down ;///// GO TO NEXT LINE /////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_down: ;///// GO TO NEXT LINE, WITH SELECTION //////////////////
;-----------------------------------------------------------------------------
 
mov eax,[cur_editor.Caret.Y]
inc eax
cmp eax,[cur_editor.Lines.Count]
jb @f
dec eax
@@: mov ecx,[cur_editor.TopLeft.Y]
mov edx,eax
sub edx,ecx
cmp edx,[lines.scr]
jb @f
inc ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.left ;///// GO TO PREVIOUS CHAR /////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_left: ;///// GO TO PREVIOUS CHAR, WITH SELECTION //////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.X]
dec eax
jns @f
inc eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@: mov [cur_editor.Caret.X],eax
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.right ;///// GO TO NEXT CHAR ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_right: ;///// GO TO NEXT CHAR, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Caret.X]
inc eax
cmp eax,[cur_editor.Columns.Count]
jbe @f
dec eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@: mov [cur_editor.Caret.X],eax
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.pgup ;///// GO TO PREVIOUS PAGE /////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_pgup: ;///// GO TO PREVIOUS PAGE, WITH SELECTION //////////////
;-----------------------------------------------------------------------------
mov edx,[lines.scr]
dec edx
mov eax,[cur_editor.Caret.Y]
mov ecx,[cur_editor.TopLeft.Y]
sub eax,edx
jns @f
xor eax,eax
@@: sub ecx,edx
jns @f
xor ecx,ecx
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.pgdn ;///// GO TO NEXT PAGE /////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_pgdn: ;///// GO TO NEXT PAGE, WITH SELECTION //////////////////
;-----------------------------------------------------------------------------
mov edx,[lines.scr]
dec edx
mov eax,[cur_editor.Caret.Y]
mov ecx,[cur_editor.TopLeft.Y]
add eax,edx
add ecx,edx
cmp eax,[cur_editor.Lines.Count]
jb @f
mov eax,[cur_editor.Lines.Count]
dec eax
@@: test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.home ;///// GO TO LINE START ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_home: ;///// GO TO LINE START, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov [cur_editor.Caret.X],0
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],0
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.end ;///// GO TO LINE END ///////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_end: ;///// GO TO LINE END, WITH SELECTION ////////////////////
;-----------------------------------------------------------------------------
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
call get_real_length
mov [cur_editor.Caret.X],eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.X],eax
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_home ;///// GO TO PAGE START ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_home: ;///// GO TO PAGE START, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.TopLeft.Y]
mov ecx,eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_end ;///// GO TO PAGE END //////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_end: ;///// GO TO PAGE END, WITH SELECTION ///////////////
;-----------------------------------------------------------------------------
mov ecx,[cur_editor.TopLeft.Y]
mov eax,[lines.scr]
cmp eax,[cur_editor.Lines.Count]
jle @f
mov eax,[cur_editor.Lines.Count]
@@: add eax,ecx
dec eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@: mov [cur_editor.Caret.Y],eax
mov [cur_editor.TopLeft.Y],ecx
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_pgup ;///// GO TO DOCUMENT START ///////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgup: ;///// GO TO DOCUMENT START, WITH SELECTION ////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [cur_editor.TopLeft.Y],eax
mov [cur_editor.Caret.Y],eax
test [chr],KM_SHIFT
jnz @f
mov [cur_editor.SelStart.Y],eax
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_pgdn ;///// GO TO DOCUMENT END /////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgdn: ;///// GO TO DOCUMENT END, WITH SELECTION //////////
;-----------------------------------------------------------------------------
mov eax,[cur_editor.Lines.Count]
mov [cur_editor.Caret.Y],eax
sub eax,[lines.scr]
jns @f
xor eax,eax
@@: mov [cur_editor.TopLeft.Y],eax
dec [cur_editor.Caret.Y]
test [chr],KM_SHIFT
jnz @f
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
@@:
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc .exit
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
mov ebp,esi
 
call get_real_length
or eax,eax
je .line_up
 
mov ecx,[cur_editor.Caret.X]
cmp ecx,eax
jae .line_up
lea edi,[ebx+ecx]
neg ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add ecx,eax;[ebp]
repe scasb
je .line_up
 
mov edi,ebx
mov ecx,[cur_editor.Caret.X]
add edi,ecx
lea esi,[edi+1]
neg ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add ecx,eax;[ebp]
dec ecx
rep movsb
mov byte[edi],' '
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
ret
 
.line_up:
mov eax,[cur_editor.Lines.Count]
dec eax
cmp eax,[cur_editor.Caret.Y]
je .exit
mov edi,[temp_buf]
add edi,sizeof.EDITOR_LINE_DATA
mov esi,ebx
mov ecx,[cur_editor.Caret.X]
rep movsb
mov ecx,[cur_editor.Caret.X]
mov eax,[temp_buf]
mov [eax+EDITOR_LINE_DATA.Size],ecx
cmp ecx,[ebp+EDITOR_LINE_DATA.Size]
jbe @f
mov eax,[ebp+EDITOR_LINE_DATA.Size]
sub ecx,eax
sub edi,ecx
mov al,' '
rep stosb
@@: lea esi,[ebx+sizeof.EDITOR_LINE_DATA]
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add esi,eax
mov ecx,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
mov eax,[temp_buf]
add [eax+EDITOR_LINE_DATA.Size],ecx
or [eax+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
rep movsb
 
mov ecx,edi
sub ecx,[temp_buf]
 
mov esi,[temp_buf]
call get_real_length
cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@:
push ecx
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
sub esi,ecx
mov eax,[ebp+EDITOR_LINE_DATA.Size]
add esi,eax
mov eax,[ebp+eax+sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
add esi,eax
lea ecx,[esi-sizeof.EDITOR_LINE_DATA]
sub ecx,ebp
std
cmp esi,edi
jb @f
jz .lp1
mov edi,ebp
add edi,[esp]
lea esi,[ebp+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
mov eax,[esi-sizeof.EDITOR_LINE_DATA*2+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
add esi,eax
mov eax,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
add esi,eax
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb
.lp1: pop ecx
mov esi,[temp_buf]
mov edi,ebp
cld
rep movsb
 
.ok.dec.lines:
dec [cur_editor.Lines.Count]
mov eax,[cur_editor.Lines.Count]
cmp [cur_editor.Caret.Y],eax
jb @f
dec eax
mov [cur_editor.Caret.Y],eax
@@: m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
 
mov ecx,[cur_editor.Lines.Count]
call get_line_offset
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
mov eax,[cur_editor.Lines]
add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
sub esi,eax
lea eax,[esi+4096]
call editor_realloc_lines
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ins ;///// TOGGLE INSERT/OVERWRITE MODE /////////////////////////////
;-----------------------------------------------------------------------------
xor [ins_mode],1
mov eax,[cur_editor.Caret.Y]
mov ebx,eax
call draw_editor_text.part
call draw_editor_caret
ret
endp
 
;-----------------------------------------------------------------------------
proc key.bkspace ;///// DELETE PREVIOUS CHAR OR SELECTION ////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc key.del.exit
 
mov eax,[cur_editor.Caret.X]
dec eax
js .line_up
 
dec [cur_editor.Caret.X]
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ebx,eax
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
mov [cur_editor.Modified],1
ret
 
@@: lea edi,[esi+sizeof.EDITOR_LINE_DATA+ebx]
mov ecx,ebx
neg ecx
mov eax,[esi+EDITOR_LINE_DATA.Size]
add ecx,eax
dec ecx
lea esi,[edi+1]
cld
rep movsb
mov byte[edi],' '
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
ret
 
.line_up:
cmp [cur_editor.Caret.Y],0
jne @f
ret
@@: mov ecx,[cur_editor.Caret.Y]
dec ecx
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ebp,esi
lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
@@: cmp byte[ebx+ecx-1],' '
jne @f
dec ecx
jg @b
@@: mov [cur_editor.Caret.X],ecx
dec [cur_editor.Caret.Y]
cld
jmp key.del.line_up
endp
 
;-----------------------------------------------------------------------------
proc key.tab ;///// TABULATE /////////////////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
mov eax,[cur_editor.Caret.X]
 
mov ecx,eax
add eax,ATABW
and eax,not(ATABW-1)
push eax ' '
sub eax,ecx
.direct:
push eax
call editor_realloc_lines
pop eax
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
xchg eax,ecx
 
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
mov eax,[cur_editor.Caret.X]
@@: mov edx,[esi+EDITOR_LINE_DATA.Size]
sub edx,eax
cmp ecx,edx
jl @f
push eax
mov eax,10
call editor_realloc_lines
add esi,eax
pop eax
pushad
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
dec ecx
mov edi,ecx
add ecx,-10+1
mov eax,[esi+EDITOR_LINE_DATA.Size]
lea eax,[esi+eax+sizeof.EDITOR_LINE_DATA]
sub ecx,eax
lea esi,[edi-10]
std
rep movsb
mov ecx,10
mov al,' '
rep stosb
popad
add [esi+EDITOR_LINE_DATA.Size],10
jmp @b
@@: lea ebx,[esi+sizeof.EDITOR_LINE_DATA]
push ecx
mov edi,[esi+EDITOR_LINE_DATA.Size]
lea edi,[ebx+edi-1]
mov esi,edi
sub esi,ecx
lea ecx,[esi+1]
sub ecx,ebx
sub ecx,[cur_editor.Caret.X]
std
rep movsb
.ok: pop ecx
pop eax
rep stosb
cld
pop [cur_editor.Caret.X]
lea esi,[ebx-sizeof.EDITOR_LINE_DATA]
call get_real_length
cmp eax,[cur_editor.Caret.X]
jae @f
mov eax,[cur_editor.Caret.X]
@@: cmp eax,[cur_editor.Columns.Count]
jbe @f
mov [cur_editor.Columns.Count],eax
@@: m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
m2m [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
 
mov eax,14
call editor_realloc_lines
 
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
 
mov ebx,[cur_editor.Caret.X]
cmp ebx,[esi+EDITOR_LINE_DATA.Size]
jb @f
mov ebx,[esi+EDITOR_LINE_DATA.Size]
dec ebx
jns @f
xor ebx,ebx
@@:
cld
 
mov edi,[temp_buf]
mov ebp,esi
lea ecx,[ebx+1]
@@: dec ecx
jz @f
cmp byte[esi+ecx+sizeof.EDITOR_LINE_DATA-1],' '
je @b
@@: lea eax,[ecx+10]
mov [edi+EDITOR_LINE_DATA.Size],eax
mov [edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
add edi,sizeof.EDITOR_LINE_DATA
jecxz @f
push esi
add esi,sizeof.EDITOR_LINE_DATA
rep movsb
pop esi
@@: mov al,' '
mov ecx,10
rep stosb
 
mov ecx,[esi+EDITOR_LINE_DATA.Size]
sub ecx,ebx
add esi,ebx
add esi,sizeof.EDITOR_LINE_DATA
inc ecx
@@: dec ecx
jz @f
cmp byte[esi+ecx-1],' '
je @b
@@: jz .lp1
@@: cmp byte[esi],' '
jne .lp1
inc esi
loop @b
.lp1: test [auto_indent],1
jz .lp2
push edi ecx
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
lea edi,[ebp+sizeof.EDITOR_LINE_DATA]
mov al,' '
repe scasb
mov eax,ecx
pop ecx edi
je .lp2
neg eax
mov edx,[ebp+EDITOR_LINE_DATA.Size]
add eax,edx;[ebp]
dec eax
jmp @f
.lp2: xor eax,eax
@@: mov edx,edi
add edi,sizeof.EDITOR_LINE_DATA
mov [cur_editor.Caret.X],eax
jecxz @f
push ecx
mov ecx,eax
mov al,' '
rep stosb
pop ecx
@@: jecxz @f
rep movsb
@@: mov ecx,10
mov al,' '
rep stosb
 
lea eax,[edi-sizeof.EDITOR_LINE_DATA]
sub eax,edx
mov [edx+EDITOR_LINE_DATA.Size],eax
mov [edx+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
 
mov ecx,edi
sub ecx,[temp_buf]
 
push ecx
mov edi,[cur_editor.Lines]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+sizeof.EDITOR_LINE_DATA]
sub esi,ecx
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
add esi,ecx
lea ecx,[esi-sizeof.EDITOR_LINE_DATA]
sub ecx,ebp
std
cmp esi,edi
jb @f
je .lp3
lea esi,[ebp+sizeof.EDITOR_LINE_DATA]
mov eax,[esp]
lea edi,[esi+eax-sizeof.EDITOR_LINE_DATA]
mov ecx,[ebp+EDITOR_LINE_DATA.Size]
add esi,ecx
mov ecx,[cur_editor.Lines]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb
.lp3: pop ecx
mov esi,[temp_buf]
mov edi,ebp
cld
rep movsb
 
inc [cur_editor.Caret.Y]
inc [cur_editor.SelStart.Y]
inc [cur_editor.Lines.Count]
 
m2m [cur_editor.SelStart.X],[cur_editor.Caret.X]
 
mov [cur_editor.Modified],1
 
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_tab ;///// SWITCH TO NEXT TAB //////////////////////////////////
;-----------------------------------------------------------------------------
cmp [tab_bar.Items.Count],1
je .exit
xor eax,eax
mov ebp,[tab_bar.Items]
@@: cmp ebp,[tab_bar.Current.Ptr]
je @f
inc eax
add ebp,sizeof.TABITEM
jmp @b
@@: add ebp,sizeof.TABITEM
inc eax
cmp eax,[tab_bar.Items.Count]
jb @f
mov ebp,[tab_bar.Items]
@@: call set_cur_tab
call make_tab_visible
call align_editor_in_tab
call draw_editor
call draw_tabctl
call update_caption
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.shift_ctrl_tab ;///// SWITCH TO PREVIOUS TAB ////////////////////////
;-----------------------------------------------------------------------------
cmp [tab_bar.Items.Count],1
je .exit
xor eax,eax
mov ebp,[tab_bar.Items]
@@: cmp ebp,[tab_bar.Current.Ptr]
je @f
inc eax
add ebp,sizeof.TABITEM
jmp @b
@@: add ebp,-sizeof.TABITEM
dec eax
jge @f
imul eax,[tab_bar.Items.Count],sizeof.TABITEM
add eax,[tab_bar.Items]
lea ebp,[eax-sizeof.TABITEM]
@@: call set_cur_tab
call make_tab_visible
call align_editor_in_tab
call draw_editor
call draw_tabctl
call update_caption
.exit:
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f4 ;///// CLOSE CURRENT TAB ////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [cur_editor.Modified],0
je .close
mov [bot_mode2],2
jmp key.ctrl_o.direct
.close:
mov [do_not_draw],1
push [tab_bar.Current.Ptr]
cmp [tab_bar.Items.Count],1
jne @f
;call create_tab
jmp key.alt_x.close ; close program
@@: pop ebp
call delete_tab
dec [do_not_draw]
call align_editor_in_tab
call draw_editor
call draw_tabctl
call draw_statusbar
ret
endp
 
;-----------------------------------------------------------------------------
proc key.shift_f9 ;///// SET DEFAULT TAB /////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[tab_bar.Current.Ptr]
cmp eax,[tab_bar.Default.Ptr]
jne @f
xor eax,eax
@@: mov [tab_bar.Default.Ptr],eax
mov ebp,[tab_bar.Current.Ptr]
call make_tab_visible
cmp [tab_bar.Style],2
jbe @f
call align_editor_in_tab
call draw_editor
@@: call draw_tabctl
ret
endp
 
;-----------------------------------------------------------------------------
proc key.f3 ;///// FIND NEXT MATCH ///////////////////////////////////////////
;-----------------------------------------------------------------------------
call search
jc @f
@@: ret
endp
 
;-----------------------------------------------------------------------------
proc key.f9 ;///// COMPILE AND RUN ///////////////////////////////////////////
;-----------------------------------------------------------------------------
mov bl,1
call start_fasm
ret
endp
 
;-----------------------------------------------------------------------------
proc key.f10 ;///// COMPILE AND RUN UNDER DEBUG //////////////////////////////
;-----------------------------------------------------------------------------
mov bl,2
call start_fasm
ret
endp
 
;-----------------------------------------------------------------------------
proc key.ctrl_f9 ;///// COMPILE //////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov bl,0
call start_fasm
ret
endp
 
;-----------------------------------------------------------------------------
proc key.alt_x ;///// EXIT PROGRAM ///////////////////////////////////////////
;-----------------------------------------------------------------------------
mov [main_closing],1
mov eax,[tab_bar.Items]
mov [exit_tab_item],eax
mov eax,[tab_bar.Items.Count]
mov [exit_tab_num],eax
.direct:
call try_to_close_tabs
or eax,eax
jz @f
mov [bot_mode2],2
jmp key.ctrl_o.direct
 
@@: stdcall save_settings
 
.close:
mov [main_closed],1
mcall -1
endp
 
;-----------------------------------------------------------------------------
proc try_to_close_tabs ;///// FIND TABS TO BE SAVED BEFORE CLOSE /////////////
;-----------------------------------------------------------------------------
push ecx ebp
call flush_cur_tab
mov ebp,[exit_tab_item] ; [tab_bar.Items]
add ebp,-sizeof.TABITEM
@@: dec [exit_tab_num]
js .ok
add ebp,sizeof.TABITEM
mov al,[ebp+TABITEM.Editor.Modified]
cmp [ebp+TABITEM.Editor.Modified],0
je @b
mov [exit_tab_item],ebp
call set_cur_tab
call make_tab_visible
xor eax,eax
inc eax
@@: pop ebp ecx
ret
.ok: xor eax,eax
jmp @b
endp