Skip to content

Commit 132a92f

Browse files
committed
Excise terminal so it can grovel
1 parent ab3605a commit 132a92f

File tree

4 files changed

+11
-236
lines changed

4 files changed

+11
-236
lines changed

.qlfile.grammatech

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ git stefil+ https://github.com/GrammaTech/stefil-.git main
55
git cffi https://github.com/death/cffi
66
git cl-tree-sitter https://github.com/death/cl-tree-sitter
77
git serapeum https://github.com/ruricolist/serapeum
8+
git terminal http://git.grammatech.com/synthesis/terminal.git

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ DOC_PACKAGES = \
7171
software-evolution-library/utility/json \
7272
software-evolution-library/utility/range \
7373
software-evolution-library/utility/task \
74-
software-evolution-library/utility/terminal \
7574
software-evolution-library/view
7675

7776
DOC_DEPS = doc/software-evolution-library/GrammaTech-CLA-SEL.pdf

utility/terminal.lisp

-104
This file was deleted.

view.lisp

+10-131
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
(:use
2828
:gt/full
2929
:diff
30-
:cl-interpol
30+
:terminal
3131
:software-evolution-library
3232
:software-evolution-library/utility/debug
33-
:software-evolution-library/utility/terminal)
33+
:terminal)
3434
(:shadow :diff)
3535
(:shadowing-import-from :arrow-macros :-<>> :-<> :<>) ; FIXME: Remove.
3636
(:export :*view-stream*
@@ -46,47 +46,8 @@
4646
:*view-max-best-lines*
4747
:*view-max-best-offset*
4848
:*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+
8749
:+golden-ratio+
8850
:label-line-print
89-
;; Utility functions.
9051
:best-print
9152
;; View functions.
9253
:timing-view-function
@@ -107,12 +68,9 @@
10768
(in-package :software-evolution-library/view)
10869
(in-readtable :curry-compose-reader-macros)
10970

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))
11674
"Dynamically bind to use modify.")
11775

11876
(defvar *view-delay* 2
@@ -149,77 +107,13 @@ For example a description of the evolution target.")
149107
(defvar *view-max-best-offset* 0
150108
"Offset into the lines of the best candidate to show.")
151109

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" "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))
198114

199115

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.
223117

224118
(defun label-line-print (&key (value "") (values)
225119
(color +color-RST+) (colors)
@@ -253,21 +147,6 @@ For example a description of the evolution target.")
253147
:initial-element filler)
254148
(string right)))))))
255149

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-
271150
(defun runtime-print ()
272151
(if *start-time*
273152
(label-line-print

0 commit comments

Comments
 (0)