     ] [ drop ] if ;
 
 : draw-caret ( -- )
-    editor get focused?>> [
+    editor get [ focused?>> ] [ blink>> ] bi and [
         editor get
         [ caret-color>> gl-color ]
         [


: point>loc ( point editor -- loc )
    [
        >r first2 r> tuck y>line dup ,
        >r dup editor-font* r>
        rot editor-line x>offset ,
    ] { } make ;


    [ hand-rel ] keep point>loc ;

: click-loc ( editor model -- )
    [ clicked-loc ] dip set-model ;

: blink-caret ( editor -- )
    [ not ] change-blink relayout-1 ;

: start-blinking ( editor -- )
    t >>blink
    dup '[ _ blink-caret ] 750 milliseconds every >>blink-alarm drop ;

: stop-blinking ( editor -- )
    blink-alarm>> cancel-alarm ;

: restart-blinking ( editor -- )
    dup focused?>> [
        [ stop-blinking ]
        [ start-blinking ]
        [ relayout-1 ]
        tri
    ] [ drop ] if ;

: focus-editor ( editor -- )
    dup start-blinking
    t >>focused?
    relayout-1 ;

: unfocus-editor ( editor -- )
    dup stop-blinking
    f >>focused?
    relayout-1 ;

: (offset>x) ( font col# str -- x )
    swap head-slice string-width ;
