{ editor-caret editor-mark } related-words
-HELP: caret-is-shape
-{ $description
- "Shape is defined as line, box, or filled box"
-}
-$nl
-{ $code
-" IN: ui.gadgets.editors"
-" +box+ caret-shape set-global"
-""
-} print-element
-$nl
+HELP: caret-style
+{ $description "Caret styles available:"
{ $table
{ "Value" "Shape" }
- { "+line+" "line (default)" }
- { "+box+" "box" }
- { "+filled+" "filled box" }
-} print-element
-
-{ $references "Set desired shape in your .factor-rc file"
- "rc-files" }
- ;
+ { { $link +line+ } "line (default)" }
+ { { $link +box+ } "box" }
+ { { $link +filled+ } "filled box" }
+}
+}
+{ $references "Set desired caret style in your .factor-rc file" "rc-files" } ;
HELP: editor-caret
{ $values { "editor" editor } { "loc" "a pair of integers" } }
M: editor preedit? preedit-start>> ;
SYMBOLS: +line+ +box+ +filled+ ;
-GLOBAL: caret-is-shape
-+line+ caret-is-shape set-global
-
-: <caret-shape> ( -- shape ) caret-is-shape get-global <model> ;
+SYMBOL: caret-style
++line+ caret-style set-global
<PRIVATE
: init-editor-locs ( editor -- editor )
<loc> >>caret
- <caret-shape> >>caret-shape
<loc> >>mark ; inline
: editor-theme ( editor -- editor )
{ [ focused?>> ] [ blink>> ]
[ [ preedit? not ] [ preedit-selection-mode?>> not ] bi or ] } 1&& ;
-: (caret-location) ( editor -- loc dim )
+: caret-line ( editor -- loc dim )
[ caret-loc ] [ caret-dim ] bi ;
-: (caret-rect) ( dim -- newdim )
- second [ 2 / ] keep 2array ;
+: caret-rect ( editor -- loc dim )
+ caret-line second [ 2 / ] keep 2array ;
: draw-caret-line ( editor -- )
- (caret-location) over v+ gl-line ;
+ caret-line over v+ gl-line ;
: draw-caret-rect ( editor -- )
- (caret-location) (caret-rect) gl-rect ;
+ caret-rect gl-rect ;
: draw-caret-rect-filled ( editor -- )
- (caret-location) (caret-rect) gl-fill-rect ;
+ caret-rect gl-fill-rect ;
: draw-caret-shape ( editor -- )
- dup caret-shape>> value>>
- {
+ caret-style get {
{ +box+ [ draw-caret-rect ] }
{ +filled+ [ draw-caret-rect-filled ] }
[ drop draw-caret-line ]
} case ;
-
: draw-caret ( editor -- )
dup draw-caret? [