• (column-writer writer)
  • (column-writer writer max-columns)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/pprint/column_writer.clj:54 top

(defn column-writer   
  ([writer] (column-writer writer *default-page-width*))
  ([writer max-columns]
     (let [fields (ref {:max max-columns, :cur 0, :line 0 :base writer})]
       (proxy [Writer IDeref] []
         (deref [] fields)
          ([^chars cbuf ^Integer off ^Integer len] 
             (let [^Writer writer (get-field this :base)] 
               (.write writer cbuf off len)))
             (condp = (class x)
               (let [^String s x
                     nl (.lastIndexOf s (int \newline))]
                 (dosync (if (neg? nl)
                           (set-field this :cur (+ (get-field this :cur) (count s)))
                             (set-field this :cur (- (count s) nl 1))
                             (set-field this :line (+ (get-field this :line)
                                                      (count (filter #(= % \newline) s)))))))
                 (.write ^Writer (get-field this :base) s))

               (write-char this x)
               (write-char this x))))))))
Vars in clojure.contrib.pprint.column-writer/column-writer: write + - = class condp count defn deref dosync filter let neg? proxy
Used in 0 other vars

Comments top

No comments for column-writer. Log in to add a comment.