diff --git a/docs/changelog.rst b/docs/changelog.rst index 81c17f31a34..430cf98cb18 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,9 @@ To update |kitty|, :doc:`follow the instructions `. - Render known country flags designated by a pair of unicode codepoints in two cells instead of four. +- diff kitten: New option to control the background color for filler lines in + the margin (:iss:`2518`) + 0.17.2 [2020-03-29] -------------------- diff --git a/kittens/diff/config.py b/kittens/diff/config.py index 8de12e565b7..ddfd91d5ce7 100644 --- a/kittens/diff/config.py +++ b/kittens/diff/config.py @@ -19,7 +19,7 @@ defaults: Optional[DiffOptions] = None -formats = { +formats: Dict[str, str] = { 'title': '', 'margin': '', 'text': '', @@ -35,6 +35,7 @@ def set_formats(opts: DiffOptions) -> None: formats['added'] = '48' + color_as_sgr(opts.added_bg) formats['removed'] = '48' + color_as_sgr(opts.removed_bg) formats['filler'] = '48' + color_as_sgr(opts.filler_bg) + formats['margin_filler'] = '48' + color_as_sgr(opts.margin_filler_bg or opts.filler_bg) formats['hunk_margin'] = '38' + color_as_sgr(opts.margin_fg) + ';48' + color_as_sgr(opts.hunk_margin_bg) formats['hunk'] = '38' + color_as_sgr(opts.margin_fg) + ';48' + color_as_sgr(opts.hunk_bg) formats['removed_highlight'] = '48' + color_as_sgr(opts.highlight_removed_bg) diff --git a/kittens/diff/config_data.py b/kittens/diff/config_data.py index 389ad97e5e9..17c7af37fa2 100644 --- a/kittens/diff/config_data.py +++ b/kittens/diff/config_data.py @@ -9,7 +9,9 @@ from typing import Any, Dict, Sequence, Union from kitty.conf.definition import Option, Shortcut, option_func -from kitty.conf.utils import positive_int, python_string, to_color +from kitty.conf.utils import ( + positive_int, python_string, to_color, to_color_or_none +) # }}} @@ -78,6 +80,8 @@ def syntax_aliases(raw: str) -> Dict[str, str]: c('added_margin_bg', '#cdffd8') c('filler_bg', '#fafbfc', long_text=_('Filler (empty) line background')) +c('margin_filler_bg', 'none', option_type=to_color_or_none, long_text=_( + 'Filler (empty) line background in margins, defaults to the filler background')) c('hunk_margin_bg', '#dbedff', long_text=_('Hunk header colors')) c('hunk_bg', '#f1f8ff') diff --git a/kittens/diff/render.py b/kittens/diff/render.py index fbf1d09444e..1db4d6e29ac 100644 --- a/kittens/diff/render.py +++ b/kittens/diff/render.py @@ -141,6 +141,7 @@ def formatted(text: str) -> str: removed_margin_format = format_func('removed_margin') added_margin_format = format_func('added_margin') filler_format = format_func('filler') +margin_filler_format = format_func('margin_filler') hunk_margin_format = format_func('hunk_margin') hunk_format = format_func('hunk') 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: return _split_with_highlights(line, truncate_pts, highlights, bg_highlight) -margin_bg_map = {'filler': filler_format, 'remove': removed_margin_format, 'add': added_margin_format, 'context': margin_format} +margin_bg_map = {'filler': margin_filler_format, 'remove': removed_margin_format, 'add': added_margin_format, 'context': margin_format} text_bg_map = {'filler': filler_format, 'remove': removed_format, 'add': added_format, 'context': text_format}