diff options
Diffstat (limited to 'lib/oneliner.lisp')
-rw-r--r-- | lib/oneliner.lisp | 27 |
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 |