mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-14 12:11:12 +03:00
Store the options object globally
This commit is contained in:
parent
b702f3daf1
commit
253b219d67
@ -515,7 +515,7 @@ def sync_os_window_title(os_window_id: int) -> None:
|
||||
|
||||
|
||||
def set_options(
|
||||
opts: Options,
|
||||
opts: Optional[Options],
|
||||
is_wayland: bool = False,
|
||||
debug_rendering: bool = False,
|
||||
debug_font_fallback: bool = False
|
||||
@ -523,6 +523,10 @@ def set_options(
|
||||
pass
|
||||
|
||||
|
||||
def get_options() -> Options:
|
||||
pass
|
||||
|
||||
|
||||
def resolve_key_mods(kitty_mod: int, mods: int) -> int:
|
||||
pass
|
||||
|
||||
|
@ -171,10 +171,11 @@ class AppRunner:
|
||||
def __call__(self, opts: OptionsStub, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||
set_scale(opts.box_drawing_scale)
|
||||
set_options(opts, is_wayland(), args.debug_rendering, args.debug_font_fallback)
|
||||
set_font_family(opts, debug_font_matching=args.debug_font_fallback)
|
||||
try:
|
||||
set_font_family(opts, debug_font_matching=args.debug_font_fallback)
|
||||
_run_app(opts, args, bad_lines)
|
||||
finally:
|
||||
set_options(None)
|
||||
free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized
|
||||
|
||||
|
||||
|
@ -694,10 +694,25 @@ PYWRAP1(handle_for_window_id) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* options_object = NULL;
|
||||
|
||||
PYWRAP0(get_options) {
|
||||
if (!options_object) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Must call set_options() before using get_options()");
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF(options_object);
|
||||
return options_object;
|
||||
}
|
||||
|
||||
PYWRAP1(set_options) {
|
||||
PyObject *ret, *opts;
|
||||
int is_wayland = 0, debug_rendering = 0, debug_font_fallback = 0;
|
||||
PA("O|ppp", &opts, &is_wayland, &debug_rendering, &debug_font_fallback);
|
||||
if (opts == Py_None) {
|
||||
Py_CLEAR(options_object);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
global_state.is_wayland = is_wayland ? true : false;
|
||||
#ifdef __APPLE__
|
||||
global_state.has_render_frames = true;
|
||||
@ -814,6 +829,8 @@ PYWRAP1(set_options) {
|
||||
#undef read_adjust
|
||||
#undef S
|
||||
#undef SS
|
||||
options_object = opts;
|
||||
Py_INCREF(options_object);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@ -1206,6 +1223,7 @@ static PyMethodDef module_methods[] = {
|
||||
MW(current_os_window, METH_NOARGS),
|
||||
MW(next_window_id, METH_NOARGS),
|
||||
MW(set_options, METH_VARARGS),
|
||||
MW(get_options, METH_NOARGS),
|
||||
MW(click_mouse_url, METH_VARARGS),
|
||||
MW(mouse_selection, METH_VARARGS),
|
||||
MW(set_in_sequence_mode, METH_O),
|
||||
|
Loading…
Reference in New Issue
Block a user