diff kitten: Make the representation of tabs configurable

This commit is contained in:
Kovid Goyal
2018-05-20 15:37:52 +05:30
parent 912b395316
commit b6baa99fce
5 changed files with 17 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ import os
from kitty.config_utils import (
init_config, load_config as _load_config, merge_dicts, parse_config_base,
resolve_config, to_color
python_string, resolve_config, to_color
)
from kitty.constants import config_dir
from kitty.rgb import color_as_sgr
@@ -50,6 +50,7 @@ def syntax_aliases(raw):
type_map = {
'syntax_aliases': syntax_aliases,
'num_context_lines': int,
'replace_tab_by': python_string,
}
for name in (

View File

@@ -17,6 +17,9 @@ num_context_lines 3
# is to search the system for either git or diff and use that, if found.
diff_cmd auto
# The string to replace tabs with. Default is to use four spaces.
replace_tab_by \x20\x20\x20\x20
# Colors
foreground black
background white

View File

@@ -19,7 +19,9 @@ from ..tui.handler import Handler
from ..tui.images import ImageManager
from ..tui.loop import Loop
from ..tui.operations import styled
from .collect import create_collection, data_for_path, set_highlight_data
from .collect import (
create_collection, data_for_path, lines_for_path, set_highlight_data
)
from .config import init_config
from .patch import Differ, set_diff_command
from .render import ImageSupportWarning, LineRef, render_diff
@@ -397,6 +399,7 @@ def main(args):
raise SystemExit('The items to be diffed should both be either directories or files. Comparing a directory to a file is not valid.')
opts = init_config(args)
set_diff_command(opts.diff_cmd)
lines_for_path.replace_tab_by = opts.replace_tab_by
loop = Loop()
handler = DiffHandler(args, opts, left, right)