Skip to content

Commit

Permalink
Minor streaming improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaaad committed Jan 28, 2021
1 parent e635e71 commit 0d2db94
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/vlaaad/reveal/stream.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(:import [clojure.lang Keyword Symbol IPersistentMap IPersistentVector IPersistentSet Fn
ISeq MultiFn IRef Var Volatile Namespace IRecord Delay
IBlockingDeref TaggedLiteral Reduced ReaderConditional
IPersistentCollection BigInt]
IPersistentCollection BigInt PersistentQueue]
[java.util.regex Pattern]
[java.io File FileNotFoundException]
[java.net URL URI]
Expand Down Expand Up @@ -114,7 +114,10 @@
(case ch
\newline ((=> (flush-builder builder style) newline) rf acc)
\tab (do (.append builder " ") acc)
\return ((flush+util builder style "\\r") rf acc)
\return (cond
(== i (dec len)) ((flush+util builder style "\\r") rf acc)
(= \newline (.charAt str (inc i))) acc
:else ((flush+util builder style "\\r") rf acc))
\formfeed ((flush+util builder style "\\f") rf acc)
\backspace ((flush+util builder style "\\b") rf acc)
(do (.append builder ch) acc)))))))))
Expand Down Expand Up @@ -149,8 +152,10 @@
(case ch
\newline ((=> (flush-builder builder style) newline) rf acc)
\tab (do (.append builder " ") acc)
;; todo except if followed by newline...
\return ((flush+util builder style "\\r") rf acc)
\return (cond
(== i (dec len)) ((flush+util builder style "\\r") rf acc)
(= \newline (.charAt str (inc i))) acc
:else ((flush+util builder style "\\r") rf acc))
\formfeed ((flush+util builder style "\\f") rf acc)
\backspace ((flush+util builder style "\\b") rf acc)
(do (.append builder ch) acc)))))))))))
Expand Down Expand Up @@ -833,6 +838,12 @@
separator
(stream (str instant))))

(defstream PersistentQueue [q]
(horizontal
(raw-string "#reveal/queue(" {:fill :object})
(items q)
(raw-string ")" {:fill :object})))

(defmacro ^:private when-class [class-name & body]
`(try
(Class/forName ^String ~class-name)
Expand Down

0 comments on commit 0d2db94

Please sign in to comment.