Skip to content

Commit 430f100

Browse files
committed
diff-hl-show-hunk-inline: Enable customization of scroll indicators
1 parent 23302ac commit 430f100

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
@@ -112,7 +119,11 @@ Compute it from LINES starting at INDEX with a WINDOW-SIZE."
112119
(defun diff-hl-show-hunk-inline--compute-header (width &optional header)
113120
"Compute the header of the popup.
114121
Compute it from some WIDTH, and some optional HEADER text."
115-
(let* ((scroll-indicator (if (eq diff-hl-show-hunk-inline--current-index 0) " " ""))
122+
(let* ((above-indicator (car diff-hl-show-hunk-inline-scroll-indicators))
123+
(scroll-indicator
124+
(if (eq diff-hl-show-hunk-inline--current-index 0)
125+
(make-string (length above-indicator) ?\s)
126+
above-indicator))
116127
(header (or header ""))
117128
(new-width (- width (length header) (length scroll-indicator)))
118129
(header (if (< new-width 0) "" header))
@@ -125,11 +136,13 @@ Compute it from some WIDTH, and some optional HEADER text."
125136
(defun diff-hl-show-hunk-inline--compute-footer (width &optional footer)
126137
"Compute the header of the popup.
127138
Compute it from some WIDTH, and some optional FOOTER text."
128-
(let* ((scroll-indicator (if (>= diff-hl-show-hunk-inline--current-index
129-
(- (length diff-hl-show-hunk-inline--current-lines)
130-
diff-hl-show-hunk-inline--height))
131-
" "
132-
""))
139+
(let* ((below-indicator (cdr diff-hl-show-hunk-inline-scroll-indicators))
140+
(scroll-indicator
141+
(if (>= diff-hl-show-hunk-inline--current-index
142+
(- (length diff-hl-show-hunk-inline--current-lines)
143+
diff-hl-show-hunk-inline--height))
144+
(make-string (length below-indicator) ?\s)
145+
below-indicator))
133146
(footer (or footer ""))
134147
(new-width (- width (length footer) (length scroll-indicator)))
135148
(footer (if (< new-width 0) "" footer))

0 commit comments

Comments
 (0)