Add a setting to adjust the width of cells, similar to the existing setting to adjust the height of cells

This commit is contained in:
Kovid Goyal 2018-01-28 10:16:59 +05:30
parent c74f4a8165
commit edf9413356
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 22 additions and 14 deletions

View File

@ -248,6 +248,7 @@ url_style.map = dict(((v, i) for i, v in enumerate('none single double curly'.sp
type_map = { type_map = {
'allow_remote_control': to_bool, 'allow_remote_control': to_bool,
'adjust_line_height': adjust_line_height, 'adjust_line_height': adjust_line_height,
'adjust_column_width': adjust_line_height,
'scrollback_lines': positive_int, 'scrollback_lines': positive_int,
'scrollback_pager': shlex.split, 'scrollback_pager': shlex.split,
'scrollback_in_new_tab': to_bool, 'scrollback_in_new_tab': to_bool,

View File

@ -290,6 +290,8 @@ update_cell_metrics() {
unsigned int before_cell_height = cell_height; 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_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_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; 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 < 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; } if (cell_height > 1000) { PyErr_SetString(PyExc_ValueError, "line height too large after adjustment"); return NULL; }

View File

@ -24,12 +24,13 @@ font_size 11.0
font_size_delta 2 font_size_delta 2
# Adjust the line height. # Adjust the cell dimensions.
# You can use either numbers, which are interpreted as pixels or percentages # You can use either numbers, which are interpreted as pixels or percentages
# (number followed by %), which are interpreted as percentages of the # (number followed by %), which are interpreted as percentages of the
# unmodified line height. You can use negative pixels or percentages less than # unmodified values. You can use negative pixels or percentages less than
# 100% to reduce line height (but this might cause rendering artifacts). # 100% to reduce sizes (but this might cause rendering artifacts).
adjust_line_height 0 adjust_line_height 0
adjust_column_width 0
# Change the sizes of the lines used for the box drawing unicode characters # 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 # These values are in pts. They will be scaled by the monitor DPI to arrive at

View File

@ -364,15 +364,19 @@ PYWRAP1(set_options) {
GA(keymap); set_special_keys(ret); GA(keymap); set_special_keys(ret);
Py_DECREF(ret); if (PyErr_Occurred()) return NULL; Py_DECREF(ret); if (PyErr_Occurred()) return NULL;
PyObject *al = PyObject_GetAttrString(opts, "adjust_line_height"); #define read_adjust(name) { \
if (PyFloat_Check(al)) { PyObject *al = PyObject_GetAttrString(opts, #name); \
OPT(adjust_line_height_frac) = (float)PyFloat_AsDouble(al); if (PyFloat_Check(al)) { \
OPT(adjust_line_height_px) = 0; OPT(name##_frac) = (float)PyFloat_AsDouble(al); \
} else { OPT(name##_px) = 0; \
OPT(adjust_line_height_frac) = 0; } else { \
OPT(adjust_line_height_px) = (int)PyLong_AsLong(al); OPT(name##_frac) = 0; \
} OPT(name##_px) = (int)PyLong_AsLong(al); \
Py_DECREF(al); } \
Py_DECREF(al); \
}
read_adjust(adjust_line_height);
read_adjust(adjust_column_width);
#undef S #undef S
Py_RETURN_NONE; Py_RETURN_NONE;
} }

View File

@ -25,9 +25,9 @@ typedef struct {
bool focus_follows_mouse; bool focus_follows_mouse;
bool macos_option_as_alt, macos_hide_titlebar; bool macos_option_as_alt, macos_hide_titlebar;
bool prefer_color_emoji; 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; int x11_bell_volume;
float adjust_line_height_frac;
float background_opacity; float background_opacity;
float inactive_text_alpha; float inactive_text_alpha;
Edge tab_bar_edge; Edge tab_bar_edge;