Apply default colors in diff kitten

This commit is contained in:
Kovid Goyal
2018-04-24 10:33:18 +05:30
parent fe5b8f3aec
commit 5c4b14468c
4 changed files with 18 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ class Handler:
self.initialize()
def __exit__(self, *a):
del self.write_buf[:]
self.finalize()
def initialize(self):

View File

@@ -376,8 +376,12 @@ class Loop:
self.return_code = 1
keep_going = False
finalize_output = b''.join(handler.write_buf).decode('utf-8')
if tb is not None:
self._report_error_loop(tb, term_manager)
self._report_error_loop(finalize_output + tb, term_manager)
if tb is None:
os.write(self.output_fd, finalize_output.encode('utf-8'))
def _report_error_loop(self, tb, term_manager):
select = self.sel.select

View File

@@ -5,7 +5,7 @@
import sys
from contextlib import contextmanager
from kitty.rgb import color_as_sharp, to_color
from kitty.rgb import Color, color_as_sharp, to_color
from kitty.terminfo import string_capabilities
S7C1T = '\033 F'
@@ -168,9 +168,9 @@ def set_default_colors(fg=None, bg=None):
if fg is None:
ans += '\x1b]110\x1b\\'
else:
ans += '\x1b]10;{}\x1b\\'.format(color_as_sharp(to_color(fg)))
ans += '\x1b]10;{}\x1b\\'.format(color_as_sharp(fg if isinstance(fg, Color) else to_color(fg)))
if bg is None:
ans += '\x1b]111\x1b\\'
else:
ans += '\x1b]11;{}\x1b\\'.format(color_as_sharp(to_color(bg)))
ans += '\x1b]11;{}\x1b\\'.format(color_as_sharp(bg if isinstance(bg, Color) else to_color(bg)))
return ans