|
27 | 27 | (:use
|
28 | 28 | :gt/full
|
29 | 29 | :diff
|
30 |
| - :cl-interpol |
| 30 | + :terminal |
31 | 31 | :software-evolution-library
|
32 | 32 | :software-evolution-library/utility/debug
|
33 |
| - :software-evolution-library/utility/terminal) |
| 33 | + :terminal) |
34 | 34 | (:shadow :diff)
|
35 | 35 | (:shadowing-import-from :arrow-macros :-<>> :-<> :<>) ; FIXME: Remove.
|
36 | 36 | (:export :*view-stream*
|
|
46 | 46 | :*view-max-best-lines*
|
47 | 47 | :*view-max-best-offset*
|
48 | 48 | :*view-functions*
|
49 |
| - ;; Colors. |
50 |
| - :+set-G1+ |
51 |
| - :+reset-G1+ |
52 |
| - :+b-start+ |
53 |
| - :+b-stop+ |
54 |
| - :+b-h+ |
55 |
| - :+b-v+ |
56 |
| - :+b-lt+ |
57 |
| - :+b-rt+ |
58 |
| - :+b-lb+ |
59 |
| - :+b-rb+ |
60 |
| - :+b-x+ |
61 |
| - :+b-vr+ |
62 |
| - :+b-vl+ |
63 |
| - :+b-ht+ |
64 |
| - :+b-hb+ |
65 |
| - :+term-home+ |
66 |
| - :+term-clear+ |
67 |
| - :+ceol+ |
68 |
| - :+cursor-hide+ |
69 |
| - :+cursor-show+ |
70 |
| - :+color-BLK+ |
71 |
| - :+color-RED+ |
72 |
| - :+color-GRN+ |
73 |
| - :+color-BRN+ |
74 |
| - :+color-BLU+ |
75 |
| - :+color-MGN+ |
76 |
| - :+color-CYA+ |
77 |
| - :+color-NOR+ |
78 |
| - :+color-GRA+ |
79 |
| - :+color-LRD+ |
80 |
| - :+color-LGN+ |
81 |
| - :+color-YEL+ |
82 |
| - :+color-LBL+ |
83 |
| - :+color-PIN+ |
84 |
| - :+color-LCY+ |
85 |
| - :+color-BRI+ |
86 |
| - :+color-RST+ |
87 | 49 | :+golden-ratio+
|
88 | 50 | :label-line-print
|
89 |
| - ;; Utility functions. |
90 | 51 | :best-print
|
91 | 52 | ;; View functions.
|
92 | 53 | :timing-view-function
|
|
107 | 68 | (in-package :software-evolution-library/view)
|
108 | 69 | (in-readtable :curry-compose-reader-macros)
|
109 | 70 |
|
110 |
| -(eval-when (:compile-toplevel :load-toplevel :execute) |
111 |
| - (enable-interpol-syntax) |
112 |
| - (defvar *view-stream* t |
113 |
| - "Dynamically bind to use modify.")) |
114 |
| - |
115 |
| -(defvar *view-length* 65 |
| 71 | +(defvar *view-length* |
| 72 | + (handler-case (nth-value 2 (term-size)) |
| 73 | + (ioctl (e) (declare (ignore e)) 72)) |
116 | 74 | "Dynamically bind to use modify.")
|
117 | 75 |
|
118 | 76 | (defvar *view-delay* 2
|
@@ -149,77 +107,13 @@ For example a description of the evolution target.")
|
149 | 107 | (defvar *view-max-best-offset* 0
|
150 | 108 | "Offset into the lines of the best candidate to show.")
|
151 | 109 |
|
152 |
| -(define-constant +golden-ratio+ 21/34) |
153 |
| - |
154 |
| -(eval-when (:compile-toplevel :load-toplevel :execute) |
155 |
| - ;; AFL, forgive me this. |
156 |
| - (mapc (lambda (triple) |
157 |
| - (destructuring-bind (name value documentation) triple |
158 |
| - (eval `(define-constant ,name ,value :test 'equalp |
159 |
| - :documentation ,documentation)))) |
160 |
| - '((+set-G1+ #?"\x1b)0" "Set G1 for box drawing") |
161 |
| - (+reset-G1+ #?"\x1b)B" "Reset G1 to ASCII") |
162 |
| - (+b-start+ #?"\x0e" "Enter G1 drawing mode") |
163 |
| - (+b-stop+ #?"\x0f" "Leave G1 drawing mode") |
164 |
| - (+b-h+ #\q "Horizontal line") |
165 |
| - (+b-v+ #\x "Vertical line") |
166 |
| - (+b-lt+ #\l "Left top corner") |
167 |
| - (+b-rt+ #\k "Right top corner") |
168 |
| - (+b-lb+ #\m "Left bottom corner") |
169 |
| - (+b-rb+ #\j "Right bottom corner") |
170 |
| - (+b-x+ #\n "Cross") |
171 |
| - (+b-vr+ #\t "Vertical, branch right") |
172 |
| - (+b-vl+ #\u "Vertical, branch left") |
173 |
| - (+b-ht+ #\v "Horizontal, branch top") |
174 |
| - (+b-hb+ #\w "Horizontal, branch bottom") |
175 |
| - (+term-home+ #?"\x1b[H" "Set terminal back to home (top left).") |
176 |
| - (+term-clear+ #?"\x1b[H[2J" "Clear terminal.") |
177 |
| - (+ceol+ #?"\x1b[0K" "Clear to end of line.") |
178 |
| - (+cursor-hide+ #?"\x1b[?25l" "Hide the cursor.") |
179 |
| - (+cursor-show+ #?"\x1b[?25h" "Show the cursor.") |
180 |
| - ;; Colors |
181 |
| - (+color-BLK+ #?"\x1b[0;30m" "Color BLK.") |
182 |
| - (+color-RED+ #?"\x1b[0;31m" "Color RED.") |
183 |
| - (+color-GRN+ #?"\x1b[0;32m" "Color GRN.") |
184 |
| - (+color-BRN+ #?"\x1b[0;33m" "Color BRN.") |
185 |
| - (+color-BLU+ #?"\x1b[0;34m" "Color BLU.") |
186 |
| - (+color-MGN+ #?"\x1b[0;35m" "Color MGN.") |
187 |
| - (+color-CYA+ #?"\x1b[0;36m" "Color CYA.") |
188 |
| - (+color-NOR+ #?"\x1b[0;37m" "Color NOR.") |
189 |
| - (+color-GRA+ #?"\x1b[1;30m" "Color GRA.") |
190 |
| - (+color-LRD+ #?"\x1b[1;31m" "Color LRD.") |
191 |
| - (+color-LGN+ #?"\x1b[1;32m" "Color LGN.") |
192 |
| - (+color-YEL+ #?"\x1b[1;33m" "Color YEL.") |
193 |
| - (+color-LBL+ #?"\x1b[1;34m" "Color LBL.") |
194 |
| - (+color-PIN+ #?"\x1b[1;35m" "Color PIN.") |
195 |
| - (+color-LCY+ #?"\x1b[1;36m" "Color LCY.") |
196 |
| - (+color-BRI+ #?"\x1b[1;37m" "Color BRI.") |
197 |
| - (+color-RST+ #?"\x1b[0m" "Color RST.")))) |
| 110 | +(defun view-truncate (line &optional (less 2)) |
| 111 | + (if (> (length line) (- *view-length* less)) |
| 112 | + (subseq line 0 (- *view-length* less)) |
| 113 | + line)) |
198 | 114 |
|
199 | 115 |
|
200 |
| -;;; Utility functions |
201 |
| - |
202 |
| -(defun clear-terminal () |
203 |
| - (format *view-stream* "~a" +term-clear+)) |
204 |
| - |
205 |
| -(defun hide-cursor () |
206 |
| - (format *view-stream* "~a" +cursor-hide+)) |
207 |
| - |
208 |
| -(defun show-cursor () |
209 |
| - (format *view-stream* "~a" +cursor-show+)) |
210 |
| - |
211 |
| -(defmacro with-line-printing (&rest body) |
212 |
| - `(unwind-protect |
213 |
| - (progn (format ,*view-stream* "~a" +set-G1+) |
214 |
| - (format ,*view-stream* "~a" +b-start+) |
215 |
| - ,@body) |
216 |
| - (format ,*view-stream* "~a" +b-stop+) |
217 |
| - (format ,*view-stream* "~a" +reset-G1+))) |
218 |
| - |
219 |
| -(defmacro with-color-printing (color &rest body) |
220 |
| - `(unwind-protect |
221 |
| - (progn (format ,*view-stream* "~a" ,color) ,@body) |
222 |
| - (format ,*view-stream* "~a" +color-RST+))) |
| 116 | +;;; View functions. |
223 | 117 |
|
224 | 118 | (defun label-line-print (&key (value "") (values)
|
225 | 119 | (color +color-RST+) (colors)
|
@@ -253,21 +147,6 @@ For example a description of the evolution target.")
|
253 | 147 | :initial-element filler)
|
254 | 148 | (string right)))))))
|
255 | 149 |
|
256 |
| -(defun string-output-stream-p (stream) |
257 |
| - (typep stream |
258 |
| - #+sbcl 'sb-impl::string-output-stream |
259 |
| - #+ccl 'ccl:string-output-stream |
260 |
| - #- (or sbcl ccl) |
261 |
| - (error "`string-output-stream-p' only supported for SBCL and CCL"))) |
262 |
| - |
263 |
| -(defun view-truncate (line &optional (less 2)) |
264 |
| - (if (> (length line) (- *view-length* less)) |
265 |
| - (subseq line 0 (- *view-length* less)) |
266 |
| - line)) |
267 |
| - |
268 |
| - |
269 |
| -;;; View functions. |
270 |
| - |
271 | 150 | (defun runtime-print ()
|
272 | 151 | (if *start-time*
|
273 | 152 | (label-line-print
|
|
0 commit comments