Store the global font_size on the opts object where it belongs
This commit is contained in:
parent
81411e6b54
commit
d09c20aa01
@ -1313,7 +1313,7 @@ set_font_data(PyObject UNUSED *m, PyObject *args) {
|
|||||||
if (!PyArg_ParseTuple(args, "OOOIIIIO!dO",
|
if (!PyArg_ParseTuple(args, "OOOIIIIO!dO",
|
||||||
&box_drawing_function, &prerender_function, &descriptor_for_idx,
|
&box_drawing_function, &prerender_function, &descriptor_for_idx,
|
||||||
&descriptor_indices.bold, &descriptor_indices.italic, &descriptor_indices.bi, &descriptor_indices.num_symbol_fonts,
|
&descriptor_indices.bold, &descriptor_indices.italic, &descriptor_indices.bi, &descriptor_indices.num_symbol_fonts,
|
||||||
&PyTuple_Type, &sm, &global_state.font_sz_in_pts, &font_feature_settings)) return NULL;
|
&PyTuple_Type, &sm, &OPT(font_size), &font_feature_settings)) return NULL;
|
||||||
Py_INCREF(box_drawing_function); Py_INCREF(prerender_function); Py_INCREF(descriptor_for_idx); Py_INCREF(font_feature_settings);
|
Py_INCREF(box_drawing_function); Py_INCREF(prerender_function); Py_INCREF(descriptor_for_idx); Py_INCREF(font_feature_settings);
|
||||||
free_font_groups();
|
free_font_groups();
|
||||||
clear_symbol_maps();
|
clear_symbol_maps();
|
||||||
|
|||||||
@ -653,7 +653,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
float xscale, yscale;
|
float xscale, yscale;
|
||||||
double xdpi, ydpi;
|
double xdpi, ydpi;
|
||||||
get_window_content_scale(temp_window, &xscale, &yscale, &xdpi, &ydpi);
|
get_window_content_scale(temp_window, &xscale, &yscale, &xdpi, &ydpi);
|
||||||
FONTS_DATA_HANDLE fonts_data = load_fonts_data(global_state.font_sz_in_pts, xdpi, ydpi);
|
FONTS_DATA_HANDLE fonts_data = load_fonts_data(OPT(font_size), xdpi, ydpi);
|
||||||
PyObject *ret = PyObject_CallFunction(get_window_size, "IIddff", fonts_data->cell_width, fonts_data->cell_height, fonts_data->logical_dpi_x, fonts_data->logical_dpi_y, xscale, yscale);
|
PyObject *ret = PyObject_CallFunction(get_window_size, "IIddff", fonts_data->cell_width, fonts_data->cell_height, fonts_data->logical_dpi_x, fonts_data->logical_dpi_y, xscale, yscale);
|
||||||
if (ret == NULL) return NULL;
|
if (ret == NULL) return NULL;
|
||||||
int width = PyLong_AsLong(PyTuple_GET_ITEM(ret, 0)), height = PyLong_AsLong(PyTuple_GET_ITEM(ret, 1));
|
int width = PyLong_AsLong(PyTuple_GET_ITEM(ret, 0)), height = PyLong_AsLong(PyTuple_GET_ITEM(ret, 1));
|
||||||
|
|||||||
@ -55,7 +55,7 @@ opt('bold_italic_font', 'auto',
|
|||||||
)
|
)
|
||||||
|
|
||||||
opt('font_size', '11.0',
|
opt('font_size', '11.0',
|
||||||
option_type='to_font_size',
|
option_type='to_font_size', ctype='double',
|
||||||
long_text='Font size (in pts)'
|
long_text='Font size (in pts)'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
@ -5,6 +5,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_python_font_size(PyObject *val, Options *opts) {
|
||||||
|
opts->font_size = PyFloat_AsDouble(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_opts_font_size(PyObject *py_opts, Options *opts) {
|
||||||
|
PyObject *ret = PyObject_GetAttrString(py_opts, "font_size");
|
||||||
|
if (ret == NULL) return;
|
||||||
|
convert_from_python_font_size(ret, opts);
|
||||||
|
Py_DECREF(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convert_from_python_force_ltr(PyObject *val, Options *opts) {
|
convert_from_python_force_ltr(PyObject *val, Options *opts) {
|
||||||
opts->force_ltr = PyObject_IsTrue(val);
|
opts->force_ltr = PyObject_IsTrue(val);
|
||||||
@ -852,6 +865,8 @@ convert_from_opts_macos_show_window_title_in(PyObject *py_opts, Options *opts) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
||||||
|
convert_from_opts_font_size(py_opts, opts);
|
||||||
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_force_ltr(py_opts, opts);
|
convert_from_opts_force_ltr(py_opts, opts);
|
||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_adjust_line_height(py_opts, opts);
|
convert_from_opts_adjust_line_height(py_opts, opts);
|
||||||
|
|||||||
18
kitty/options/types.py
generated
18
kitty/options/types.py
generated
@ -811,10 +811,10 @@ if is_macos:
|
|||||||
defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ()))
|
defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ()))
|
||||||
defaults.mouse_map = [
|
defaults.mouse_map = [
|
||||||
MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')),
|
MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')),
|
|
||||||
MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')),
|
MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')),
|
MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')),
|
MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')),
|
||||||
|
MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')),
|
||||||
MouseMapping(2, 0, -1, False, KeyAction('paste_selection')),
|
MouseMapping(2, 0, -1, False, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))),
|
MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))),
|
||||||
@ -822,18 +822,18 @@ defaults.mouse_map = [
|
|||||||
MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))),
|
MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))),
|
||||||
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')),
|
|
||||||
MouseMapping(2, 1, -1, True, KeyAction('paste_selection')),
|
MouseMapping(2, 1, -1, True, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))),
|
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))),
|
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))),
|
||||||
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))),
|
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))),
|
||||||
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))),
|
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))),
|
||||||
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))),
|
||||||
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
|
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
|
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
|
||||||
|
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -179,7 +179,7 @@ add_os_window() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ans->font_sz_in_pts = global_state.font_sz_in_pts;
|
ans->font_sz_in_pts = OPT(font_size);
|
||||||
END_WITH_OS_WINDOW_REFS
|
END_WITH_OS_WINDOW_REFS
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
@ -824,8 +824,8 @@ PYWRAP1(pt_to_px) {
|
|||||||
PYWRAP1(global_font_size) {
|
PYWRAP1(global_font_size) {
|
||||||
double set_val = -1;
|
double set_val = -1;
|
||||||
PA("|d", &set_val);
|
PA("|d", &set_val);
|
||||||
if (set_val > 0) global_state.font_sz_in_pts = set_val;
|
if (set_val > 0) OPT(font_size) = set_val;
|
||||||
return Py_BuildValue("d", global_state.font_sz_in_pts);
|
return Py_BuildValue("d", OPT(font_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
PYWRAP1(os_window_font_size) {
|
PYWRAP1(os_window_font_size) {
|
||||||
@ -1066,7 +1066,7 @@ finalize(void) {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
init_state(PyObject *module) {
|
init_state(PyObject *module) {
|
||||||
global_state.font_sz_in_pts = 11.0;
|
OPT(font_size) = 11.0;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define DPI 72.0
|
#define DPI 72.0
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -72,6 +72,7 @@ typedef struct {
|
|||||||
} url_prefixes;
|
} url_prefixes;
|
||||||
bool detect_urls;
|
bool detect_urls;
|
||||||
bool tab_bar_hidden;
|
bool tab_bar_hidden;
|
||||||
|
double font_size;
|
||||||
} Options;
|
} Options;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -204,7 +205,6 @@ typedef struct {
|
|||||||
bool has_pending_resizes, has_pending_closes;
|
bool has_pending_resizes, has_pending_closes;
|
||||||
bool in_sequence_mode;
|
bool in_sequence_mode;
|
||||||
bool check_for_active_animated_images;
|
bool check_for_active_animated_images;
|
||||||
double font_sz_in_pts;
|
|
||||||
struct { double x, y; } default_dpi;
|
struct { double x, y; } default_dpi;
|
||||||
id_type active_drag_in_window;
|
id_type active_drag_in_window;
|
||||||
int active_drag_button;
|
int active_drag_button;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user