Skip to content

Commit f3a4bc2

Browse files
committed
diff-hl-show-hunk-inline: Enable customization of scroll indicators
1 parent 2f1623d commit f3a4bc2

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

diff-hl-show-hunk-inline.el

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ the hunk consist only on added lines, then
7474
`diff-hl-show-hunk--no-lines-removed-message' it is shown."
7575
:type 'boolean)
7676

77+
(defcustom diff-hl-show-hunk-inline-scroll-indicators '("" . "")
78+
"Strings used to indicate hidden inline popup content.
79+
The car is used for hidden content above the popup; the cdr is used for
80+
hidden content below it. Each string includes any surrounding padding."
81+
:type '(cons (string :tag "Above")
82+
(string :tag "Below")))
83+
7784
(defun diff-hl-show-hunk-inline--splice (list offset length)
7885
"Compute a sublist of LIST starting at OFFSET, of LENGTH."
7986
(butlast
@@ -108,7 +115,11 @@ Compute it from LINES starting at INDEX with a WINDOW-SIZE."
108115
(defun diff-hl-show-hunk-inline--compute-header (width &optional header)
109116
"Compute the header of the popup.
110117
Compute it from some WIDTH, and some optional HEADER text."
111-
(let* ((scroll-indicator (if (eq diff-hl-show-hunk-inline--current-index 0) " " ""))
118+
(let* ((above-indicator (car diff-hl-show-hunk-inline-scroll-indicators))
119+
(scroll-indicator
120+
(if (eq diff-hl-show-hunk-inline--current-index 0)
121+
(make-string (length above-indicator) ?\s)
122+
above-indicator))
112123
(header (or header ""))
113124
(new-width (- width (length header) (length scroll-indicator)))
114125
(header (if (< new-width 0) "" header))
@@ -121,11 +132,13 @@ Compute it from some WIDTH, and some optional HEADER text."
121132
(defun diff-hl-show-hunk-inline--compute-footer (width &optional footer)
122133
"Compute the header of the popup.
123134
Compute it from some WIDTH, and some optional FOOTER text."
124-
(let* ((scroll-indicator (if (>= diff-hl-show-hunk-inline--current-index
125-
(- (length diff-hl-show-hunk-inline--current-lines)
126-
diff-hl-show-hunk-inline--height))
127-
" "
128-
""))
135+
(let* ((below-indicator (cdr diff-hl-show-hunk-inline-scroll-indicators))
136+
(scroll-indicator
137+
(if (>= diff-hl-show-hunk-inline--current-index
138+
(- (length diff-hl-show-hunk-inline--current-lines)
139+
diff-hl-show-hunk-inline--height))
140+
(make-string (length below-indicator) ?\s)
141+
below-indicator))
129142
(footer (or footer ""))
130143
(new-width (- width (length footer) (length scroll-indicator)))
131144
(footer (if (< new-width 0) "" footer))

0 commit comments

Comments
 (0)