Skip to content

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

@vindarel

Description

@vindarel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions