Clean up history code
parent
4381c8bc58
commit
5f2fd87ce1
|
@ -9,15 +9,11 @@ TUPLE: history document elements index ;
|
||||||
: <history> ( document -- history )
|
: <history> ( document -- history )
|
||||||
V{ } clone 0 history boa ;
|
V{ } clone 0 history boa ;
|
||||||
|
|
||||||
: history-add ( history -- input )
|
<PRIVATE
|
||||||
dup elements>> length 1+ >>index
|
|
||||||
[ document>> doc-string [ <input> ] [ empty? ] bi ] keep
|
|
||||||
'[ [ _ elements>> push ] keep ] unless ;
|
|
||||||
|
|
||||||
: save-history ( history -- )
|
: save-history ( history -- input )
|
||||||
[ document>> doc-string ] keep
|
[ document>> doc-string [ <input> ] [ empty? ] bi ] keep
|
||||||
'[ <input> _ [ index>> ] [ elements>> ] bi set-nth ]
|
'[ [ _ [ index>> ] [ elements>> ] bi set-nth ] keep ] unless ;
|
||||||
unless-empty ;
|
|
||||||
|
|
||||||
: update-document ( history -- )
|
: update-document ( history -- )
|
||||||
[ [ index>> ] [ elements>> ] bi nth string>> ]
|
[ [ index>> ] [ elements>> ] bi nth string>> ]
|
||||||
|
@ -31,12 +27,18 @@ TUPLE: history document elements index ;
|
||||||
: history-recall ( history i -- )
|
: history-recall ( history i -- )
|
||||||
[ [ elements>> empty? ] keep ] dip '[
|
[ [ elements>> empty? ] keep ] dip '[
|
||||||
_
|
_
|
||||||
[ save-history ]
|
[ save-history drop ]
|
||||||
[ _ change-history-index ]
|
[ _ change-history-index ]
|
||||||
[ update-document ]
|
[ update-document ]
|
||||||
tri
|
tri
|
||||||
] unless ;
|
] unless ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: history-add ( history -- input )
|
||||||
|
dup elements>> length 1+ >>index
|
||||||
|
save-history ;
|
||||||
|
|
||||||
: history-recall-previous ( history -- )
|
: history-recall-previous ( history -- )
|
||||||
-1 history-recall ;
|
-1 history-recall ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue