Show italic file types correctly.
- Some file types have italic lscolors style, e.g. pem files. - Using TermStr.from_term to parse lscodes now it exists.
This commit is contained in:
parent
06fc1be36d
commit
28b2c9bae9
1 changed files with 2 additions and 16 deletions
|
|
@ -739,24 +739,10 @@ def run_tool_no_error(path, tool):
|
||||||
pygments.styles.get_style_by_name(os.environ["PYGMENT_STYLE"]))
|
pygments.styles.get_style_by_name(os.environ["PYGMENT_STYLE"]))
|
||||||
|
|
||||||
|
|
||||||
def _convert_lscolor_code_to_charstyle(lscolor_code):
|
|
||||||
parts = lscolor_code.split(";")
|
|
||||||
if len(parts) == 1:
|
|
||||||
is_bold = parts[0] == "1"
|
|
||||||
fg_color = None
|
|
||||||
elif len(parts) == 2:
|
|
||||||
is_bold = False
|
|
||||||
fg_color = int(parts[1])
|
|
||||||
else:
|
|
||||||
is_bold = len(parts) == 4 and parts[3] == "1"
|
|
||||||
fg_color = int(parts[2])
|
|
||||||
return termstr.CharStyle(fg_color=fg_color, is_bold=is_bold)
|
|
||||||
|
|
||||||
|
|
||||||
def _charstyle_of_path(path):
|
def _charstyle_of_path(path):
|
||||||
color_code = lscolors.color_code_for_path(path, _LS_COLOR_CODES)
|
color_code = lscolors.color_code_for_path(path, _LS_COLOR_CODES)
|
||||||
return (termstr.CharStyle() if color_code is None else
|
term_text = termstr.ESC + "[" + color_code + "m-"
|
||||||
_convert_lscolor_code_to_charstyle(color_code))
|
return termstr.TermStr.from_term(term_text).style[0]
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=100)
|
@functools.lru_cache(maxsize=100)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue