aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-08-09 10:38:41 -0500
committerColin Okay <colin@cicadas.surf>2022-08-09 10:38:41 -0500
commit2fab4d7f237c91568c2206527535c70d657b2846 (patch)
treead66bccb19dc387920170acc82205f64603da8a2
parent33798548a62ca1610252a583875690e94c8619f6 (diff)
[change] printout of oneliners
-rw-r--r--lib/oneliner.lisp27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/oneliner.lisp b/lib/oneliner.lisp
index 3935a0e..3c92a26 100644
--- a/lib/oneliner.lisp
+++ b/lib/oneliner.lisp
@@ -69,11 +69,18 @@
;;; PRINTING
+(defun print-in-center-of-term (string)
+ (when (and *term-width* (< (length string) *term-width*))
+ (let ((pad
+ (floor (* 0.5 (- *term-width* (length string))))))
+ (loop repeat pad do (princ #\space))))
+ (princ string))
+
(defun print-oneliner-result-for-user (ol)
"Prints information about the oneliner to the terminal."
(unless *term-width* (set-term-width)) ; setting here as a fallback, can set it elswere if desired.
(let* ((title-line-format-str
- (concatenate 'string "~" (prin1-to-string *term-width*) "<[~a]~;~a~;~a~>~%"))
+ (concatenate 'string "~" (prin1-to-string *term-width*) "<id:~a~;~a~;~a~>~%"))
(tags-line-format-string
(concatenate 'string "~" (prin1-to-string *term-width*) "<~a~;by ~a ~a~>~%")))
(loop repeat *term-width* do (princ #\_))
@@ -85,18 +92,22 @@
(oneliner-isflagged ol)
(oneliner-islocked ol)
(equalp "manual" (oneliner-runstyle ol))))
- (format t tags-line-format-string
- (format nil "tags: ~{~a~^ ~}" (oneliner-tags ol))
- (or (oneliner-createdby ol) " ")
- (if (oneliner-createdat ol)
- (datestring-of-universal-time (oneliner-createdat ol))
- " "))
+
(loop
for x from 0 to (length (oneliner-brief ol)) by *term-width*
do (format t "~a~%"
(string-trim '(#\space)
(alexandria-2:subseq* (oneliner-brief ol) x (+ x *term-width*)))))
- (format t "~%~a~%~%" (oneliner-oneliner ol))))
+ (princ #\newline)
+ (print-in-center-of-term (oneliner-oneliner ol))
+ (princ #\newline) (princ #\newline)
+ (format t tags-line-format-string
+ (format nil "[~{~a~^ ~}]" (oneliner-tags ol))
+ (or (oneliner-createdby ol) " ")
+ (if (oneliner-createdat ol)
+ (datestring-of-universal-time (oneliner-createdat ol))
+ " "))
+ (princ #\newline)))
;;;; json serialization