Fix problem with out-of-bounds hand-click#
parent
96a1cbe72a
commit
8761885287
|
@ -1,6 +1,6 @@
|
||||||
USING: ui.gadgets.editors tools.test kernel io io.streams.plain
|
USING: ui.gadgets.editors tools.test kernel io io.streams.plain
|
||||||
io.streams.string definitions namespaces ui.gadgets
|
io.streams.string definitions namespaces ui.gadgets
|
||||||
ui.gadgets.grids prettyprint documents ;
|
ui.gadgets.grids prettyprint documents ui.gestures ;
|
||||||
|
|
||||||
[ t ] [
|
[ t ] [
|
||||||
<editor> "editor" set
|
<editor> "editor" set
|
||||||
|
@ -27,3 +27,12 @@ ui.gadgets.grids prettyprint documents ;
|
||||||
"editor" get gadget-selection
|
"editor" get gadget-selection
|
||||||
"editor" get ungraft*
|
"editor" get ungraft*
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ ] [
|
||||||
|
<editor> "editor" set
|
||||||
|
"editor" get graft*
|
||||||
|
"foo bar\nbaz quux" "editor" get set-editor-string
|
||||||
|
4 hand-click# set
|
||||||
|
"editor" get position-caret
|
||||||
|
"editor" get ungraft*
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -5,7 +5,7 @@ ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labels
|
||||||
ui.gadgets.scrollers ui.gadgets.theme ui.gadgets.controls
|
ui.gadgets.scrollers ui.gadgets.theme ui.gadgets.controls
|
||||||
ui.render ui.gestures io kernel math models namespaces opengl
|
ui.render ui.gestures io kernel math models namespaces opengl
|
||||||
opengl.gl sequences strings io.styles math.vectors sorting
|
opengl.gl sequences strings io.styles math.vectors sorting
|
||||||
colors ;
|
colors combinators ;
|
||||||
IN: ui.gadgets.editors
|
IN: ui.gadgets.editors
|
||||||
|
|
||||||
TUPLE: editor
|
TUPLE: editor
|
||||||
|
@ -292,11 +292,11 @@ M: editor gadget-text* editor-string % ;
|
||||||
|
|
||||||
: position-caret ( editor -- )
|
: position-caret ( editor -- )
|
||||||
hand-click# get {
|
hand-click# get {
|
||||||
[ ]
|
{ 1 [ (position-caret) ] }
|
||||||
[ dup (position-caret) ]
|
{ 2 [ T{ one-word-elt } select-elt ] }
|
||||||
[ dup T{ one-word-elt } select-elt ]
|
{ 3 [ T{ one-line-elt } select-elt ] }
|
||||||
[ dup T{ one-line-elt } select-elt ]
|
[ 2drop ]
|
||||||
} ?nth call drop ;
|
} case ;
|
||||||
|
|
||||||
: insert-newline "\n" swap user-input ;
|
: insert-newline "\n" swap user-input ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue