Function: indent-bars--draw-line
indent-bars--draw-line is a natively compiled function defined in
indent-bars.el.
Signature
(indent-bars--draw-line STYLE NBARS START END &optional SKIP INVENT SWITCH-AFTER STYLE2)
Documentation
Draw NBARS bars on the line between positions START and END.
Bars are drawn in style STYLE, indent-bars-style by default. START is
assumed to be on a line beginning position. Drawing starts at a column
determined by indent-bars-starting-column. Tabs at the line beginning
have appropriate display properties applied if indent-tabs-mode(var)/indent-tabs-mode(fun) is
enabled.
If SWITCH-AFTER is an integer, switch from STYLE to STYLE2 after drawing (or skipping) that many bars. If it is t, use STYLE2 exclusively.
If SKIP is non-nil, it should be a list of bar numbers to skip while drawing (where the first and leftmost possible bar is number 1).
If INVENT is non-nil and the line's length is insufficient to display all NBARS bars (whether by replacing tabs or adding properties to existing non-tab whitespace), bars will be "invented". That is, the line's final newline, which is (only in this case) expected to be located at END, will have its display properties set to fill out the remaining bars, if any are needed.
Source Code
;; Defined in /nix/store/zkcdcnmcj3605fj09x584bf58d85brax-emacs-packages-deps/share/emacs/site-lisp/elpa/indent-bars-1.0.1/indent-bars.el
(defun indent-bars--draw-line ( style nbars start end &optional
skip invent switch-after style2)
"Draw NBARS bars on the line between positions START and END.
Bars are drawn in style STYLE, `indent-bars-style' by default. START is
assumed to be on a line beginning position. Drawing starts at a column
determined by `indent-bars-starting-column'. Tabs at the line beginning
have appropriate display properties applied if `indent-tabs-mode' is
enabled.
If SWITCH-AFTER is an integer, switch from STYLE to STYLE2 after
drawing (or skipping) that many bars. If it is t, use STYLE2
exclusively.
If SKIP is non-nil, it should be a list of bar numbers to skip while
drawing (where the first and leftmost possible bar is number 1).
If INVENT is non-nil and the line's length is insufficient to display
all NBARS bars (whether by replacing tabs or adding properties to
existing non-tab whitespace), bars will be \"invented\". That is, the
line's final newline, which is (only in this case) expected to be
located at END, will have its display properties set to fill out the
remaining bars, if any are needed."
(let* ((tabs (and indent-tabs-mode
(save-excursion
(goto-char start) (looking-at "^\t+"))
(- (match-end 0) (match-beginning 0))))
(vp indent-bars--offset)
(style (or style indent-bars-style))
(bar 1) prop fun tnum bars-drawn)
(when tabs ; deal with initial tabs
(while (and (<= bar nbars) (< (setq tnum (/ vp tab-width)) tabs))
(setq bars-drawn
(indent-bars--tab-display style (+ start tnum) (mod vp tab-width)
bar skip (- nbars bar -1)
switch-after style2))
(when (integerp switch-after)
(cl-decf switch-after bars-drawn)
(when (<= switch-after 0)
(setq switch-after t))) ; switch style of the rest
(cl-incf bar bars-drawn)
(cl-incf vp (* bars-drawn indent-bars-spacing)))
(cl-incf start (+ (/ vp tab-width) (mod vp tab-width))))
(when (<= bar nbars) ; still bars to show?
(if indent-bars--no-stipple
(setq prop 'indent-bars-display fun #'indent-bars--no-stipple-char)
(setq prop 'face fun #'indent-bars--face))
(let ((pos (if tabs start (+ start indent-bars--offset))))
(while (and (<= bar nbars) (< pos end))
(unless (memql bar skip)
(put-text-property
pos (1+ pos)
prop (funcall fun
(cond ((integerp switch-after)
(prog1
(if (> switch-after 0) style style2)
(cl-decf switch-after)
(when (<= switch-after 0)
(setq switch-after t))))
((eq switch-after t) style2)
(t style))
bar)))
(cl-incf bar)
(cl-incf pos indent-bars-spacing))
;; STILL bars to show: invent them (if requested)
(when (and invent (<= bar nbars))
(add-text-properties
end (1+ end) ; atop the final newline
`(indent-bars-display
,(concat (indent-bars--blank-string
style (- pos end) (- nbars bar -1) bar skip nil
switch-after style2)
"\n")
rear-nonsticky t)))))))