Edit for android words a lot better now

parent a966d8d5
......@@ -23,6 +23,14 @@
\ platform specific action handler
\ edit actor
edit-terminal-c class
cell uvar edit$ \ pointer to the edited string
end-class edit-widget-c
edit-widget-c ' new static-a with-allocater Constant edit-widget
[IFDEF] x11 include x11-actors.fs [THEN]
[IFDEF] android include android-actors.fs [THEN]
......@@ -123,13 +131,7 @@ box-actor is clicked
: box[] ( o -- o )
>o box-actor new to act o act >o to caller-w o> o o> ;
\ edit actor
edit-terminal-c class
cell uvar edit$ \ pointer to the edited string
end-class edit-widget-c
edit-widget-c ' new static-a with-allocater Constant edit-widget
\ edit widget
: grow-edit$ { max span addr pos1 more -- max span addr pos1 true }
max span more + u> IF max span addr pos1 true EXIT THEN
......@@ -212,11 +214,11 @@ edit-terminal edit-out !
\ edit things
: edit-xt ( xt o:actor -- )
edit-out @ >r history >r edit-widget edit-out ! >r 0 to history
history >r >r 0 to history
edit-w >o addr text$ curpos cursize 0 max o> to xselw
>r dup edit$ ! $@ swap over swap r>
r> catch >r edit-w >o to curpos 0 to cursize o> drop edit$ @ $!len drop
r> r> edit-out ! r> to history throw
r> r> to history throw
need-sync on need-glyphs on ;
: edit>curpos ( x o:actor -- )
......
......@@ -110,13 +110,60 @@ Create actions
ELSE drop THEN
o> ;
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 ,
DOES> ( akey -- ekey )
swap >r
BEGIN dup cell+ swap @ r@ <> WHILE cell+
dup @ 0= UNTIL r@ unknown-key# !
THEN @ rdrop ;
also jni
: key>action ( event -- )
key>event
BEGIN key? WHILE ekey
ekey>xchar over #del <> and over bl u>= and
IF >xstring top-act .ukeyed
ELSE top-act .ekeyed THEN
REPEAT ;
dup to key-event >o
ke_getMetaState meta-key# !
getAction dup 2 = IF drop
getKeyCode
?dup-IF keycode>ekey top-act .ekeyed
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
THEN
THEN
THEN o> ;
:noname ( -- )
uptimeMillis lasttime 2@ d- twoclicks s>d d>= IF
......@@ -128,10 +175,33 @@ Create actions
THEN
THEN ; is ?looper-timeouts
: edit-setstring ( string -- )
jstring>sstring setstring$ $! jfree
need-sync on need-glyphs on ;
: edit-commit ( string/0 -- ) ?dup-IF
jstring>sstring setstring$ $! jfree
THEN
setstring$ @ { w^ s$ } setstring$ off
s$ $@
BEGIN dup WHILE over c@ #del = WHILE
2>r #bs top-act .ekeyed 2r> 1 /string REPEAT THEN
BEGIN dup WHILE 2dup "\e[3~" string-prefix? WHILE
2>r k-delete top-act .ekeyed 2r> 4 /string REPEAT THEN
?dup-IF top-act .ukeyed ELSE drop THEN
s$ $free ;
previous
: enter-minos ( -- )
['] touch>action is android-touch
['] key>action is android-key ;
edit-widget edit-out !
['] touch>action is android-touch
['] key>action is android-key
['] edit-setstring is android-setstring
['] edit-commit is android-commit ;
: leave-minos ( -- )
edit-terminal edit-out !
['] touch>event is android-touch
['] key>event is android-key
[ action-of android-setstring ]L is android-setstring
[ action-of android-commit ]L is android-commit
need-sync on need-show on ;
\ No newline at end of file
......@@ -277,15 +277,15 @@ Variable need-glyphs
w border f2* f- text-w f/ to x-scale
text$ render-string ;
: text-!size ( -- )
text-font to font text$ load-glyph$
text$ layout-string
border f+ to h
border f+ to d
fdup to text-w border f2* f+ to w ;
:noname
: text-init
need-glyphs @ IF
text-font to font text$ load-glyph$
THEN ; text to draw-init
THEN ;
' text-init text to draw-init
' text-text text to draw-text
' text-!size text to !size
:noname text-w border f2* f+
......@@ -301,13 +301,22 @@ text class
value: start-curpos \ selection mode
end-class edit
:noname text-init need-glyphs @ IF
cursize 0= setstring$ $@len and IF
setstring$ $@ load-glyph$
THEN
THEN ; edit to draw-init
:noname ( -- )
cursize 0< ?EXIT text-font to font
w border f2* f- text-w f/ { f: scale }
text$ curpos umin layout-string fdrop fdrop
scale f* { f: w }
text$ curpos safe/string cursize m2c:curminchars# @ umax umin
layout-string fdrop fdrop m2c:curminwidth% f@ fmax scale f* { f: cw }
setstring$ $@len IF
setstring$ $@ layout-string fdrop fdrop scale f*
ELSE
text$ curpos cursize m2c:curminchars# @ umax + umin
layout-string fdrop fdrop scale f* w f-
THEN m2c:curminwidth% f@ fmax { f: cw }
x w f+ border f+ y d border f- f+ { f: x0 f: y0 }
x0 cw f+ y h border f- f- { f: x1 f: y1 }
i? m2c:selectioncolor# m2c:cursorcolor# cursize 0> select @ >v
......@@ -317,6 +326,36 @@ end-class edit
x0 y0 >xy rgba>c n> 1e 1e >st v+
v> dup i, dup 1+ i, dup 2 + i, dup i, dup 2 + i, 3 + i,
; edit to draw-marking
$FFFF7FFF Value setstring-color
: edit-text ( -- )
x border f+ penxy sf! y penxy sfloat+ sf!
text-font to font text-color color !
w border f2* f- text-w f/ to x-scale
cursize 0= setstring$ $@len and IF
text$ curpos umin render-string
setstring-color color !
setstring$ $@ render-string
text-color color !
text$ curpos safe/string render-string
ELSE
text$ render-string
THEN ;
: edit-!size ( -- )
text-font to font
cursize 0= setstring$ $@len and IF
text$ curpos umin layout-string { f: d f: h }
setstring$ $@ layout-string
h fmax to h d fmax to d f+
text$ curpos safe/string layout-string
h fmax to h d fmax to d f+ d h
ELSE
text$ layout-string
THEN
border f+ to h
border f+ to d
fdup to text-w border f2* f+ to w ;
' edit-text edit to draw-text
' edit-!size edit to !size
: edit! ( addr u font -- )
text! text$ nip to curpos -1 to cursize -1 to start-curpos
......
......@@ -166,8 +166,10 @@ Variable xy$
x11-handler ' new static-a with-allocater Constant x11-keyboard
: enter-minos ( -- )
edit-widget edit-out !
x11-keyboard event-handler ! ;
: leave-minos ( -- )
edit-terminal edit-out !
[ event-handler @ ]L event-handler !
need-sync on need-show on ;
......
......@@ -325,10 +325,12 @@ Variable rendering -2 rendering ! \ -2: on, -1: pause, 0: stop
: android-characters ( string -- ) jstring>sstring
nostring inskeys jfree ;
: android-commit ( string/0 -- ) ?dup-0=-IF insstring ELSE
jstring>sstring inskeys jfree setstring$ $off THEN ;
: android-setstring ( string -- ) jstring>sstring setstring$ $! jfree
ctrl L inskey ;
Defer android-commit
:noname ( string/0 -- ) ?dup-0=-IF insstring ELSE
jstring>sstring inskeys jfree setstring$ $off THEN ; is android-commit
Defer android-setstring
:noname ( string -- ) jstring>sstring setstring$ $! jfree
ctrl L inskey ; is android-setstring
: android-unicode ( uchar -- ) >xstring inskeys ;
: android-keycode ( keycode -- ) keycode>keys inskeys ;
......
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