diff kitten: Make the representation of tabs configurable
This commit is contained in:
parent
912b395316
commit
b6baa99fce
@ -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 (
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@ -13,7 +12,8 @@ from contextlib import contextmanager
|
||||
from . import fast_data_types as defines
|
||||
from .config_utils import (
|
||||
init_config, load_config as _load_config, merge_dicts, parse_config_base,
|
||||
positive_float, positive_int, to_bool, to_cmdline, to_color, unit_float
|
||||
positive_float, positive_int, python_string, to_bool, to_cmdline, to_color,
|
||||
unit_float
|
||||
)
|
||||
from .constants import cache_dir, defconf
|
||||
from .fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
||||
@ -223,8 +223,7 @@ def parse_symbol_map(val):
|
||||
|
||||
|
||||
def parse_send_text_bytes(text):
|
||||
return ast.literal_eval("'''" + text.replace("'''", "'\\''") + "'''"
|
||||
).encode('utf-8')
|
||||
return python_string(text).encode('utf-8')
|
||||
|
||||
|
||||
def parse_send_text(val, key_definitions):
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import ast
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
@ -38,6 +39,10 @@ def to_cmdline(x):
|
||||
return ans
|
||||
|
||||
|
||||
def python_string(text):
|
||||
return ast.literal_eval("'''" + text.replace("'''", "'\\''") + "'''")
|
||||
|
||||
|
||||
def parse_line(line, type_map, special_handling, ans, all_keys, base_path_for_includes):
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#'):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user