diff --git a/basis/ui/tools/listener/history/history.factor b/basis/ui/tools/listener/history/history.factor index aacd618338..d318a2cb1c 100644 --- a/basis/ui/tools/listener/history/history.factor +++ b/basis/ui/tools/listener/history/history.factor @@ -9,15 +9,11 @@ TUPLE: history document elements index ; : ( document -- history ) V{ } clone 0 history boa ; -: history-add ( history -- input ) - dup elements>> length 1+ >>index - [ document>> doc-string [ ] [ empty? ] bi ] keep - '[ [ _ elements>> push ] keep ] unless ; +> doc-string ] keep - '[ _ [ index>> ] [ elements>> ] bi set-nth ] - unless-empty ; +: save-history ( history -- input ) + [ document>> doc-string [ ] [ empty? ] bi ] keep + '[ [ _ [ index>> ] [ elements>> ] bi set-nth ] keep ] unless ; : update-document ( history -- ) [ [ index>> ] [ elements>> ] bi nth string>> ] @@ -31,12 +27,18 @@ TUPLE: history document elements index ; : history-recall ( history i -- ) [ [ elements>> empty? ] keep ] dip '[ _ - [ save-history ] + [ save-history drop ] [ _ change-history-index ] [ update-document ] tri ] unless ; +PRIVATE> + +: history-add ( history -- input ) + dup elements>> length 1+ >>index + save-history ; + : history-recall-previous ( history -- ) -1 history-recall ;