diff --git a/basis/ui/tools/listener/history/history.factor b/basis/ui/tools/listener/history/history.factor index 4ce7cc8e431..d843ff42cf3 100644 --- a/basis/ui/tools/listener/history/history.factor +++ b/basis/ui/tools/listener/history/history.factor @@ -1,24 +1,30 @@ ! Copyright (C) 2009 Slava Pestov. ! See https://factorcode.org/license.txt for BSD license. -USING: accessors continuations documents io io.encodings.utf8 +USING: accessors documents environment io io.encodings.utf8 io.files io.styles kernel math math.order namespaces -prettyprint.backend prettyprint.config sequences strings.parser ; +prettyprint.backend prettyprint.config sequences strings.parser +; IN: ui.tools.listener.history TUPLE: history document elements start index ; -CONSTANT: history-file "~/.factor-history" +: history-file ( -- path ) + "FACTOR_HISTORY" os-env [ "~/.factor-history" ] unless* ; : read-history ( -- elements ) - history-file file-exists? [ history-file utf8 file-lines [ unescape-string ] V{ } map-as ] [ V{ } clone ] if ; + history-file file-exists? [ + history-file utf8 file-lines + [ unescape-string ] V{ } map-as + ] [ V{ } clone ] if ; : append-history ( history -- ) - history-file file-exists? - [ + history-file file-exists? [ [ history-file utf8 [ f string-limit? [ - [ elements>> ] [ start>> ] bi [ string>> f f unparse-string print ] swap each-from + [ elements>> ] [ start>> ] bi + [ string>> f f unparse-string print ] swap + each-from ] with-variable ] with-file-appender ] [ [ index>> ] keep start<< ] bi