-
Notifications
You must be signed in to change notification settings - Fork 5
/
core.clj
36 lines (30 loc) · 1.09 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(ns aprint.core
(:require [clojure.pprint :as pprint :refer [write-out with-pprint-dispatch]]
[clansi.core :as clansi]
[aprint.utils :refer :all]
[aprint.tty :refer [tty-width clear-screen]]
[aprint.dispatch :refer [color-dispatch]]
[aprint.writer :refer [with-awesome-writer]]))
(def ^:dynamic *use-aprint* false)
(defn aprint
([object] (aprint object *out*))
([object writer]
(if (need-clear-screen? object)
(clear-screen))
(binding [pprint/*print-right-margin* (tty-width)]
(with-pprint-dispatch color-dispatch
(with-awesome-writer writer
(binding [pprint/*print-pretty* true]
(binding-map (if (or (not (= pprint/*print-base* 10)) pprint/*print-radix*) {#'pr #'pprint/pr-with-base} {})
(write-out object)))
(if (not (= 0 (#'pprint/get-column *out*)))
(prn)))))))
(defmacro ap []
`(aprint *1))
(defn nprint
([object] (nprint object *out*))
([object writer]
(clansi/without-ansi
(aprint object writer))))
(defmacro np []
`(nprint *1))