editbox update by Prohor N.

git-svn-id: svn://kolibrios.org@7919 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-05-14 19:14:14 +00:00
parent fc19507247
commit e8665a7cf1
3 changed files with 1185 additions and 1069 deletions

View File

@ -22,6 +22,7 @@ include '../../../../KOSfuncs.inc'
include 'bl_sys.mac'
include 'box_lib.mac' ;macro which should make life easier :)
;include '../../../../debug.inc'
include 'keys.inc'
;-----------------------------------------------------------------------------
mem.alloc dd ? ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè

View File

@ -1,57 +1,3 @@
macro use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll,pgup,pgdown
{
if up eq
else
cmp ah,178
jz edit_box.editbox_exit
end if
if down eq
else
cmp ah,177
jz edit_box.editbox_exit
end if
if esc eq
else
cmp ah,27 ;ESC - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if enter eq
else
cmp ah,13 ;ENTER - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if tab eq
else
cmp ah,9 ;TAB - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if numl eq
else
cmp ah,4 ;Num Lock - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if capsl eq
else
cmp ah,2 ;Caps Lock - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if scrolll eq
else
cmp ah,1 ;Scroll Lock - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if pgup eq
else
cmp ah,184 ;Page Up - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
if pgdown eq
else
cmp ah,183 ;Page Dwon - ª« ¢¨è  ))
jz edit_box.editbox_exit
end if
}
SCAN_LWIN_RELEASE = 0xDB
SCAN_RWIN_RELEASE = 0xDC
@ -83,12 +29,12 @@ edit_box:
call .draw_border
.draw_bg_cursor_text:
;test word ed_flags,ed_focus ; for unfocused controls =>
;jz .sjip_offset ; do not recalculate offset (big OS behaviour)
;jz .skip_offset ; do not recalculate offset
call .check_offset
;.sjip_offset:
;.skip_offset:
call .draw_bg
test word ed_flags,ed_focus ; for unfocused controls =>
jz .draw_cursor_text ; do not draw selection(named shift)
test word ed_flags,ed_focus ; do not draw selection(named shift)
jz .draw_cursor_text ;
call .draw_shift
.draw_cursor_text:
call .draw_text
@ -116,78 +62,90 @@ edit_box_key:
;--------------------------------------
; this code for Win-keys, works with
; kernel SVN r.3356 or later
push eax
push ebx
mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS
test ax,0x200 ; LWin
jnz .win_key_pressed
test ax,0x400 ; RWin
jz @f
.win_key_pressed:
pop ebx
pop eax
jmp edit_box.editbox_exit
@@: pop ebx
pop eax
test ah,$06 ; LWin ($02) & RWin ($04)
jnz edit_box.editbox_exit
;--------------------------------------
;<3B>஢¥àª  ­ ¦ â shift ?
call edit_box_key.check_shift_ctrl_alt
test al,$03
je @f
or word ed_flags,ed_shift ;ãáâ ­®¢¨¬ ä« £ Shift
@@:
and word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
test al,$0C
je @f
or word ed_flags,ed_ctrl_on ;ãáâ ­®¢¨¬ ä« £ Ctrl
@@:
and word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
test al,$30
je @f
or word ed_flags,ed_alt_on ;ãáâ ­®¢¨¬ ä« £ Alt
@@:
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
jz edit_box_key.backspace
cmp ah,0xb6
jz edit_box_key.delete
cmp ah,176
jz edit_box_key.left
cmp ah,179
jz edit_box_key.right
cmp ah,180
jz edit_box_key.home
cmp ah,181
jz edit_box_key.end
cmp ah,185 ;insert
jz edit_box_key.insert
mov eax,[esp+28]
; get scancode in ah
ror eax,8
; check for ctrl+ combinations
test word ed_flags,ed_ctrl_on
jz @f
cmp ah,45 ; Ctrl + X
cmp ah,SCAN_CODE_X ; Ctrl + X
je edit_box_key.ctrl_x
cmp ah,46 ; Ctrl + C
cmp ah,SCAN_CODE_C ; Ctrl + C
je edit_box_key.ctrl_c
cmp ah,47 ; Ctrl + V
cmp ah,SCAN_CODE_V ; Ctrl + V
je edit_box_key.ctrl_v
cmp ah,30 ; Ctrl + A
cmp ah,SCAN_CODE_A ; Ctrl + A
je edit_box_key.ctrl_a
jmp edit_box.editbox_exit
@@:
cmp ah,SCAN_LWIN_RELEASE
cmp ah,SCAN_CODE_SPACE
ja @F
cmp al,ASCII_KEY_BACK
jz edit_box_key.backspace
cmp ah,SCAN_CODE_ESCAPE
jz edit_box.editbox_exit
cmp ah,SCAN_RWIN_RELEASE
cmp ah,SCAN_CODE_TAB
jz edit_box.editbox_exit
; restore ascii code
rol eax,8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§ â.¥. ¯à¨ ®¡­ à㦥­¨¨
;íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll,pgup,pgdown
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;<3B>஢¥àª  ãáâ ­®¢«¥­ «¨ ä« £ ¯à¨ ª®â®à®¬ ­ã¦­® ¢ë¢®¤¨âì
;⮫쪮 æ¨äàë ¢ ­ã¦­®¬ ¡®ªá¥
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp ah,SCAN_CODE_RETURN
jz edit_box.editbox_exit
jmp .printable_character
@@:
cmp ah,SCAN_CODE_DELETE
ja edit_box.editbox_exit
cmp ah,SCAN_CODE_HOME
jb edit_box.editbox_exit
cmp ax,SCAN_CODE_CLEAR shl 8 + ASCII_KEY_CLEAR ; not operate numpad unlocked 5
jz edit_box.editbox_exit
;here best place to filter up,down,pgup,pgdown
cmp al,ASCII_KEY_LEFT
jb .printable_character
and eax,$F
mov ebx,.unlock_numpad_filtration
jmp dword[ebx+eax*4]
.unlock_numpad_filtration \
dd edit_box_key.left, \ ; LEFT
edit_box.editbox_exit,\ ; DOWN
edit_box.editbox_exit,\ ; UP
edit_box_key.right, \ ; RIGHT
edit_box_key.home, \ ; HOME
edit_box_key.end, \ ; END
edit_box_key.delete, \ ; DELETE
edit_box.editbox_exit,\ ; PGDN
edit_box.editbox_exit,\ ; PGUP
edit_box_key.insert ; INSERT
.printable_character:
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë?
jz @f
cmp ah,'0'
cmp al,'0'
jb edit_box.editbox_exit
cmp ah,'9'
cmp al,'9'
ja edit_box.editbox_exit
@@:
; restore ascii code
rol eax,8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;¯à®¢¥àª  ­  shift, ¡ë« «¨ ­ ¦ â
@ -263,12 +221,7 @@ edit_box_key.In_k:
;Ž¡à ¡®âª  ª« ¢¨è insert,delete,backspace,home,end,left,right
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
edit_box_key.insert:
test word ed_flags,ed_insert
je @f
and word ed_flags,ed_insert_cl
jmp edit_box.editbox_exit
@@: or word ed_flags,ed_insert
xor word ed_flags,ed_insert
jmp edit_box.editbox_exit
edit_box_key.ins_v:
@ -874,31 +827,35 @@ edit_box.draw_border:
jne @f
mov edx,ed_blur_border_color
@@:
;mov edx,$808080
mov ebx,ed_left
mov ecx,ebx
mov eax,ebx
shl ebx,16
add ebx,ecx
add ebx,ed_width
add ebx,eax
;add ebx,ed_width
mov ecx,ed_top
mov esi,ecx
mov eax,ecx
shl ecx,16
add ecx,esi
mcall SF_DRAW_LINE ; top
mov esi,ecx
add ecx,eax
push ecx
inc ecx
add ecx,ed_height
mov ebp,ecx
shl ecx,16
mov cx,bp
mcall ; bottom
mov cx,si
mov ebp,ebx
sub ebx,ed_width
mcall ; left
mov ebx,ebp
shl ebx,16
mov bx,bp
mcall SF_DRAW_LINE ; left
xchg ecx,[esp]
add ebx,ed_width
mcall ; top
;or edx,-1
pop ecx
push cx
push cx
push ebx
push bx
push bx
pop ebx
mcall ; right
pop ebx
pop ecx
mcall ; bottom
ret
;----------------------------------------------------------
@ -1308,29 +1265,6 @@ edit_box_key.draw_rectangle:
mov edx,ebp
jmp edit_box.draw_bg_eax
;;;;;;;;;;;;;;;;;;
;;<3B>஢¥àª  ­ ¦ â «¨ shift
;;;;;;;;;;;;;;;;;;
edit_box_key.check_shift_ctrl_alt:
pusha
mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS
test al,11b
je @f
or word ed_flags,ed_shift ;ãáâ ­®¢¨¬ ä« £ Shift
@@:
and word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
test al,1100b
je @f
or word ed_flags,ed_ctrl_on ;ãáâ ­®¢¨¬ ä« £ Ctrl
@@:
and word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
test al,110000b
je @f
or word ed_flags,ed_alt_on ;ãáâ ­®¢¨¬ ä« £ Alt
@@:
popad
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;”㭪樨 ¤«ï à ¡®âë á mouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -0,0 +1,181 @@
; Key scan codes
SCAN_CODE_ESCAPE = $01
SCAN_CODE_1 = $02
SCAN_CODE_2 = $03
SCAN_CODE_3 = $04
SCAN_CODE_4 = $05
SCAN_CODE_5 = $06
SCAN_CODE_6 = $07
SCAN_CODE_7 = $08
SCAN_CODE_8 = $09
SCAN_CODE_9 = $0A
SCAN_CODE_0 = $0B
SCAN_CODE_MINUS = $0C
SCAN_CODE_PLUS = $0D
SCAN_CODE_BACK = $0E
SCAN_CODE_TAB = $0F
SCAN_CODE_Q = $10
SCAN_CODE_W = $11
SCAN_CODE_E = $12
SCAN_CODE_R = $13
SCAN_CODE_T = $14
SCAN_CODE_Y = $15
SCAN_CODE_U = $16
SCAN_CODE_I = $17
SCAN_CODE_O = $18
SCAN_CODE_P = $19
SCAN_CODE_RETURN = $1C
SCAN_CODE_A = $1E
SCAN_CODE_S = $1F
SCAN_CODE_D = $20
SCAN_CODE_F = $21
SCAN_CODE_G = $22
SCAN_CODE_H = $23
SCAN_CODE_J = $24
SCAN_CODE_K = $25
SCAN_CODE_L = $26
SCAN_CODE_Z = $2C
SCAN_CODE_X = $2D
SCAN_CODE_C = $2E
SCAN_CODE_V = $2F
SCAN_CODE_B = $30
SCAN_CODE_N = $31
SCAN_CODE_M = $32
SCAN_CODE_DIVIDE = $35 ; Numpad divide (has ASCII $2F)
SCAN_CODE_MULTIPLY = $37 ; Numpad multiply (has ASCII $2A)
SCAN_CODE_SNAPSHOT = $37 ; Print Screen (has ASCII $34)
SCAN_CODE_SPACE = $39
SCAN_CODE_CAPITAL_PRESSED = $3A ; Caps Lock
SCAN_CODE_F1 = $3B
SCAN_CODE_F2 = $3C
SCAN_CODE_F3 = $3D
SCAN_CODE_F4 = $3E
SCAN_CODE_F5 = $3F
SCAN_CODE_F6 = $40
SCAN_CODE_F7 = $41
SCAN_CODE_F8 = $42
SCAN_CODE_F9 = $43
SCAN_CODE_F10 = $44
SCAN_CODE_NUMLOCK_PRESSED = $45
SCAN_CODE_SCROLL_PRESSED = $46 ; Scroll Lock
SCAN_CODE_CANCEL_PRESSED = $46 ; Ctrl+Break ; share with scroll lock ASCII & scan code, but require 2 buttons Ctrl & Pause Break to be pressed same time, while scroll lock only 1 button
SCAN_CODE_NUMPAD_7 = $47
SCAN_CODE_HOME = $47
SCAN_CODE_NUMPAD_8 = $48
SCAN_CODE_UP = $48
SCAN_CODE_NUMPAD_9 = $49
SCAN_CODE_PGUP = $49
SCAN_CODE_SUBTRACT = $4A ; Numpad substract (has ASCII $4A)
SCAN_CODE_NUMPAD_4 = $4B
SCAN_CODE_LEFT = $4B
SCAN_CODE_NUMPAD_5 = $4C
SCAN_CODE_CLEAR = $4C ; Numpad unlocked 5(has ASCII $37)
SCAN_CODE_NUMPAD_6 = $4D
SCAN_CODE_RIGHT = $4D
SCAN_CODE_ADD = $4E ; Numpad add (has ASCII $2B)
SCAN_CODE_NUMPAD_1 = $4F
SCAN_CODE_END = $4F
SCAN_CODE_NUMPAD_2 = $50
SCAN_CODE_DOWN = $50
SCAN_CODE_NUMPAD_3 = $51
SCAN_CODE_PGDN = $51
SCAN_CODE_NUMPAD_0 = $52
SCAN_CODE_INSERT = $52
SCAN_CODE_DECIMAL = $53 ; Numpad loced decimal separator
SCAN_CODE_DELETE = $53
SCAN_CODE_LWIN_PRESSED = $5B
SCAN_CODE_RWIN_PRESSED = $5C
SCAN_CODE_CONTEXT = $5D ; right mouse button analog
SCAN_CODE_CAPITAL_RELEASED = $BA ; Caps Lock
SCAN_CODE_NUMLOCK_RELEASED = $C5
SCAN_CODE_SCROLL_RELEASED = $C6 ; Scroll Lock
SCAN_CODE_CANCEL_RELEASED = $C6 ; Ctrl+Break
SCAN_CODE_LWIN_RELEASED = $DB
SCAN_CODE_RWIN_RELEASED = $DC
; ASCII key codes
_ASCII equ $FF and
_CTRL equ $A0 +
ASCII_KEY_CANCEL = $01 ; ; Ctrl+Break ; share with scroll lock ASCII & scan code, but require 2 buttons Ctrl & Pause Break to be pressed same time, while scroll lock only 1 button
ASCII_KEY_SCROLL = $01 ; ; Scroll Lock
ASCII_KEY_NUMLOCK = $02
ASCII_KEY_CAPITAL = $04 ; Caps Lock
ASCII_KEY_BACK = $08
ASCII_KEY_CTRL_BACK = _ASCII(_CTRL(ASCII_KEY_BACK))
ASCII_KEY_TAB = $09
ASCII_KEY_CTRL_TAB = _ASCII(_CTRL(ASCII_KEY_TAB))
ASCII_KEY_RETURN = $0D
ASCII_KEY_CTRL_RETURN = _ASCII(_CTRL(ASCII_KEY_RETURN))
ASCII_KEY_ESCAPE = $1B
ASCII_KEY_CTRL_ESCAPE = _ASCII(_CTRL(ASCII_KEY_ESCAPE))
ASCII_KEY_SPACE = $20
ASCII_KEY_CTRL_SPACE = _ASCII(_CTRL(ASCII_KEY_SPACE))
ASCII_KEY_CTRL_0 = _ASCII(_CTRL('0'))
ASCII_KEY_CTRL_1 = _ASCII(_CTRL('1'))
ASCII_KEY_CTRL_2 = _ASCII(_CTRL('2'))
ASCII_KEY_CTRL_3 = _ASCII(_CTRL('3'))
ASCII_KEY_CTRL_4 = _ASCII(_CTRL('4'))
ASCII_KEY_CTRL_5 = _ASCII(_CTRL('5'))
ASCII_KEY_CTRL_6 = _ASCII(_CTRL('6'))
ASCII_KEY_CTRL_7 = _ASCII(_CTRL('7'))
ASCII_KEY_CTRL_8 = _ASCII(_CTRL('8'))
ASCII_KEY_CTRL_9 = _ASCII(_CTRL('9'))
ASCII_KEY_NUMPAD_0 = '0' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_0 = '0' ; numpad locked 0
ASCII_KEY_NUMPAD_1 = '1' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_1 = '1' ; numpad locked 0
ASCII_KEY_NUMPAD_2 = '2' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_2 = '2' ; numpad locked 0
ASCII_KEY_NUMPAD_3 = '3' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_3 = '3' ; numpad locked 0
ASCII_KEY_NUMPAD_4 = '4' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_4 = '4' ; numpad locked 0
ASCII_KEY_NUMPAD_5 = '5' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_5 = '5' ; numpad locked 0
ASCII_KEY_NUMPAD_6 = '6' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_6 = '6' ; numpad locked 0
ASCII_KEY_NUMPAD_7 = '7' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_7 = '7' ; numpad locked 0
ASCII_KEY_NUMPAD_8 = '8' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_8 = '8' ; numpad locked 0
ASCII_KEY_NUMPAD_9 = '9' ; numpad locked 0
ASCII_KEY_CTRL_NUMPAD_9 = '9' ; numpad locked 0
ASCII_KEY_CLEAR = $37 ; Numpad unlocked 5
ASCII_KEY_CTRL_CLEAR = _ASCII(_CTRL(ASCII_KEY_CLEAR))
ASCII_KEY_LEFT = $B0
ASCII_KEY_CTRL_LEFT = _ASCII(_CTRL(ASCII_KEY_LEFT))
ASCII_KEY_DOWN = $B1
ASCII_KEY_CTRL_DOWN = _ASCII(_CTRL(ASCII_KEY_DOWN))
ASCII_KEY_UP = $B2
ASCII_KEY_CTRL_UP = _ASCII(_CTRL(ASCII_KEY_UP))
ASCII_KEY_RIGHT = $B3
ASCII_KEY_CTRL_RIGHT = _ASCII(_CTRL(ASCII_KEY_RIGHT))
ASCII_KEY_HOME = $B4
ASCII_KEY_CTRL_HOME = _ASCII(_CTRL(ASCII_KEY_HOME))
ASCII_KEY_END = $B5
ASCII_KEY_CTRL_END = _ASCII(_CTRL(ASCII_KEY_END))
ASCII_KEY_DELETE = $B6
ASCII_KEY_CTRL_DELETE = _ASCII(_CTRL(ASCII_KEY_DELETE))
ASCII_KEY_PGDN = $B7
ASCII_KEY_CTRL_PGDN = _ASCII(_CTRL(ASCII_KEY_PGDN))
ASCII_KEY_PGUP = $B8
ASCII_KEY_CTRL_PGUP = _ASCII(_CTRL(ASCII_KEY_PGUP))
ASCII_KEY_INSERT = $B9
ASCII_KEY_CTRL_INSERT = _ASCII(_CTRL(ASCII_KEY_INSERT))