Display comments in highlights.
This commit is contained in:
parent
39554768b3
commit
48ec6a5dcf
1 changed files with 22 additions and 1 deletions
23
listing.scm
23
listing.scm
|
@ -91,6 +91,21 @@
|
||||||
#t
|
#t
|
||||||
(loop (cdr highlights)))))))
|
(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
|
;; Prints and highlights a selection of source listing lines and
|
||||||
;; their optional context.
|
;; their optional context.
|
||||||
(define (print-source-listing lines highlights context hl-pre hl-post ctx-pre ctx-post ellipsis)
|
(define (print-source-listing lines highlights context hl-pre hl-post ctx-pre ctx-post ellipsis)
|
||||||
|
@ -112,7 +127,13 @@
|
||||||
(display hl-pre)
|
(display hl-pre)
|
||||||
(when context?
|
(when context?
|
||||||
(display ctx-pre)))
|
(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?
|
(if content?
|
||||||
(display hl-post)
|
(display hl-post)
|
||||||
(when context?
|
(when context?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue