diff --git a/kitty/config.py b/kitty/config.py index ce7aab3c6..0e6a8785c 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -248,6 +248,7 @@ url_style.map = dict(((v, i) for i, v in enumerate('none single double curly'.sp type_map = { 'allow_remote_control': to_bool, 'adjust_line_height': adjust_line_height, + 'adjust_column_width': adjust_line_height, 'scrollback_lines': positive_int, 'scrollback_pager': shlex.split, 'scrollback_in_new_tab': to_bool, diff --git a/kitty/fonts.c b/kitty/fonts.c index b62e14519..31cccea8f 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -290,6 +290,8 @@ update_cell_metrics() { unsigned int before_cell_height = cell_height; if (OPT(adjust_line_height_px) != 0) cell_height += OPT(adjust_line_height_px); if (OPT(adjust_line_height_frac) != 0.f) cell_height *= OPT(adjust_line_height_frac); + if (OPT(adjust_column_width_px != 0)) cell_width += OPT(adjust_column_width_px); + if (OPT(adjust_column_width_frac) != 0.f) cell_height *= OPT(adjust_column_width_frac); int line_height_adjustment = cell_height - before_cell_height; if (cell_height < 4) { PyErr_SetString(PyExc_ValueError, "line height too small after adjustment"); return NULL; } if (cell_height > 1000) { PyErr_SetString(PyExc_ValueError, "line height too large after adjustment"); return NULL; } diff --git a/kitty/kitty.conf b/kitty/kitty.conf index c2e9efd33..8d48b1779 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -24,12 +24,13 @@ font_size 11.0 font_size_delta 2 -# Adjust the line height. +# Adjust the cell dimensions. # You can use either numbers, which are interpreted as pixels or percentages # (number followed by %), which are interpreted as percentages of the -# unmodified line height. You can use negative pixels or percentages less than -# 100% to reduce line height (but this might cause rendering artifacts). +# unmodified values. You can use negative pixels or percentages less than +# 100% to reduce sizes (but this might cause rendering artifacts). adjust_line_height 0 +adjust_column_width 0 # Change the sizes of the lines used for the box drawing unicode characters # These values are in pts. They will be scaled by the monitor DPI to arrive at diff --git a/kitty/state.c b/kitty/state.c index 410272e01..2c982cb95 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -364,15 +364,19 @@ PYWRAP1(set_options) { GA(keymap); set_special_keys(ret); Py_DECREF(ret); if (PyErr_Occurred()) return NULL; - PyObject *al = PyObject_GetAttrString(opts, "adjust_line_height"); - if (PyFloat_Check(al)) { - OPT(adjust_line_height_frac) = (float)PyFloat_AsDouble(al); - OPT(adjust_line_height_px) = 0; - } else { - OPT(adjust_line_height_frac) = 0; - OPT(adjust_line_height_px) = (int)PyLong_AsLong(al); - } - Py_DECREF(al); +#define read_adjust(name) { \ + PyObject *al = PyObject_GetAttrString(opts, #name); \ + if (PyFloat_Check(al)) { \ + OPT(name##_frac) = (float)PyFloat_AsDouble(al); \ + OPT(name##_px) = 0; \ + } else { \ + OPT(name##_frac) = 0; \ + OPT(name##_px) = (int)PyLong_AsLong(al); \ + } \ + Py_DECREF(al); \ +} + read_adjust(adjust_line_height); + read_adjust(adjust_column_width); #undef S Py_RETURN_NONE; } diff --git a/kitty/state.h b/kitty/state.h index 119b48602..4adf4b875 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -25,9 +25,9 @@ typedef struct { bool focus_follows_mouse; bool macos_option_as_alt, macos_hide_titlebar; bool prefer_color_emoji; - int adjust_line_height_px; + int adjust_line_height_px, adjust_column_width_px; + float adjust_line_height_frac, adjust_column_width_frac; int x11_bell_volume; - float adjust_line_height_frac; float background_opacity; float inactive_text_alpha; Edge tab_bar_edge;