diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 2cf6d24154..d42df93b72 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -120,9 +120,10 @@ M: editor ungraft* : scroll>caret ( editor -- ) dup graft-state>> second [ - dup caret-loc over caret-dim - over scroll>rect - ] when drop ; + [ + [ caret-loc ] [ caret-dim { 1 0 } v+ ] bi + ] keep scroll>rect + ] [ drop ] if ; : draw-caret ( -- ) editor get focused?>> [ diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index d1429c4006..6c37c37acf 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -43,7 +43,7 @@ scroller H{ dup model>> dependencies>> second >>y dup y>> @right grid-add tuck model>> >>viewport - dup viewport>> @center grid-add ; + dup viewport>> @center grid-add ; inline : ( gadget -- scroller ) scroller new-scroller ; @@ -54,18 +54,18 @@ scroller H{ ] keep 2dup control-value = [ 2drop ] [ set-control-value ] if ; -: rect-min ( rect1 rect2 -- rect ) - >r [ rect-loc ] keep r> [ rect-dim ] bi@ vmin ; +: rect-min ( rect dim -- rect' ) + [ [ loc>> ] [ dim>> ] bi ] dip vmin ; : (scroll>rect) ( rect scroller -- ) [ scroller-value vneg offset-rect viewport-gap offset-rect ] keep - [ viewport>> rect-min ] keep + [ viewport>> dim>> rect-min ] keep [ viewport>> 2rect-extent - >r >r v- { 0 0 } vmin r> r> v- { 0 0 } vmax v+ + [ v- { 1 1 } v- { 0 0 } vmin ] [ v- { 0 0 } vmax ] 2bi* v+ ] keep dup scroller-value rot v+ swap scroll ; : relative-scroll-rect ( rect gadget scroller -- newrect )