Display comments in highlights.

This commit is contained in:
Dominik Pantůček 2023-03-19 21:53:18 +01:00
parent 39554768b3
commit 48ec6a5dcf

View file

@ -91,6 +91,21 @@
#t
(loop (cdr highlights)))))))
;; Returns comment if there is any
(define (highlight-comment number highlights)
(let loop ((highlights highlights))
(if (null? highlights)
#f
(let* ((highlight (car highlights))
(line-number (if (list? highlight)
(car highlight)
highlight)))
(if (= number line-number)
(if (list? highlight)
(cadr highlight)
#f)
(loop (cdr highlights)))))))
;; Prints and highlights a selection of source listing lines and
;; their optional context.
(define (print-source-listing lines highlights context hl-pre hl-post ctx-pre ctx-post ellipsis)
@ -112,7 +127,13 @@
(display hl-pre)
(when context?
(display ctx-pre)))
(display (sprintf "~A~A" (format-line-number number digits) (car lines)))
(display (sprintf "~A~A~A"
(format-line-number number digits)
(car lines)
(let ((comment (highlight-comment number highlights)))
(if comment
(sprintf " # <<< ~A" comment)
""))))
(if content?
(display hl-post)
(when context?