When running kittens, use the colorscheme of the current window rather than the configured colorscheme
Fixes #1906
This commit is contained in:
parent
afcaca85da
commit
472c6f6b8d
@ -19,6 +19,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- macOS: Add an option :opt:`macos_show_window_title_in` to control
|
||||
showing the window title in the menubar/titlebar (:pull:`1837`)
|
||||
|
||||
- When running kittens, use the colorscheme of the current window
|
||||
rather than the configured colorscheme (:iss:`1906`)
|
||||
|
||||
- Dont fail to start if running the shell to read the EDITOR env var fails
|
||||
(:iss:`1869`)
|
||||
|
||||
|
||||
@ -716,7 +716,9 @@ class Boss:
|
||||
},
|
||||
cwd=w.cwd_of_child,
|
||||
overlay_for=w.id
|
||||
))
|
||||
),
|
||||
copy_colors_from=w
|
||||
)
|
||||
overlay_window.action_on_close = partial(self.on_kitten_finish, w.id, end_kitten)
|
||||
return overlay_window
|
||||
|
||||
|
||||
@ -98,6 +98,15 @@ update_ansi_color_table(ColorProfile *self, PyObject *val) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
copy_color_profile(ColorProfile *dest, ColorProfile *src) {
|
||||
memcpy(dest->color_table, src->color_table, sizeof(dest->color_table));
|
||||
memcpy(dest->orig_color_table, src->orig_color_table, sizeof(dest->color_table));
|
||||
memcpy(&dest->configured, &src->configured, sizeof(dest->configured));
|
||||
memcpy(&dest->overridden, &src->overridden, sizeof(dest->overridden));
|
||||
dest->dirty = true;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
patch_color_profiles(PyObject *module UNUSED, PyObject *args) {
|
||||
PyObject *spec, *profiles, *v; ColorProfile *self; int change_configured; PyObject *cursor_text_color;
|
||||
|
||||
@ -278,6 +278,7 @@ Cursor* alloc_cursor(void);
|
||||
LineBuf* alloc_linebuf(unsigned int, unsigned int);
|
||||
HistoryBuf* alloc_historybuf(unsigned int, unsigned int, unsigned int);
|
||||
ColorProfile* alloc_color_profile(void);
|
||||
void copy_color_profile(ColorProfile*, ColorProfile*);
|
||||
PyObject* create_256_color_table(void);
|
||||
PyObject* parse_bytes_dump(PyObject UNUSED *, PyObject *);
|
||||
PyObject* parse_bytes(PyObject UNUSED *, PyObject *);
|
||||
|
||||
@ -1989,6 +1989,12 @@ is_rectangle_select(Screen *self, PyObject *a UNUSED) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
copy_colors_from(Screen *self, Screen *other) {
|
||||
copy_color_profile(self->color_profile, other->color_profile);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
text_for_selection(Screen *self, PyObject *a UNUSED) {
|
||||
FullSelectionBoundary start, end;
|
||||
@ -2294,6 +2300,7 @@ static PyMethodDef methods[] = {
|
||||
MND(toggle_alt_screen, METH_NOARGS)
|
||||
MND(reset_callbacks, METH_NOARGS)
|
||||
MND(paste, METH_O)
|
||||
MND(copy_colors_from, METH_O)
|
||||
{"select_graphic_rendition", (PyCFunction)_select_graphic_rendition, METH_VARARGS, ""},
|
||||
|
||||
{NULL} /* Sentinel */
|
||||
|
||||
@ -232,9 +232,13 @@ class Tab: # {{{
|
||||
ans.fork()
|
||||
return ans
|
||||
|
||||
def new_window(self, use_shell=True, cmd=None, stdin=None, override_title=None, cwd_from=None, cwd=None, overlay_for=None, env=None, location=None):
|
||||
def new_window(
|
||||
self, use_shell=True, cmd=None, stdin=None, override_title=None,
|
||||
cwd_from=None, cwd=None, overlay_for=None, env=None, location=None,
|
||||
copy_colors_from=None
|
||||
):
|
||||
child = self.launch_child(use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd, env=env)
|
||||
window = Window(self, child, self.opts, self.args, override_title=override_title)
|
||||
window = Window(self, child, self.opts, self.args, override_title=override_title, copy_colors_from=copy_colors_from)
|
||||
if overlay_for is not None:
|
||||
overlaid = next(w for w in self.windows if w.id == overlay_for)
|
||||
window.overlay_for = overlay_for
|
||||
@ -245,8 +249,8 @@ class Tab: # {{{
|
||||
self.relayout_borders()
|
||||
return window
|
||||
|
||||
def new_special_window(self, special_window, location=None):
|
||||
return self.new_window(False, *special_window, location=location)
|
||||
def new_special_window(self, special_window, location=None, copy_colors_from=None):
|
||||
return self.new_window(False, *special_window, location=location, copy_colors_from=copy_colors_from)
|
||||
|
||||
def close_window(self):
|
||||
if self.windows:
|
||||
|
||||
@ -131,7 +131,7 @@ def text_sanitizer(as_ansi, add_wrap_markers):
|
||||
|
||||
class Window:
|
||||
|
||||
def __init__(self, tab, child, opts, args, override_title=None):
|
||||
def __init__(self, tab, child, opts, args, override_title=None, copy_colors_from=None):
|
||||
self.action_on_close = None
|
||||
self.layout_data = None
|
||||
self.pty_resized_once = False
|
||||
@ -158,7 +158,10 @@ class Window:
|
||||
self.child, self.opts = child, opts
|
||||
cell_width, cell_height = cell_size_for_window(self.os_window_id)
|
||||
self.screen = Screen(self, 24, 80, opts.scrollback_lines, cell_width, cell_height, self.id)
|
||||
setup_colors(self.screen, opts)
|
||||
if copy_colors_from is not None:
|
||||
self.screen.copy_colors_from(copy_colors_from.screen)
|
||||
else:
|
||||
setup_colors(self.screen, opts)
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user