mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 02:31:45 +02:00
Make modify_font available to C code
This commit is contained in:
@@ -216,7 +216,7 @@ You can do this with e.g.::
|
||||
'''
|
||||
)
|
||||
|
||||
opt('+modify_font', '',
|
||||
opt('+modify_font', '', ctype='!modify_font',
|
||||
option_type='modify_font',
|
||||
add_to_default=False,
|
||||
long_text='''
|
||||
|
||||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
@@ -83,6 +83,19 @@ convert_from_opts_disable_ligatures(PyObject *py_opts, Options *opts) {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_modify_font(PyObject *val, Options *opts) {
|
||||
modify_font(val, opts);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_opts_modify_font(PyObject *py_opts, Options *opts) {
|
||||
PyObject *ret = PyObject_GetAttrString(py_opts, "modify_font");
|
||||
if (ret == NULL) return;
|
||||
convert_from_python_modify_font(ret, opts);
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_cursor_shape(PyObject *val, Options *opts) {
|
||||
opts->cursor_shape = PyLong_AsLong(val);
|
||||
@@ -1046,6 +1059,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_disable_ligatures(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_modify_font(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_cursor_shape(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_cursor_beam_thickness(py_opts, opts);
|
||||
|
||||
@@ -115,6 +115,22 @@ window_logo_path(PyObject *src, Options *opts) { STR_SETTER(default_window_logo)
|
||||
|
||||
#undef STR_SETTER
|
||||
|
||||
static void
|
||||
parse_font_mod_size(PyObject *val, float *sz, bool *is_percent) {
|
||||
PyObject *mv = PyObject_GetAttrString(val, "mod_value");
|
||||
if (mv) {
|
||||
*sz = PyFloat_AsFloat(PyTuple_GET_ITEM(mv, 0));
|
||||
*is_percent = PyLong_AsLong(PyTuple_GET_ITEM(mv, 1)) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
modify_font(PyObject *mf, Options *opts) {
|
||||
#define S(which) { PyObject *v = PyDict_GetItemString(mf, #which); if (v) parse_font_mod_size(v, &opts->which.val, &opts->which.is_percent); }
|
||||
S(underline_position); S(underline_thickness); S(strikethrough_thickness); S(strikethrough_position);
|
||||
#undef S
|
||||
}
|
||||
|
||||
static MouseShape
|
||||
pointer_shape(PyObject *shape_name) {
|
||||
const char *name = PyUnicode_AsUTF8(shape_name);
|
||||
|
||||
Reference in New Issue
Block a user