sbcli icon indicating copy to clipboard operation
sbcli copied to clipboard

syntax-hl function prints first output line with too many blank lines and whitespaces

Open vindarel opened this issue 7 months ago • 0 comments

Entering something like this:

(format t "~s" '(hello some test arithmetic))

is printed like

(HELLO
                                                                                                                                                                                                                                                                   SOME
                                                                                                                                                                                                                                                                   TEST
                                                                  etc

I found it's because of syntax-hl, then I do this to enable it ONLY in case of syntax highlihgting.

  (when *syntax-highlighting*
    (rl:register-function :redisplay #'syntax-hl))

(edit) or rather

  (if *syntax-highlighting*
      (rl:register-function :redisplay #'syntax-hl)
      (rl:register-function :redisplay #'rl:redisplay))

I also don't understand the magic it's doing.


(defun syntax-hl ()
  ;; XXX: when enabled, this f* up the whitespace output of the first output line.
  ;; To try, print this:
  ;; (format t "~s" '(hello some test arithmetic))
  ;; it will be shown on multiple lines with lots of whitespace.
  (rl:redisplay)
  (let ((res (maybe-highlight rl:*line-buffer*)))
    (format t "~c[2K~c~a~a~c[~aD" #\esc #\return rl:*display-prompt* res #\esc (- rl:+end+ rl:*point*))
    (when (= rl:+end+ rl:*point*)
      (format t "~c[1C" #\esc))
    (finish-output)))

vindarel avatar May 09 '25 11:05 vindarel