Fix ekey/xkey problem

parent f851cf22
......@@ -196,6 +196,9 @@ Variable ekey-buffer
THEN
0 ;
: clear-ekey-buffer ( -- )
ekey-buffer $off ;
: esc-prefix ( -- u )
key? \ ?dup-0=-if 1 ms key? endif \ workaround for Windows 1607 Linux
if
......@@ -203,11 +206,11 @@ Variable ekey-buffer
ekey-buffer $@ esc-mask >r
esc-sequences search-wordlist
if
execute r> or exit
execute r> or clear-ekey-buffer exit
endif
rdrop
endif
ekey-buffer $@ unkeys #esc ;
ekey-buffer $@ unkeys #esc clear-ekey-buffer ;
: esc-sequence ( u1 addr u -- ; name execution: -- u2 ) recursive
\ define escape sequence addr u (=name) to have value u1; if u1=0,
......@@ -294,9 +297,6 @@ k-down s" OB" esc-sequence
set-current
[ENDIF]
: clear-ekey-buffer ( -- )
ekey-buffer $off ;
[IFDEF] max-single-byte
: read-xkey ( key -- flag )
ekey-buffer c$+!
......@@ -327,8 +327,7 @@ set-current
dup EOK = IF drop k-eof EXIT THEN
dup #esc =
if
drop clear-ekey-buffer
esc-prefix exit
drop esc-prefix exit
then
[IFDEF] max-single-byte
get-xkey
......@@ -374,31 +373,6 @@ Variable vt100-modifier
ctrl-i postpone Literal ;
interpret/compile: ctrl ( "<char>" -- ctrl-code )
keycode-limit keycode-start - buffer: ekey>ctrl
: ekey-bind ( ctrl-key ekey -- )
keycode-start - ekey>ctrl + c! ;
ctrl B k-left ekey-bind
ctrl F k-right ekey-bind
ctrl P k-up ekey-bind
ctrl N k-down ekey-bind
ctrl A k-home ekey-bind
ctrl E k-end ekey-bind
ctrl X k-delete ekey-bind
ctrl L k-winch ekey-bind
ctrl D k-eof ekey-bind
: ekey>ckey ( key -- ckey )
dup k-left u>= IF
dup [ 1 mask-shift# lshift 1- ]l and ekey>ctrl + c@
swap mask-shift# rshift 7 and vt100-modifier !
ELSE vt100-modifier off
THEN ;
: edit-ekey ( -- key )
ekey ekey>ckey ;
' ekey is edit-key
\G True if a keyboard event is available.
......
......@@ -110,41 +110,46 @@ Create actions
ELSE drop THEN
o> ;
: togglekb-0 togglekb 0 ;
: aback-0 aback 0 ;
Create keycode>ekey
AKEYCODE_HOME , k-home ,
AKEYCODE_DPAD_UP , k-up ,
AKEYCODE_DPAD_DOWN , k-down ,
AKEYCODE_VOLUME_UP , k-up ,
AKEYCODE_VOLUME_DOWN , k-down ,
AKEYCODE_DPAD_LEFT , k-left ,
AKEYCODE_DPAD_RIGHT , k-right ,
AKEYCODE_TAB , #tab ,
AKEYCODE_ENTER , #cr ,
AKEYCODE_DEL , #bs ,
AKEYCODE_FORWARD_DEL , k-delete ,
AKEYCODE_PAGE_UP , k-prior ,
AKEYCODE_PAGE_DOWN , k-next ,
AKEYCODE_MOVE_HOME , k-home ,
AKEYCODE_MOVE_END , k-end ,
AKEYCODE_INSERT , k-insert ,
AKEYCODE_F1 , k-f1 ,
AKEYCODE_F2 , k-f2 ,
AKEYCODE_F3 , k-f3 ,
AKEYCODE_F4 , k-f4 ,
AKEYCODE_F5 , k-f5 ,
AKEYCODE_F6 , k-f6 ,
AKEYCODE_F7 , k-f7 ,
AKEYCODE_F8 , k-f8 ,
AKEYCODE_F9 , k-f9 ,
AKEYCODE_F10 , k-f10 ,
AKEYCODE_F11 , k-f11 ,
AKEYCODE_F12 , k-f12 ,
0 , 0 ,
AKEYCODE_HOME , ' k-home ,
AKEYCODE_DPAD_UP , ' k-up ,
AKEYCODE_DPAD_DOWN , ' k-down ,
AKEYCODE_VOLUME_UP , ' k-up ,
AKEYCODE_VOLUME_DOWN , ' k-down ,
AKEYCODE_DPAD_LEFT , ' k-left ,
AKEYCODE_DPAD_RIGHT , ' k-right ,
AKEYCODE_TAB , ' #tab ,
AKEYCODE_ENTER , ' #cr ,
AKEYCODE_DEL , ' #bs ,
AKEYCODE_FORWARD_DEL , ' k-delete ,
AKEYCODE_PAGE_UP , ' k-prior ,
AKEYCODE_PAGE_DOWN , ' k-next ,
AKEYCODE_MOVE_HOME , ' k-home ,
AKEYCODE_MOVE_END , ' k-end ,
AKEYCODE_INSERT , ' k-insert ,
AKEYCODE_F1 , ' k-f1 ,
AKEYCODE_F2 , ' k-f2 ,
AKEYCODE_F3 , ' k-f3 ,
AKEYCODE_F4 , ' k-f4 ,
AKEYCODE_F5 , ' k-f5 ,
AKEYCODE_F6 , ' k-f6 ,
AKEYCODE_F7 , ' k-f7 ,
AKEYCODE_F8 , ' k-f8 ,
AKEYCODE_F9 , ' k-f9 ,
AKEYCODE_F10 , ' k-f10 ,
AKEYCODE_F11 , ' k-f11 ,
AKEYCODE_F12 , ' k-f12 ,
AKEYCODE_MENU , ' togglekb-0 ,
AKEYCODE_BACK , ' aback-0 ,
0 , ' false ,
DOES> ( akey -- ekey )
swap >r
BEGIN dup cell+ swap @ r@ <> WHILE cell+
dup @ 0= UNTIL r@ unknown-key# !
THEN @ rdrop ;
BEGIN dup cell+ swap @ r@ <> WHILE
dup cell+ swap @ 0= UNTIL r@ unknown-key# !
THEN perform rdrop ;
also jni
......@@ -153,14 +158,14 @@ also jni
ke_getMetaState meta-key# !
getAction dup 2 = IF drop
getKeyCode
?dup-IF keycode>ekey top-act .ekeyed
?dup-IF keycode>ekey ?dup-IF top-act .ekeyed THEN
ELSE nostring getCharacters jstring>sstring top-act .ukeyed jfree
THEN
ELSE
0= IF
getUnicodeChar
?dup-IF >xstring top-act .ukeyed
ELSE getKeyCode keycode>ekey top-act .ekeyed
ELSE getKeyCode keycode>ekey ?dup-IF top-act .ekeyed THEN
THEN
THEN
THEN o> ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment