Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 176 → Rev 178

/programs/develop/tinypad/trunk/build_en.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm tinypad.asm tinypad
@erase lang.inc
@pause
/programs/develop/tinypad/trunk/build_ru.bat
1,4 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm tinypad.asm tinypad
@erase lang.inc
@pause
/programs/develop/tinypad/trunk/macros.inc
1,6 → 1,3
; language for programs
lang fix en ; ru en fr ge fi
 
@^ fix macro comment {
^@ fix }
 
331,21 → 328,34
; structure definition helper
include 'struct.inc'
 
struct RECT
left dd ?
top dd ?
right dd ?
bottom dd ?
ends
 
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
 
; structures used in MeOS
struct process_information
cpu_usage dd ? ; +0
window_stack_position dw ? ; +4
window_stack_value dw ? ; +6
not_used1 dw ? ; +8
dw ? ; +8
process_name rb 12 ; +10
memory_start dd ? ; +22
used_memory dd ? ; +26
PID dd ? ; +30
x_start dd ? ; +34
y_start dd ? ; +38
x_size dd ? ; +42
y_size dd ? ; +46
box BOX ; +34
slot_state dw ? ; +50
dw ? ; +52
client_box BOX ; +54
rb (1024-52)
ends
 
/programs/develop/tinypad/trunk/tinypad.asm
1,9 → 1,10
;-----------------------------------------------------------------------------
; project name: TINYPAD
; compiler: flat assembler 1.64
; memory to compile: 3.0/11.5 MBytes (without/with size optimizations)
; version: 4.0
; last update: 2006-04-13 (Apr 13, 2006)
; compiler: flat assembler 1.67.1
; memory to compile: 2.0/7.0 MBytes (without/with size optimizations)
; version: 4.0.3
; last update: 2006-08-28 (Aug 28, 2006)
; minimal kernel: revision #138 (svn://kolibrios.org/kernel)
;-----------------------------------------------------------------------------
; originally by: Ville Michael Turjanmaa >> villemt@aton.co.jyu.fi
; maintained by: Ivan Poddubny >> ivan-yar@bk.ru
10,13 → 11,36
; Mike Semenyako >> mike.dld@gmail.com
;-----------------------------------------------------------------------------
; TODO:
; optimize drawing (reduce flickering);
; optimize memory usage (allocate only needed amount, not static 3 Mbytes);
; add block selection ability, undo action;
; working with multiple files (add tabs);
; other bugfixes and speed/size optimizations
; - optimize drawing (reduce flickering)
; - optimize memory usage (allocate only needed amount, not static 3 Mbytes)
; - add block selection ability, undo action, goto position
; - working with multiple files (add tabs)
; - improve window drawing with small dimensions
; - other bugfixes and speed/size optimizations
;
; HISTORY:
; 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 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 (fix 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 65535 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)
68,7 → 92,7
; 3.77 (mike.dld)
; changed save_string to collapse SPACEs into TABs;
; rewrote drawfile from scratch (speed++)
; through some drawing improvements still needed
; through some drawing improvements needed
; (some checkups to reduce flickering);
; writepos (size--);
; fixed drawing window while height < 100px, and for non-asm files;
110,9 → 134,11
; copy/paste area 0x2f0000 +
;-----------------------------------------------------------------------------
 
include 'lang.inc'
include 'macros.inc' ; useful stuff
;include 'proc32.inc'
include 'tinypad.inc'
purge mov,add,sub ;  SPEED
;purge mov,add,sub ;  SPEED
 
header '01',1,@CODE,TINYPAD_END,AREA_ENDMEM,MAIN_STACK,@PARAMS,self_path
 
126,6 → 152,7
LINEH = 10 ; line height (pixels)
PATHL = 255 ; maximum path length (chars) !!! don't change !!!
AMINS = 8 ; minimal scroll thumb size (pixels)
LCHGW = 2 ; changed/saved marker width
 
STATH = 14 ; status bar height
 
148,6 → 175,8
RGB(255,255,255) ; RGB(224,224,224) ; RGB(255,255,255) ; background
RGB(255,255,255) ; RGB(255,255,255) ; RGB(255,255,255) ; selection text
RGB( 10, 36,106) ; RGB( 0, 0,128) ; RGB( 0, 64,128) ; selection background
RGB( 0,255, 0) ; modified line marker
RGB(255,255, 0) ; saved line marker
 
ins_mode db 1
 
165,6 → 194,17
 
; fninit
 
; stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_left,50
; mov [mainwnd_pos.x],eax
; stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_top,50
; mov [mainwnd_pos.y],eax
; stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_right,350
; sub eax,[mainwnd_pos.x]
; mov [mainwnd_pos.w],eax
; stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_bottom,450
; sub eax,[mainwnd_pos.y]
; mov [mainwnd_pos.h],eax
 
cld
mov edi,@UDATA
mov ecx,@PARAMS-@UDATA
171,16 → 211,13
mov al,0
rep stosb
 
inc [do_not_draw]
 
mov [left_ofs],40+1
mov [f_info+4],0
mov [f_info+12],AREA_TEMP
mov [f_info+16],AREA_EDIT-AREA_TEMP
 
; mov esi,s_example
; mov edi,s_fname
; mov ecx,s_example.size
; mov [s_fname.size],ecx
; rep movsb
mov esi,s_example
mov edi,tb_opensave.text
mov ecx,s_example.size
200,18 → 237,21
 
cmp byte[@PARAMS],'*'
jne .noipc
; convert size from decimal representation to dword
 
;// diamond [ (convert size from decimal representation to dword)
;-- mov edx,dword[@PARAMS+1]
mov esi, @PARAMS+1
xor edx, edx
xor eax, eax
@@:
lodsb
@@: lodsb
test al, al
jz @f
lea edx, [edx*4+edx]
lea edx, [edx*2+eax]
lea edx,[edx*2+eax-'0']
jmp @b
@@:
;// diamond ]
 
add edx,20
mcall 60,1,AREA_TEMP-16 ; 0x10000-16
mov dword[AREA_TEMP-16+4],8 ; [0x10000-16+4],8
225,8 → 265,6
inc eax
call load_file.file_found
jmp @f
; call file_found ; çàãðóçêà ôàéëà
; jmp do_load_file.restorecursor ; îòîáðàæåíèå
.noipc:
 
;// Willow's code to support DOCPAK ]
250,9 → 288,12
call new_file
 
@@:
call drawwindow
dec [do_not_draw]
mcall 66,1,1
mcall 40,00100111b
red:
call drawwindow
call check_inv_all.skip_check
 
;-----------------------------------------------------------------------------
 
275,14 → 316,6
jmp still.skip_write
 
;-----------------------------------------------------------------------------
func red ;///// window redraw ////////////////////////////////////////////////
;-----------------------------------------------------------------------------
call drawwindow
call check_inv_all.skip_check
jmp still
endf
 
;-----------------------------------------------------------------------------
func start_fasm ;/////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; BL = run after compile
362,7 → 395,11
je @f
mov dword[edi-1],',run'
mov byte[edi+3],0
@@: mcall 19,fasm_filename,fasm_parameters
@@:
mov ebx, fasm_start
start_ret:
mov eax, 70
int 0x40
ret
endf
 
369,46 → 406,49
;-----------------------------------------------------------------------------
func open_debug_board ;///////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mcall 19,debug_filename,0
ret
mov ebx, board_start
jmp start_ret
endf
 
;-----------------------------------------------------------------------------
func open_sysfuncs_txt ;//////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mcall 19,docpak_filename,sysfuncs_param
mov ebx, docpak_start
call start_ret
cmp eax,0xfffffff0
jb @f
mcall 19,tinypad_filename,sysfuncs_filename
mov ebx, tinypad_start
mov dword [ebx+8], sysfuncs_filename
call start_ret
@@: ret
endf
 
;-----------------------------------------------------------------------------
func layout ;///// change keyboard layout ///////////////////////////////////
;func layout ;///// change keyboard layout ///////////////////////////////////
;-----------------------------------------------------------------------------
mcall 19,setup,param_setup
mcall 5,eax
; call activate_me
; ret
; mcall 19,setup,param_setup
; mcall 5,eax
;; call activate_me
;; ret
;;endf
 
;;func activate_me
; mcall 9,p_info,-1
; inc eax
; inc eax
; mov ecx,eax
; mov edi,[p_info.PID]
; mov ebx,p_info
; @@: dec ecx
; jz @f ; counter=0 => not found? => return
; mcall 9
; cmp edi,[p_info.PID]
; jne @b
; mcall 18,3
; mcall 5,eax
; @@: ret
;endf
 
;func activate_me
mcall 9,p_info,-1
inc eax
inc eax
mov ecx,eax
mov edi,[p_info.PID]
mov ebx,p_info
@@: dec ecx
jz @f ; counter=0 => not found? => return
mcall 9
cmp edi,[p_info.PID]
jne @b
mcall 18,3
mcall 5,eax
@@: ret
endf
 
func set_opt
test [options],al
je @f
453,16 → 493,16
 
include 'tp-draw.asm'
include 'tp-key.asm'
;include 'tp-key2.asm'
include 'tp-butto.asm'
include 'tp-mouse.asm'
include 'tp-files.asm'
include 'tp-commo.asm'
include 'tp-dialo.asm'
;include 'tp-find.asm'
include 'tp-popup.asm'
include 'tp-tbox.asm'
 
;include 'lib-ini.asm'
 
;-----------------------------------------------------------------------------
section @DATA ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;-----------------------------------------------------------------------------
593,15 → 633,42
 
;error_beep db 0xA0,0x30,0
 
s_status dd 0
 
sz s_example,'EXAMPLE.ASM'
sz s_still ,'still'
 
;sz param_setup,'LANG',0 ; parameter for SETUP
 
sz fasm_filename ,'FASM '
sz debug_filename ,'BOARD '
sz tinypad_filename,'TINYPAD '
sz docpak_filename ,'DOCPAK '
fasm_start:
dd 7
dd 0
dd fasm_parameters
dd 0
dd 0
db '/RD/1/FASM',0
board_start:
dd 7
dd 0
dd 0
dd 0
dd 0
db '/RD/1/BOARD',0
tinypad_start:
dd 7
dd 0
dd ?
dd 0
dd 0
db '/RD/1/TINYPAD',0
docpak_start:
dd 7
dd 0
dd sysfuncs_param
dd 0
dd 0
db '/RD/1/DOCPAK',0
 
;sz setup ,'SETUP ' ; to change keyboard layout
 
sz sysfuncs_param,'g',0
610,7 → 677,7
ru,<'SYSFUNCR.TXT',0>,\
en,<'SYSFUNCS.TXT',0>
 
sz htext,'TINYPAD'
sz htext,'TINYPAD 4.0.3'
 
lszc help_text,b,\
ru,'ŠŽŒ€„›:',\
665,7 → 732,7
ru,'®¢ë©' ,'Ctrl+N',key.ctrl_n ,\
ru,'Žâªàëâì...' ,'Ctrl+O',key.ctrl_o ,\
ru,'‘®åà ­¨âì' ,'Ctrl+S',key.ctrl_s ,\
ru,'‘®åà ­¨âì ª ª...','' ,key.shift_ctrl_s,\
ru,'‘®åà ­¨âì ª ª...','Ctrl+Shift+S',key.shift_ctrl_s,\
ru,'-' ,'' ,0 ,\
ru,'‚ë室' ,'Alt+X' ,key.alt_x ,\
\
672,7 → 739,7
en,'New' ,'Ctrl+N',key.ctrl_n ,\
en,'Open...' ,'Ctrl+O',key.ctrl_o ,\
en,'Save' ,'Ctrl+S',key.ctrl_s ,\
en,'Save as...','' ,key.shift_ctrl_s,\
en,'Save as...','Ctrl+Shift+S',key.shift_ctrl_s,\
en,'-' ,'' ,0 ,\
en,'Exit' ,'Alt+X' ,key.alt_x
 
683,6 → 750,8
ru,'“¤ «¨âì' ,'' ,key.del ,\
ru,'-' ,'' ,0 ,\
ru,'‚뤥«¨âì ¢áñ','Ctrl+A',key.ctrl_a,\
\; ru,'-' ,'' ,0 ,\
\; ru,'‚¥à⨪ «ì­®¥ ¢ë¤¥«¥­¨¥','Alt+Ins',0 ,\
\
en,'Cut' ,'Ctrl+X',key.ctrl_x,\
en,'Copy' ,'Ctrl+C',key.ctrl_c,\
689,7 → 758,9
en,'Paste' ,'Ctrl+V',key.ctrl_v,\
en,'Delete' ,'' ,key.del ,\
en,'-' ,'' ,0 ,\
en,'Select all','Ctrl+A',key.ctrl_a
en,'Select all','Ctrl+A',key.ctrl_a;,\
; en,'-' ,'' ,0 ,\
; en,'Vertical selection','Alt+Ins',0
 
popup_res popup_search,\
ru,'¥à¥©â¨...' ,'Ctrl+G',key.ctrl_g,\
763,9 → 834,61
ru,'Žâ¬¥­ ',\
en,'Cancel'
 
lsz s_enter_filename,\
ru,<'‚¢¥¤¨â¥ ¨¬ï ä ©« ',0>,\
en,<'Enter filename',0>
 
lsz s_enter_text_to_find,\
ru,<'‚¢¥¤¨â¥ ⥪áâ ¤«ï ¯®¨áª ',0>,\
en,<'Enter text to find',0>
 
lsz s_enter_text_to_replace,\
ru,<'‚¢¥¤¨â¥ ⥪áâ ¤«ï § ¬¥­ë',0>,\
en,<'Enter text to replace',0>
 
lsz s_text_not_found,\
ru,<'„®á⨣­ãâ ª®­¥æ ä ©« , ⥪áâ ­¥ ­ ©¤¥­',0>,\
en,<'Reached end of file, text not found',0>
 
lszc s_fs_error,b,\
ru,<'Ž¯¥à æ¨ï § ¢¥à襭  ãᯥ譮 (0)',0>,\
ru,<'',0>,\
ru,<'”ã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë (2)',0>,\
ru,<'¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬  (3)',0>,\
ru,<'',0>,\
ru,<'¥¢®§¬®¦­® ®âªàëâì ä ©« (5)',0>,\
ru,<'Ž¯¥à æ¨ï § ¢¥à襭  ãᯥ譮 (6)',0>,\
ru,<'€¤à¥á ­ å®¤¨âáï §  £à ­¨æ ¬¨ ¯ ¬ï⨠¯à®£à ¬¬ë (7)',0>,\
ru,<'  ¤¨áª¥ ­¥â ᢮¡®¤­®£® ¬¥áâ  (8)',0>,\
ru,<'’ ¡«¨æ  FAT ã­¨ç⮦¥­  (9)',0>,\
ru,<'„®áâ㯠§ ¯à¥éñ­ (10)',0>,\
ru,<'Žè¨¡ª  ãáâனá⢠ (11)',0>,\
\
en,<'Operation executed successfully (0)',0>,\
en,<'',0>,\
en,<'Function is not supported for the given filesystem (2)',0>,\
en,<'Unknown filesystem (3)',0>,\
en,<'',0>,\
en,<'Unable to open file (5)',0>,\
en,<'Operation executed successfully (6)',0>,\
en,<'Pointer lies outside of application memory (7)',0>,\
en,<'Disk is full (8)',0>,\
en,<'FAT table is destroyed (9)',0>,\
en,<'Access denied (10)',0>,\
en,<'Device error (11)',0>
 
sz symbols_ex,';?.%"',"'"
sz symbols ,'#&*\:/<>|{}()[]=+-, '
 
ini_sec_window db 'Window',0
ini_window_top db 'Top',0
ini_window_left db 'Left',0
ini_window_right db 'Right',0
ini_window_bottom db 'Bottom',0
 
finfo_ini dd ?,?,?,AREA_TEMP,AREA_EDIT-AREA_TEMP
db '/rd/1/tinypad.ini',0
 
TINYPAD_END: ; end of file
 
self_path rb PATHL
774,6 → 897,8
section @UDATA ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;-----------------------------------------------------------------------------
 
f_info70 rd 7
 
f_info.length dd ?
f_info dd ?,?,?,?,?;?,0,?,AREA_TEMP,AREA_EDIT-AREA_TEMP
 
798,7 → 923,7
vscrl_size dd ?
hscrl_top dd ?
hscrl_size dd ?
skinh dd ? ; skin height
;skinh dd ? ; skin height
__rc dd ?,?,?,?
;filelen dd ? ; file size (on save) ???
filesize dd ? ; file size (on load) ???
/programs/develop/tinypad/trunk/tinypad.inc
0,0 → 1,288
virtual at -20
POPUP:
.actions dd ?
.data dd ?
.acc_ofs dd ?
.size:
.height dw ?
.width dw ?
.pos:
.y dw ?
.x dw ?
end virtual
 
macro popup_res _name,[_lang,_title,_accel,_action]
{
common
local s1,s2,m1,m2,c1,c2
m1 = 0
m2 = 0
c1 = 0
c2 = 0
if used _name
dd _name#.actions
dd _name#.data
dd ?
dw ? ; height
dw ? ; width
dw ? ; y
dw ? ; x
_name:
forward
if (lang eq _lang)
db 1
end if
common
.data:
forward
if lang eq _lang
if _title eq '-'
db 1,'-'
c2 = c2+1
else
virtual at 0
db _title
s1 = $
end virtual
if m1 < s1
m1 = s1
end if
virtual at 0
db _accel
s2 = $
end virtual
if m2 < s2
m2 = s2
end if
db s1,_title,s2,_accel
c1 = c1+1
end if
end if
common
db 0
align 4
.actions:
forward
if lang eq _lang
dd _action
end if
common
.size = $-_name+20
.max_title = m1
.max_accel = m2
.cnt_item = c1
.cnt_sep = c2
if (m2 = 0)
m2 = -2
end if
store word (m1*6+m2*6+6*8) at _name+POPUP.width
store word (c1*POP_IHEIGHT+c2*4+4) at _name+POPUP.height
store dword (((m1+2)*6-1)*65536) at _name+POPUP.acc_ofs
end if
}
 
macro menubar_res _name,[_lang,_title,_popup,_onshow]
{
common
local s,m,c,x
m = 0
c = 0
x = 2
if used _name
_name:
forward
if lang eq _lang
virtual at 0
db _title
s = $
end virtual
if m < s
m = s
end if
dw (s+2)*6,x,ATOPH-1,0
db s,_title
c = c+1
x = x + (s+2)*6
end if
common
db 0
align 4
.popups:
forward
if lang eq _lang
dd _popup
end if
common
align 4
.onshow:
forward
if lang eq _lang
dd _onshow
end if
common
.size = $-_name
.max_title = m
.cnt_item = c
.width = x-7
end if
}
 
;// OPTIONS
 
OPTS_SECURESEL = 00000001b
OPTS_AUTOBRACES = 00000010b
OPTS_AUTOINDENT = 00000100b
OPTS_SMARTTAB = 00001000b
OPTS_OPTIMSAVE = 00010000b
OPTS_LINENUMS = 00100000b
 
;// KEY MODIFIERS
 
KM_SHIFT = 0x00010000
KM_CTRL = 0x00020000
KM_ALT = 0x00040000
 
KM_CTRLSHIFT = 0x00030000
KM_ALTSHIFT = 0x00050000
KM_CTRLALT = 0x00060000
 
KM_CTRLALTSHIFT = 0x00070000
 
;// KEY CODES
 
KEY_ESCAPE = 0x00000001
KEY_SNAPSHOT = 0x00000137
KEY_PAUSE = 0x0000021D
 
KEY_F1 = 0x0000003B
KEY_F2 = 0x0000003C
KEY_F3 = 0x0000003D
KEY_F4 = 0x0000003E
KEY_F5 = 0x0000003F
KEY_F6 = 0x00000040
KEY_F7 = 0x00000041
KEY_F8 = 0x00000042
KEY_F9 = 0x00000043
KEY_F10 = 0x00000044
KEY_F11 = 0x00000057
KEY_F12 = 0x00000058
 
KEY_TILDE = 0x00000029
KEY_MINUS = 0x0000000C
KEY_EQUAL = 0x0000000D
KEY_BACKSPACE = 0x0000000E
KEY_TAB = 0x0000000F
KEY_SQBRACE1 = 0x0000001A
KEY_SQBRACE2 = 0x0000001B
KEY_SLASH1 = 0x00000035
KEY_SLASH2 = 0x0000002B
KEY_SEMICOLON = 0x00000027
KEY_QUOTE = 0x00000028
KEY_COMMA = 0x00000033
KEY_DOT = 0x00000034
KEY_SPACE = 0x00000039
 
KEY_1 = 0x00000002
KEY_2 = 0x00000003
KEY_3 = 0x00000004
KEY_4 = 0x00000005
KEY_5 = 0x00000006
KEY_6 = 0x00000007
KEY_7 = 0x00000008
KEY_8 = 0x00000009
KEY_9 = 0x0000000A
KEY_0 = 0x0000000B
 
KEY_A = 0x0000001E
KEY_B = 0x00000030
KEY_C = 0x0000002E
KEY_D = 0x00000020
KEY_E = 0x00000012
KEY_F = 0x00000021
KEY_G = 0x00000022
KEY_H = 0x00000023
KEY_I = 0x00000017
KEY_J = 0x00000024
KEY_K = 0x00000025
KEY_L = 0x00000026
KEY_M = 0x00000032
KEY_N = 0x00000031
KEY_O = 0x00000018
KEY_P = 0x00000019
KEY_Q = 0x00000010
KEY_R = 0x00000013
KEY_S = 0x0000001F
KEY_T = 0x00000014
KEY_U = 0x00000016
KEY_V = 0x0000002F
KEY_W = 0x00000011
KEY_X = 0x0000002D
KEY_Y = 0x00000015
KEY_Z = 0x0000002C
 
KEY_CAPSLK = 0x0000003A
KEY_SCRLK = 0x00000046
KEY_NUMLK = 0x00000069
 
KEY_RETURN = 0x0000001C
KEY_NUMRETURN = 0x0000011C
 
KEY_LCONTROL = 0x0000001D
KEY_RCONTROL = 0x0000011D
KEY_LSHIFT = 0x0000002A
KEY_RSHIFT = 0x00000036
KEY_LALT = 0x00000038
KEY_RALT = 0x00000138
 
KEY_LWIN = 0x0000015B
KEY_RWIN = 0x0000015C
KEY_APPS = 0x0000015D
 
KEY_INSERT = 0x00000152
KEY_DELETE = 0x00000153
KEY_HOME = 0x00000147
KEY_END = 0x0000014F
KEY_PAGEUP = 0x00000149
KEY_PAGEDOWN = 0x00000151
KEY_UP = 0x00000148
KEY_LEFT = 0x0000014B
KEY_RIGHT = 0x0000014D
KEY_DOWN = 0x00000150
 
KEY_DIVIDE = 0x00000135
KEY_MULTIPLY = 0x00000037
KEY_SUBTRACT = 0x0000004A
KEY_ADD = 0x0000004E
KEY_SEPARATOR = 0x00000053
 
KEY_NUM1 = 0x0000004F
KEY_NUM2 = 0x00000050
KEY_NUM3 = 0x00000051
KEY_NUM4 = 0x0000004B
KEY_NUM5 = 0x0000004C
KEY_NUM6 = 0x0000004D
KEY_NUM7 = 0x00000047
KEY_NUM8 = 0x00000048
KEY_NUM9 = 0x00000049
KEY_NUM0 = 0x00000052
 
;// EXTENDED KEY CODES (MULTIMEDIA KEYBOARDS)
 
KEY_MYDOCUMENTS = 0x0000014C
KEY_MYPICTURES = 0x00000164
KEY_MYMUSIC = 0x0000013C
KEY_MUTE = 0x00000120
KEY_PLAYPAUSE = 0x00000122
KEY_STOP = 0x00000124
KEY_VOLUMEUP = 0x00000130
KEY_VOLUMEDOWN = 0x0000013E
KEY_PREVSONG = 0x00000110
KEY_NEXTSONG = 0x00000119
KEY_MEDIA = 0x0000016D
KEY_MAIL = 0x0000016C
KEY_WEBHOME = 0x00000132
KEY_MESSENGER = 0x00000105
 
KEY_CALCULATOR = 0x00000121
KEY_LOGOFF = 0x00000116
KEY_SLEEP = 0x0000015F
/programs/develop/tinypad/trunk/tp-butto.asm
0,0 → 1,346
button:
mcall 17
cmp al,0
jne still
shr eax,8
 
cmp [bot_mode],0
je @f
mov ebx,eax
mov al,3
call [bot_dlg_handler]
jmp still
 
@@: mov esi,accel_table2
.acc: cmp eax,[esi]
jne @f
call dword[esi+4]
jmp still.skip_write
@@: add esi,8
cmp byte[esi],0
jne .acc
 
jmp still.skip_write
 
; cmp eax,BUTTON_SCRLUP
; jne not_up
btn.scroll_up:
dec [top_line]
jns @f
inc [top_line]
ret;jmp still.skip_write
@@: call check_inv_all.skip_check
ret
; not_up:
 
; cmp eax,BUTTON_SCRLDN
; jne not_down
btn.scroll_down:
inc [top_line]
mov eax,[lines]
sub eax,[lines.scr]
cmp eax,[top_line]
jge @f
dec [top_line]
;dec eax
;mov [top_line],eax
ret;jmp still.skip_write
@@: call check_inv_all.skip_check
ret
; not_down:
 
; cmp eax,BUTTON_SCRLLT
; jne not_left
btn.scroll_left:
dec [left_col]
jns @f
inc [left_col]
ret;jmp still.skip_write
@@: call check_inv_all.skip_check
ret
; not_left:
 
; cmp eax,BUTTON_SCRLRT
; jne not_right
btn.scroll_right:
inc [left_col]
mov eax,[columns]
sub eax,[columns.scr]
cmp eax,[left_col]
jge @f
dec [left_col]
;dec eax
;mov [left_col],eax
ret;jmp still.skip_write
@@: call check_inv_all.skip_check
ret
; not_right:
 
; SEARCH {
; search:
; cmp al,BUTTON_SEARCH
; jne no_search
btn.search:
key.f3:
call search
jc @f
call check_inv_all
@@: ret
 
 
func search
cld
mov ecx,[pos.y]
mov edx,ecx
call get_line_offset
cmp word[esi],0
je .exit
call get_real_length
add esi,4
or eax,eax
jz .end_line.2
mov ecx,eax
sub ecx,[pos.x]
push esi
add esi,[pos.x]
;dec ecx
;inc esi
jmp @f
 
.next_line:
push esi
@@: sub ecx,[s_search.size]
inc ecx
 
.next_char:
dec ecx
js .end_line
xor edi,edi
 
.next_ok:
movzx eax,byte[edi+esi]
movzx ebx,byte[edi+s_search]
 
cmp al,$61
jb @f
add al,[eax+add_table-$61]
@@: cmp bl,$61
jb @f
add bl,[ebx+add_table-$61]
@@:
cmp al,bl
je @f
 
inc esi
jmp .next_char
@@:
inc edi
cmp edi,[s_search.size]
jne .next_ok
 
.found:
add esp,4
mov [pos.y],edx
mov [sel.y],edx
mov ecx,edx
lea eax,[esi-4]
call get_line_offset
sub eax,esi
mov [sel.x],eax
add eax,[s_search.size]
mov [pos.x],eax
mov [s_status],0
clc
ret
 
.end_line:
pop esi
.end_line.2:
movzx eax,word[esi-4]
add esi,eax;[esi-4]
inc edx
call get_real_length
mov ecx,eax
lodsd
or eax,eax
jnz .next_line
.exit:
mov [s_status],s_text_not_found
stc
ret
endf
 
; SEARCH }
 
; no_search:
 
; TOOLBAR {
; cmp eax,10000
; jb no_toolbar
 
; add eax,-10000
; jnz @f
btn.compile:
key.ctrl_f9:
mov bl,0;[run_outfile],0
call start_fasm
ret;jmp still
; @@: dec eax
; jnz @f
btn.compile_run:
key.f9:
mov bl,1;[run_outfile],1
call start_fasm
ret;jmp still
; @@: dec eax
; jnz @f
btn.debug_board:
call open_debug_board
ret;jmp still
; @@: dec eax
; jnz still
btn.sysfuncs_txt:
call open_sysfuncs_txt
ret;jmp still
; TOOLBAR }
 
; no_toolbar:
 
; cmp al,4
; jne noid4
 
; LOAD_FILE {
; do_load_file:
btn.load_file:
key.ctrl_l:
; cmp [s_fname],'/'
; jne @f
; call load_hd_file
; jmp .restorecursor
; @@: call load_file
call load_file
jnc @f
ret
; .restorecursor:
@@:
xor eax,eax
mov [top_line],eax
mov [left_col],eax
mov [pos.x],eax
mov [pos.y],eax
mov [sel.x],eax
mov [sel.y],eax
 
mov [modified],al
 
; enable color syntax for ASM and INC files:
mov [asm_mode],al
 
mov eax,[f_info.length] ; [s_fname.size]
add eax,f_info.path ; s_fname
mov byte[eax],0
mov ecx, dword [eax-3]
or ecx, 0x202020
cmp ecx, 'asm'
jne @f
inc [asm_mode]
jmp .nocol
@@: cmp ecx, 'inc'
jne .nocol
inc [asm_mode]
.nocol:
 
update_caption:
macro unused {
movzx ecx,[f_info.length] ; [s_fname.size]
add ecx,10 ; strlen(" - TINYPAD");
cmp ecx,[s_title.size]
jne @f
add ecx,-10
mov esi,f_info.path ; s_fname ; strcmp(s_fname,header);
mov edi,s_title
repe cmpsb
jne @f
; call draw_file
clc
ret;jmp still
@@:
}
; set window title:
mov esi,f_info.path ; s_fname
mov edi,s_title
 
cld
mov ecx,[f_info.length] ; [s_fname.size]
jecxz @f
;lea eax,[ecx+10]
;mov [s_title.size],eax
;cld
rep movsb
 
mov dword[edi],' - '
add edi,3
@@: mov esi,htext
mov ecx,htext.size
rep movsb
 
mov al,0
stosb
 
; call drawwindow
clc
ret;jmp still
; LOAD_FILE }
 
; noid4:
 
; cmp al, 2
; jz yessave
 
; dec al ; close if butid == 1
; jnz nosave
; EXIT:
btn.close_main_window:
key.alt_x:
mov esi,self_path
mov byte[esi+PATHL-1],0
mov edi,f_info.path
cld
@@: lodsb
stosb
or al,al
jnz @b
mov ebx,f_info
mov dword[ebx+0],1
mov dword[ebx+8],self_path
mov dword[ebx+12],0
mcall 58
 
; test eax,eax
; je .close
; cmp eax,6
; je .close
; ret
 
.close:
mov [main_closed],1
mcall -1
 
; SAVE_FILE {
; yessave:
; btn.save_file:
; key.ctrl_s:
; mov [bot_mode],1
; mov [bot_save_mode],1
; mov [bot_dlg_height],16*2+4*2-1
; mov [bot_dlg_handler],osdlg_handler
; call drawwindow
; call save_file
; ret;jmp still
; SAVE_FILE }
 
; nosave:
; btn.save_enter_name:
; inc al
; call read_string
; ret;jmp still
/programs/develop/tinypad/trunk/tp-commo.asm
0,0 → 1,590
;-----------------------------------------------------------------------------
func check_cur_vis_inv ;//////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push eax ebx
xor bl,bl
.chk_y:
mov eax,[pos.y]
or eax,eax
jge @f
mov [pos.y],0
jmp .chk_dy
@@: cmp eax,[lines]
jl .chk_dy
mov eax,[lines]
dec eax
mov [pos.y],eax
.chk_dy:
mov eax,[top_line]
cmp eax,[pos.y]
jle @f
push [pos.y]
pop [top_line]
inc bl
@@: add eax,[lines.scr]
cmp eax,[pos.y]
jg .chk_x
mov eax,[pos.y]
sub eax,[lines.scr]
inc eax
mov [top_line],eax
inc bl
.chk_x:
mov eax,[pos.x]
or eax,eax
jge @f
mov [pos.x],0
jmp .chk_dx
@@: cmp eax,[columns]
jl .chk_dx
mov eax,[columns]
mov [pos.x],eax
.chk_dx:
mov eax,[left_col]
cmp eax,[pos.x]
jle @f
push [pos.x]
pop [left_col]
inc bl
@@: add eax,[columns.scr]
cmp eax,[pos.x]
jg @f
mov eax,[pos.x]
sub eax,[columns.scr]
inc eax
mov [left_col],eax
inc bl
@@: cmp [mev],MEV_LDOWN
jne .exit
push [pos.x] [pos.y]
pop [sel.y] [sel.x]
.exit:
or bl,bl
clc
jz @f
call draw_file
stc
@@: pop ebx eax
ret
endf
 
;-----------------------------------------------------------------------------
func clear_selection ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push eax ebx
mov eax,[sel.y]
mov ebx,[pos.y]
cmp eax,ebx
jle @f
xchg eax,ebx
@@: push [pos.x] [pos.y]
pop [sel.y] [sel.x]
call draw_file.ex
pop ebx eax
ret
endf
 
;-----------------------------------------------------------------------------
func pt_in_rect ;/////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp eax,[ecx+0x0]
jl @f
cmp ebx,[ecx+0x4]
jl @f
cmp eax,[ecx+0x8]
jg @f
cmp ebx,[ecx+0xC]
jg @f
stc
ret
@@: clc
ret
endf
 
;-----------------------------------------------------------------------------
func check_bottom_right ;/////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push eax
mov eax,[top_line]
add eax,[lines.scr]
cmp eax,[lines]
jbe .lp1
mov eax,[lines]
sub eax,[lines.scr]
jns @f
xor eax,eax
@@: mov [top_line],eax
.lp1: mov eax,[left_col]
add eax,[columns.scr]
cmp eax,[columns]
jbe .exit
mov eax,[columns]
sub eax,[columns.scr]
jns @f
xor eax,eax
@@: mov [left_col],eax
.exit:
pop eax
ret
endf
 
;-----------------------------------------------------------------------------
func check_inv_str ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
@^
mov eax,[pos.y]
mov ecx,[top_line]
.skip_init:
call check_cur_vis
mov [pos.y],eax
mov [top_line],ecx
.skip_check:
; call invalidate_string
call drawfile
ret
^@
endf
 
;-----------------------------------------------------------------------------
func check_inv_all ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[pos.y]
mov ecx,[top_line]
.skip_init:
call check_cur_vis
mov [pos.y],eax
mov [top_line],ecx
.skip_check:
; call clear_screen
call draw_file
ret
endf
 
;-----------------------------------------------------------------------------
func check_cur_vis ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp eax,ecx
jb .low
mov edx,ecx
add edx,[lines.scr]
cmp edx,[lines]
jbe @f
mov edx,[lines]
@@: cmp eax,edx
jb @f
lea ecx,[eax+1]
sub ecx,[lines.scr]
jns @f
xor ecx,ecx
jmp @f
.low: mov ecx,eax
@@: mov edx,ecx
add edx,[lines.scr]
cmp edx,[lines]
jbe @f
mov ecx,[lines]
sub ecx,[lines.scr]
jns @f
xor ecx,ecx
@@:;mov [top_line],ecx
 
pushad
mov eax,[pos.x]
mov ebx,[left_col]
mov ecx,ebx
add ecx,[columns.scr]
cmp eax,ebx
jb .lp1
cmp eax,ecx
jb .exit
lea ebx,[eax]
sub ebx,[columns.scr]
jmp @f
.lp1: mov ebx,eax
@@: mov [left_col],ebx
 
.exit:
mov [pos.x],eax
popad
 
ret
endf
 
;-----------------------------------------------------------------------------
func get_real_length ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
movzx eax,word[esi]
@@: cmp byte[esi+eax+4-1],' '
jne @f
dec eax
jnz @b
@@: ret
endf
 
;-----------------------------------------------------------------------------
func get_line_offset ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ECX = line number
; Output:
; ESI = line data offset
;-----------------------------------------------------------------------------
push eax ecx
mov esi,AREA_EDIT
jecxz .exit
@@: movzx eax,word[esi]
dec ecx
lea esi,[esi+eax+4]
jnz @b
.exit:
pop ecx eax
ret
endf
 
;-----------------------------------------------------------------------------
func init_sel_vars ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [sel.selected],1
mov eax,[sel.x]
mov ebx,[sel.y]
mov ecx,[pos.x]
mov edx,[pos.y]
cmp ebx,edx
jl .lp2
jne @f
cmp eax,ecx
jl .lp2
jne .lp1
dec [sel.selected]
jmp .lp2
@@: xchg ebx,edx
.lp1: xchg eax,ecx
.lp2: mov [sel.begin.x],eax
mov [sel.begin.y],ebx
mov [sel.end.x],ecx
mov [sel.end.y],edx
popad
ret
endf
 
;-----------------------------------------------------------------------------
func get_scroll_vars ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; EAX = maximum data size (units)
; EBX = visible data size (units)
; ECX = current data position (units)
; EDX = scrolling area size (pixels)
; Output:
; EAX = srcoller offset (pixels)
; EBX = scroller size (pixels)
;-----------------------------------------------------------------------------
push eax ebx edx
; sub eax,ebx
mov esi,eax
mov eax,edx
imul ebx
idiv esi
cmp eax,[esp]
jge .null
cmp eax,AMINS
jge @f
neg eax
add eax,AMINS
sub [esp],eax
mov eax,AMINS
@@: mov [esp+4],eax ; scroller size
mov eax,[esp]
imul ecx
idiv esi
or eax,eax
jns @f
xor eax,eax
@@: mov [esp+8],eax ; scroller offset
add eax,[esp+4]
cmp eax,[esp]
jle @f
; mov eax,[esp]
; sub eax,[esp+4]
; js @f
; mov [esp+8],eax
@@:
pop edx ebx eax
ret
.null:
mov dword[esp+4],0
mov dword[esp+8],0
jmp @b
endf
 
;-----------------------------------------------------------------------------
func uint2strz ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
dec ebx
jz @f
xor edx,edx
div ecx
push edx
call uint2strz
pop eax
@@: cmp al,10
sbb al,$69
das
stosb
ret
endf
 
;-----------------------------------------------------------------------------
func uint2str ;///////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp eax,ecx
jb @f
xor edx,edx
div ecx
push edx
call uint2str
pop eax
@@: cmp al,10
sbb al,$69
das
stosb
ret
endf
 
;-----------------------------------------------------------------------------
func rgb_to_gray ;////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push 0 eax
and dword[esp],0x000000FF
fild dword[esp]
fmul [float_gray_b]
shr eax,8
mov [esp],eax
and dword[esp],0x000000FF
fild dword[esp]
fmul [float_gray_g]
faddp
shr eax,8
and eax,0x000000FF
mov [esp],eax
fild dword[esp]
fmul [float_gray_r]
faddp
frndint
fist dword[esp]
fist dword[esp+1]
fistp dword[esp+2]
pop eax
add esp,4
ret
endf
 
;float_gray_r dd 0.30f
;float_gray_g dd 0.59f
;float_gray_b dd 0.11f
 
;-----------------------------------------------------------------------------
func get_active_menu_item ;///////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [mi_cur],0
mcall 37,1
movsx ebx,ax
sar eax,16
mov ecx,__rc
pushd 2 0 (main_menu.width+7) (ATOPH-2)
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
; add [__rc+0xC],ATOPH-2
call pt_in_rect
jnc .outside_menu
m2m dword[ecx+0x8],dword[ecx+0x0]
mov edx,main_menu
@@: inc [mi_cur]
movzx esi,word[edx+0]
add [ecx+0x8],esi
call pt_in_rect
jc .exit
m2m dword[ecx+0x0],dword[ecx+0x8]
add edx,8+1
movzx esi,byte[edx-1]
add edx,esi
cmp byte[edx+8],0
jne @b
mov [mi_cur],0
.exit:
popad
ret
.outside_menu:
or [mi_cur],-1
@@: popad
ret
endf
 
;-----------------------------------------------------------------------------
func get_active_popup_item ;//////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [pi_cur],0
mcall 37,1
movsx ebx,ax
sar eax,16
mov ecx,__rc
mov dword[ecx+0x0],0
mov dword[ecx+0x4],0
movzx edx,[ebp+POPUP.width]
mov dword[ecx+0x8],edx;POP_WIDTH
movzx edx,[ebp+POPUP.height]
mov dword[ecx+0xC],edx;POP_HEIGHT
call pt_in_rect
jnc .outside_window
inc dword[ecx+0x0]
mov dword[ecx+0x4],3
dec dword[ecx+0x8]
mov dword[ecx+0xC],3+POP_IHEIGHT-1
mov edx,[ebp+POPUP.data];popup_text.data
@@: inc [pi_cur]
inc edx
movzx esi,byte[edx-1]
cmp byte[edx],'-'
jne .lp1
pushd [ecx+0xC]
sub dword[ecx+0xC],POP_IHEIGHT-4
call pt_in_rect
popd [ecx+0xC]
jc .separator
add dword[ecx+0x4],4
add dword[ecx+0xC],4
jmp .lp3
.lp1: call pt_in_rect
jnc .lp2
mov eax,[pi_cur]
test byte[ebp+eax-1],1;byte[popup_text+eax-1],1
jnz .exit
jmp .separator
.lp2: add dword[ecx+0x4],POP_IHEIGHT
add dword[ecx+0xC],POP_IHEIGHT
add edx,esi
inc edx
movzx esi,byte[edx-1]
.lp3: add edx,esi
cmp byte[edx],0
jne @b
.separator:
mov [pi_cur],0
.exit:
popad
ret
.outside_window:
or [pi_cur],-1
jmp .exit
endf
 
;-----------------------------------------------------------------------------
func line_add_spaces ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; esi = line offset
; ecx = needed line length
;-----------------------------------------------------------------------------
pushad
movzx edx,word[esi]
cmp ecx,edx
jbe .exit
sub ecx,edx
push ecx
mov edi,AREA_TEMP2
mov eax,esi
mov esi,edi
sub esi,ecx
lea ecx,[eax+4]
add ecx,edx;[eax]
push ecx
neg ecx
lea ecx,[esi+ecx+1]
std
rep movsb
pop edi ecx
add [eax],cx
mov al,' '
cld
rep stosb
.exit:
popad
ret
endf
 
;-----------------------------------------------------------------------------
func delete_selection ;///////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [sel.selected],0
je .exit.2
 
pushad
mov ecx,[sel.begin.y]
cmp ecx,[sel.end.y]
je .single_line
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
mov ecx,[sel.begin.x]
call line_add_spaces
lea edi,[esi+4]
mov ecx,[sel.end.y]
call get_line_offset
call get_real_length
cmp eax,[sel.end.x]
jbe @f
mov eax,[sel.end.x]
@@: movzx ecx,word[esi]
sub ecx,eax
mov ebx,[sel.begin.x]
add ebx,ecx
mov [edi-4],bx
add edi,[sel.begin.x]
lea esi,[esi+eax+4]
mov ecx,AREA_TEMP2
sub ecx,esi
cld
rep movsb
mov eax,[sel.end.y]
sub eax,[sel.begin.y]
sub [lines],eax
jmp .exit
 
.single_line:
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
call get_real_length
cmp eax,[sel.begin.x]
jbe .exit
mov ecx,[sel.end.x]
cmp ecx,eax
jbe @f
mov ecx,eax
@@: sub ecx,[sel.begin.x]
sub [esi],cx
lea edi,[esi+4]
add edi,[sel.begin.x]
lea esi,[edi+ecx]
mov ecx,AREA_TEMP2
sub ecx,esi
cld
rep movsb
 
.exit:
mov eax,[sel.begin.x]
mov [pos.x],eax
mov [sel.x],eax
mov eax,[sel.begin.y]
mov [pos.y],eax
mov [sel.y],eax
popad
mov [modified],1
clc
ret
 
.exit.2:
stc
ret
endf
/programs/develop/tinypad/trunk/tp-dialo.asm
0,0 → 1,330
;-----------------------------------------------------------------------------
func define_3d_button ;///////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; ebx = <x,width>
; ecx = <y,height>
; esp+4*3 = id
; esp+4*2 = text
; esp+4*1 = text length
;-----------------------------------------------------------------------------
pushad
mov edx,[esp+4*8+4+4*2]
or edx,0x40000000
mcall 8
mov eax,[esp+4*8+4*1]
add eax,2
imul eax,6
pushad
shr ebx,16
shr ecx,16
push ebx ecx eax 15
call draw_3d_panel
popad
shr ecx,16
mov bx,cx
add ebx,7*65536+4
mcall 4,,[sc.work_text],[esp+4*8+4*2],[esp+4*8+4*1]
popad
ret 4*3
endf
 
finddlg_handler:
cmp al,1
je .draw
cmp al,2
je .key
cmp al,3
je botdlg.button
ret
 
.draw:
mov ebx,[bot_ofs]
add ebx,(1+3)*65536+6
mcall 4,,[sc.work_text],s_2find,s_2find.size+1
mov ecx,[bot_ofs]
shl ecx,16
add ecx,(3+17)*65536+15
 
push ecx
cmp [bot_dlg_mode2],0
je @f
add ebx,18
mcall 4,,[sc.work_text],s_2replace,s_2replace.size+1
mov ecx,[esp]
add ecx,18*65536
@@:
 
mov ebx,[p_info.client_box.width]
shl ebx,16
 
push 20003
cmp [bot_dlg_mode2],0
jne .draw.lp1
add ebx,-(2+6*(s_2find.size+2))*65536+6*(s_2find.size+2)
push s_2find s_2find.size
jmp @f
 
.draw.lp1:
add ebx,-(2+6*(s_2replace.size+2))*65536+6*(s_2replace.size+2)
push s_2replace s_2replace.size
 
@@: call define_3d_button
sub ebx,(6*(s_2cancel.size+2)+3)*65536
mov bx,6*(s_2cancel.size+2)
push 20001 s_2cancel s_2cancel.size
call define_3d_button
 
mov ecx,[esp]
 
mov ebp,tb_find
mov eax,[p_info.client_box.width]
sub eax,6*(s_2find.size+2)+1
add eax,6*(s_2find.size+2)*65536
mov dword[tbox.x],eax
add ecx,-18*65536+1
mov dword[tbox.y],ecx
call textbox.draw
 
pop ecx
 
cmp [bot_dlg_mode2],0
je @f
mov ebp,tb_replace
mov eax,[p_info.client_box.width]
sub eax,6*(s_2replace.size+2)+1
add eax,6*(s_2replace.size+2)*65536
mov dword[tbox.x],eax
inc ecx
mov dword[tbox.y],ecx
call textbox.draw
@@:
 
ret
 
.key:
cmp ebx,KEY_ESCAPE
je btn.bot.cancel
cmp ebx,KEY_RETURN
je btn.bot.find
cmp ebx,KEY_NUMRETURN
je btn.bot.find
cmp ebx,KEY_TAB
je ..tab
call textbox.key
ret
 
..tab:
cmp [bot_dlg_mode2],0
je @f
mov eax,tb_replace
cmp eax,[focused_tb]
jne .key.lp1
mov eax,tb_find
.key.lp1:
mov [focused_tb],eax
call .draw
@@: ret
 
osdlg_handler:
cmp al,1
je .draw
cmp al,2
je .key
cmp al,3
je botdlg.button
ret
 
.draw:
mov ebx,[bot_ofs]
add ebx,(1+3)*65536+6
mcall 4,,[sc.work_text],s_2filename,s_2filename.size
mov ebx,[p_info.client_box.width]
shl ebx,16
mov ecx,[bot_ofs]
shl ecx,16
add ecx,(2+18)*65536+15
 
push 20002
cmp [bot_dlg_mode2],0
jne .draw.lp1
add ebx,-(2+6*(s_2open.size+2))*65536+6*(s_2open.size+2)
push s_2open s_2open.size
jmp @f
.draw.lp1:
add ebx,-(2+6*(s_2save.size+2))*65536+6*(s_2save.size+2)
push s_2save s_2save.size
 
@@: call define_3d_button
sub ebx,(6*(s_2cancel.size+2)+3)*65536
mov bx,6*(s_2cancel.size+2)
push 20001 s_2cancel s_2cancel.size
call define_3d_button
 
mov ebp,tb_opensave
mov eax,[p_info.client_box.width]
sub eax,6*(s_2filename.size+1)+1
add eax,6*(s_2filename.size+1)*65536
mov dword[tbox.x],eax
add ecx,-18*65536+1
mov dword[tbox.y],ecx
call textbox.draw
 
ret
 
.key:
cmp ebx,KEY_ESCAPE
je btn.bot.cancel
cmp ebx,KEY_RETURN
je btn.bot.opensave
cmp ebx,KEY_NUMRETURN
je btn.bot.opensave
call textbox.key
ret
 
gotodlg_handler:
cmp al,1
je .draw
cmp al,2
je .key
cmp al,3
je botdlg.button
ret
 
.draw:
mov ebx,[bot_ofs]
add ebx,(1+3)*65536+6
mcall 4,,[sc.work_text],s_2filename,s_2filename.size
mov ebx,[p_info.box.width]
shl ebx,16
mov ecx,[bot_ofs]
shl ecx,16
add ecx,(2+18)*65536+15
 
push 20002
cmp [bot_dlg_mode2],0
jne .draw.lp1
add ebx,-(2+6*(s_2open.size+2))*65536+6*(s_2open.size+2)
push s_2open s_2open.size
jmp @f
.draw.lp1:
add ebx,-(2+6*(s_2save.size+2))*65536+6*(s_2save.size+2)
push s_2save s_2save.size
 
@@: call define_3d_button
sub ebx,(6*(s_2cancel.size+2)+3)*65536
mov bx,6*(s_2cancel.size+2)
push 20001 s_2cancel s_2cancel.size
call define_3d_button
 
mov ebp,tb_opensave
mov eax,[p_info.box.width]
sub eax,6*(s_2filename.size+3)
add eax,6*(s_2filename.size+2)*65536
mov dword[tbox.x],eax
add ecx,-18*65536+1
mov dword[tbox.y],ecx
call textbox.draw
 
ret
 
.key:
cmp ebx,KEY_ESCAPE
je btn.bot.cancel
cmp ebx,KEY_RETURN
je btn.bot.opensave
cmp ebx,KEY_NUMRETURN
je btn.bot.opensave
call textbox.key
ret
 
botdlg.button:
mov esi,accel_table2_botdlg
.acc: cmp ebx,[esi]
jne @f
call dword[esi+4]
ret
@@: add esi,8
cmp byte[esi],0
jne .acc
ret
 
btn.bot.cancel:
xor eax,eax
mov [bot_mode],al
mov [bot_dlg_height],eax
call drawwindow
ret
 
btn.bot.opensave:
cmp [bot_dlg_mode2],0
je .lp1
call save_file
jnc @f
jmp .lp2
.lp1: call btn.load_file
jnc @f
.lp2:
ret
@@: call update_caption
xor eax,eax
mov [bot_mode],al
mov [bot_dlg_height],eax
call drawwindow
ret
 
btn.bot.find:
movzx ecx,[tb_find.length]
mov [s_search.size],ecx
mov esi,tb_find.text
mov edi,s_search
cld
rep movsb
 
cmp [bot_dlg_mode2],0
je @f
call search
jnc .found
call check_inv_all
ret
 
.found:
;---------------------------------------
push [copy_size] [copy_count]
 
mov esi,AREA_CBUF
mov edi,AREA_CBUF-304
mov ecx,300/4
rep movsd
 
movzx eax,[tb_replace.length]
mov esi,tb_replace.text
mov edi,AREA_CBUF
stosd
mov ecx,eax
jecxz .lp1
rep movsb
.lp1: add eax,4
mov [copy_size],eax
mov [copy_count],1
 
push [sel.x]
call init_sel_vars
call key.ctrl_v
pop [sel.x]
 
mov esi,AREA_CBUF-304
mov edi,AREA_CBUF
mov ecx,300/4
rep movsd
 
pop [copy_count] [copy_size]
;---------------------------------------
 
call check_inv_all
ret
@@: xor eax,eax
mov [bot_mode],al
mov [bot_dlg_height],eax
call btn.search
call drawwindow
ret
/programs/develop/tinypad/trunk/tp-draw.asm
0,0 → 1,1251
;-----------------------------------------------------------------------------
func drawwindow ;///// DRAW WINDOW ///////////////////////////////////////////
;-----------------------------------------------------------------------------
 
cmp [just_from_popup],1
jne @f
ret
@@:
 
mcall 48,3,sc,sizeof.system_colors
call calc_3d_colors
 
test [options],OPTS_LINENUMS
jnz @f
mov eax,2+LCHGW
jmp .lp1
@@: mov edi,p_info+100
mov eax,[lines]
mov ecx,10
call uint2str
lea eax,[edi-p_info-100]
cmp eax,3
jae @f
mov eax,3
@@: imul eax,6
add eax,2+4+LCHGW
.lp1: mov [left_ofs],eax
 
mcall 12,1
 
push [color_tbl+4*5]
pop [sc.work]
 
mov edx,[sc.work]
add edx,0x33000000
mov ebx,[mainwnd_pos.x-2]
mov bx,word[mainwnd_pos.w]
mov ecx,[mainwnd_pos.y-2]
mov cx,word[mainwnd_pos.h]
mcall 0,,,,,s_title
 
mcall 9,p_info,-1
mov esi,p_info.box.left
mov edi,mainwnd_pos
mov ecx,4
cld
rep movsd
 
; mcall 9,p_info,-1
cmp [p_info.client_box.height],LINEH
jl .exit.2
 
mov [top_ofs],ATOPH;+1
 
mov eax,[p_info.client_box.width]
sub eax,SCRLW+1
sub eax,[left_ofs]
cdq
mov ebx,6
div ebx
mov [columns.scr],eax
 
mov eax,[p_info.client_box.height] ; calculate buttons position
add eax,-STATH;*3-2-2
sub eax,[bot_dlg_height]
mov [bot_ofs],eax
 
call draw_bottom_dialog
 
mov [do_not_draw],1 ; do_not_draw = true
 
mov ebx,eax
sub ebx,[top_ofs]
sub ebx,SCRLW*3+AMINS+5
js .no_draw
 
dec [do_not_draw] ; do_not_draw = false
sub eax,SCRLW+3
sub eax,[top_ofs]
cdq
mov ebx,LINEH
div ebx
mov [lines.scr],eax
 
mov ebx,[p_info.client_box.width]
mov ecx,[top_ofs-2]
mov cx,word[top_ofs]
sub ecx,1*65536+1
mcall 38,,,[cl_3d_inset];[sc.work_text]
mov ecx,[p_info.client_box.height]
sub ecx,STATH+1
push cx
shl ecx,16
pop cx
mcall
 
inc [top_ofs]
 
call draw_main_menu
 
jmp .exit
 
.no_draw:
mov [top_ofs],2
mov eax,[p_info.client_box.height]
inc eax
mov [bot_ofs],eax
sub eax,2
push eax
add eax,-2-SCRLW
cdq
mov ebx,LINEH
idiv ebx
mov [lines.scr],eax
pop eax
 
mov ebx,[p_info.client_box.height]
sub ebx,SCRLW*3+AMINS+2
jns @f
 
inc [do_not_draw]
 
dec eax
cdq
mov ebx,LINEH
idiv ebx
mov [lines.scr],eax
 
mov eax,[p_info.client_box.width]
cdq
mov ebx,6
idiv ebx
mov [columns.scr],eax
@@:
 
.exit:
call draw_file
.exit.2:
mcall 12,2
ret
endf
 
;-----------------------------------------------------------------------------
func draw_bottom_dialog ;/////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [bot_dlg_height],0
je .exit
pushad
mov ebx,[p_info.client_box.width]
mov ecx,[bot_ofs]
dec ecx
push cx
shl ecx,16
pop cx
mcall 38,,,[cl_3d_inset]
mov ecx,[bot_ofs-2]
mov cx,word[bot_dlg_height]
dec ecx
mov ebx,[p_info.client_box.width]
inc ebx
mcall 13,,,[cl_3d_normal]
mov al,1
call [bot_dlg_handler]
popad
 
.exit:
ret
endf
 
mi_sel dd ?
mi_cur dd -1
 
;-----------------------------------------------------------------------------
func draw_main_menu ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov ebx,[p_info.client_box.width]
inc ebx
mcall 13,,ATOPH-1,[cl_3d_normal]
 
mov edx,main_menu
mov ebx,9*65536+ATOPH/2-4
mov ecx,[sc.work_text]
mov [mi_sel],0
mov edi,[mi_cur]
@@: inc [mi_sel]
cmp [mi_sel],main_menu.cnt_item
ja .exit
cmp edi,[mi_sel]
jne .lp1
pushad
push edx
mcall 13,[edx+0],[edx+4],[cl_3d_pushed]
mov edx,[esp]
mov bx,[edx+2]
mcall 38,,,[cl_3d_inset]
pop edx
movzx eax,word[edx]
add ebx,eax
shl eax,16
add ebx,eax
mcall 38,,,[cl_3d_inset]
popad
.lp1: add edx,8+1
movzx esi,byte[edx-1]
mcall 4
add edx,esi
add esi,2
imul esi,6*65536
add ebx,esi
jmp @b
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func draw_file.ex ;///////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; EAX = start line
; EBX = end line
;-----------------------------------------------------------------------------
cmp [p_info.client_box.height],LINEH
jge @f
ret
@@:
call init_sel_vars
call check_bottom_right
 
pushad
 
cmp [lines.scr],0
jle draw_file.exit
 
cmp eax,ebx
jle @f
xchg eax,ebx
@@: cmp eax,[top_line]
jge @f
mov eax,[top_line]
@@: mov ecx,[top_line]
add ecx,[lines.scr]
cmp ebx,ecx
jl @f
dec ecx
mov ebx,ecx
@@: cmp eax,ebx
jg draw_file.exit
 
mov ecx,eax
push eax
call get_line_offset
 
.start:
mov ecx,ebx
sub ecx,eax
inc ecx
 
mov ebx,[top_ofs]
add ebx,[left_ofs-2]
sub eax,[top_line]
imul eax,LINEH
add ebx,eax
 
imul ebp,[left_col],6*65536
or [draw_blines],-1
 
jmp draw_file.next_line
endf
 
;-----------------------------------------------------------------------------
func draw_file ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [p_info.client_box.height],LINEH
jge @f
ret
@@:
call init_sel_vars
call check_bottom_right
 
pushad
 
mov ebx,[top_ofs]
add ebx,[left_ofs-2]
 
mov ecx,[top_line]
push ecx
call get_line_offset
 
.start:
add esp,4
mov ecx,[lines.scr]
or ecx,ecx
jle .exit
add esp,-4
 
imul ebp,[left_col],6*65536
mov eax,[lines.scr]
sub eax,[lines]
mov [draw_blines],eax
 
.next_line:
 
push ecx ebx
 
mov ecx,ebx
shl ecx,16
mov cl,LINEH
mov ebx,[p_info.client_box.width]
add ebx,-SCRLW
add ebx,[left_ofs-2]
sub ebx,[left_ofs]
add ebx,-1*65536+1
 
; selection (text background)
mov [in_sel],0
mov edx,[color_tbl+4*5]
mov eax,[esp+4*2]
cmp eax,[sel.begin.y]
jl .lp6
je .lp1
cmp eax,[sel.end.y]
jg .lp6
je .lp3
jmp .lp6.2
.lp1: mov eax,[sel.begin.y]
cmp eax,[sel.end.y]
je .lp5
.lp2: mov eax,[sel.begin.x]
sub eax,[left_col]
jle .lp6.2
cmp eax,[columns.scr]
jge .lp6
imul eax,6
pushad
sub bx,ax
rol ebx,16
mov bx,ax
add ebx,[left_ofs];OLEFT-1
dec ebx
rol ebx,16
mov edx,[color_tbl+4*7]
mcall 13
popad
; inc eax
mov bx,ax
mov [in_sel],2
jmp .lp6
.lp3: mov eax,[sel.begin.y]
cmp eax,[sel.end.y]
je .lp5
.lp4: mov eax,[sel.end.x]
sub eax,[left_col]
jle .lp6
cmp eax,[columns.scr]
jg .lp6.2
imul eax,6
pushad
sub bx,ax
rol ebx,16
add eax,[left_ofs];OLEFT-1
dec eax
mov bx,ax
rol ebx,16
; inc ebx
mcall 13
popad
mov edx,[color_tbl+4*7]
mov bx,ax
mov [in_sel],3
jmp .lp6
.lp5: mov eax,[left_col]
cmp eax,[sel.begin.x]
jge .lp4
add eax,[columns.scr]
cmp eax,[sel.end.x]
jl .lp2
mov eax,[sel.begin.x]
cmp eax,[sel.end.x]
je .lp6
sub eax,[left_col]
imul eax,6
pushad
mov ebx,[sel.end.x]
sub ebx,[sel.begin.x]
; inc ebx
imul ebx,6
sal ebx,16
dec eax
add eax,[left_ofs]
mov bx,ax
rol ebx,16
mov edx,[color_tbl+4*7]
mcall 13
movzx eax,bx
sar ebx,16
add eax,ebx
mov ebx,eax
sal ebx,16
sub ax,[esp+4*4]
neg ax
add ax,word[left_ofs]
mov bx,ax
mov edx,[color_tbl+4*5]
mcall 13
popad
mov bx,ax
mov [in_sel],4
jmp .lp6
 
.lp6.2:
mov edx,[color_tbl+4*7]
inc [in_sel]
.lp6:
mcall 13
 
lodsd
 
pushad
mov edx,[color_tbl+4*5]
test eax,0x00010000
jz @f
mov edx,[color_tbl+4*8]
test eax,0x00020000
jz @f
mov edx,[color_tbl+4*9]
@@: mov ebx,[left_ofs]
add ebx,-4
shl ebx,16
mov bx,LCHGW
mcall 13
popad
 
 
xor ecx,ecx
and eax,0x0000FFFF
mov [cur_line_len],eax
 
or eax,eax
ja .next_block
add esp,4*2
jmp .draw_cursor
 
.next_block:
 
push esi ecx
call get_next_part
pop ebx
 
push ecx
mov ecx,eax
 
push esi ebx
mov eax,ebx
sub ebx,[left_col]
cmp ebx,[columns.scr]
jge .skip_t
add ebx,esi
jle .skip_t
mov ebx,[esp+8+4*2] ;// 4*2=esi+ebx
sub eax,[left_col]
jge .qqq
sub edx,eax
add esi,eax
; mov eax,OLEFT*65536
xor eax,eax
jmp .qqq2
.qqq:
; inc eax
imul eax,6*65536
.qqq2:
and ebx,0x0000FFFF
add eax,[left_ofs-2];OLEFT*65536
add ebx,eax
 
mov eax,[esp] ; ebx
add eax,[esp+4] ; esi
sub eax,[left_col]
sub eax,[columns.scr]
jle .qweqwe
sub esi,eax
.qweqwe:
 
mov al,[in_sel]
cmp al,0
je .draw_t
dec al
jz .ya4
.nt1: dec al
jnz .nt2
mov eax,[esp]
cmp eax,[sel.begin.x]
jge .ya4
add eax,[esp+4]
cmp eax,[sel.begin.x]
jl .draw_t
;---[ selection crosses block from the right ]-(-
.ya1: mov eax,esi
mov esi,[sel.begin.x]
sub esi,[esp]
pushad
mov ecx,[left_col]
sub ecx,[esp+4*8]
jle @f
sub esi,ecx
sub [esp+4],ecx
@@: sub eax,esi
add edx,esi
imul esi,6
rol ebx,16
add bx,si
rol ebx,16
mov esi,eax
mov ecx,[color_tbl+4*6]
mcall 4
popad
jmp .draw_t
;----------------------------------------------)-
.nt2: dec al
jnz .nt3
mov eax,[esp]
cmp eax,[sel.end.x]
jge .draw_t
add eax,[esp+4]
cmp eax,[sel.end.x]
jl .ya4
;---[ selection crosses block from the left ]--(-
.ya2: mov eax,[sel.end.x]
sub eax,[esp]
push ebx
mov ebx,[esp+4]
sub ebx,[left_col]
jge .ya2.1
add eax,ebx
.ya2.1:
pop ebx
pushad
mov esi,eax
mov ecx,[color_tbl+4*6]
mcall 4
popad
sub esi,eax
add edx,eax
imul eax,6*65536
add ebx,eax
jmp .draw_t
;----------------------------------------------)-
.nt3: mov eax,[esp]
cmp eax,[sel.end.x]
jge .draw_t
cmp eax,[sel.begin.x]
jge @f
add eax,[esp+4]
cmp eax,[sel.begin.x]
jl .draw_t
cmp eax,[sel.end.x]
jl .ya1
;---[ selection inside block ]-----------------(-
mov eax,esi
mov esi,[sel.begin.x]
sub esi,[esp]
push eax
mov eax,[esp+4]
sub eax,[left_col]
jge .nt3.1
add esi,eax
.nt3.1:
pop eax
sub eax,esi
pushad
add edx,esi
imul esi,6*65536
add ebx,esi
mov esi,[sel.end.x]
sub esi,[sel.begin.x]
mov ecx,[color_tbl+4*6]
sub eax,esi
push eax
mcall 4
add edx,esi
imul esi,6*65536
add ebx,esi
pop esi
mov ecx,[esp+4*6]
mcall 4
popad
jmp .draw_t
;----------------------------------------------)-
@@: add eax,esi
dec eax
cmp eax,[sel.end.x]
jge .ya2
;---[ block inside selection ]-----------------(-
.ya4: mov ecx,[color_tbl+4*6]
;----------------------------------------------)-
 
.draw_t:
mcall 4;[esp+8]
.skip_t:
pop eax eax ; ebx esi
imul eax,6
add [esp+4*2+2],ax
pop ecx esi
cmp ecx,[cur_line_len];LINE_WIDTH
jl .next_block
 
pop ebx ecx
and ebx,0x0000FFFF
add ebx,[left_ofs-2]
add ebx,LINEH
add esi,[cur_line_len];LINE_WIDTH
inc dword[esp]
dec ecx
jg .next_line
 
;------------------------------------------------
.draw_cursor:
 
;------------------------------------------------
mov ebx,[left_ofs]
cmp ebx,2+LCHGW
je .no_gutter
add esp,-4*8*2
sub ebx,3+LCHGW
mov ecx,[top_ofs]
dec ecx
shl ecx,16
add ecx,[bot_ofs]
sub ecx,[top_ofs]
sub ecx,SCRLW
mcall 13,,,[cl_3d_normal]
 
push bx
shl ebx,16
pop bx
add ecx,[top_ofs]
dec ecx
mcall 38,,,[cl_3d_inset]
 
mov ebx,[left_ofs]
add ebx,-3-LCHGW
shl ebx,16
add ebx,[top_ofs]
mov edi,[sc.work_text]
mov ecx,[top_line]
inc ecx
mov edx,p_info+100
@@: pushad
push eax edx edi
mov eax,ecx
mov ecx,10
mov edi,edx
call uint2str
mov esi,edi
pop edi edx eax
sub esi,edx
imul eax,esi,6*65536
sub ebx,eax
mcall 4,,edi
popad
add ebx,LINEH
inc ecx
cmp ecx,[lines]
jg @f
mov esi,ecx
sub esi,[top_line]
cmp esi,[lines.scr]
jbe @b
@@: add esp,4*8*2
 
.no_gutter:
;------------------------------------------------
 
mov ebx,[draw_blines]
or ebx,ebx
js @f
imul ebx,LINEH
mov ecx,[esp-8]
shl ecx,16
mov cx,bx
mov ebx,[p_info.client_box.width]
add ebx,[left_ofs-2]
sub ebx,[left_ofs]
add ebx,-1*65536-SCRLW+1 ; <OLEFT-1,LINE_WIDTH*6+2>
mcall 13,,,[color_tbl+4*5]
@@:
 
add esp,4
cmp [bot_mode],0
jne @f
mov ebx,[pos.x]
sub ebx,[left_col]
js @f
cmp ebx,[columns.scr]
ja @f
imul ebx,6
add ebx,[left_ofs]
dec ebx
push bx
shl ebx,16
pop bx
mov eax,[pos.y]
sub eax,[top_line]
js @f
cmp eax,[lines.scr]
jge @f
imul eax,LINEH
add eax,[top_ofs]
; inc eax
mov esi,eax
shl esi,16
add eax,LINEH-2
mov si,ax
mov ecx,2
cmp [ins_mode],0
jne .lp8
add cl,4
.lp8: push ecx
mcall 38,,esi,0x01000000
add ebx,0x00010001
pop ecx
loop .lp8
@@:
;------------------------------------------------
cmp [do_not_draw],2
je .exit
 
; mov ebx,[p_info.x_size]
; shl ebx,16
; add ebx,(-SCRLW-5+2)*65536+SCRLW-2
; mov ecx,[top_ofs-2]
; mov cx,SCRLW-1
; mcall 8,,,'UP',[sc.work_button]
;!!!!!!!!!!!!!!!!!!
mov ebx,[p_info.client_box.width]
shl ebx,16
add ebx,(-SCRLW)*65536+SCRLW
mov ecx,[top_ofs-2]
mov cx,SCRLW
sub ecx,0x00020000
mcall 8,,,'UP' or 0x40000000
pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
call draw_3d_panel
popad
mov eax,8
;!!!!!!!!!!!!!!!!!!
 
pushad
push 0x18
shr ecx,16
mov bx,cx
add ebx,(SCRLW/2-2)*65536+SCRLW/2-3
mcall 4,,[sc.work_text],esp,1
add esp,4
popad
 
; mov ecx,[bot_ofs]
; shl ecx,16
; add ecx,(-SCRLW*2-1)*65536+SCRLW-1
; mcall ,,,'DN'
;!!!!!!!!!!!!!!!!!!
mov ecx,[bot_ofs]
shl ecx,16
add ecx,(-SCRLW*2-1)*65536+SCRLW
mcall ,,,'DN' or 0x40000000
pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
call draw_3d_panel
popad
mov eax,8
;!!!!!!!!!!!!!!!!!!
 
pushad
push 0x19
shr ecx,16
mov bx,cx
add ebx,(SCRLW/2-2)*65536+SCRLW/2-3
mcall 4,,[sc.work_text],esp,1
add esp,4
popad
; sub ebx,1*65536-2
 
push ebx
mov eax,[lines]
mov ebx,[lines.scr]
mov ecx,[top_line]
mov edx,[bot_ofs]
sub edx,[top_ofs]
add edx,-SCRLW*3+1
call get_scroll_vars
mov [vscrl_top],eax
mov [vscrl_size],ebx
pop ebx
 
mov ecx,eax
add ecx,[top_ofs]
add ecx,SCRLW-1
; shl ecx,16
; mov cx,word[vscrl_size]
 
; mcall 13,,,[sc.work_button]
;!!!!!!!!!!!!!!!!!!
pushad
sar ebx,16
; rol ecx,16
; movsx eax,cx
; sar ecx,16
push ebx ecx SCRLW [vscrl_size]
dec dword[esp]
call draw_3d_panel
popad
mov eax,13
;!!!!!!!!!!!!!!!!!!
inc ebx
 
mov ecx,[top_ofs-2]
mov cx,word[vscrl_top]
add ecx,(SCRLW-1)*65536
mov edx,[sc.work];[color_tbl+4*5]
or cx,cx
jle @f
mcall 13
@@:
mov ecx,[top_ofs]
add ecx,[vscrl_top]
add ecx,[vscrl_size]
add ecx,SCRLW-1
mov di,cx
shl ecx,16
mov cx,word[bot_ofs]
sub cx,di
sub cx,SCRLW*2+1
jle @f
mcall
@@:
;-----------------------
; mov eax,ebx
; shr eax,16
; add bx,ax
; mov ecx,[top_ofs-2]
; mov cx,word[top_ofs]
; add ecx,SCRLW*65536+SCRLW
; mcall 38,,,[sc.work_graph];[sc.work_text]
; mov ecx,[bot_ofs-2]
; mov cx,word[bot_ofs]
; sub ecx,(SCRLW*2+2)*65536+(SCRLW*2+2)
; mcall
rol ebx,16
push bx
rol ebx,16
pop bx
mov ecx,[top_ofs-2]
mov cx,word[bot_ofs]
add ecx,(SCRLW-1)*65536-SCRLW*2-2
mcall 38,,,[cl_3d_inset]
;------------------------------------------------
; mov ebx,5*65536+SCRLW-1
; mov ecx,[bot_ofs]
; shl ecx,16
; add ecx,(-SCRLW)*65536+SCRLW-2
; mcall 8,,,'LT',[sc.work_button]
;!!!!!!!!!!!!!!!!!!
mov ebx,SCRLW
mov ecx,[bot_ofs]
shl ecx,16
add ecx,(-SCRLW-1)*65536+SCRLW
mcall 8,,,'LT' or 0x40000000
pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
call draw_3d_panel
popad
;!!!!!!!!!!!!!!!!!!
 
pushad
push 0x1B
shr ecx,16
mov bx,cx
add ebx,(SCRLW/2-2)*65536+SCRLW/2-3
mcall 4,,[sc.work_text],esp,1
add esp,4
popad
 
; mov ebx,[p_info.x_size]
; shl ebx,16
; add ebx,(-SCRLW*2-5)*65536+SCRLW
; mcall ,,,'RT'
;!!!!!!!!!!!!!!!!!!
mov ebx,[p_info.client_box.width]
shl ebx,16
add ebx,(-SCRLW*2)*65536+SCRLW
mcall 8,,,'RT' or 0x40000000
pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
call draw_3d_panel
popad
;!!!!!!!!!!!!!!!!!!
 
pushad
push 0x1A
shr ecx,16
mov bx,cx
add ebx,(SCRLW/2-2)*65536+SCRLW/2-3
mcall 4,,[sc.work_text],esp,1
add esp,4
popad
; inc ecx
 
push ecx
mov eax,[columns]
mov ebx,[columns.scr]
mov ecx,[left_col]
mov edx,[p_info.client_box.width]
add edx,-(SCRLW*3)
call get_scroll_vars
mov [hscrl_top],eax
mov [hscrl_size],ebx
pop ecx
 
mov ebx,eax
add ebx,1+SCRLW
shl ebx,16
mov bx,word[hscrl_size]
 
; mcall 13,,,[sc.work_button]
;!!!!!!!!!!!!!!!!!!
pushad
sar ecx,16
rol ebx,16
movsx eax,bx
sar ebx,16
dec ebx
push eax ecx ebx SCRLW
call draw_3d_panel
popad
;!!!!!!!!!!!!!!!!!!
 
mov ebx,(1+SCRLW)*65536
mov bx,word[hscrl_top]
mcall 13,,,[sc.work];[color_tbl+4*5]
mov ebx,1+SCRLW
add ebx,[hscrl_top]
add ebx,[hscrl_size]
mov di,bx
shl ebx,16
mov bx,word[p_info.client_box.width]
sub bx,di
sub bx,SCRLW*2
jle @f
mcall
@@:
; mov eax,ebx
; shr eax,16
; add bx,ax
; mov ecx,[bot_ofs-2]
; mov cx,word[bot_ofs]
; sub ecx,SCRLW*65536+2
; mcall 38,<OLEFT+SCRLW-1,OLEFT+SCRLW-1>,,[sc.work_graph];[sc.work_text]
; mov ebx,[p_info.x_size-2]
; mov bx,word[p_info.x_size]
; sub ebx,(SCRLW*2+6)*65536+(SCRLW*2+6)
; mcall
mov ebx,[p_info.client_box.width]
; add ebx,5*65536-5
mov ecx,[bot_ofs-2]
mov cx,word[bot_ofs]
sub ecx,(SCRLW+1)*65536+(SCRLW+1)
mcall 38,,,[cl_3d_inset]
;------------------------------------------------
.exit:
popad
ret
endf
 
;-----------------------------------------------------------------------------
func get_next_part ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ECX = current letter
; ESI = string
; Output:
; ECX = color
; EDX = string
; ESI = length
;-----------------------------------------------------------------------------
cmp [asm_mode],0
je .plain.text
xor ebx,ebx
mov edx,ecx
add esi,ecx
mov edi,symbols
mov al,[esi]
cmp al,';'
je .comment
mov ecx,symbols.size
repne scasb
je .symbol
cmp al,'$'
jne @f
mov edi,symbols
mov al,[esi+1]
mov ecx,symbols.size
repne scasb
je .not_symbol
jmp .number
@@: cmp al,'0'
jb @f
cmp al,'9'
jbe .number
@@: cmp al,"'"
je .string
cmp al,'"'
je .string
.not_symbol:
inc ebx
inc edx
cmp edx,[cur_line_len];LINE_WIDTH
jge @f
mov edi,symbols
mov al,[esi+ebx]
cmp al,';'
je @f
mov ecx,symbols.size
repne scasb
jne .not_symbol
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl+4*0]
ret
.symbol:
inc ebx
inc edx
cmp edx,[cur_line_len];LINE_WIDTH
jge @f
mov edi,symbols
mov al,[esi+ebx]
mov ecx,symbols.size
repne scasb
je .symbol
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl+4*4]
ret
.comment:
neg edx
add edx,[cur_line_len];LINE_WIDTH
xchg edx,esi
mov ecx,[cur_line_len];LINE_WIDTH
mov eax,[color_tbl+4*3]
ret
.number:
inc ebx
inc edx
cmp edx,[cur_line_len];LINE_WIDTH
jge @f
mov edi,symbols
mov al,[esi+ebx]
cmp al,';'
je @f
mov ecx,symbols.size
repne scasb
jne .number
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl+4*1]
ret
.string:
inc ebx
inc edx
cmp edx,[cur_line_len];LINE_WIDTH
jge @f
cmp [esi+ebx],al
jne .string
inc ebx
inc edx
@@:
mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl+4*2]
ret
.plain.text:
mov edx,[cur_line_len];LINE_WIDTH
xchg edx,esi
mov ecx,[cur_line_len];LINE_WIDTH
mov eax,[color_tbl+4*0]
ret
endf
 
;-----------------------------------------------------------------------------
func writepos ;///// WRITE POSITION //////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp [do_not_draw],1 ; return if drawing is not permitted
jae .exit
pusha
 
; mcall 9,p_info,-1
 
mov ecx,[p_info.client_box.height-2]
mov cx,word[p_info.client_box.height]
sub ecx,STATH*65536
; mpack ebx,6*13,6*13
; add ebx,[left_ofs-2]
; add ebx,[left_ofs]
mcall 38,<6*13,6*13>,,[cl_3d_inset]
 
pushad
; sub ebx,(6*13+1)*65536-1
; sub ebx,[left_ofs]
mov cx,STATH+1
mcall 13,<0,6*13>,,[cl_3d_normal]
mcall ,<6*13+1,6*(s_modified.size+2)-1>
mov ebx,(6*(s_modified.size+15)+1)*65536
mov bx,word[p_info.client_box.width]
sub bx,6*(s_modified.size+15)
mcall
popad
 
add ebx,6*(s_modified.size+2)*65536+6*(s_modified.size+2)
mcall
 
and ecx,0x0000FFFF
push ecx
 
mov eax,[pos.y]
inc eax
mov ecx,10
mov edi,p_info+0x100;htext2.pos1
cld
call uint2str
mov al,','
stosb
mov eax,[pos.x]
inc eax
call uint2str
 
pop ebx
 
lea esi,[edi-p_info-0x100]
lea edi,[esi*3]
shl edi,16
 
; add ebx,[left_ofs-2]
add ebx,(1+6*6+3)*65536-STATH/2-3
sub ebx,edi
mcall 4,,[sc.work_text],p_info+0x100
 
cmp [modified],0
je @f
and ebx,0x0000FFFF
; add ebx,[left_ofs-2]
add ebx,(1+12*6+12+1)*65536
mcall ,,,s_modified,s_modified.size
 
@@: cmp [s_status],0
je @f
and ebx,0x0000FFFF
add ebx,6*(s_modified.size+16)*65536
or ecx, 80000000h
mcall ,,,[s_status]
 
@@: popa
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func print_text ;/////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pusha
; mov ebx,(LBTNW+5+2)*65536
mov bx,word[p_info.box.width]
; sub bx,LBTNW+RBTNW+10+3
mov ecx,[ya-2]
; mov cx,ABTNH+1
mcall 13,,,[sc.work]
; mov ebx,(LBTNW+5+2+4)*65536+ABTNH/2-3
add ebx,[ya]
mov eax,[p_info.box.width]
; sub eax,LBTNW+RBTNW+10+8
push eax
cdq
mov ecx,6
div ecx
cmp eax,PATHL
jbe @f
mov eax,PATHL
@@: mov esi,eax
mcall 4,,[color_tbl+0],[addr]
 
mov eax,[ya]
mov ebx,eax
; add eax,ABTNH/2-6
shl eax,16
add eax,ebx
; add eax,ABTNH/2-6+11
mov ecx,eax
imul eax,[temp],6
pop ebx
cmp eax,ebx
jae @f
; add eax,LBTNW+5+2+4
mov ebx,eax
shl eax,16
add ebx,eax
mcall 38,,,[color_tbl+0]
 
@@: popa
ret
endf
 
func draw_framerect ; ebx,ecx
push ebx ecx
 
add bx,[esp+6]
mov cx,[esp+2]
dec ebx
mcall 38,,,[cl_3d_inset]
add cx,[esp]
rol ecx,16
add cx,[esp]
sub ecx,0x00010001
mcall
 
mov ebx,[esp+4]
mov ecx,[esp]
mov bx,[esp+6]
add cx,[esp+2]
dec ecx
mcall
add bx,[esp+4]
rol ebx,16
add bx,[esp+4]
sub ebx,0x00010001
mcall
 
add esp,8
ret
endf
/programs/develop/tinypad/trunk/tp-files.asm
0,0 → 1,307
;-----------------------------------------------------------------------------
func save_file ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
 
mov esi,tb_opensave.text
mov edi,f_info.path
movzx ecx,[tb_opensave.length]
mov [f_info.length],ecx
cld
rep movsb
mov byte[edi],0
 
mov esi,AREA_EDIT ; 0x70000 = 448 Kbytes (maximum)
mov edi,AREA_TEMP
 
.new_string:
call save_string
cmp dword[esi],0
jne .new_string
sub edi,AREA_TEMP+2 ; minus last CRLF
;! mov [filelen],edi
cmp byte[f_info.path],'/'
je .systree_save
mcall 33,f_info.path,AREA_TEMP,edi,0;[filelen],0
or eax,eax
jz .exit
; call file_not_found
jmp .exit.2
 
.systree_save:
;! mov eax,[filelen]
; mov [f_info+8],edi ;! eax
; mov [f_info+0],1
; mov esi,s_fname
; mov edi,f_info.path
; mov ecx,PATHL
; cld
; rep movsb
;mcall 58,f_info
 
mov [f_info70+0],2
mov [f_info70+12],edi
mov [f_info70+16],AREA_TEMP
mov byte[f_info70+20],0
mov [f_info70+21],f_info.path
mcall 70,f_info70
 
call set_status_fs_error
 
or eax,eax
jnz .exit.2
 
.exit:
mov [modified],0
clc
ret
 
.exit.2:
stc
ret
endf
 
;-----------------------------------------------------------------------------
func save_string ;////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
movzx ecx,word[esi]
test dword[esi],0x00010000
jz @f
or dword[esi],0x00020000
@@: add esi,4
; mov ecx,eax
 
@@: cmp byte[esi+ecx-1],' '
jne @f
loop @b
@@: jecxz .endcopy
xor edx,edx
mov ebx,edx
mov ah,dl
 
.next_char:
mov al,[esi+ebx]
inc ebx
; cmp [asm_mode],0
; je .put
test [options],OPTS_OPTIMSAVE
jz .put
test ah,00000001b
jnz .char
cmp al,'"'
jne @f
xor ah,00000100b
jmp .char
@@: cmp al,"'"
jne @f
xor ah,00000010b
jmp .char
@@: test ah,00000110b
jnz .char
cmp al,';'
jne @f
test ah,00000001b
jnz .char
xor ah,00000001b
jmp .char
@@: cmp al,' '
jne .char
inc edx
test ebx,ATABW-1
jnz @f
dec edx
jle .put
mov al,9
xor edx,edx
jmp .put
.char:
or edx,edx
jz .put
push ecx eax
mov ecx,edx
mov al,' '
rep stosb
pop eax ecx
xor edx,edx
.put:
stosb
@@: loop .next_char
 
.endcopy:
mov eax,0x0A0D
stosw
movzx eax,word[esi-4]
add esi,eax;[esi-4]
ret
endf
 
func set_status_fs_error
push eax
mov esi,s_fs_error
@@: dec eax
js @f
movzx ecx,byte[esi]
lea esi,[esi+ecx+1]
jmp @b
@@: inc esi
mov [s_status],esi
pop eax
call writepos
ret
endf
 
;-----------------------------------------------------------------------------
func load_hd_file ;///////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov [f_info+0],0
mov [f_info+8],300000/512
; mov esi,s_fname
; mov edi,f_info.path;pathfile_read
; mov ecx,PATHL
; cld
; rep movsb
;mcall 58,f_info ; fileinfo_read
 
mov [f_info70+0],0
mov [f_info70+4],0
mov [f_info70+8],0
mov [f_info70+12],300000;/512
mov [f_info70+16],AREA_TEMP
mov byte[f_info70+20],0
mov [f_info70+21],f_info.path
mcall 70,f_info70
 
call set_status_fs_error
 
xchg eax,ebx
inc eax
test ebx,ebx
je load_file.file_found
cmp ebx,6 ;// ATV driver fix (6 instead of 5)
je load_file.file_found
; jmp file_not_found
stc
ret
endf
 
;-----------------------------------------------------------------------------
func load_file ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
 
mov esi,tb_opensave.text
mov edi,f_info.path
movzx ecx,[tb_opensave.length]
mov [f_info.length],ecx
cld
rep movsb
mov byte[edi],0
 
cmp byte[f_info.path],'/'
je load_hd_file
 
mcall 6,f_info.path,0,16800,AREA_TEMP ; 6 = open file
inc eax ; eax = -1 -> file not found
jnz .file_found
; jmp file_not_found
stc
ret
 
.file_found:
dec eax
mov [filesize],eax
mov [lines],1
mov [columns],0
mov esi,AREA_TEMP
mov edi,AREA_EDIT
mov edx,eax
 
.next_line:
mov ebx,edi
add edi,4
.next_char:
or edx,edx
jle .exit
lodsb
dec edx
cmp al,13
je .CR
cmp al,10
je .LF
cmp al,9
je .TB
cmp al,0
je .exit
stosb
jmp .next_char
 
.exit:
mov ecx,10
mov al,' '
rep stosb
lea eax,[edi-4]
sub eax,ebx
mov [ebx],eax
mov dword[ebx+eax+4],0
sub eax,10
jnz @f
inc eax
@@: cmp eax,[columns]
jbe @f
mov [columns],eax
@@: mov [modified],0
clc
ret
 
.CR: cmp byte[esi],10
jne .LF
lodsb
dec edx
.LF: mov ecx,10
mov al,' '
rep stosb
lea eax,[edi-4]
sub eax,ebx
mov [ebx],eax
inc [lines]
add eax,-10
cmp eax,[columns]
jbe .next_line
mov [columns],eax
jmp .next_line
 
.TB: lea eax,[edi-4]
sub eax,ebx
mov ecx,eax
add ecx,ATABW
and ecx,not(ATABW-1)
sub ecx,eax
mov al,' '
rep stosb
jmp .next_char
endf
 
;-----------------------------------------------------------------------------
func new_file ;///////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; mcall 55,eax,error_beep ; beep
mov [lines],1 ; open empty document
mov [columns],1
xor eax,eax
mov [top_line],eax
mov [pos.x],eax
mov [pos.y],eax
mov edi,AREA_EDIT+4
mov ecx,10
mov [edi-4],ecx
mov [edi+10],eax
mov al,' '
cld
rep stosb
 
mov [f_info.length],0
mov [modified],0
mov [asm_mode],0
call update_caption
call drawwindow
 
ret
endf
/programs/develop/tinypad/trunk/tp-key.asm
0,0 → 1,1404
key:
mov ecx,1
mcall 66,3
xor ebx,ebx
test al,0x03
jz @f
or ebx,KM_SHIFT
@@: test al,0x0C
jz @f
or ebx,KM_CTRL
@@: test al,0x30
jz @f
or ebx,KM_ALT
@@: mov [shi],ebx
test al,0x03
jz @f
inc cl
@@: mcall 26,2,,key1
 
mcall 2
cmp al,0
jne still.skip_write
shr eax,8
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
or eax,[shi]
 
test al,0x80
jnz still.skip_write
mov [chr],al
 
cmp [bot_mode],0
je @f
mov ebx,eax
mov al,2
call [bot_dlg_handler]
jmp still
@@:
 
mov esi,accel_table
.acc: cmp eax,[esi]
jne @f
test [options],OPTS_SECURESEL
jz .lp1
m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
.lp1: mov [s_status],0
call dword[esi+4]
jmp still
@@: add esi,8
cmp byte[esi],0
jne .acc
 
test dword[shi],KM_CTRLALT
jnz still.skip_write
 
mov [s_status],0
 
movzx eax,[chr]
movzx eax,[eax+key0]
or al,al
jz still.skip_write
movzx eax,[eax+key1]
push eax
 
test [options],OPTS_SECURESEL
jz .lp2
m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
jmp .put
.lp2: call delete_selection
 
test [options],OPTS_AUTOBRACES
jz .put
cmp al,'['
jne @f
mov al,']'
call .lp3
dec [pos.x]
jmp .put
@@: cmp al,'('
jne @f
mov al,')'
call .lp3
dec [pos.x]
jmp .put
@@: cmp al,'{'
jne .put
mov al,'}'
call .lp3
dec [pos.x]
 
.put: pop eax
push still
inc [sel.x]
.lp3: push [pos.x] eax
inc dword[esp+4]
mov eax,1
jmp key.tab.direct
 
;-----------------------------------------------------------------------------
func key.ctrl_a ;///// SELECT ALL DOCUMENT ///////////////////////////////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [sel.x],eax
mov [sel.y],eax
mov ecx,[lines]
dec ecx
mov [pos.y],ecx
call get_line_offset
call get_real_length
mov [pos.x],eax
call draw_file
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_o ;///// ENTER OPEN FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_dlg_mode2],0
 
.direct:
mov [s_status],s_enter_filename
 
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 ecx,[f_info.length]
mov [tb_opensave.length],cl
jecxz @f
mov esi,f_info.path
mov edi,tb_opensave.text
cld
rep movsb
 
@@: mov al,[tb_opensave.length]
mov [tb_opensave.pos.x],al
mov [tb_opensave.sel.x],0
mov [tb_casesen],1
call drawwindow
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_s ;///// ENTER SAVE FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
cmp [modified],0
je .exit
cmp [f_info.length],0
je key.shift_ctrl_s
call save_file
call drawwindow
.exit:
ret
 
key.shift_ctrl_s:
mov [bot_dlg_mode2],1
jmp key.ctrl_o.direct
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_n ;///// ENTER SAVE FILENAME ///////////////////////////////////
;-----------------------------------------------------------------------------
call new_file
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_f ;///// ENTER KEYWORD TO FIND /////////////////////////////////
;-----------------------------------------------------------------------------
mov [bot_dlg_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
endf
 
func key.ctrl_h
mov [bot_dlg_mode2],1
mov [bot_dlg_height],16*3+4*2+1
 
mov [s_status],s_enter_text_to_replace
 
jmp key.ctrl_f.direct
endf
 
func key.ctrl_g
ret
macro comment {
mov [bot_dlg_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
}
endf
 
; CHANGE_LANG_LAYOUT { ; Ctrl + F8
; 3 times english -> russian
; 2 times russian -> english
; call layout
; jmp still
; CHANGE_LANG_LAYOUT }
 
;-----------------------------------------------------------------------------
func key.ctrl_left ;///// GO TO PREVIOUS WORD ////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_left: ;///// GO TO PREVIOUS WORD, WITH SELECTION /////////
;-----------------------------------------------------------------------------
mov ebx,[pos.y]
mov edx,[pos.x]
cld
mov ecx,ebx
call get_line_offset
.lp1: cmp dx,[esi]
jle @f
movzx edx,word[esi]
@@: dec edx
jl .nx1
add esi,4
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
movzx edx,word[esi]
dec edx
jmp .lp1
@@:
mov ecx,ebx
call get_line_offset
.lp2: cmp dx,[esi]
jle @f
movzx edx,word[esi]
@@: or edx,edx
jl .nx2
add esi,4
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
movzx edx,word[esi]
dec edx
jmp .lp2
@@:
inc edx
mov [pos.y],ebx
mov [pos.x],edx
test byte[shi+2],0x01
jnz @f
mov [sel.y],ebx
mov [sel.x],edx
@@: sub ebx,[top_line]
jge @f
add [top_line],ebx
@@: mov eax,edx
sub eax,[left_col]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [left_col],eax
jmp .exit
@@: cmp edx,[left_col]
jge .exit
mov [left_col],edx
.exit:
call draw_file
.exit.2:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_right ;///// GO TO NEXT WORD ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_right: ;///// GO TO NEXT WORD, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov ebx,[pos.y]
mov edx,[pos.x]
cld
.lp1: mov ecx,ebx
call get_line_offset
movzx ecx,word[esi]
cmp edx,ecx
jge .nx1
add esi,4
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,[lines]
jge .exit.2
xor edx,edx
jmp .lp1
@@:
 
.lp2: mov ecx,ebx
call get_line_offset
movzx ecx,word[esi]
cmp edx,ecx
jge .nx2
add esi,4
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,[lines]
jge .exit.2
xor edx,edx
jmp .lp2
@@:
mov [pos.y],ebx
mov [pos.x],edx
test byte[shi+2],0x01
jnz @f
mov [sel.y],ebx
mov [sel.x],edx
@@: sub ebx,[top_line]
cmp ebx,[lines.scr]
jl @f
sub ebx,[lines.scr]
inc ebx
add [top_line],ebx
@@: mov eax,edx
sub eax,[left_col]
cmp eax,[columns.scr]
jl @f
sub eax,[columns.scr]
inc eax
add [left_col],eax
jmp .exit
@@: cmp edx,[left_col]
jge .exit
mov [left_col],edx
.exit:
call draw_file
.exit.2:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_x
cmp [sel.selected],0
je @f
call key.ctrl_c
call key.del
mov [modified],1
@@: ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_c
mov [copy_size],0
cmp [sel.selected],0
je .exit
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,AREA_CBUF
call get_real_length
sub eax,[sel.begin.x]
jge @f
xor eax,eax
@@: add esi,[sel.begin.x]
add esi,4
stosd
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
movzx eax,word[esi]
add esi,4
; lodsd
cmp eax,[sel.end.x]
jle @f
mov eax,[sel.end.x]
@@: mov ebx,edi
stosd
; add esi,eax
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,AREA_CBUF
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,AREA_CBUF
stosd
mov ecx,[sel.begin.y]
call get_line_offset
mov ebx,[sel.begin.x]
mov ecx,[sel.end.x]
cmp ebx,[esi]
jge .add_spaces
cmp ecx,[esi]
jle .lp1
mov ecx,[esi]
.lp1: sub ecx,[sel.begin.x]
sub eax,ecx
lea esi,[esi+ebx+4]
rep movsb
 
.add_spaces:
mov ecx,eax
mov al,' '
jecxz @b
rep stosb
jmp @b
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_v
cmp [copy_size],0
je .exit
 
call delete_selection
 
mov ecx,[pos.y]
call get_line_offset
pushd [esi] esi
mov ecx,[pos.x]
call line_add_spaces
mov ecx,[copy_size]
sub ecx,4
mov edi,AREA_TEMP2
mov eax,esi
mov esi,edi
sub esi,ecx
lea ecx,[eax+4]
add ecx,[pos.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,4
mov esi,AREA_CBUF
lodsd
 
mov ebx,[pos.x]
add eax,ebx
mov [edi-4],ax
sub eax,ebx
call .check_columns
add edi,ebx
@@: push ecx
mov ecx,eax
rep movsb
lodsd
and eax,0x0000FFFF
stosd
or dword[edi-4],0x00010000
pop ecx
loop @b
 
pop ecx
sub ecx,ebx
add [edi-4],cx
call .check_columns
mov ecx,eax
rep movsb
 
mov [pos.x],eax
mov [sel.x],eax
mov eax,[copy_count]
dec eax
add [pos.y],eax
add [sel.y],eax
add [lines],eax
 
call check_inv_all
mov [modified],1
jmp .exit
 
.single_line:
cld
pop edi
add edi,4
mov esi,AREA_CBUF
lodsd
add [edi-4],ax
and dword[edi-4],not 0x00020000
or dword[edi-4],0x00010000
call .check_columns
add edi,[pos.x]
add esp,4
mov ecx,eax
rep movsb
 
add [pos.x],eax
add [sel.x],eax
 
call check_inv_all
mov [modified],1
 
.exit:
ret
 
.check_columns:
push eax
movzx eax,word[edi-4]
cmp eax,[columns]
jbe @f
mov [columns],eax
@@: pop eax
ret
; push eax ebx esi
; add esi,eax
; xor ebx,ebx
; neg eax
; jz .lp1
; @@: cmp byte[esi+ebx-1],' '
; jne .lp1
; dec ebx
; cmp ebx,eax
; jg @b
; .lp1: add ebx,[edi-4]
; cmp [columns],ebx
; jae @f
; mov [columns],ebx
; @@: pop esi ebx eax
; ret
 
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_d ;///// INSERT SEPARATOR //////////////////////////////////////
;-----------------------------------------------------------------------------
mov ecx,[pos.y]
call get_line_offset
mov ebx,esi
 
mov ecx,[lines]
call get_line_offset
lea edi,[esi+90+4]
lea ecx,[esi+4]
sub ecx,ebx
std
rep movsb
 
lea edi,[ebx+5]
mov word[ebx],90
mov al,ASEPC
mov ecx,79
cld
rep stosb
mov al,' '
mov ecx,10
rep stosb
mov byte[ebx+4],';'
 
inc [lines]
inc [pos.y]
m2m [sel.y],[pos.y]
 
call check_inv_all
mov [modified],1
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_y ;///// DELETE CURRENT LINE ///////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[pos.y]
inc eax
cmp eax,[lines]
jge .exit
 
mov ecx,[pos.y]
call get_line_offset
mov edi,esi
lodsd
add esi,eax
 
dec [lines]
mov ecx,AREA_TEMP2
sub ecx,esi
shr ecx,2 ;// fixed (was 4)
cld
rep movsd
call check_inv_all
mov [modified],1
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.up ;///// GO TO PREVIOUS LINE ///////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_up: ;///// GO TO PREVIOUS LINE, WITH SELECTION ////////////////
;-----------------------------------------------------------------------------
mov eax,[pos.y]
dec eax
jns @f
xor eax,eax
@@: mov ecx,[top_line]
cmp eax,ecx
jae @f
dec ecx
jns @f
xor ecx,ecx
@@: test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.down ;///// GO TO NEXT LINE /////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_down: ;///// GO TO NEXT LINE, WITH SELECTION //////////////////
;-----------------------------------------------------------------------------
 
mov eax,[pos.y]
inc eax
cmp eax,[lines]
jb @f
dec eax
@@: mov ecx,[top_line]
mov edx,eax
sub edx,ecx
cmp edx,[lines.scr]
jb @f
inc ecx
@@: test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.left ;///// GO TO PREVIOUS CHAR /////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_left: ;///// GO TO PREVIOUS CHAR, WITH SELECTION //////////////
;-----------------------------------------------------------------------------
mov eax,[pos.x]
dec eax
jns @f
inc eax
@@: test byte[shi+2],0x01
jnz @f
mov [sel.x],eax
@@: mov [pos.x],eax
call check_inv_all
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.right ;///// GO TO NEXT CHAR ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_right: ;///// GO TO NEXT CHAR, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov eax,[pos.x]
inc eax
cmp eax,[columns]
jbe @f
dec eax
@@: test byte[shi+2],0x01
jnz @f
mov [sel.x],eax
@@: mov [pos.x],eax
call check_inv_all
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func 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,[pos.y]
mov ecx,[top_line]
sub eax,edx
jns @f
xor eax,eax
@@: sub ecx,edx
jns @f
xor ecx,ecx
@@: test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func 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,[pos.y]
mov ecx,[top_line]
add eax,edx
add ecx,edx
cmp eax,[lines]
jb @f
mov eax,[lines]
dec eax
@@: test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.home ;///// GO TO LINE START ////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_home: ;///// GO TO LINE START, WITH SELECTION /////////////////
;-----------------------------------------------------------------------------
mov [pos.x],0
test byte[shi+2],0x01
jnz @f
mov [sel.x],0
@@: call check_inv_all
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.end ;///// GO TO LINE END ///////////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_end: ;///// GO TO LINE END, WITH SELECTION ////////////////////
;-----------------------------------------------------------------------------
mov ecx,[pos.y]
call get_line_offset
call get_real_length
mov [pos.x],eax
test byte[shi+2],0x01
jnz @f
mov [sel.x],eax
@@: call check_inv_all
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_home ;///// GO TO PAGE START ///////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_home: ;///// GO TO PAGE START, WITH SELECTION ////////////
;-----------------------------------------------------------------------------
mov eax,[top_line]
mov ecx,eax
test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_end ;///// GO TO PAGE END //////////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_end: ;///// GO TO PAGE END, WITH SELECTION ///////////////
;-----------------------------------------------------------------------------
mov ecx,[top_line]
mov eax,[lines.scr]
cmp eax,[lines]
jle @f
mov eax,[lines]
@@: add eax,ecx
dec eax
test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_init
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_pgup ;///// GO TO DOCUMENT START ///////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgup: ;///// GO TO DOCUMENT START, WITH SELECTION ////////
;-----------------------------------------------------------------------------
xor eax,eax
mov [top_line],eax
mov [pos.y],eax
test byte[shi+2],0x01
jnz @f
mov [sel.y],eax
@@: call check_inv_all.skip_check
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.ctrl_pgdn ;///// GO TO DOCUMENT END /////////////////////////////////
;-----------------------------------------------------------------------------
call clear_selection
 
;-----------------------------------------------------------------------------
key.shift_ctrl_pgdn: ;///// GO TO DOCUMENT END, WITH SELECTION //////////
;-----------------------------------------------------------------------------
mov eax,[lines] ; eax = lines in the file
mov [pos.y],eax
sub eax,[lines.scr] ; eax -= lines on the screen
jns @f
xor eax,eax
@@: mov [top_line],eax
dec [pos.y]
test byte[shi+2],0x01
jnz @f
push [pos.y]
pop [sel.y]
@@: call check_inv_all.skip_check
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc .exit.2
 
mov ecx,[pos.y]
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
lea ebx,[esi+4]
mov ebp,esi
 
call get_real_length
or eax,eax
je .line_up
 
mov ecx,[pos.x]
cmp ecx,eax
jae .line_up
lea edi,[ebx+ecx]
neg ecx
movzx eax,word[ebp]
add ecx,eax;[ebp]
repe scasb
je .line_up
 
mov edi,ebx
mov ecx,[pos.x]
add edi,ecx
lea esi,[edi+1]
neg ecx
movzx eax,word[ebp]
add ecx,eax;[ebp]
dec ecx
rep movsb
mov byte[edi],' '
 
m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
call check_inv_all
mov [modified],1
ret
 
.line_up:
mov eax,[lines]
dec eax
cmp eax,[pos.y]
je .exit
mov edi,AREA_TEMP+4
mov esi,ebx
mov ecx,[pos.x]
rep movsb
mov ecx,[pos.x]
mov [AREA_TEMP],ecx
cmp cx,[ebp]
jbe @f
movzx eax,word[ebp]
sub ecx,eax;[ebp]
sub edi,ecx
mov al,' '
rep stosb
@@: lea esi,[ebx+4]
movzx eax,word[ebp]
add esi,eax;[ebp]
movzx ecx,word[esi-4]
add [AREA_TEMP],ecx
or dword[AREA_TEMP],0x00010000
rep movsb
 
lea ecx,[edi-AREA_TEMP]
 
mov esi,AREA_TEMP
call get_real_length
cmp eax,[columns]
jbe @f
mov [columns],eax
@@:
push ecx
mov edi,AREA_TEMP2
lea esi,[edi+8]
sub esi,ecx
movzx eax,word[ebp]
add esi,eax;[ebp]
; lea eax,[ebp+4]
; add eax,[ebp]
movzx eax,word[ebp]
movzx eax,word[ebp+eax+4]
add esi,eax;[eax]
lea ecx,[esi-4]
sub ecx,ebp
std
cmp esi,edi
jb @f
jz .lp1
mov edi,ebp
add edi,[esp]
lea esi,[ebp+8]
movzx eax,word[esi-8]
add esi,eax;[esi-8]
movzx eax,word[esi-4]
add esi,eax;[esi-4]
mov ecx,AREA_TEMP2
sub ecx,esi
cld
@@: rep movsb
.lp1: pop ecx
mov esi,AREA_TEMP
mov edi,ebp
cld
rep movsb
 
.ok.dec.lines:
dec [lines]
mov eax,[lines]
cmp [pos.y],eax
jb @f
dec eax
mov [pos.y],eax
@@: m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
 
mov [modified],1
.exit.2:
call check_inv_all
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
; INSERT {
key.ins:
;// ... toggle insert/overwrite mode here ...
xor [ins_mode],1
call check_inv_str
ret
; INSERT }
 
;-----------------------------------------------------------------------------
func key.bkspace ;///// DELETE PREVIOUS CHAR OR SELECTION ////////////////////
;-----------------------------------------------------------------------------
call delete_selection
jnc key.del.exit.2
 
mov eax,[pos.x]
dec eax
js .line_up
 
dec [pos.x]
mov ecx,[pos.y]
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
 
mov ebx,eax
call get_real_length
cmp eax,[pos.x]
jae @f
m2m [sel.x],[pos.x]
call check_inv_all
mov [modified],1
ret
 
@@: lea edi,[esi+4+ebx]
mov ecx,ebx
neg ecx
movzx eax,word[esi]
add ecx,eax;[esi]
dec ecx
lea esi,[edi+1]
cld
rep movsb
mov byte[edi],' '
 
m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
call check_inv_str
mov [modified],1
ret
 
.line_up:
cmp [pos.y],0
jne @f
ret
@@: mov ecx,[pos.y]
dec ecx
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
 
mov ebp,esi
lea ebx,[esi+4]
movzx ecx,word[ebp]
@@: cmp byte[ebx+ecx-1],' '
jne @f
dec ecx
jg @b
@@: mov [pos.x],ecx
dec [pos.y]
cld
jmp key.del.line_up
endf
 
;-----------------------------------------------------------------------------
func key.tab ;///// TABULATE /////////////////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
mov eax,[pos.x]
 
mov ecx,eax
add eax,ATABW
and eax,not(ATABW-1)
push eax ' '
sub eax,ecx
.direct:
mov ecx,[pos.y]
call get_line_offset
and dword[esi],not 0x00020000
or dword[esi],0x00010000
 
xchg eax,ecx
 
call get_real_length
cmp eax,[pos.x]
jae @f
mov eax,[pos.x]
@@: movzx edx,word[esi]
sub edx,eax
cmp ecx,edx
jl @f
pushad; esi ecx eax
mov ecx,AREA_TEMP2-10+1
; lea eax,[esi+4]
; add eax,[esi]
movzx eax,word[esi]
lea eax,word[esi+eax+4]
sub ecx,eax
mov edi,AREA_TEMP2
mov esi,AREA_TEMP2-10
std
rep movsb
mov ecx,10
mov al,' '
rep stosb
popad; eax ecx esi
add word[esi],10
jmp @b
@@: lea ebx,[esi+4]
push ecx
; lea edi,[ebx-1]
; add edi,[esi]
movzx edi,word[esi]
lea edi,[ebx+edi-1]
mov esi,edi
sub esi,ecx
lea ecx,[esi+1]
sub ecx,ebx
sub ecx,[pos.x]
std
rep movsb
.ok: pop ecx ;*******
pop eax
rep stosb
cld
pop [pos.x]
lea esi,[ebx-4]
call get_real_length
cmp eax,[pos.x]
jae @f
mov eax,[pos.x]
@@: cmp eax,[columns]
jbe @f
mov [columns],eax
@@: m2m [sel.x],[pos.x]
m2m [sel.y],[pos.y]
call check_inv_all
mov [modified],1
 
.exit:
ret
endf
 
;-----------------------------------------------------------------------------
func key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
;-----------------------------------------------------------------------------
call delete_selection
 
mov ecx,[pos.y]
call get_line_offset
 
mov ebx,[pos.x]
cmp bx,[esi]
jb @f
movzx ebx,word[esi]
dec ebx
jns @f
xor ebx,ebx
@@:
cld
 
mov edi,AREA_TEMP
mov ebp,esi
mov ecx,ebx
inc ecx
@@: dec ecx
jz @f
cmp byte[esi+ecx+4-1],' '
je @b
@@: lea eax,[ecx+10]
or eax,0x00010000
stosd
jecxz @f
push esi
add esi,4
rep movsb
pop esi
@@: mov al,' '
mov ecx,10
rep stosb
 
movzx ecx,word[esi]
sub ecx,ebx;[pos.x]
add esi,ebx;[pos.x]
add esi,4
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 [options],OPTS_AUTOINDENT
jz .lp2
push edi ecx
movzx ecx,word[ebp]
lea edi,[ebp+4]
mov al,' '
repe scasb
mov eax,ecx
pop ecx edi
je .lp2
neg eax
movzx edx,word[ebp]
add eax,edx;[ebp]
dec eax
jmp @f
.lp2: xor eax,eax
@@: mov edx,edi
add edi,4
mov [pos.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-4]
sub eax,edx
or eax,0x00010000
mov [edx],eax
 
lea ecx,[edi-AREA_TEMP]
 
push ecx
mov edi,AREA_TEMP2
lea esi,[edi+4]
sub esi,ecx
movzx ecx,word[ebp]
add esi,ecx;[ebp]
lea ecx,[esi-4]
sub ecx,ebp
std
cmp esi,edi
jb @f
je .lp3
lea esi,[ebp+4]
mov eax,[esp]
lea edi,[esi+eax-4]
movzx ecx,word[ebp]
add esi,ecx;[ebp]
mov ecx,AREA_TEMP2
sub ecx,esi
cld
@@: rep movsb
.lp3: pop ecx
mov esi,AREA_TEMP
mov edi,ebp
cld
rep movsb
 
inc [pos.y]
inc [sel.y]
inc [lines]
 
m2m [sel.x],[pos.x]
 
call check_inv_all
mov [modified],1
 
.exit:
ret
endf
/programs/develop/tinypad/trunk/tp-mouse.asm
0,0 → 1,422
func check_mouse_in_edit_area
mcall 37,1
mov ebx,eax
and ebx,0x0000FFFF
shr eax,16
mov ecx,[top_ofs]
inc ecx
pushd [left_ofs] ATOPH [p_info.client_box.width] ATOPH
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
sub [__rc+0x8],SCRLW+6
imul ecx,[lines.scr],LINEH
dec ecx
add [__rc+0xC],ecx
mov ecx,__rc
call pt_in_rect
ret
endf
 
func get_mouse_event
mcall 37,2
and al,3
mov bl,[ecx]
cmp [ecx],al
mov [ecx],al
jne @f
mov eax,MEV_MOVE
ret
@@: mov bh,al
and ebx,0x0101
cmp bl,bh
je .rb
test al,1
jz @f
mov eax,MEV_LDOWN
ret
@@: mov eax,MEV_LUP
ret
.rb: test al,2
jz @f
mov eax,MEV_RDOWN
ret
@@: mov eax,MEV_RUP
ret
endf
 
mouse_ev dd mouse.l_down,mouse.l_up,mouse.r_down,mouse.r_up,mouse.move
 
mouse:
mov ecx,mst
call get_mouse_event
cmp [bot_mode],0
je @f
mov ah,al
mov al,4
call [bot_dlg_handler]
jmp still
@@: cmp al,MEV_MOVE
jne .no_move
cmp [popup_active],1
je @f
.no_move:
mov [s_status],0
 
push eax
mcall 9,p_info,-1
cmp ax,[p_info.window_stack_position]
pop eax
jne still.skip_write
@@:
cmp [just_from_popup],0
je @f
cmp al,MEV_LUP
jne still.skip_write
@@: mov [mev],al
jmp [mouse_ev+eax*4-4]
 
.move:
mcall 37,1
movsx ebx,ax
sar eax,16
cmp [body_capt],0
jge .check_body.2
cmp [vscrl_capt],0
jge .check_vscroll.2
cmp [hscrl_capt],0
jge .check_hscroll.2
 
cmp [do_not_draw],0
jne still.skip_write
mov eax,[mi_cur]
call get_active_menu_item
cmp eax,[mi_cur]
je still.skip_write
push [mi_cur]
cmp [popup_active],0
je @f
mov [mi_cur],eax
@@: call draw_main_menu
pop [mi_cur]
cmp [popup_active],0
je still.skip_write
; mcall 18,2,[h_popup]
mov ecx,[mi_cur]
or ecx,ecx
js still.skip_write
mov eax,[main_menu.popups+ecx*4-4]
mov edx,main_menu
call dword[main_menu.onshow+ecx*4-4]
call setup_main_menu_popup
mcall 60,2,[h_popup],POPUP_STACK,4
; mcall 51,1,popup_thread_start,POPUP_STACK
 
jmp still.skip_write
 
 
.r_down:
@@: cmp [popup_active],0
je @f
mcall 5,1
jmp @b
@@: cmp [mouse_captured],0
jne still.skip_write
call check_mouse_in_edit_area
jnc still.skip_write
mcall 37,0
mov [popup_edit+POPUP.pos],eax
@@: mcall 37,2
cmp eax,ebx
jnz @f
mcall 5,1
jmp @b
@@: and [mst],0xFD
call onshow.edit
mov dword[POPUP_STACK],popup_edit
mcall 51,1,popup_thread_start,POPUP_STACK
mov [h_popup],eax
jmp still.skip_write
 
.r_up:
jmp still.skip_write
 
.l_down:
call check_mouse_in_edit_area
jnc .check_vscroll
mov [mouse_captured],1
mov [body_capt],1
 
call clear_selection
 
.check_body.2:
sub eax,[left_ofs]
sub ebx,[top_ofs]
dec ebx
; sub ebx,[__rc+0x4]
push eax
mov eax,ebx
cdq;xor edx,edx
mov ecx,LINEH
idiv ecx
@@: add eax,[top_line]
mov ebx,eax
pop eax
cdq;xor edx,edx
mov ecx,6
idiv ecx
@@: add eax,[left_col]
 
cmp eax,[columns]
jl @f
mov eax,[columns]
@@: cmp ebx,[lines]
jl @f
mov ebx,[lines]
dec ebx
@@:
cmp [pos.x],eax
jne .change_cur_pos
cmp [pos.y],ebx
je still.skip_write
 
.change_cur_pos:
mov [pos.x],eax
mov eax,[pos.y]
mov [pos.y],ebx
call check_cur_vis_inv
jc .check_ldown
; cmp eax,ebx
; je @f
; push ebx
; mov ebx,eax
; call drawfile.ex
; pop eax
; @@: mov ebx,eax
call draw_file.ex
.check_ldown:
jmp still
 
.check_vscroll:
mov ecx,[p_info.client_box.width]
sub ecx,SCRLW-2
pushd ecx [top_ofs] ecx [bot_ofs]
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
add [__rc+0x8],SCRLW-1;!!!!!!!!!!!!!!-2
add [__rc+0x4],SCRLW;!!!!!!!!!!!!!!+1
sub [__rc+0xC],SCRLW*2+3
mov ecx,__rc
call pt_in_rect
jnc .check_hscroll
 
.check_vscroll.2:
sub ebx,[top_ofs]
sub ebx,SCRLW;!!!!!!!!!!!!!!+1
; sub ebx,[__rc+0x4]
cmp [vscrl_capt],0
jge .vcaptured
mov eax,[vscrl_top]
cmp ebx,eax
jb .center_vcapture
add eax,[vscrl_size]
cmp ebx,eax
jae .center_vcapture
mov eax,ebx
sub eax,[vscrl_top]
dec eax
mov [vscrl_capt],eax
dec ebx
jmp .vcaptured
.center_vcapture:
mov eax,[vscrl_size]
shr eax,1
mov [vscrl_capt],eax
.vcaptured:
sub ebx,[vscrl_capt]
jns @f
xor ebx,ebx
@@: mov [mouse_captured],1
mov eax,[bot_ofs]
sub eax,[top_ofs]
sub eax,[vscrl_size]
sub eax,SCRLW*3-2
cmp eax,ebx
jge @f
mov ebx,eax
@@:
mov [vscrl_top],ebx
mov eax,[lines]
sub eax,[lines.scr]
imul ebx
mov ebx,[bot_ofs]
sub ebx,[top_ofs]
sub ebx,SCRLW*3-2 ;**
sub ebx,[vscrl_size]
idiv ebx
cmp eax,[top_line]
je still.skip_write
mov [top_line],eax
call check_bottom_right
call draw_file
jmp still.skip_write
 
.check_hscroll:
pushd (5+SCRLW+1) [bot_ofs] [p_info.box.width] [bot_ofs]
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
add [__rc+0x8],-SCRLW*2-10-1
add [__rc+0x4],-SCRLW
add [__rc+0xC],-2
mov ecx,__rc
call pt_in_rect
jnc .check_main_menu
 
.check_hscroll.2:
mov ebx,eax
sub ebx,(5+SCRLW+1)
; sub ebx,[__rc+0x0]
cmp [hscrl_capt],0
jge .hcaptured
mov eax,[hscrl_top]
cmp ebx,eax
jl .center_hcapture
add eax,[hscrl_size]
cmp ebx,eax
jge .center_hcapture
mov eax,ebx
sub eax,[hscrl_top]
dec eax
mov [hscrl_capt],eax
dec ebx
jmp .hcaptured
.center_hcapture:
mov eax,[hscrl_size]
shr eax,1
mov [hscrl_capt],eax
.hcaptured:
sub ebx,[hscrl_capt]
jns @f
xor ebx,ebx
@@: mov [mouse_captured],1
mov eax,[p_info.box.width]
sub eax,[hscrl_size]
sub eax,SCRLW*3+10+1
cmp eax,ebx
jge @f
mov ebx,eax
@@:
mov [hscrl_top],ebx
mov eax,[columns]
sub eax,[columns.scr]
imul ebx
mov ebx,[p_info.box.width]
sub ebx,SCRLW*3+10+1 ;**
sub ebx,[hscrl_size]
idiv ebx
cmp eax,[left_col]
je still.skip_write
mov [left_col],eax
call check_bottom_right
call draw_file
jmp still.skip_write
 
.check_main_menu:
cmp [do_not_draw],0
jne .capture_off
 
@@: mcall 37,2
test eax,0x01
jz @f
mcall 5,1
jmp @b
@@: and [mst],0xFE
 
cmp [mi_cur],0
jle .capture_off
mov ecx,[mi_cur]
mov eax,[main_menu.popups+ecx*4-4]
mov edx,main_menu
call dword[main_menu.onshow+ecx*4-4]
call setup_main_menu_popup
mcall 51,1,popup_thread_start,POPUP_STACK
mov [h_popup],eax
 
.l_up:
.capture_off:
or eax,-1
mov [vscrl_capt],eax
mov [hscrl_capt],eax
mov [body_capt],eax
mov [mouse_captured],0
mov [just_from_popup],0
jmp still.skip_write
 
 
func setup_main_menu_popup
mov ebx,[p_info.box.left]
add ebx,[p_info.client_box.left]
@@: dec ecx
jz @f
add edx,8+1
movzx esi,byte[edx-1]
add edx,esi
jmp @b
@@: movzx ecx,word[edx+2]
add ebx,ecx
 
mov [eax+POPUP.x],bx
mov ebx,[p_info.box.top]
add ebx,[p_info.client_box.top]
add ebx,ATOPH-1
mov [eax+POPUP.y],bx
mov [POPUP_STACK],eax
ret
endf
 
onshow:
 
.file:
or byte[popup_file+3],0x01
cmp [f_info.length],0
jne @f
and byte[popup_file+3],0xFE
@@: ret
 
.edit:
or byte[popup_edit+2],0x01
cmp [copy_size],0
jne @f
and byte[popup_edit+2],0xFE
@@: or dword[popup_edit+0],0x01000101
cmp [sel.selected],0
jne @f
and dword[popup_edit+0],0xFEFFFEFE
@@: ret
 
.search:
mov byte[popup_search+0],0
;mov byte[popup_search+4],0
ret
.run:
ret
.options:
mov word[popup_options+0],0
mov byte[popup_options+5],0
or byte[popup_options+2],0x02
test [options],OPTS_SECURESEL
jnz @f
and byte[popup_options+2],0xFD
@@: or byte[popup_options+3],0x02
test [options],OPTS_AUTOBRACES
jnz @f
and byte[popup_options+3],0xFD
@@: or byte[popup_options+4],0x02
test [options],OPTS_AUTOINDENT
jnz @f
and byte[popup_options+4],0xFD
@@: or byte[popup_options+6],0x02
test [options],OPTS_OPTIMSAVE
jnz @f
and byte[popup_options+6],0xFD
@@: or byte[popup_options+8],0x02
test [options],OPTS_LINENUMS
jnz @f
and byte[popup_options+8],0xFD
@@: ret
/programs/develop/tinypad/trunk/tp-popup.asm
0,0 → 1,321
;POP_WIDTH = (popup_text.max_title+popup_text.max_accel+6)*6
POP_IHEIGHT = 16
;POP_HEIGHT = popup_text.cnt_item*POP_IHEIGHT+popup_text.cnt_sep*4+4
 
func calc_middle
shr eax,1
shr ebx,1
and eax,0x007F7F7F
and ebx,0x007F7F7F
add eax,ebx
ret
endf
 
func calc_3d_colors
pushad
m2m [cl_3d_normal],[sc.work]
m2m [cl_3d_inset],[sc.work_graph]
push [cl_3d_normal]
add byte[esp],48
jnc @f
mov byte[esp],255
@@: add byte[esp+1],48
jnc @f
mov byte[esp+1],255
@@: add byte[esp+2],48
jnc @f
mov byte[esp+2],255
@@: pop [cl_3d_outset]
mov eax,[cl_3d_inset]
mov ebx,[cl_3d_outset]
call calc_middle
mov [cl_3d_pushed],eax
mov eax,[cl_3d_normal]
mov ebx,[sc.work_text]
call calc_middle
mov [cl_3d_grayed],eax
popad
ret
endf
 
func draw_3d_panel ; x,y,w,h
cmp dword[esp+8],4
jl .exit
cmp dword[esp+4],4
jl .exit
mov ebx,[esp+16-2]
mov bx,[esp+8]
inc ebx
mov ecx,[esp+12-2]
mov cx,[esp+4]
inc ecx
mcall 13,,,[cl_3d_normal];0x00EEEEEE;[sc.work]
dec ebx
add bx,[esp+16]
mov cx,[esp+12]
mcall 38,,,[cl_3d_inset];0x006382BF;[sc.work_text]
add ecx,[esp+4-2]
add cx,[esp+4]
mcall
mov bx,[esp+16]
mov ecx,[esp+12-2]
mov cx,[esp+4]
add cx,[esp+12]
mcall
add ebx,[esp+8-2]
add bx,[esp+8]
mcall
mov ebx,[esp+16-2]
mov bx,[esp+8]
add bx,[esp+16]
add ebx,1*65536-1
mov ecx,[esp+12-2]
mov cx,[esp+12]
add ecx,0x00010001
mcall ,,,[cl_3d_outset]
mov bx,[esp+16]
inc ebx
mov ecx,[esp+12-2]
mov cx,[esp+4]
add cx,[esp+12]
add ecx,2*65536-1
mcall
.exit:
ret 4*4
endf
 
popup_thread_start:
mov [popup_active],1
mov [pi_cur],0
mov ebp,[esp]
mcall 14
movzx ebx,ax
shr eax,16
movzx ecx,[ebp+POPUP.x]
add cx,[ebp+POPUP.width]
cmp ecx,eax
jle @f
mov cx,[ebp+POPUP.width]
sub [ebp+POPUP.x],cx
@@: movzx ecx,[ebp+POPUP.y]
add cx,[ebp+POPUP.height]
cmp ecx,ebx
jle @f
mov cx,[ebp+POPUP.height]
sub [ebp+POPUP.y],cx
@@: mcall 40,01100111b ; ipc mouse button key redraw
cmp [mi_cur],0
jl .2
sub esp,32-16
push 0 0 8 0
mcall 60,1,esp,32
.2: call draw_popup_wnd
 
still_popup:
cmp [main_closed],1
je close_popup
mcall 10
cmp eax,1
je popup_thread_start.2
cmp eax,2
je key_popup
cmp eax,3
je button_popup
cmp eax,6
je mouse_popup
cmp eax,7
jne still_popup
 
mov ebp,[POPUP_STACK];-32+12+4]
mov dword[POPUP_STACK-32+4],8
movzx ebx,[ebp+POPUP.x]
movzx ecx,[ebp+POPUP.y]
movzx edx,[ebp+POPUP.width]
movzx esi,[ebp+POPUP.height]
mcall 67
; call draw_popup_wnd
jmp still_popup
 
mouse_popup:
mov ecx,mst2
call get_mouse_event
cmp al,MEV_LDOWN
je check_popup_click
cmp al,MEV_MOVE
je check_popup_move
 
mcall 9,p_info2,-1
cmp ax,[p_info2.window_stack_position]
jne close_popup
 
jmp still_popup
 
check_popup_click:
mov eax,[pi_cur]
or al,al
js close_popup
jz still_popup
mov ebx,[ebp+POPUP.actions]
mov [just_from_popup],1
call dword[ebx+eax*4-4];dword[popup_text.actions+eax*4-4]
inc [just_from_popup]
jmp close_popup
 
check_popup_move:
mov eax,[pi_cur]
call get_active_popup_item
cmp eax,[pi_cur]
je still_popup
call draw_popup_wnd
jmp still_popup
 
key_popup:
mcall ;2
cmp ah,27
jne still_popup
 
button_popup:
mcall 17
 
close_popup:
mcall 18,3,[p_info.PID]
mov [popup_active],0
mcall -1
 
func draw_popup_wnd
mcall 12,1
 
; mcall 48,3,sc,sizeof.system_colors
; call calc_3d_colors
 
; mov ebx,[p_pos]
; mov ecx,[p_pos-2]
; mov bx,POP_WIDTH
; mov cx,POP_HEIGHT
mov ebx,dword[ebp+POPUP.x-2]
mov bx,[ebp+POPUP.width]
mov ecx,dword[ebp+POPUP.y-2]
mov cx,[ebp+POPUP.height]
mcall 0,,,0x01000000,0x01000000
 
movzx ebx,bx
movzx ecx,cx
pushd 0 0 ebx ecx ;POP_WIDTH POP_HEIGHT
call draw_3d_panel
 
mov [pi_sel],0
; mcall 37,1
; movsx ebx,ax
; sar eax,16
; mov [c_pos.x],eax
; mov [c_pos.y],ebx
 
mov eax,4
mpack ebx,3*6,3
mov ecx,[sc.work_text]
mov edx,[ebp+POPUP.data];popup_text.data
@@: inc [pi_sel]
inc edx
movzx esi,byte[edx-1]
cmp byte[edx],'-'
jne .lp1
pushad
mov ecx,ebx
shl ecx,16
mov cx,bx
movzx ebx,[ebp+POPUP.width]
add ebx,0x00010000-1
; mpack ebx,1,POP_WIDTH-1
add ecx,0x00010001
mcall 38,,,[cl_3d_inset];0x006382BF;[sc.work_text]
add ecx,0x00010001
mcall ,,,[cl_3d_outset];0x00FFFFFF
popad
add ebx,4
jmp .lp2
.lp1: mov edi,[pi_sel]
cmp edi,[pi_cur]
jne .lp3
test byte[ebp+edi-1],0x01 ; byte[popup_text+edi-1],0x01
jz .lp3
pushad
movzx ecx,bx
shl ecx,16
mov cl,POP_IHEIGHT-1
movzx ebx,[ebp+POPUP.width]
add ebx,0x00010000-1
; mpack ebx,1,POP_WIDTH-1
mcall 13,,,[cl_3d_pushed];0x00A3B8CC
rol ecx,16
mov ax,cx
rol ecx,16
mov cx,ax
mcall 38,,,[cl_3d_inset];0x006382BF
add ecx,(POP_IHEIGHT-1)*65536+POP_IHEIGHT-1
mcall ,,,[cl_3d_outset];0x00FFFFFF
popad
.lp3: add ebx,(POP_IHEIGHT-7)/2
 
pushad
test byte[ebp+edi-1],0x02
jz .lp8
movzx ecx,bx
shl ecx,16
mov cx,bx
shr ebx,16
push bx
shl ebx,16
pop bx
add ecx,0x00040003
sub ebx,0x000A000B
mcall 38,,,[sc.work_text]
add ecx,0x00010001
mcall
add ebx,4
sub ecx,2
mcall
sub ecx,0x00010001
mcall
.lp8: popad
 
mov ecx,[sc.work_text];0x00000000
test byte[ebp+edi-1],0x01 ; byte[popup_text+edi-1],0x01
jnz .lp5
add ebx,0x00010001
mov ecx,[cl_3d_outset]
mcall
sub ebx,0x00010001
mov ecx,[cl_3d_inset]
;mov ecx,[sc.grab_text];0x007F7F7F
.lp5: mcall
push ebx
add edx,esi
inc edx
movzx esi,byte[edx-1]
add ebx,[ebp+POPUP.acc_ofs] ; ((popup_text.max_title+2)*6-1)*65536
cmp edi,[pi_cur]
je .lp4
mov ecx,[cl_3d_inset];0x006382BF
.lp4: test byte[ebp+edi-1],0x01 ; byte[popup_text+edi-1],0x01
jnz .lp6
add ebx,0x00010001
mov ecx,[cl_3d_outset]
mcall
sub ebx,0x00010001
mov ecx,[cl_3d_inset]
;mov ecx,[sc.grab_text];0x007F7F7F
.lp6: mcall
pop ebx
add ebx,POP_IHEIGHT-(POP_IHEIGHT-7)/2
.lp2: add edx,esi
cmp byte[edx],0
jne @b
.exit:
mcall 12,2
ret
endf
 
pi_sel dd ?
pi_cur dd ?
p_pos dd ?
popup_active db 0
/programs/develop/tinypad/trunk/tp-tbox.asm
0,0 → 1,390
struct TBOX
x dw ?
width dw ?
y dw ?
height dw ?
sel.x db ?
pos.x db ?
ofs.x db ?
length db ?
text rb 255
ends
 
virtual at ebp
tbox TBOX
end virtual
 
tb.pos.x db ?
tb.sel.x db ?
tb.sel.selected db ?
 
func textbox.get_width
push ebx edx
movzx eax,[tbox.width-2]
add eax,-6
xor edx,edx
mov ebx,6
div ebx
movzx ebx,[tbox.length]
cmp eax,ebx
jle @f
mov eax,ebx
@@: pop edx ebx
ret
endf
 
func textbox.delete_selection
cmp [tb.sel.selected],0
je .exit.2
pushad
movzx ecx,[tbox.length]
sub cl,[tb.sel.x]
lea eax,[tbox.text]
movzx esi,[tb.pos.x]
movzx edi,[tb.sel.x]
add esi,eax
add edi,eax
mov eax,esi
sub eax,edi
sub [tbox.length],al
cld
rep movsb
 
.exit:
mov al,[tb.sel.x]
mov [tbox.pos.x],al
mov [tbox.sel.x],al
popad
clc
ret
 
.exit.2:
stc
ret
endf
 
func textbox.draw ; TBOX* ebp
call textbox.get_width
movzx ebx,[tbox.pos.x]
sub bl,[tbox.ofs.x]
sub ebx,eax
jle @f
mov bl,[tbox.pos.x]
sub bl,al
mov [tbox.ofs.x],bl
@@:
mov [tb.sel.selected],0
mov al,[tbox.pos.x]
mov ah,[tbox.sel.x]
cmp al,ah
je @f
inc [tb.sel.selected]
ja @f
xchg al,ah
@@: mov [tb.pos.x],al
mov [tb.sel.x],ah
 
mcall 13,dword[tbox.x],dword[tbox.y],[color_tbl+4*5];[sc.work]
call draw_framerect
 
call textbox.get_width
mov esi,eax
mov edi,eax
 
cmp ebp,[focused_tb]
je @f
mov ebx,dword[tbox.x]
mov bx,[tbox.y+2]
movzx eax,[tbox.height-2]
shr eax,1
add eax,4*65536-4
add ebx,eax
lea edx,[tbox.text]
; movzx esi,[tbox.length]
mcall 4,,[color_tbl+4*0];[sc.work_text]
ret
 
@@: movzx eax,[tb.pos.x]
cmp al,[tb.sel.x]
je @f
sub al,[tbox.ofs.x]
jz @f
movzx ebx,[tb.sel.x]
sub bl,[tbox.ofs.x]
jge .lp1
xor ebx,ebx
.lp1: push eax ebx
sub eax,ebx
mov ecx,edi
sub ecx,ebx
cmp eax,ecx
jbe .lp2
mov eax,ecx
.lp2: imul eax,6
imul ebx,6
movzx ecx,[tbox.x+2]
add ecx,3
; sub eax,ebx
add ebx,ecx
shl ebx,16
add ebx,eax
movzx ecx,[tbox.height-2]
shr ecx,1
add cx,[tbox.y+2]
shl ecx,16
add ecx,-5*65536+10
mcall 13,,,[color_tbl+4*7];0x0000007F
 
mov esi,[esp]
lea edx,[tbox.text]
movzx eax,[tbox.ofs.x]
add edx,eax
mov ebx,dword[tbox.x]
mov bx,[tbox.y+2]
movzx eax,[tbox.height-2]
shr eax,1
add eax,4*65536-4
add ebx,eax
mov eax,4
or esi,esi
jz .lp3
mcall ,,[color_tbl+4*0];[sc.work_text]
.lp3: sub edi,esi
jnz .lp4
add esp,8
jmp .exit
.lp4:
add edx,esi
imul esi,6*65536
add ebx,esi
pop ecx esi
sub esi,ecx
cmp esi,edi
jbe .lp5
mov esi,edi
.lp5:
mcall ,,[color_tbl+4*6];0x00FFFFFF
sub edi,esi
jz .exit
add edx,esi
imul esi,6*65536
add ebx,esi
lea ecx,[tbox.text]
; sub ecx,edx
; add edi,ecx
mcall ,,[color_tbl+4*0],,edi;[sc.work_text],,edi
jmp .exit
 
@@: lea edx,[tbox.text]
movzx eax,[tbox.ofs.x]
add edx,eax
mov ebx,dword[tbox.x]
mov bx,[tbox.y+2]
movzx eax,[tbox.height-2]
shr eax,1
add eax,4*65536-4
add ebx,eax
movzx eax,[tbox.ofs.x]
call textbox.get_width
mov esi,eax
mcall 4,,[color_tbl+4*0];[sc.work_text]
 
.exit:
movzx ebx,[tbox.pos.x]
movzx eax,[tbox.ofs.x]
sub ebx,eax
imul ebx,6
movzx eax,[tbox.x+2]
add eax,3
add ebx,eax
push bx
shl ebx,16
pop bx
movzx ecx,[tbox.height-2]
shr ecx,1
add cx,[tbox.y+2]
push cx
shl ecx,16
pop cx
add ecx,-5*65536+4
mcall 38,,,0x01000000
add ebx,0x00010001
mcall
ret
endf
 
func textbox.key
mov ebp,[focused_tb]
mov esi,accel_table_textbox
.acc: cmp ebx,[esi]
jne @f
call dword[esi+4]
jmp .exit.2
@@: add esi,8
cmp byte[esi],0
jne .acc
 
test byte[shi+2],0x06
jnz .exit
cmp [tbox.length],255
je .exit
 
movzx eax,[chr]
movzx eax,[eax+key0]
or al,al
jz .exit
mov al,[eax+key1]
cmp [tb_casesen],0
je @f
cmp al,$60
jle @f
add al,[add_table-$60+eax]
@@:
call textbox.delete_selection
 
mov ecx,255
sub cl,[tbox.pos.x]
lea edi,[tbox.text]
add edi,255
lea esi,[edi-1]
std
rep movsb
stosb
cld
inc [tbox.length]
call key.tb.right
 
.exit.2:
call textbox.draw
.exit:
ret
endf
 
textbox.mouse:
ret
 
func key.tb.bkspace
call textbox.delete_selection
jnc @f
 
cmp [tbox.pos.x],0
je @f
call key.tb.left
jmp key.tb.del.direct
 
@@: ret
endf
 
func key.tb.home
xor al,al
mov [tbox.pos.x],al
mov [tbox.sel.x],al
mov [tbox.ofs.x],al
ret
endf
 
func key.tb.left
mov al,[tbox.pos.x]
mov [tbox.sel.x],al
dec al
js @f
mov [tbox.pos.x],al
mov [tbox.sel.x],al
cmp [tbox.ofs.x],al
jl @f
sub [tbox.ofs.x],8
jge @f
mov [tbox.ofs.x],0
@@: ret
endf
 
func key.tb.right
call textbox.get_width
mov bl,[tbox.pos.x]
mov [tbox.sel.x],bl
inc bl
cmp bl,[tbox.length]
ja @f
mov [tbox.pos.x],bl
mov [tbox.sel.x],bl
sub bl,[tbox.ofs.x]
cmp bl,al
jbe @f
inc [tbox.ofs.x]
@@: ret
endf
 
func key.tb.end
call textbox.get_width
movzx ebx,[tbox.length]
mov [tbox.pos.x],bl
mov [tbox.sel.x],bl
sub ebx,eax
jge @f
xor bl,bl
@@: mov [tbox.ofs.x],bl
ret
endf
 
func key.tb.del
call textbox.delete_selection
jnc @f
.direct:
movzx ecx,[tbox.length]
sub cl,[tbox.pos.x]
jz @f
lea eax,[tbox.text]
movzx edi,[tbox.pos.x]
add edi,eax
lea esi,[edi+1]
dec [tbox.length]
cld
rep movsb
 
@@: ret
endf
 
func key.tb.shift_home
xor al,al
mov [tbox.pos.x],al
mov [tbox.ofs.x],al
ret
endf
 
func key.tb.shift_left
mov al,[tbox.pos.x]
dec al
js @f
mov [tbox.pos.x],al
cmp [tbox.ofs.x],al
jl @f
sub [tbox.ofs.x],8
jge @f
mov [tbox.ofs.x],0
@@: ret
endf
 
func key.tb.shift_right
call textbox.get_width
mov bl,[tbox.pos.x]
inc bl
cmp bl,[tbox.length]
ja @f
mov [tbox.pos.x],bl
sub bl,[tbox.ofs.x]
cmp bl,al
jbe @f
inc [tbox.ofs.x]
@@: ret
endf
 
func key.tb.shift_end
call textbox.get_width
movzx ebx,[tbox.length]
mov [tbox.pos.x],bl
sub ebx,eax
jge @f
xor bl,bl
@@: mov [tbox.ofs.x],bl
ret
endf