*added OptionBox

*temporary links to editbox and checkbox (..\..\..\develop\examples...) for rdsave, run, scrshoot
*optimised circle

git-svn-id: svn://kolibrios.org@353 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2007-02-16 02:22:14 +00:00
parent 3ad5b727b9
commit fcf5e6d6b9
14 changed files with 567 additions and 3164 deletions

View File

@ -0,0 +1,2 @@
@fasm circle.asm circle
@pause

View File

@ -1,4 +0,0 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm circle.asm circle
@pause

View File

@ -1,4 +0,0 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm circle.asm circle
@pause

View File

@ -16,7 +16,6 @@ use32
dd 0x1000 ; esp dd 0x1000 ; esp
dd 0x00000000 ; reserved=no extended header dd 0x00000000 ; reserved=no extended header
include 'lang.inc'
include 'macros.inc' include 'macros.inc'
@ -24,7 +23,7 @@ include 'macros.inc'
START: ; start of execution START: ; start of execution
call shape_window ; function for shaping call shape_window ; function for shaping
red:
call draw_window ; at first, draw the window call draw_window ; at first, draw the window
still: still:
@ -32,32 +31,24 @@ still:
mov eax,10 ; wait here for event mov eax,10 ; wait here for event
int 0x40 int 0x40
cmp eax,1 ; redraw request ? dec eax ; redraw request ?
je red jz red
cmp eax,2 ; key in buffer ? dec eax ; key in buffer ?
je key jz key
cmp eax,3 ; button in buffer ?
je button
jmp still button:
mov al,17 ; get id
red: ; redraw
call draw_window
jmp still
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
button: ; button
mov eax,17 ; get id
int 0x40 int 0x40
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jne noclose jne noclose
mov eax,-1 ; close this program or eax,-1 ; close this program
int 0x40 int 0x40
key: ; key
mov al,2 ; just read it and ignore
int 0x40
jmp still
noclose: noclose:
jmp still jmp still
@ -130,7 +121,7 @@ draw_window:
int 0x40 int 0x40
; DRAW WINDOW ; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536 ; [x start] *65536 + [x size] mov ebx,100*65536 ; [x start] *65536 + [x size]
mov ecx,100*65536 ; [y start] *65536 + [y size] mov ecx,100*65536 ; [y start] *65536 + [y size]
mov bx,word [x_size] mov bx,word [x_size]

View File

@ -0,0 +1,2 @@
@fasm optxampl.asm optxample
@pause

View File

@ -0,0 +1,269 @@
; new application structure
macro meos_app_start
{
use32
org 0x0
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
dd 0x0
}
MEOS_APP_START fix meos_app_start
macro code
{
__start:
}
CODE fix code
macro data
{
__data:
}
DATA fix data
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
macro mov arg1,arg2
{
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 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
.slot_state dw ? ; +50
dw ? ; +52 - reserved
.client_left dd ? ; +54
.client_top dd ? ; +58
.client_width dd ? ; +62
.client_height dd ? ; +66
.wnd_state db ? ; +70
rb (1024-71)
}
struct process_information
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
; constants
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b

View File

@ -0,0 +1,112 @@
;
;OptionBox for MenuetOS
;
;by Harald Weber
;kitemaster@gmx.at
;
;16.02.07 Heavyiorn - optimizations for kolibri system functions
;
;######### USAGE ############
;include "optionbox.inc"
;
;//in end of draw_window procedure
;draw_optionboxes:
; mov eax, [pos_x] shl 16 + [pos_y]
; mov cl, buttonid
; mov edx, Text ;pointer to text beginning
;call optionbox
;
;
;Text db 'Optionbox Text',0
;
;//for more info see optxampl.asm
;##########################
optionbox:
mov [optionbox_pos_y],ax
shr eax,16
mov [optionbox_pos_x],ax
mov [optionbox_text],edx
mov [optionbox_id],cl
;######### Draw Checkbox ########
optionbox_draw:
mov eax, 13
mov bx, [optionbox_pos_x]
shl ebx, 16
add bx, 11
mov cx, [optionbox_pos_y]
shl ecx, 16
add cx, 11
mov edx,[sc.work_text]
int 0x40
mov edx,[sc.work]
add ebx, 1 shl 16 - 2
add ecx, 1 shl 16 -2
int 0x40
;######### Draw Hidden Button ######
optionbox_hid_button:
mov eax,8
mov bx,[optionbox_pos_x]
sub bx,1
shl ebx,16
mov bx,13
mov cx,[optionbox_pos_y]
sub cx,1
shl ecx,16
mov cx,13
mov dl,[optionbox_id] ;buttonid
or edx,0x60000000 ;button in invisible without frame
int 0x40
;######### Draw X #######
optionbox_x_draw:
mov al,[optionbox_id]
cmp [optionbox_checked],al
jne optionbox_dis
mov eax, 13
mov bx, [optionbox_pos_x]
add bx, 3
shl ebx, 16
add bx, 5
mov cx, [optionbox_pos_y]
add cx, 3
shl ecx, 16
add cx, 5
mov edx,[sc.work_text]
int 0x40
optionbox_dis:
;######### Checkbox Text #####
optionbox_draw_text:
mov eax,4 ; function 4 : write text to window
mov bx,[optionbox_pos_x]
add bx, 14
shl ebx,16
mov bx,[optionbox_pos_y]
add bx, 2 ; [x start] *65536 + [y start]
mov ecx,[sc.work_text] ; color of text RRGGBB
or ecx,0x80000000
mov edx,[optionbox_text] ; pointer to text beginning
int 0x40
ret
;######### Set OptionBox #####
set_optionbox:
mov [optionbox_checked],ah
call draw_optionboxes
ret
;########## Data Area ########
optionbox_pos_x dw ?
optionbox_pos_y dw ?
optionbox_text dd ?
optionbox_checked db ?
optionbox_id db ?

View File

@ -0,0 +1,165 @@
;
; EXAMPLE APPLICATION
;
; Compile with FASM for Menuet
;
include 'macros.inc'
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
START: ; start of execution
red:
call draw_window
still:
push 10 ; wait here for event
pop eax
int 0x40
dec eax ; redraw request ?
jz red
dec eax ; key in buffer ?
jz key
button: ; button
mov al,17 ; get id
int 0x40
cmp ah,2
je button2
cmp ah,3
je button3
cmp ah,4
je button4
cmp ah,5
je button5
cmp ah,1 ; button id=1 ?
jne noclose
or eax,-1 ; close this program
int 0x40
noclose:
jmp still
button2: ;option 1
call set_optionbox
jmp still
button3: ;option 2
call set_optionbox
jmp still
button4: ;option 3
call set_optionbox
jmp still
button5:
mov eax,4 ; function 4 : write text to window
mov ebx,170*65536+35 ; [x start] *65536 + [y start]
mov ecx,[sc.work_button_text] ; font 1 & color ( 0xF0RRGGBB )
mov edx,options-1
add dl, [optionbox_checked] ; pointer to text beginning
mov esi,1 ; text length
int 0x40
jmp still
key: ; key
mov al,2 ; just read it and ignore
int 0x40
jmp still
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
int 0x40
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+300 ; [x start] *65536 + [x size]
mov ecx,100*65536+120 ; [y start] *65536 + [y size]
mov edx,[sc.work] ; color of work area RRGGBB,8->color gl
or edx,0x33000000
mov edi,header ; WINDOW LABEL
int 0x40
mov eax,8 ; function 8 : define and draw button
mov ebx,165*65536+15 ; [x start] *65536 + [x size]
mov ecx,30*65536+15 ; [y start] *65536 + [y size]
mov edx,5 ; button id
mov esi,[sc.work_button] ; button color RRGGBB
int 0x40
draw_optionboxes:
;draw optionbox1
mov eax, 45 shl 16 + 20 ; [x start] shl 16 + [y start]
mov cl, 2 ; button id
mov edx, optiontext1 ; pointer to text beginning
call optionbox
;draw optionbox2
mov eax, 45 shl 16 + 40 ; [x start] shl 16 + [y start]
mov cl, 3 ; button id
mov edx, optiontext2 ; pointer to text beginning
call optionbox
;draw optionbox3
mov eax, 45 shl 16 + 60 ; [x start] shl 16 + [y start]
mov cl, 4 ; button id
mov edx, optiontext3 ; pointer to text beginning
call optionbox
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
include "optbox.inc"
; DATA AREA
optiontext1: db 'OptionBox1',0
optiontext2: db 'OptionBox2',0
optiontext3: db 'OptionBox3',0
options: db '0123'
header db 'OptionBox example',0
I_END:
sc system_colors

View File

@ -1,196 +0,0 @@
macro use_check_box
{
ch_text_margin=3
ch_size=10
ch_left equ [edi]
ch_top equ [edi+2]
ch_color equ [edi+4]
ch_border_color equ [edi+8]
ch_text_color equ [edi+12]
ch_text_ptr equ [edi+16]
ch_flags equ [edi+20]
check_box:
.draw:
pusha
mov eax,38
mov bx,ch_left
push bx
shl ebx,16
pop bx
mov cx,ch_top
push cx
shl ecx,16
pop cx
push cx
add cx,ch_size
mov edx,ch_border_color
int 0x40
push bx
add bx,ch_size
ror ebx,16
add bx,ch_size
int 0x40
pop bx
pop cx
int 0x40
add cx,ch_size
push cx
shl ecx,16
pop cx
int 0x40
mov eax,13
mov bx,ch_left
inc bx
shl ebx,16
mov bx,ch_size
dec bx
push bx
mov cx,ch_top
inc cx
shl ecx,16
pop cx
mov edx,ch_color
int 0x40
bt dword ch_flags,1
jnc @f
call .draw_ch
@@:
call .get_text_n
mov bx,ch_left
add bx,(ch_size+ch_text_margin)
shl ebx,16
mov bx,ch_top
add bx,(ch_size-9+2)
mov ecx,ch_text_color
mov eax,4
int 0x40
popa
ret
.get_text_n:
push eax
xor esi,esi
mov edx,ch_text_ptr
@@:
mov ah,[edx+esi]
inc esi
test ah,ah
jnz @b
dec esi
pop eax
ret
.clear_ch:
mov edx,ch_color
jmp @f
.draw_ch:
mov edx,ch_border_color
@@:
mov bx,ch_left
add bx,(ch_size/3)
shl ebx,16
mov bx,(ch_size/2)
push bx
mov cx,ch_top
add cx,(ch_size/3)
shl ecx,16
pop cx
mov eax,13
int 0x40
ret
.mouse:
pusha
mov eax,37
mov ebx,2
int 0x40
bt eax,0
jc @f
btr dword ch_flags,2
popa
ret
@@:
bts dword ch_flags,2
jc .mouse_end
call .get_text_n
imul esi,6
add si,ch_text_margin
mov eax,37
xor ebx,ebx
inc ebx
int 0x40
mov bx,ch_top
cmp ax,bx
jl .mouse_end
add bx,ch_size
cmp ax,bx
jg .mouse_end
shr eax,16
mov bx,ch_left
cmp ax,bx
jl .mouse_end
add bx,ch_size
add bx,si
cmp ax,bx
jg .mouse_end
bts dword ch_flags,1
jc @f
call .draw_ch
jmp .mouse_end
@@:
btr dword ch_flags,1
call .clear_ch
.mouse_end:
popa
ret
}
struc check_box left,top,color,border_color,text_color,text,flags
{
.left: dw left ;+0
.top: dw top ;+2
.color: dd color ;+4
.border_color: dd border_color ;+8
.text_color: dd text_color ;+12
.text: dd text ;+16
.flags: dd flags+0 ;+20
}
ch_struc_size=24
macro draw_check_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ch_struc_size)
@@:
call check_box.draw
add edi,ch_struc_size
loop @b
}
macro mouse_check_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ch_struc_size)
@@:
call check_box.mouse
add edi,ch_struc_size
loop @b
}
macro check_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ch_struc_size)
mov esi,color_table
@@:
push dword [esi+32]
pop dword ch_text_color
push dword [esi+36]
pop dword ch_border_color
add edi,ch_struc_size
loop @b
}

View File

@ -1,978 +0,0 @@
; <Lrz> 01.02.2007 ¤®à ¡®âª  edit_box, ¨á¯à ¢¨« ¡ £¨.
; <Lrz> 26.01.2007 ­®à¬ «ì­ ï à ¡®â  ª®¬¯ ­¥­â  ¨á¯à ¢¨« äãªæ¨î .check_offset
; <Lrz> 24.01.2007 ¯®ä¨ªá¥« ¡ £¨ ¢ë§¢ ­ë¥ ­¥ ¯à ¢¨«ì­ë¬ ª®¤®¬ )).
; <Lrz> 22.01.2007 ¨§¡ ¢¨«áï ®â £«îª®¢ ¯à¨ à ¡®â¥ á ¢ë¤¥«¥­¨¥¬ ¨ 㤠«¥­¨¥, ª®à४⭠ï à ¡®â  ª« ¢¨è¥© del & backspase
; <Lrz> 20.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª  ¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace, 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª« ¢¨è¨
; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.06.06 10:40
; <EFBFBD> ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
; <EFBFBD>à®æ¥¤ãàë:
; edit_box.draw - ¯®«­ ï ¯¥à¥à¨á®¢ª ;
; edit_box.key - ®¡à ¡®âª  ª« ¢¨ âãàë;
; edit_box.mouse - ®¡à ¡®âª  ¬ëè¨;
; edit_box.focus - ãáâ ­®¢ª  䮪ãá ;
; edit_box.blur - ¥£® à §¬ë¢ ­¨¥;
; edit_box.get_n - ¯®«ãç¨âì ª®«¨ç¥á⢮ ¯à®à¨á®¢ë¢ ¥¬ëå ᨬ¢®«®¢.
; <EFBFBD>ਠ¢ë§®¢¥ «î¡ëå ¨§ íâ¨å ¯à®æ¥¤ãà ¢ ॣ¨áâॠedi á«¥¤ã¥â
; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
; <EFBFBD>ਬ¥à áâàãªâãàë:
; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
; ¤«¨­ , ¢ëá®â , ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. <EFBFBD>ãä¥à ¤®«¦¥­
; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
; some_edit_text:
; rb 256 ;255+1
; <EFBFBD>ਬ¥à ¢ë§®¢  ¯à®æ¥¤ãàë:
; mov edi,some_edit
; call edit_box.draw
; <EFBFBD>ਠ¢ë§®¢¥ ¯à®æ¥¤ãàë edit_box.key ª®¤ ª« ¢¨è¨ ¤®«¦¥­
; ­ å®¤¨âáï ¢ ah, â® ¥áâì ¯¥à¥¤ ¢ë§®¢®¬ í⮩ ¯à®æ¥¤ãàë ­ ¤® ¢ë§¢ âì
; 2-ãî á¨á¥¬­ãî äã­ªæ¨î, ­ ¯à¨¬¥à:
; mov eax,2
; int 0x40
; mov edi,some_edit1
; call edit_box.key
; mov edi,some_edit2
; call edit_box.key
; <EFBFBD>¥à¥¤ ¢ë§®¢®¬ ®¡à ¡®â稪  ¬ëè¨ á«¥¤ã¥â ¯à®¢¥à¨âì, ï¥âáï «¨ ®ª­®
;  ªâ¨¢­ë¬.
; …᫨ 饫箪 ¬ëè¨ ¡ë« ¯à®©§¢¥¤¥­ §  ¯à¥¤¥« ¬¨ edit box
; 䮪ãá â¥àï¥âáï.
macro use_edit_box
{
edit_box:
ed_width equ [edi] ;è¨à¨­  ª®¬¯®­¥­â 
ed_left equ [edi+4] ;¯®«®¦¥­¨¥ ¯® ®á¨ å
ed_top equ [edi+8] ;¯®«®¦¥­¨¥ ¯® ®á¨ ã
ed_color equ [edi+12] ;梥â ä®­  ª®¬¯®­¥­â 
ed_focus_border_color equ [edi+16] ;梥â à ¬ª¨ ª®¬¯®­¥­â 
ed_blur_border_color equ [edi+20] ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
ed_text_color equ [edi+24] ;梥â ⥪áâ 
ed_max equ [edi+28] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
ed_text equ [edi+32] ;㪠§ â¥«ì ­  ¡ãä¥à
ed_flags equ [edi+36] ;ä« £¨
ed_size equ [edi+38] ;ª®«-¢® ᨬ¢®«®¢
ed_pos equ [edi+42] ;¯®§¨æ¨ï ªãàá®à 
ed_offset equ [edi+46] ;ᬥ饭¨¥
cl_curs_x equ [edi+50] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
cl_curs_y equ [edi+54] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
ed_shift_pos equ [edi+58]
ed_height=14 ; ¢ëá®â 
shift_color=0x6a9480
ed_insert=10000b
ed_insert_cl=1111111111101111b
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
.draw:
pusha
;--- à¨á㥬 à ¬ªã ---
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
.draw_bg_cursor_text:
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
call .check_offset ;¢ëç¨á«¥­¨¥ ¯®§¨æ¨¨ ªãàá®à  áâ ¡¨«ì­ 
;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
call .draw_bg ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª à ¡®ç¥© ®¡« áâ¨
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test word ed_flags,ed_focus
je @f
call .draw_cursor
@@:
call .draw_text
popa
ret
;.str:
; mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
; ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
; cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
; jb @f
; xor edx,edx ;®ç¨áâ¨âì edx
; div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
; push edx ;¯®«®¦¨âì ¢ á⥪
; ;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
; call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
; pop eax
; @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
; ;sbb al,$69 ;- ç¥áâ­® ¤ ­­ ï ¨­áâàãªæ¨ï ¬¥­ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ­¥ §­ î ª ª íâ® à ¡®â ¥â
; ;das ;¯®á«¥ ¤ ­­®© ª®¬ ­¤ë ª ª ¡ë ¯à®¨á室¨â 㬥­ì襭¨¥ al ­  66h (¢ ª­¨£¥ ­ ¯¨á ­® ¤à㣮¥)
; or al,0x30 ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥
; stosb ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
;
; ret ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
.draw_text:
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
call .get_n
mov esi,ed_size
mov ebx,ed_offset
sub esi,ebx
cmp eax,esi
jae @F
mov esi,eax ;çâ®¡ë ­¥ ¢ë室¨âì §  ¯à¥¤¥«ë íªà ­ 
;--- à¨á㥬 ⥪áâ ---
@@: mov eax,4
mov ebx,ed_left
mov edx,ed_offset
add ebx,2
shl ebx,16
mov bx,ed_top
add ebx,4
mov ecx,ed_text_color
add edx,ed_text
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
;¢å®¤­ë¥ ¤ ­­ë¥
;eax
;edx - color
;----------------------------------------------------------
.draw_bg_eax:
mov ecx,ed_top
add ecx,1
shl ecx,16
mov cx,13
mov eax,13
int 0x40
ret
jmp @f
.draw_bg:
mov ebx,ed_left
add ebx,1
shl ebx,16
mov bx,ed_width
sub ebx,1
@@:
mov ecx,ed_top
mov eax,13
add ecx,1
shl ecx,16
mov edx,ed_color
mov cx,ed_height
sub ecx,1
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨­¥ ª®¬¯®­¥­â  --------------
;----------------------------------------------------------
.get_n:
mov eax,ed_width ;¯®«ã祬 è¨à¨­ã ª®¬¯®­¥­â 
xor edx,edx ;१ã«ìâ â à á¯®«®£ ¥âáï ¢ ¯ à¥ edx:eax ¢ eax - ®áâ â®ª
sub eax,4 ;¢ëç⨬ 4
mov ebx,6 ;§ £à㧬¨ ¤¥«¨â¥«ì
div ebx ;à §¬¤¥«¨¬ ­  6
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï ªãàá®à  --------------------------
;----------------------------------------------------------
.clear_cursor:
mov edx,ed_color
test word ed_flags,ed_shift
je @f
mov edx,shift_color
@@:
mov ebx,cl_curs_x
mov ecx,cl_curs_y
jmp .draw_curs
.draw_cursor:
mov edx,ed_text_color
@@:
mov ebx,ed_pos
mov ecx,ed_offset
sub ebx,ecx
lea ebx,[ebx*2+ebx]
shl ebx,1
;imul ebx,6
add bx,ed_left
mov ecx,ed_top
inc ebx
add ecx,2
mov ebp,ebx
shl ebx,16
mov bx,bp
mov ebp,ecx
shl ecx,16
mov cx,bp
add cx,ed_height-4
mov cl_curs_x,ebx
mov cl_curs_y,ecx
.draw_curs:
mov eax,38
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
test dword ed_flags,ed_focus
mov edx,ed_focus_border_color
jne @f
mov edx,ed_blur_border_color
@@:
;--- ᢥàåã ---
mov eax,38
mov ebx,ed_left
mov ecx,ebx
shl ebx,16
mov bx,cx
add bx,ed_width
mov ecx, ed_top
mov esi,ecx
shl ecx,16
mov cx,si
int 0x40
;--- á­¨§ã ---
mov esi,ecx
add ecx,ed_height
mov ebp,ecx
shl ecx,16
mov cx,bp
int 0x40
;--- á«¥¢  ---
mov cx,si
mov ebp,ebx
sub bx,ed_width
int 0x40
;--- á¯à ¢  ---
mov ebx,ebp
shl ebx,16
mov bx,bp
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
;--- eax = -1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
; ¨§¬¥­¨«®áì
;----------------------------------------------------------
.check_offset:
pushad
mov ecx,ed_pos
mov ebx,ed_offset
cmp ebx,ecx
ja .sub_8
push ebx
call .get_n ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ à¥ ॣ¨áâ஢ edx:eax
pop ebx
mov edx,ebx
add edx,eax ;ed_offset+width editbox
cmp edx,ecx
ja @f
mov edx,ed_size
cmp edx,ecx
je .add_end
sub edx,ecx
cmp edx,8
jbe .add_8
add ebx,8
jmp .chk_d
.sub_8: cmp ecx,0
je .sub_min
cmp ebx,8
jbe .sub_min
sub ebx,8 ;ebx=ed_offset
jmp .chk_d
.sub_min:
xor ebx,ebx
jmp .chk_d
.add_end:sub edx,eax
mov ebx,edx
jmp .chk_d
.add_8: add ebx,edx
; ;----------- ®â« ¤ª 
; pushad
; mov [data_of_code],0
; mov eax,ebx;ed_offset
; mov edi,data_of_code
; call .str
; ;à¨á®¢ ­¨¥ ä®­ 
; mov eax,13
; mov ebx,178*65536+36
; mov ecx,28*65536+10
; xor edx,edx
; int 0x40
; ;¢ë¢®¤ §­ ç¥­¨ï ­  íªà ­
; mov eax,4
; mov ebx,180*65536+30
; mov ecx,0x10DDBBCC
; mov edx,data_of_code
; mov esi,4
; int 0x40
; popad
; ;----------- ®â« ¤ª 
.chk_d: mov ed_offset,ebx
call .draw_bg
mov dword [esp+28],-1
popad
ret
@@:
mov dword [esp+28],0
popad
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mov ebx,eax
; mov eax,ed_pos
; xor edx,edx
; idiv ebx
; xor edx,edx
; imul eax,ebx
; mov ed_offset,eax
; pop ebx
; cmp ax,bx
; je @f
;;;;;;;; ¤ ­­ë¥ ¤«ï § ªà è¨¢ ­¨ï ¢á¥© ¯®«®áë ¯àאַ㣮«ì­¨ª 
; mov ebx,ed_left
; inc ebx
; shl ebx,16
; mov bx,ed_width
; dec ebx
; mov edx,ed_color
; call .draw_bg_eax
; mov dword [esp+28],0
;@@: popad
; ret
;==========================================================
;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
;==========================================================
.key:
pusha
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je .no_figure ;@f
xor ecx,ecx
push eax
inc ecx
mov eax,66
mov ebx,3
int 0x40
test al,0x03
je @f
or word ed_flags,ed_shift
@@: pop eax
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
jz .backspace
cmp ah,0xb6
jz .delete
cmp ah,176
jz .left
cmp ah,179
jz .right
cmp ah,180
jz .home
cmp ah,181
jz .end
cmp ah,185 ;insert
jz .insert
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp ah,177
jz .no_figure
cmp ah,178
jz .no_figure
cmp ah,27 ;ESC - ª« ¢¨è  ))
jz .no_figure
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë ?
jz @f
cmp ah,'0'
jb .no_figure
cmp ah,'9'
ja .no_figure
;¯à®¢¥àª  ­  shift
@@: test word ed_flags,ed_shift_on
je @f
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
push eax
mov edx,ed_size
mov ecx,ed_pos
call .del_char
;;;;
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
pop eax
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
@@: mov ecx,ed_size
mov edx, ed_max
cmp ecx,edx
jae .no_figure
mov ebx, ed_pos
cmp ebx,edx
jl @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
.no_figure:
popa
ret
.insert: test word ed_flags,ed_insert ;not word ed_insert
je .insert_1
and word ed_flags,ed_insert_cl
jmp .no_figure
.insert_1:
or word ed_flags,ed_insert
jmp .no_figure
.ins_v:
dec dword [ebp+38];ed_size ;processing is insert
sub esi,ecx
add esi,ebx
mov edi,esi
jmp .In_k
@@: ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov ecx,ed_size
push edi eax
mov ebp,edi
mov esi,ed_text ; “ª § â¥«ì ­  ¡ãä¥à
;<EFBFBD>㤥¬ à ¡®â âì á® áâப®©
add esi,ecx ;add ed_size ¤®¡ ¢¨¬ max size
mov edi,esi
cmp ecx,ebx ;…᫨ ã ­ á ¯®§¨æ¨ï ªãàá®à  = ⥪ã饬ã à §¬¥àã ­ ¯¥ç â ­­ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®­æ¥
je .In_k
test word [ebp+36],ed_insert ;IF insert is enable â.ª. edi ¨§¬¥­¥­  ¤à¥á㥬 ç¥à¥§ ebp
jne .ins_v
sub ecx,ebx ;<EFBFBD> ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥­¨ï.
inc edi ;‘¬¥á⨬ ­ è¨ ᨬ¢®«ë ¢ ¯à ¢®
std
inc ecx
@@:
;--------
lodsb
stosb
;--------
loop @b
.In_k: cld
pop eax
mov al,ah
stosb
pop edi
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
inc dword ed_pos
call .draw_all2
jmp .shift;.draw_cursor_text
.delete:
mov edx,ed_size
mov ecx,ed_pos
cmp edx,ecx
jg .bac_del
test word ed_flags,ed_shift_on
jne .del_bac
popa
ret
.bac_del:
call .del_char
jmp .draw_all
;--- ­ ¦ â  ª« ¢¨è  backspace ---
.backspace:
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
mov edx,ed_size
mov ecx,ed_pos
test ecx,ecx
jnz .del_bac
test word ed_flags,ed_shift_on
jne .bac_del
popa
ret
.del_bac:
cmp edx,ecx ;if ed_pos=ed_size
je @f
dec ecx
call .del_char
@@: test word ed_flags,ed_shift_on
jne .bac_del
dec dword ed_pos
.draw_all:
push .shift;.draw_cursor_text;eax
test word ed_flags,ed_shift_on
je @f
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
jmp .draw_all2
@@: dec dword ed_size
.draw_all2:
and word ed_flags,ed_shift_cl
call .clear_cursor
call .check_offset
;;;;;;;;;;;;;;;
test eax,eax
jne @f
call .draw_bg
ret
;;;;;;;;;;;;;;;
@@: call .get_n
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,ed_size
cmp eax,ebx
jb @f
mov eax,ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;It is don't optimal
pop eax ;ed_pos
mov ecx,ed_offset
sub eax,ecx
.nxt:
mov ebp,eax ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
add ebp,ebx
pop edx
cmp ebp,edx
je @f
inc ebx
@@: mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,ed_color
call .draw_bg_eax
ret
; jmp .shift
;--- ­ ¦ â  ª« ¢¨è  left ---
.left: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
dec dword ed_pos
jmp .nd_k
;--- ­ ¦ â  ª« ¢¨è  right ---
.right: call .sh_enable
mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
call .clear_cursor
inc dword ed_pos
jmp .nd_k
.home: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
xor eax,eax
mov ed_pos,eax
jmp .nd_k
.end: call .sh_enable
mov ebx,ed_pos
cmp ebx,dword ed_size
je .nd_k
call .clear_cursor
mov eax,ed_size
mov ed_pos,eax
.nd_k: call .check_offset
;test eax,eax
;jz .draw_bg_cursor_text
call .draw_cursor
.shift: ;;;;;;;SHIFT
call .draw_bg ;­¥ ®¯â¨¬ «ì­®
test word ed_flags,ed_shift
je .f_exit
;;;;;;SHIFT end
mov eax,dword ed_pos
mov ebx,dword ed_shift_pos
cmp eax,ebx
jae .sh_n
push eax ;¬¥­ì襥 ¢ eax
push ebx ;¡®«ì襥
jmp .sh_n1
;¥á«¨ ¨­ ç¥
.sh_n: push ebx
push eax
.sh_n1:
; jmp .draw_all2
;;;;;;;;;;;;;;;;;;;;;;;;;
;call .clear_cursor
call .check_offset
call .get_n
mov edx,eax ;size of ed_box
; push eax
mov ecx,ed_offset
add eax,ecx ;eax = w_off= ed_offset+width
mov ebp,eax ;save
pop ebx ;¡®«ì襥
pop eax ;¬¥­ì襥
cmp eax,ecx ;áà ¢­¥­¨¥ á ¬¥­ì襣® á offset.
jae .f_f ;¥á«¨ ¡®«ìè¥
xor eax,eax
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jb @f
sub ebx,ecx
jmp .nxt_f
@@: mov ebx,ebp
sub ebx,ecx
jmp .nxt_f
.f_f:
sub eax,ecx
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jle @f
sub ebx,ecx
sub ebx,eax
jmp .nxt_f
@@:
mov ebx,ebp
sub ebx,ecx
sub ebx,eax
.nxt_f:
mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,shift_color
call .draw_bg_eax
and word ed_flags,1111111111111011b
jmp .draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
.f_exit: and word ed_flags,ed_shift_cl
jmp .draw_cursor_text
;¯à®¢¥àª  á®áâ®ï­¨ï shift ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
.sh_enable:
test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne .sh_ext_en
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
ret
@@: and word ed_flags,ed_shift_cl
.sh_ext_en: ret
;- 㤠«¥­¨¥ ᨬ¢®« 
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
.del_char:
mov esi,ed_text
test word ed_flags,ed_shift_on
je @f
mov eax,dword ed_shift_pos
mov ebx,esi
cmp eax,ecx
jae .dh_n
mov ed_pos,eax ;çâ® ¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
mov ebp,ecx
sub ebp,eax
add ebx,eax ;eax ¬¥­ìè¥
sub edx,ecx
add esi,ecx
mov ed_shift_pos,ebp
jmp .del_ch_sh
;¥á«¨ ¨­ ç¥
.dh_n:
mov ebp,eax
sub ebp,ecx
add ebx,ecx
sub edx,eax
add esi,eax
mov ed_shift_pos,ebp
jmp .del_ch_sh
@@: add esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãää¥àã
mov ebx,esi
inc esi
cld
sub edx,ecx
.del_ch_sh:
push edi
mov edi,ebx
@@:
lodsb
stosb
dec edx
jns @b
pop edi
ret
;==========================================================
;=== ®¡à ¡®âª  ¬ëè¨ =======================================
;==========================================================
.mouse:
pusha
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
;----------------------------------------------------------
mov eax,37
mov ebx,2
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
;----------------------------------------------------------
test eax,1
jnz .mouse_left_button
@@: popa
ret
.mouse_left_button:
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
;----------------------------------------------------------
mov eax,37
xor ebx,ebx
inc ebx
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
;----------------------------------------------------------
mov ebx,ed_top
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_height
cmp ax,bx
jg ._blur;.mouse_end_no_focus
shr eax,16
mov bx,ed_left
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_width
cmp ax,bx
jg ._blur;.mouse_end_no_focus
;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
push eax
call .clear_cursor
pop eax
xor dx,dx
sub ax,ed_left
add ax,2
mov bx,6
div bx
add ax,ed_offset
cmp ax,ed_size
jna @f
mov ax,ed_size
@@:
mov ed_pos,ax
call .check_offset
call .draw_cursor
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
bts word ed_flags,1
jc .mouse_pressed
call .draw_cursor
call .draw_border
.mouse_pressed:
popa
ret
;.mouse_end_no_focus:
; call .blur
;popa
;ret
;.blur:
;pusha
._blur:
test word ed_flags,ed_always_focus
jne @f
btr word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
jnc @f
call .clear_cursor
call .draw_border
@@:
popa
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à §¬ë¢ ­¨ï 䮪ãá  --------------------------
;----------------------------------------------------------
;.blur:
;pusha
;._blur:
;btr ed_flags,1
;jnc @f
;call .draw_border
;call .clear_cursor
;@@:
;popa
;ret
}
ed_figure_only=1000000000000000b
ed_always_focus=100000000000000b
ed_focus=10b
ed_shift_on=1000b
ed_shift=100b
ed_shift_cl=1111111111110011b
macro draw_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.draw
add edi,ed_struc_size
loop @b
}
macro mouse_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.mouse
add edi,ed_struc_size
loop @b
}
macro key_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.key
add edi,ed_struc_size
loop @b
}
ed_struc_size=62
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
.width dd width
.left dd left
.top dd top
.color dd color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.max dd max
.text dd text
.flags dw flags+0
.size dd size+0
.pos dd 0
.offset dd 0
.cl_curs_x dd 0
.cl_curs_y dd 0
.shift dd 0
}
macro edit_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
mov esi,color_table
@@:
mov eax,[esi+36]
mov ebx,[esi+20]
mov ed_focus_border_color,eax
shr bh,1
shr bl,1
shr ah,1
shr al,1
add ah,bh
add al,bl
ror eax,16
ror ebx,16
shr bl,1
shr al,1
add al,bl
ror eax,16
mov ed_blur_border_color,eax
add edi,ed_struc_size
loop @b
}
macro draw_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.draw
}
macro mouse_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.mouse
}
macro key_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.key
}

View File

@ -1,9 +1,9 @@
;--- ¤à㣨¥ ¬ ªà®áë --- ;--- ¤à㣨¥ ¬ ªà®áë ---
include 'editbox.inc' include '..\..\develop\examples\editbox\trunk\editbox.inc'
include 'txtbut.inc' include 'txtbut.inc'
;include 'gp.inc' ;include 'gp.inc'
include 'label.inc' include 'label.inc'
;include 'checkbox.inc' ;include '..\..\develop\examples\checkbox\trunk\checkbox.inc'
include 'check.inc' include 'check.inc'
include 'file_sys.inc' include 'file_sys.inc'
include 'textwork.inc' include 'textwork.inc'

View File

@ -1,978 +0,0 @@
; <Lrz> 01.02.2007 ¤®à ¡®âª  edit_box, ¨á¯à ¢¨« ¡ £¨.
; <Lrz> 26.01.2007 ­®à¬ «ì­ ï à ¡®â  ª®¬¯®­¥­â  ¨á¯à ¢¨« äãªæ¨î .check_offset
; <Lrz> 24.01.2007 ¯®ä¨ªá¨« ¡ £¨, ¢ë§¢ ­­ë¥ ­¥¯à ¢¨«ì­ë¬ ª®¤®¬ )).
; <Lrz> 22.01.2007 ¨§¡ ¢¨«áï ®â £«îª®¢ ¯à¨ à ¡®â¥ á ¢ë¤¥«¥­¨¥¬ ¨ 㤠«¥­¨¥¬, ª®à४⭠ï à ¡®â  ª« ¢¨è del & backspase
; <Lrz> 20.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace, 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª« ¢¨è¨
; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.06.06 10:40
; <EFBFBD> ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
; <EFBFBD>à®æ¥¤ãàë:
; edit_box.draw - ¯®«­ ï ¯¥à¥à¨á®¢ª ;
; edit_box.key - ®¡à ¡®âª  ª« ¢¨ âãàë;
; edit_box.mouse - ®¡à ¡®âª  ¬ëè¨;
; edit_box.focus - ãáâ ­®¢ª  䮪ãá ;
; edit_box.blur - ¥£® à §¬ë¢ ­¨¥;
; edit_box.get_n - ¯®«ãç¨âì ª®«¨ç¥á⢮ ¯à®à¨á®¢ë¢ ¥¬ëå ᨬ¢®«®¢.
; <EFBFBD>ਠ¢ë§®¢¥ «î¡ëå ¨§ íâ¨å ¯à®æ¥¤ãà ¢ ॣ¨áâॠedi á«¥¤ã¥â
; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
; <EFBFBD>ਬ¥à áâàãªâãàë:
; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
; ¤«¨­ , ¢ëá®â , ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. <EFBFBD>ãä¥à ¤®«¦¥­
; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
; some_edit_text:
; rb 256 ;255+1
; <EFBFBD>ਬ¥à ¢ë§®¢  ¯à®æ¥¤ãàë:
; mov edi,some_edit
; call edit_box.draw
; <EFBFBD>ਠ¢ë§®¢¥ ¯à®æ¥¤ãàë edit_box.key ª®¤ ª« ¢¨è¨ ¤®«¦¥­
; ­ å®¤¨âáï ¢ ah, â® ¥áâì ¯¥à¥¤ ¢ë§®¢®¬ í⮩ ¯à®æ¥¤ãàë ­ ¤® ¢ë§¢ âì
; 2-ãî á¨á¥¬­ãî äã­ªæ¨î, ­ ¯à¨¬¥à:
; mov eax,2
; int 0x40
; mov edi,some_edit1
; call edit_box.key
; mov edi,some_edit2
; call edit_box.key
; <EFBFBD>¥à¥¤ ¢ë§®¢®¬ ®¡à ¡®â稪  ¬ëè¨ á«¥¤ã¥â ¯à®¢¥à¨âì, ï¥âáï «¨ ®ª­®
;  ªâ¨¢­ë¬.
; …᫨ 饫箪 ¬ëè¨ ¡ë« ¯à®©§¢¥¤¥­ §  ¯à¥¤¥« ¬¨ edit box
; 䮪ãá â¥àï¥âáï.
macro use_edit_box
{
edit_box:
ed_width equ [edi] ;è¨à¨­  ª®¬¯®­¥­â 
ed_left equ [edi+4] ;¯®«®¦¥­¨¥ ¯® ®á¨ å
ed_top equ [edi+8] ;¯®«®¦¥­¨¥ ¯® ®á¨ ã
ed_color equ [edi+12] ;梥â ä®­  ª®¬¯®­¥­â 
ed_focus_border_color equ [edi+16] ;梥â à ¬ª¨ ª®¬¯®­¥­â 
ed_blur_border_color equ [edi+20] ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
ed_text_color equ [edi+24] ;梥â ⥪áâ 
ed_max equ [edi+28] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
ed_text equ [edi+32] ;㪠§ â¥«ì ­  ¡ãä¥à
ed_flags equ [edi+36] ;ä« £¨
ed_size equ [edi+38] ;ª®«-¢® ᨬ¢®«®¢
ed_pos equ [edi+42] ;¯®§¨æ¨ï ªãàá®à 
ed_offset equ [edi+46] ;ᬥ饭¨¥
cl_curs_x equ [edi+50] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
cl_curs_y equ [edi+54] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
ed_shift_pos equ [edi+58]
ed_height=14 ; ¢ëá®â 
shift_color=0x6a9480
ed_insert=10000b
ed_insert_cl=1111111111101111b
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
.draw:
pusha
;--- à¨á㥬 à ¬ªã ---
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
.draw_bg_cursor_text:
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
call .check_offset ;¢ëç¨á«¥­¨¥ ¯®§¨æ¨¨ ªãàá®à  áâ ¡¨«ì­ 
;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
call .draw_bg ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª à ¡®ç¥© ®¡« áâ¨
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test word ed_flags,ed_focus
je @f
call .draw_cursor
@@:
call .draw_text
popa
ret
;.str:
; mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
; ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
; cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
; jb @f
; xor edx,edx ;®ç¨áâ¨âì edx
; div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
; push edx ;¯®«®¦¨âì ¢ á⥪
; ;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
; call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
; pop eax
; @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
; ;sbb al,$69 ;- ç¥áâ­® ¤ ­­ ï ¨­áâàãªæ¨ï ¬¥­ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ­¥ §­ î ª ª íâ® à ¡®â ¥â
; ;das ;¯®á«¥ ¤ ­­®© ª®¬ ­¤ë ª ª ¡ë ¯à®¨á室¨â 㬥­ì襭¨¥ al ­  66h (¢ ª­¨£¥ ­ ¯¨á ­® ¤à㣮¥)
; or al,0x30 ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥
; stosb ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
;
; ret ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
.draw_text:
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
call .get_n
mov esi,ed_size
mov ebx,ed_offset
sub esi,ebx
cmp eax,esi
jae @F
mov esi,eax ;çâ®¡ë ­¥ ¢ë室¨âì §  ¯à¥¤¥«ë íªà ­ 
;--- à¨á㥬 ⥪áâ ---
@@: mov eax,4
mov ebx,ed_left
mov edx,ed_offset
add ebx,2
shl ebx,16
mov bx,ed_top
add ebx,4
mov ecx,ed_text_color
add edx,ed_text
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
;¢å®¤­ë¥ ¤ ­­ë¥
;eax
;edx - color
;----------------------------------------------------------
.draw_bg_eax:
mov ecx,ed_top
add ecx,1
shl ecx,16
mov cx,13
mov eax,13
int 0x40
ret
jmp @f
.draw_bg:
mov ebx,ed_left
add ebx,1
shl ebx,16
mov bx,ed_width
sub ebx,1
@@:
mov ecx,ed_top
mov eax,13
add ecx,1
shl ecx,16
mov edx,ed_color
mov cx,ed_height
sub ecx,1
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨­¥ ª®¬¯®­¥­â  --------------
;----------------------------------------------------------
.get_n:
mov eax,ed_width ;¯®«ã祬 è¨à¨­ã ª®¬¯®­¥­â 
xor edx,edx ;१ã«ìâ â à á¯®«®£ ¥âáï ¢ ¯ à¥ edx:eax ¢ eax - ®áâ â®ª
sub eax,4 ;¢ëç⨬ 4
mov ebx,6 ;§ £à㧬¨ ¤¥«¨â¥«ì
div ebx ;à §¬¤¥«¨¬ ­  6
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï ªãàá®à  --------------------------
;----------------------------------------------------------
.clear_cursor:
mov edx,ed_color
test word ed_flags,ed_shift
je @f
mov edx,shift_color
@@:
mov ebx,cl_curs_x
mov ecx,cl_curs_y
jmp .draw_curs
.draw_cursor:
mov edx,ed_text_color
@@:
mov ebx,ed_pos
mov ecx,ed_offset
sub ebx,ecx
lea ebx,[ebx*2+ebx]
shl ebx,1
;imul ebx,6
add bx,ed_left
mov ecx,ed_top
inc ebx
add ecx,2
mov ebp,ebx
shl ebx,16
mov bx,bp
mov ebp,ecx
shl ecx,16
mov cx,bp
add cx,ed_height-4
mov cl_curs_x,ebx
mov cl_curs_y,ecx
.draw_curs:
mov eax,38
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
test dword ed_flags,ed_focus
mov edx,ed_focus_border_color
jne @f
mov edx,ed_blur_border_color
@@:
;--- ᢥàåã ---
mov eax,38
mov ebx,ed_left
mov ecx,ebx
shl ebx,16
mov bx,cx
add bx,ed_width
mov ecx, ed_top
mov esi,ecx
shl ecx,16
mov cx,si
int 0x40
;--- á­¨§ã ---
mov esi,ecx
add ecx,ed_height
mov ebp,ecx
shl ecx,16
mov cx,bp
int 0x40
;--- á«¥¢  ---
mov cx,si
mov ebp,ebx
sub bx,ed_width
int 0x40
;--- á¯à ¢  ---
mov ebx,ebp
shl ebx,16
mov bx,bp
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
;--- eax = -1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
; ¨§¬¥­¨«®áì
;----------------------------------------------------------
.check_offset:
pushad
mov ecx,ed_pos
mov ebx,ed_offset
cmp ebx,ecx
ja .sub_8
push ebx
call .get_n ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ à¥ ॣ¨áâ஢ edx:eax
pop ebx
mov edx,ebx
add edx,eax ;ed_offset+width editbox
cmp edx,ecx
ja @f
mov edx,ed_size
cmp edx,ecx
je .add_end
sub edx,ecx
cmp edx,8
jbe .add_8
add ebx,8
jmp .chk_d
.sub_8: cmp ecx,0
je .sub_min
cmp ebx,8
jbe .sub_min
sub ebx,8 ;ebx=ed_offset
jmp .chk_d
.sub_min:
xor ebx,ebx
jmp .chk_d
.add_end:sub edx,eax
mov ebx,edx
jmp .chk_d
.add_8: add ebx,edx
; ;----------- ®â« ¤ª 
; pushad
; mov [data_of_code],0
; mov eax,ebx;ed_offset
; mov edi,data_of_code
; call .str
; ;à¨á®¢ ­¨¥ ä®­ 
; mov eax,13
; mov ebx,178*65536+36
; mov ecx,28*65536+10
; xor edx,edx
; int 0x40
; ;¢ë¢®¤ §­ ç¥­¨ï ­  íªà ­
; mov eax,4
; mov ebx,180*65536+30
; mov ecx,0x10DDBBCC
; mov edx,data_of_code
; mov esi,4
; int 0x40
; popad
; ;----------- ®â« ¤ª 
.chk_d: mov ed_offset,ebx
call .draw_bg
mov dword [esp+28],-1
popad
ret
@@:
mov dword [esp+28],0
popad
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mov ebx,eax
; mov eax,ed_pos
; xor edx,edx
; idiv ebx
; xor edx,edx
; imul eax,ebx
; mov ed_offset,eax
; pop ebx
; cmp ax,bx
; je @f
;;;;;;;; ¤ ­­ë¥ ¤«ï § ªà è¨¢ ­¨ï ¢á¥© ¯®«®áë ¯àאַ㣮«ì­¨ª 
; mov ebx,ed_left
; inc ebx
; shl ebx,16
; mov bx,ed_width
; dec ebx
; mov edx,ed_color
; call .draw_bg_eax
; mov dword [esp+28],0
;@@: popad
; ret
;==========================================================
;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
;==========================================================
.key:
pusha
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je .no_figure ;@f
xor ecx,ecx
push eax
inc ecx
mov eax,66
mov ebx,3
int 0x40
test al,0x03
je @f
or word ed_flags,ed_shift
@@: pop eax
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
jz .backspace
cmp ah,0xb6
jz .delete
cmp ah,176
jz .left
cmp ah,179
jz .right
cmp ah,180
jz .home
cmp ah,181
jz .end
cmp ah,185 ;insert
jz .insert
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp ah,177
jz .no_figure
cmp ah,178
jz .no_figure
cmp ah,27 ;ESC - ª« ¢¨è  ))
jz .no_figure
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë ?
jz @f
cmp ah,'0'
jb .no_figure
cmp ah,'9'
ja .no_figure
;¯à®¢¥àª  ­  shift
@@: test word ed_flags,ed_shift_on
je @f
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
push eax
mov edx,ed_size
mov ecx,ed_pos
call .del_char
;;;;
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
pop eax
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
@@: mov ecx,ed_size
mov edx, ed_max
cmp ecx,edx
jae .no_figure
mov ebx, ed_pos
cmp ebx,edx
jl @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
.no_figure:
popa
ret
.insert: test word ed_flags,ed_insert ;not word ed_insert
je .insert_1
and word ed_flags,ed_insert_cl
jmp .no_figure
.insert_1:
or word ed_flags,ed_insert
jmp .no_figure
.ins_v:
dec dword [ebp+38];ed_size ;processing is insert
sub esi,ecx
add esi,ebx
mov edi,esi
jmp .In_k
@@: ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov ecx,ed_size
push edi eax
mov ebp,edi
mov esi,ed_text ; “ª § â¥«ì ­  ¡ãä¥à
;<EFBFBD>㤥¬ à ¡®â âì á® áâப®©
add esi,ecx ;add ed_size ¤®¡ ¢¨¬ max size
mov edi,esi
cmp ecx,ebx ;…᫨ ã ­ á ¯®§¨æ¨ï ªãàá®à  = ⥪ã饬ã à §¬¥àã ­ ¯¥ç â ­­ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®­æ¥
je .In_k
test word [ebp+36],ed_insert ;IF insert is enable â.ª. edi ¨§¬¥­¥­  ¤à¥á㥬 ç¥à¥§ ebp
jne .ins_v
sub ecx,ebx ;<EFBFBD> ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥­¨ï.
inc edi ;‘¬¥á⨬ ­ è¨ ᨬ¢®«ë ¢ ¯à ¢®
std
inc ecx
@@:
;--------
lodsb
stosb
;--------
loop @b
.In_k: cld
pop eax
mov al,ah
stosb
pop edi
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
inc dword ed_pos
call .draw_all2
jmp .shift;.draw_cursor_text
.delete:
mov edx,ed_size
mov ecx,ed_pos
cmp edx,ecx
jg .bac_del
test word ed_flags,ed_shift_on
jne .del_bac
popa
ret
.bac_del:
call .del_char
jmp .draw_all
;--- ­ ¦ â  ª« ¢¨è  backspace ---
.backspace:
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
mov edx,ed_size
mov ecx,ed_pos
test ecx,ecx
jnz .del_bac
test word ed_flags,ed_shift_on
jne .bac_del
popa
ret
.del_bac:
cmp edx,ecx ;if ed_pos=ed_size
je @f
dec ecx
call .del_char
@@: test word ed_flags,ed_shift_on
jne .bac_del
dec dword ed_pos
.draw_all:
push .shift;.draw_cursor_text;eax
test word ed_flags,ed_shift_on
je @f
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
jmp .draw_all2
@@: dec dword ed_size
.draw_all2:
and word ed_flags,ed_shift_cl
call .clear_cursor
call .check_offset
;;;;;;;;;;;;;;;
test eax,eax
jne @f
call .draw_bg
ret
;;;;;;;;;;;;;;;
@@: call .get_n
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,ed_size
cmp eax,ebx
jb @f
mov eax,ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;It is don't optimal
pop eax ;ed_pos
mov ecx,ed_offset
sub eax,ecx
.nxt:
mov ebp,eax ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
add ebp,ebx
pop edx
cmp ebp,edx
je @f
inc ebx
@@: mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,ed_color
call .draw_bg_eax
ret
; jmp .shift
;--- ­ ¦ â  ª« ¢¨è  left ---
.left: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
dec dword ed_pos
jmp .nd_k
;--- ­ ¦ â  ª« ¢¨è  right ---
.right: call .sh_enable
mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
call .clear_cursor
inc dword ed_pos
jmp .nd_k
.home: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
xor eax,eax
mov ed_pos,eax
jmp .nd_k
.end: call .sh_enable
mov ebx,ed_pos
cmp ebx,dword ed_size
je .nd_k
call .clear_cursor
mov eax,ed_size
mov ed_pos,eax
.nd_k: call .check_offset
;test eax,eax
;jz .draw_bg_cursor_text
call .draw_cursor
.shift: ;;;;;;;SHIFT
call .draw_bg ;­¥ ®¯â¨¬ «ì­®
test word ed_flags,ed_shift
je .f_exit
;;;;;;SHIFT end
mov eax,dword ed_pos
mov ebx,dword ed_shift_pos
cmp eax,ebx
jae .sh_n
push eax ;¬¥­ì襥 ¢ eax
push ebx ;¡®«ì襥
jmp .sh_n1
;¥á«¨ ¨­ ç¥
.sh_n: push ebx
push eax
.sh_n1:
; jmp .draw_all2
;;;;;;;;;;;;;;;;;;;;;;;;;
;call .clear_cursor
call .check_offset
call .get_n
mov edx,eax ;size of ed_box
; push eax
mov ecx,ed_offset
add eax,ecx ;eax = w_off= ed_offset+width
mov ebp,eax ;save
pop ebx ;¡®«ì襥
pop eax ;¬¥­ì襥
cmp eax,ecx ;áà ¢­¥­¨¥ á ¬¥­ì襣® á offset.
jae .f_f ;¥á«¨ ¡®«ìè¥
xor eax,eax
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jb @f
sub ebx,ecx
jmp .nxt_f
@@: mov ebx,ebp
sub ebx,ecx
jmp .nxt_f
.f_f:
sub eax,ecx
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jle @f
sub ebx,ecx
sub ebx,eax
jmp .nxt_f
@@:
mov ebx,ebp
sub ebx,ecx
sub ebx,eax
.nxt_f:
mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,shift_color
call .draw_bg_eax
and word ed_flags,1111111111111011b
jmp .draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
.f_exit: and word ed_flags,ed_shift_cl
jmp .draw_cursor_text
;¯à®¢¥àª  á®áâ®ï­¨ï shift ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
.sh_enable:
test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne .sh_ext_en
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
ret
@@: and word ed_flags,ed_shift_cl
.sh_ext_en: ret
;- 㤠«¥­¨¥ ᨬ¢®« 
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
.del_char:
mov esi,ed_text
test word ed_flags,ed_shift_on
je @f
mov eax,dword ed_shift_pos
mov ebx,esi
cmp eax,ecx
jae .dh_n
mov ed_pos,eax ;çâ® ¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
mov ebp,ecx
sub ebp,eax
add ebx,eax ;eax ¬¥­ìè¥
sub edx,ecx
add esi,ecx
mov ed_shift_pos,ebp
jmp .del_ch_sh
;¥á«¨ ¨­ ç¥
.dh_n:
mov ebp,eax
sub ebp,ecx
add ebx,ecx
sub edx,eax
add esi,eax
mov ed_shift_pos,ebp
jmp .del_ch_sh
@@: add esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãää¥àã
mov ebx,esi
inc esi
cld
sub edx,ecx
.del_ch_sh:
push edi
mov edi,ebx
@@:
lodsb
stosb
dec edx
jns @b
pop edi
ret
;==========================================================
;=== ®¡à ¡®âª  ¬ëè¨ =======================================
;==========================================================
.mouse:
pusha
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
;----------------------------------------------------------
mov eax,37
mov ebx,2
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
;----------------------------------------------------------
test eax,1
jnz .mouse_left_button
@@: popa
ret
.mouse_left_button:
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
;----------------------------------------------------------
mov eax,37
xor ebx,ebx
inc ebx
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
;----------------------------------------------------------
mov ebx,ed_top
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_height
cmp ax,bx
jg ._blur;.mouse_end_no_focus
shr eax,16
mov bx,ed_left
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_width
cmp ax,bx
jg ._blur;.mouse_end_no_focus
;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
push eax
call .clear_cursor
pop eax
xor dx,dx
sub ax,ed_left
add ax,2
mov bx,6
div bx
add ax,ed_offset
cmp ax,ed_size
jna @f
mov ax,ed_size
@@:
mov ed_pos,ax
call .check_offset
call .draw_cursor
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
bts word ed_flags,1
jc .mouse_pressed
call .draw_cursor
call .draw_border
.mouse_pressed:
popa
ret
;.mouse_end_no_focus:
; call .blur
;popa
;ret
;.blur:
;pusha
._blur:
test word ed_flags,ed_always_focus
jne @f
btr word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
jnc @f
call .clear_cursor
call .draw_border
@@:
popa
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à §¬ë¢ ­¨ï 䮪ãá  --------------------------
;----------------------------------------------------------
;.blur:
;pusha
;._blur:
;btr ed_flags,1
;jnc @f
;call .draw_border
;call .clear_cursor
;@@:
;popa
;ret
}
ed_figure_only=1000000000000000b
ed_always_focus=100000000000000b
ed_focus=10b
ed_shift_on=1000b
ed_shift=100b
ed_shift_cl=1111111111110011b
macro draw_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.draw
add edi,ed_struc_size
loop @b
}
macro mouse_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.mouse
add edi,ed_struc_size
loop @b
}
macro key_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.key
add edi,ed_struc_size
loop @b
}
ed_struc_size=62
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
.width dd width
.left dd left
.top dd top
.color dd color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.max dd max
.text dd text
.flags dw flags+0
.size dd size+0
.pos dd 0
.offset dd 0
.cl_curs_x dd 0
.cl_curs_y dd 0
.shift dd 0
}
macro edit_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
mov esi,color_table
@@:
mov eax,[esi+36]
mov ebx,[esi+20]
mov ed_focus_border_color,eax
shr bh,1
shr bl,1
shr ah,1
shr al,1
add ah,bh
add al,bl
ror eax,16
ror ebx,16
shr bl,1
shr al,1
add al,bl
ror eax,16
mov ed_blur_border_color,eax
add edi,ed_struc_size
loop @b
}
macro draw_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.draw
}
macro mouse_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.mouse
}
macro key_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.key
}

View File

@ -25,7 +25,7 @@ version equ '1.2'
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï) dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
dd 0x0 ; § à¥§¥à¢¨à®¢ ­® dd 0x0 ; § à¥§¥à¢¨à®¢ ­®
include 'editbox.inc' include '..\..\..\develop\examples\editbox\trunk\editbox.inc'
use_edit_box use_edit_box
;--------------------------------------------------------------------- ;---------------------------------------------------------------------

View File

@ -1,978 +0,0 @@
; <Lrz> 01.02.2007 ¤®à ¡®âª  edit_box, ¨á¯à ¢¨« ¡ £¨.
; <Lrz> 26.01.2007 ­®à¬ «ì­ ï à ¡®â  ª®¬¯ ­¥­â  ¨á¯à ¢¨« äãªæ¨î .check_offset
; <Lrz> 24.01.2007 ¯®ä¨ªá¥« ¡ £¨ ¢ë§¢ ­ë¥ ­¥ ¯à ¢¨«ì­ë¬ ª®¤®¬ )).
; <Lrz> 22.01.2007 ¨§¡ ¢¨«áï ®â £«îª®¢ ¯à¨ à ¡®â¥ á ¢ë¤¥«¥­¨¥¬ ¨ 㤠«¥­¨¥, ª®à४⭠ï à ¡®â  ª« ¢¨è¥© del & backspase
; <Lrz> 20.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª  ¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace, 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª« ¢¨è¨
; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.06.06 10:40
; <EFBFBD> ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
; <EFBFBD>à®æ¥¤ãàë:
; edit_box.draw - ¯®«­ ï ¯¥à¥à¨á®¢ª ;
; edit_box.key - ®¡à ¡®âª  ª« ¢¨ âãàë;
; edit_box.mouse - ®¡à ¡®âª  ¬ëè¨;
; edit_box.focus - ãáâ ­®¢ª  䮪ãá ;
; edit_box.blur - ¥£® à §¬ë¢ ­¨¥;
; edit_box.get_n - ¯®«ãç¨âì ª®«¨ç¥á⢮ ¯à®à¨á®¢ë¢ ¥¬ëå ᨬ¢®«®¢.
; <EFBFBD>ਠ¢ë§®¢¥ «î¡ëå ¨§ íâ¨å ¯à®æ¥¤ãà ¢ ॣ¨áâॠedi á«¥¤ã¥â
; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
; <EFBFBD>ਬ¥à áâàãªâãàë:
; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
; ¤«¨­ , ¢ëá®â , ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. <EFBFBD>ãä¥à ¤®«¦¥­
; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
; some_edit_text:
; rb 256 ;255+1
; <EFBFBD>ਬ¥à ¢ë§®¢  ¯à®æ¥¤ãàë:
; mov edi,some_edit
; call edit_box.draw
; <EFBFBD>ਠ¢ë§®¢¥ ¯à®æ¥¤ãàë edit_box.key ª®¤ ª« ¢¨è¨ ¤®«¦¥­
; ­ å®¤¨âáï ¢ ah, â® ¥áâì ¯¥à¥¤ ¢ë§®¢®¬ í⮩ ¯à®æ¥¤ãàë ­ ¤® ¢ë§¢ âì
; 2-ãî á¨á¥¬­ãî äã­ªæ¨î, ­ ¯à¨¬¥à:
; mov eax,2
; int 0x40
; mov edi,some_edit1
; call edit_box.key
; mov edi,some_edit2
; call edit_box.key
; <EFBFBD>¥à¥¤ ¢ë§®¢®¬ ®¡à ¡®â稪  ¬ëè¨ á«¥¤ã¥â ¯à®¢¥à¨âì, ï¥âáï «¨ ®ª­®
;  ªâ¨¢­ë¬.
; …᫨ 饫箪 ¬ëè¨ ¡ë« ¯à®©§¢¥¤¥­ §  ¯à¥¤¥« ¬¨ edit box
; 䮪ãá â¥àï¥âáï.
macro use_edit_box
{
edit_box:
ed_width equ [edi] ;è¨à¨­  ª®¬¯®­¥­â 
ed_left equ [edi+4] ;¯®«®¦¥­¨¥ ¯® ®á¨ å
ed_top equ [edi+8] ;¯®«®¦¥­¨¥ ¯® ®á¨ ã
ed_color equ [edi+12] ;梥â ä®­  ª®¬¯®­¥­â 
ed_focus_border_color equ [edi+16] ;梥â à ¬ª¨ ª®¬¯®­¥­â 
ed_blur_border_color equ [edi+20] ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
ed_text_color equ [edi+24] ;梥â ⥪áâ 
ed_max equ [edi+28] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
ed_text equ [edi+32] ;㪠§ â¥«ì ­  ¡ãä¥à
ed_flags equ [edi+36] ;ä« £¨
ed_size equ [edi+38] ;ª®«-¢® ᨬ¢®«®¢
ed_pos equ [edi+42] ;¯®§¨æ¨ï ªãàá®à 
ed_offset equ [edi+46] ;ᬥ饭¨¥
cl_curs_x equ [edi+50] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
cl_curs_y equ [edi+54] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
ed_shift_pos equ [edi+58]
ed_height=14 ; ¢ëá®â 
shift_color=0x6a9480
ed_insert=10000b
ed_insert_cl=1111111111101111b
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
.draw:
pusha
;--- à¨á㥬 à ¬ªã ---
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
.draw_bg_cursor_text:
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
call .check_offset ;¢ëç¨á«¥­¨¥ ¯®§¨æ¨¨ ªãàá®à  áâ ¡¨«ì­ 
;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
call .draw_bg ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª à ¡®ç¥© ®¡« áâ¨
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test word ed_flags,ed_focus
je @f
call .draw_cursor
@@:
call .draw_text
popa
ret
;.str:
; mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
; ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
; cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
; jb @f
; xor edx,edx ;®ç¨áâ¨âì edx
; div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
; push edx ;¯®«®¦¨âì ¢ á⥪
; ;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
; call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
; pop eax
; @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
; ;sbb al,$69 ;- ç¥áâ­® ¤ ­­ ï ¨­áâàãªæ¨ï ¬¥­ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ­¥ §­ î ª ª íâ® à ¡®â ¥â
; ;das ;¯®á«¥ ¤ ­­®© ª®¬ ­¤ë ª ª ¡ë ¯à®¨á室¨â 㬥­ì襭¨¥ al ­  66h (¢ ª­¨£¥ ­ ¯¨á ­® ¤à㣮¥)
; or al,0x30 ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥
; stosb ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
;
; ret ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
.draw_text:
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
call .get_n
mov esi,ed_size
mov ebx,ed_offset
sub esi,ebx
cmp eax,esi
jae @F
mov esi,eax ;çâ®¡ë ­¥ ¢ë室¨âì §  ¯à¥¤¥«ë íªà ­ 
;--- à¨á㥬 ⥪áâ ---
@@: mov eax,4
mov ebx,ed_left
mov edx,ed_offset
add ebx,2
shl ebx,16
mov bx,ed_top
add ebx,4
mov ecx,ed_text_color
add edx,ed_text
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
;¢å®¤­ë¥ ¤ ­­ë¥
;eax
;edx - color
;----------------------------------------------------------
.draw_bg_eax:
mov ecx,ed_top
add ecx,1
shl ecx,16
mov cx,13
mov eax,13
int 0x40
ret
jmp @f
.draw_bg:
mov ebx,ed_left
add ebx,1
shl ebx,16
mov bx,ed_width
sub ebx,1
@@:
mov ecx,ed_top
mov eax,13
add ecx,1
shl ecx,16
mov edx,ed_color
mov cx,ed_height
sub ecx,1
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨­¥ ª®¬¯®­¥­â  --------------
;----------------------------------------------------------
.get_n:
mov eax,ed_width ;¯®«ã祬 è¨à¨­ã ª®¬¯®­¥­â 
xor edx,edx ;१ã«ìâ â à á¯®«®£ ¥âáï ¢ ¯ à¥ edx:eax ¢ eax - ®áâ â®ª
sub eax,4 ;¢ëç⨬ 4
mov ebx,6 ;§ £à㧬¨ ¤¥«¨â¥«ì
div ebx ;à §¬¤¥«¨¬ ­  6
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï ªãàá®à  --------------------------
;----------------------------------------------------------
.clear_cursor:
mov edx,ed_color
test word ed_flags,ed_shift
je @f
mov edx,shift_color
@@:
mov ebx,cl_curs_x
mov ecx,cl_curs_y
jmp .draw_curs
.draw_cursor:
mov edx,ed_text_color
@@:
mov ebx,ed_pos
mov ecx,ed_offset
sub ebx,ecx
lea ebx,[ebx*2+ebx]
shl ebx,1
;imul ebx,6
add bx,ed_left
mov ecx,ed_top
inc ebx
add ecx,2
mov ebp,ebx
shl ebx,16
mov bx,bp
mov ebp,ecx
shl ecx,16
mov cx,bp
add cx,ed_height-4
mov cl_curs_x,ebx
mov cl_curs_y,ecx
.draw_curs:
mov eax,38
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
test dword ed_flags,ed_focus
mov edx,ed_focus_border_color
jne @f
mov edx,ed_blur_border_color
@@:
;--- ᢥàåã ---
mov eax,38
mov ebx,ed_left
mov ecx,ebx
shl ebx,16
mov bx,cx
add bx,ed_width
mov ecx, ed_top
mov esi,ecx
shl ecx,16
mov cx,si
int 0x40
;--- á­¨§ã ---
mov esi,ecx
add ecx,ed_height
mov ebp,ecx
shl ecx,16
mov cx,bp
int 0x40
;--- á«¥¢  ---
mov cx,si
mov ebp,ebx
sub bx,ed_width
int 0x40
;--- á¯à ¢  ---
mov ebx,ebp
shl ebx,16
mov bx,bp
int 0x40
ret
;----------------------------------------------------------
;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
;--- eax = -1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
; ¨§¬¥­¨«®áì
;----------------------------------------------------------
.check_offset:
pushad
mov ecx,ed_pos
mov ebx,ed_offset
cmp ebx,ecx
ja .sub_8
push ebx
call .get_n ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ à¥ ॣ¨áâ஢ edx:eax
pop ebx
mov edx,ebx
add edx,eax ;ed_offset+width editbox
cmp edx,ecx
ja @f
mov edx,ed_size
cmp edx,ecx
je .add_end
sub edx,ecx
cmp edx,8
jbe .add_8
add ebx,8
jmp .chk_d
.sub_8: cmp ecx,0
je .sub_min
cmp ebx,8
jbe .sub_min
sub ebx,8 ;ebx=ed_offset
jmp .chk_d
.sub_min:
xor ebx,ebx
jmp .chk_d
.add_end:sub edx,eax
mov ebx,edx
jmp .chk_d
.add_8: add ebx,edx
; ;----------- ®â« ¤ª 
; pushad
; mov [data_of_code],0
; mov eax,ebx;ed_offset
; mov edi,data_of_code
; call .str
; ;à¨á®¢ ­¨¥ ä®­ 
; mov eax,13
; mov ebx,178*65536+36
; mov ecx,28*65536+10
; xor edx,edx
; int 0x40
; ;¢ë¢®¤ §­ ç¥­¨ï ­  íªà ­
; mov eax,4
; mov ebx,180*65536+30
; mov ecx,0x10DDBBCC
; mov edx,data_of_code
; mov esi,4
; int 0x40
; popad
; ;----------- ®â« ¤ª 
.chk_d: mov ed_offset,ebx
call .draw_bg
mov dword [esp+28],-1
popad
ret
@@:
mov dword [esp+28],0
popad
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mov ebx,eax
; mov eax,ed_pos
; xor edx,edx
; idiv ebx
; xor edx,edx
; imul eax,ebx
; mov ed_offset,eax
; pop ebx
; cmp ax,bx
; je @f
;;;;;;;; ¤ ­­ë¥ ¤«ï § ªà è¨¢ ­¨ï ¢á¥© ¯®«®áë ¯àאַ㣮«ì­¨ª 
; mov ebx,ed_left
; inc ebx
; shl ebx,16
; mov bx,ed_width
; dec ebx
; mov edx,ed_color
; call .draw_bg_eax
; mov dword [esp+28],0
;@@: popad
; ret
;==========================================================
;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
;==========================================================
.key:
pusha
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je .no_figure ;@f
xor ecx,ecx
push eax
inc ecx
mov eax,66
mov ebx,3
int 0x40
test al,0x03
je @f
or word ed_flags,ed_shift
@@: pop eax
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
jz .backspace
cmp ah,0xb6
jz .delete
cmp ah,176
jz .left
cmp ah,179
jz .right
cmp ah,180
jz .home
cmp ah,181
jz .end
cmp ah,185 ;insert
jz .insert
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp ah,177
jz .no_figure
cmp ah,178
jz .no_figure
cmp ah,27 ;ESC - ª« ¢¨è  ))
jz .no_figure
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë ?
jz @f
cmp ah,'0'
jb .no_figure
cmp ah,'9'
ja .no_figure
;¯à®¢¥àª  ­  shift
@@: test word ed_flags,ed_shift_on
je @f
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
push eax
mov edx,ed_size
mov ecx,ed_pos
call .del_char
;;;;
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
pop eax
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
@@: mov ecx,ed_size
mov edx, ed_max
cmp ecx,edx
jae .no_figure
mov ebx, ed_pos
cmp ebx,edx
jl @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
.no_figure:
popa
ret
.insert: test word ed_flags,ed_insert ;not word ed_insert
je .insert_1
and word ed_flags,ed_insert_cl
jmp .no_figure
.insert_1:
or word ed_flags,ed_insert
jmp .no_figure
.ins_v:
dec dword [ebp+38];ed_size ;processing is insert
sub esi,ecx
add esi,ebx
mov edi,esi
jmp .In_k
@@: ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov ecx,ed_size
push edi eax
mov ebp,edi
mov esi,ed_text ; “ª § â¥«ì ­  ¡ãä¥à
;<EFBFBD>㤥¬ à ¡®â âì á® áâப®©
add esi,ecx ;add ed_size ¤®¡ ¢¨¬ max size
mov edi,esi
cmp ecx,ebx ;…᫨ ã ­ á ¯®§¨æ¨ï ªãàá®à  = ⥪ã饬ã à §¬¥àã ­ ¯¥ç â ­­ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®­æ¥
je .In_k
test word [ebp+36],ed_insert ;IF insert is enable â.ª. edi ¨§¬¥­¥­  ¤à¥á㥬 ç¥à¥§ ebp
jne .ins_v
sub ecx,ebx ;<EFBFBD> ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥­¨ï.
inc edi ;‘¬¥á⨬ ­ è¨ ᨬ¢®«ë ¢ ¯à ¢®
std
inc ecx
@@:
;--------
lodsb
stosb
;--------
loop @b
.In_k: cld
pop eax
mov al,ah
stosb
pop edi
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
inc dword ed_pos
call .draw_all2
jmp .shift;.draw_cursor_text
.delete:
mov edx,ed_size
mov ecx,ed_pos
cmp edx,ecx
jg .bac_del
test word ed_flags,ed_shift_on
jne .del_bac
popa
ret
.bac_del:
call .del_char
jmp .draw_all
;--- ­ ¦ â  ª« ¢¨è  backspace ---
.backspace:
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
mov edx,ed_size
mov ecx,ed_pos
test ecx,ecx
jnz .del_bac
test word ed_flags,ed_shift_on
jne .bac_del
popa
ret
.del_bac:
cmp edx,ecx ;if ed_pos=ed_size
je @f
dec ecx
call .del_char
@@: test word ed_flags,ed_shift_on
jne .bac_del
dec dword ed_pos
.draw_all:
push .shift;.draw_cursor_text;eax
test word ed_flags,ed_shift_on
je @f
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
jmp .draw_all2
@@: dec dword ed_size
.draw_all2:
and word ed_flags,ed_shift_cl
call .clear_cursor
call .check_offset
;;;;;;;;;;;;;;;
test eax,eax
jne @f
call .draw_bg
ret
;;;;;;;;;;;;;;;
@@: call .get_n
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,ed_size
cmp eax,ebx
jb @f
mov eax,ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;It is don't optimal
pop eax ;ed_pos
mov ecx,ed_offset
sub eax,ecx
.nxt:
mov ebp,eax ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
add ebp,ebx
pop edx
cmp ebp,edx
je @f
inc ebx
@@: mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,ed_color
call .draw_bg_eax
ret
; jmp .shift
;--- ­ ¦ â  ª« ¢¨è  left ---
.left: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
dec dword ed_pos
jmp .nd_k
;--- ­ ¦ â  ª« ¢¨è  right ---
.right: call .sh_enable
mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
call .clear_cursor
inc dword ed_pos
jmp .nd_k
.home: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
xor eax,eax
mov ed_pos,eax
jmp .nd_k
.end: call .sh_enable
mov ebx,ed_pos
cmp ebx,dword ed_size
je .nd_k
call .clear_cursor
mov eax,ed_size
mov ed_pos,eax
.nd_k: call .check_offset
;test eax,eax
;jz .draw_bg_cursor_text
call .draw_cursor
.shift: ;;;;;;;SHIFT
call .draw_bg ;­¥ ®¯â¨¬ «ì­®
test word ed_flags,ed_shift
je .f_exit
;;;;;;SHIFT end
mov eax,dword ed_pos
mov ebx,dword ed_shift_pos
cmp eax,ebx
jae .sh_n
push eax ;¬¥­ì襥 ¢ eax
push ebx ;¡®«ì襥
jmp .sh_n1
;¥á«¨ ¨­ ç¥
.sh_n: push ebx
push eax
.sh_n1:
; jmp .draw_all2
;;;;;;;;;;;;;;;;;;;;;;;;;
;call .clear_cursor
call .check_offset
call .get_n
mov edx,eax ;size of ed_box
; push eax
mov ecx,ed_offset
add eax,ecx ;eax = w_off= ed_offset+width
mov ebp,eax ;save
pop ebx ;¡®«ì襥
pop eax ;¬¥­ì襥
cmp eax,ecx ;áà ¢­¥­¨¥ á ¬¥­ì襣® á offset.
jae .f_f ;¥á«¨ ¡®«ìè¥
xor eax,eax
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jb @f
sub ebx,ecx
jmp .nxt_f
@@: mov ebx,ebp
sub ebx,ecx
jmp .nxt_f
.f_f:
sub eax,ecx
cmp ebp,ebx ; ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jle @f
sub ebx,ecx
sub ebx,eax
jmp .nxt_f
@@:
mov ebx,ebp
sub ebx,ecx
sub ebx,eax
.nxt_f:
mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,shift_color
call .draw_bg_eax
and word ed_flags,1111111111111011b
jmp .draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
.f_exit: and word ed_flags,ed_shift_cl
jmp .draw_cursor_text
;¯à®¢¥àª  á®áâ®ï­¨ï shift ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
.sh_enable:
test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne .sh_ext_en
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
ret
@@: and word ed_flags,ed_shift_cl
.sh_ext_en: ret
;- 㤠«¥­¨¥ ᨬ¢®« 
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
.del_char:
mov esi,ed_text
test word ed_flags,ed_shift_on
je @f
mov eax,dword ed_shift_pos
mov ebx,esi
cmp eax,ecx
jae .dh_n
mov ed_pos,eax ;çâ® ¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
mov ebp,ecx
sub ebp,eax
add ebx,eax ;eax ¬¥­ìè¥
sub edx,ecx
add esi,ecx
mov ed_shift_pos,ebp
jmp .del_ch_sh
;¥á«¨ ¨­ ç¥
.dh_n:
mov ebp,eax
sub ebp,ecx
add ebx,ecx
sub edx,eax
add esi,eax
mov ed_shift_pos,ebp
jmp .del_ch_sh
@@: add esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãää¥àã
mov ebx,esi
inc esi
cld
sub edx,ecx
.del_ch_sh:
push edi
mov edi,ebx
@@:
lodsb
stosb
dec edx
jns @b
pop edi
ret
;==========================================================
;=== ®¡à ¡®âª  ¬ëè¨ =======================================
;==========================================================
.mouse:
pusha
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
;----------------------------------------------------------
mov eax,37
mov ebx,2
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
;----------------------------------------------------------
test eax,1
jnz .mouse_left_button
@@: popa
ret
.mouse_left_button:
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
;----------------------------------------------------------
mov eax,37
xor ebx,ebx
inc ebx
int 0x40
;----------------------------------------------------------
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
;----------------------------------------------------------
mov ebx,ed_top
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_height
cmp ax,bx
jg ._blur;.mouse_end_no_focus
shr eax,16
mov bx,ed_left
cmp ax,bx
jl ._blur;.mouse_end_no_focus
add bx,ed_width
cmp ax,bx
jg ._blur;.mouse_end_no_focus
;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
push eax
call .clear_cursor
pop eax
xor dx,dx
sub ax,ed_left
add ax,2
mov bx,6
div bx
add ax,ed_offset
cmp ax,ed_size
jna @f
mov ax,ed_size
@@:
mov ed_pos,ax
call .check_offset
call .draw_cursor
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
bts word ed_flags,1
jc .mouse_pressed
call .draw_cursor
call .draw_border
.mouse_pressed:
popa
ret
;.mouse_end_no_focus:
; call .blur
;popa
;ret
;.blur:
;pusha
._blur:
test word ed_flags,ed_always_focus
jne @f
btr word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
jnc @f
call .clear_cursor
call .draw_border
@@:
popa
ret
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  à §¬ë¢ ­¨ï 䮪ãá  --------------------------
;----------------------------------------------------------
;.blur:
;pusha
;._blur:
;btr ed_flags,1
;jnc @f
;call .draw_border
;call .clear_cursor
;@@:
;popa
;ret
}
ed_figure_only=1000000000000000b
ed_always_focus=100000000000000b
ed_focus=10b
ed_shift_on=1000b
ed_shift=100b
ed_shift_cl=1111111111110011b
macro draw_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.draw
add edi,ed_struc_size
loop @b
}
macro mouse_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.mouse
add edi,ed_struc_size
loop @b
}
macro key_edit_boxes start,end
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
@@:
call edit_box.key
add edi,ed_struc_size
loop @b
}
ed_struc_size=62
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
.width dd width
.left dd left
.top dd top
.color dd color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.max dd max
.text dd text
.flags dw flags+0
.size dd size+0
.pos dd 0
.offset dd 0
.cl_curs_x dd 0
.cl_curs_y dd 0
.shift dd 0
}
macro edit_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ed_struc_size)
mov esi,color_table
@@:
mov eax,[esi+36]
mov ebx,[esi+20]
mov ed_focus_border_color,eax
shr bh,1
shr bl,1
shr ah,1
shr al,1
add ah,bh
add al,bl
ror eax,16
ror ebx,16
shr bl,1
shr al,1
add al,bl
ror eax,16
mov ed_blur_border_color,eax
add edi,ed_struc_size
loop @b
}
macro draw_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.draw
}
macro mouse_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.mouse
}
macro key_edit_box ed_ptr
{
mov edi,ed_ptr
call edit_box.key
}