Skip to content

Commit 4e7bf80

Browse files
committed
diff kitten: New option to control the background color for filler lines in the margin
Fixes #2518
1 parent e39df50 commit 4e7bf80

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
1919
- Render known country flags designated by a pair of unicode codepoints
2020
in two cells instead of four.
2121

22+
- diff kitten: New option to control the background color for filler lines in
23+
the margin (:iss:`2518`)
24+
2225

2326
0.17.2 [2020-03-29]
2427
--------------------

kittens/diff/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
defaults: Optional[DiffOptions] = None
2121

22-
formats = {
22+
formats: Dict[str, str] = {
2323
'title': '',
2424
'margin': '',
2525
'text': '',
@@ -35,6 +35,7 @@ def set_formats(opts: DiffOptions) -> None:
3535
formats['added'] = '48' + color_as_sgr(opts.added_bg)
3636
formats['removed'] = '48' + color_as_sgr(opts.removed_bg)
3737
formats['filler'] = '48' + color_as_sgr(opts.filler_bg)
38+
formats['margin_filler'] = '48' + color_as_sgr(opts.margin_filler_bg or opts.filler_bg)
3839
formats['hunk_margin'] = '38' + color_as_sgr(opts.margin_fg) + ';48' + color_as_sgr(opts.hunk_margin_bg)
3940
formats['hunk'] = '38' + color_as_sgr(opts.margin_fg) + ';48' + color_as_sgr(opts.hunk_bg)
4041
formats['removed_highlight'] = '48' + color_as_sgr(opts.highlight_removed_bg)

kittens/diff/config_data.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from typing import Any, Dict, Sequence, Union
1010

1111
from kitty.conf.definition import Option, Shortcut, option_func
12-
from kitty.conf.utils import positive_int, python_string, to_color
12+
from kitty.conf.utils import (
13+
positive_int, python_string, to_color, to_color_or_none
14+
)
1315

1416
# }}}
1517

@@ -78,6 +80,8 @@ def syntax_aliases(raw: str) -> Dict[str, str]:
7880
c('added_margin_bg', '#cdffd8')
7981

8082
c('filler_bg', '#fafbfc', long_text=_('Filler (empty) line background'))
83+
c('margin_filler_bg', 'none', option_type=to_color_or_none, long_text=_(
84+
'Filler (empty) line background in margins, defaults to the filler background'))
8185

8286
c('hunk_margin_bg', '#dbedff', long_text=_('Hunk header colors'))
8387
c('hunk_bg', '#f1f8ff')

kittens/diff/render.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def formatted(text: str) -> str:
141141
removed_margin_format = format_func('removed_margin')
142142
added_margin_format = format_func('added_margin')
143143
filler_format = format_func('filler')
144+
margin_filler_format = format_func('margin_filler')
144145
hunk_margin_format = format_func('hunk_margin')
145146
hunk_format = format_func('hunk')
146147
highlight_map = {'remove': ('removed_highlight', 'removed'), 'add': ('added_highlight', 'added')}
@@ -214,7 +215,7 @@ def split_with_highlights(line: str, width: int, highlights: List, bg_highlight:
214215
return _split_with_highlights(line, truncate_pts, highlights, bg_highlight)
215216

216217

217-
margin_bg_map = {'filler': filler_format, 'remove': removed_margin_format, 'add': added_margin_format, 'context': margin_format}
218+
margin_bg_map = {'filler': margin_filler_format, 'remove': removed_margin_format, 'add': added_margin_format, 'context': margin_format}
218219
text_bg_map = {'filler': filler_format, 'remove': removed_format, 'add': added_format, 'context': text_format}
219220

220221

0 commit comments

Comments
 (0)