Merge branch 'underline_thickness_option' of https://github.com/noomly/kitty

This commit is contained in:
Kovid Goyal 2020-02-06 21:14:34 +05:30
commit 20a7050564
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 15 additions and 7 deletions

View File

@ -16,8 +16,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- A new :opt:`background_tint` option to darken the background under the text
area when using background images and/or transparent windows.
- A new :opt:`cursor_beam_thickness` option to control the thickness of the
beam cursor (:iss:`2337`)
- New options :opt:`cursor_beam_thickness` and :opt:`cursor_underline_thickness` to control the thickness of the
beam and underline cursors (:iss:`2337` and :pull:`2342`)
- X11: Fix arrow mouse cursor using right pointing instead of the default left
pointing arrow (:iss:`2341`)

View File

@ -396,6 +396,8 @@ o('cursor_shape', 'block', option_type=to_cursor_shape, long_text=_(
'The cursor shape can be one of (block, beam, underline)'))
o('cursor_beam_thickness', 1.5, option_type=positive_float, long_text=_(
'Defines the thickness of the beam cursor (in pts)'))
o('cursor_underline_thickness', 2.0, option_type=positive_float, long_text=_(
'Defines the thickness of the underline cursor (in pts)'))
o('cursor_blink_interval', -1, option_type=float, long_text=_('''
The interval (in seconds) at which to blink the cursor. Set to zero to disable
blinking. Negative values mean use system default. Note that numbers smaller

View File

@ -1232,7 +1232,7 @@ send_prerendered_sprites(FontGroup *fg) {
current_send_sprite_to_gpu((FONTS_DATA_HANDLE)fg, x, y, z, fg->canvas);
do_increment(fg, &error);
if (error != 0) { sprite_map_set_error(error); PyErr_Print(); fatal("Failed"); }
PyObject *args = PyObject_CallFunction(prerender_function, "IIIIIfdd", fg->cell_width, fg->cell_height, fg->baseline, fg->underline_position, fg->underline_thickness, OPT(cursor_beam_thickness), fg->logical_dpi_x, fg->logical_dpi_y);
PyObject *args = PyObject_CallFunction(prerender_function, "IIIIIffdd", fg->cell_width, fg->cell_height, fg->baseline, fg->underline_position, fg->underline_thickness, OPT(cursor_beam_thickness), fg->logical_dpi_x, fg->logical_dpi_y);
if (args == NULL) { PyErr_Print(); fatal("Failed to pre-render cells"); }
for (ssize_t i = 0; i < PyTuple_GET_SIZE(args) - 1; i++) {
x = fg->sprite_tracker.x; y = fg->sprite_tracker.y; z = fg->sprite_tracker.z;

View File

@ -192,7 +192,7 @@ def render_special(
return ans
def render_cursor(which, cursor_beam_thickness, cell_width=0, cell_height=0, dpi_x=0, dpi_y=0):
def render_cursor(which, cursor_beam_thickness, cursor_underline_thickness, cell_width=0, cell_height=0, dpi_x=0, dpi_y=0):
CharTexture = ctypes.c_ubyte * (cell_width * cell_height)
ans = CharTexture()
@ -215,19 +215,23 @@ def render_cursor(which, cursor_beam_thickness, cell_width=0, cell_height=0, dpi
if which == 1: # beam
vert('left', cursor_beam_thickness)
elif which == 2: # underline
horz('bottom', 2.0)
horz('bottom', cursor_underline_thickness)
elif which == 3: # hollow
vert('left'), vert('right'), horz('top'), horz('bottom')
return ans
def prerender_function(cell_width, cell_height, baseline, underline_position, underline_thickness, cursor_beam_thickness, dpi_x, dpi_y):
def prerender_function(
cell_width, cell_height, baseline, underline_position, underline_thickness,
cursor_beam_thickness, cursor_underline_thickness, dpi_x, dpi_y):
# Pre-render the special underline, strikethrough and missing and cursor cells
f = partial(
render_special, cell_width=cell_width, cell_height=cell_height, baseline=baseline,
underline_position=underline_position, underline_thickness=underline_thickness)
c = partial(
render_cursor, cursor_beam_thickness=cursor_beam_thickness, cell_width=cell_width, cell_height=cell_height, dpi_x=dpi_x, dpi_y=dpi_y)
render_cursor, cursor_beam_thickness=cursor_beam_thickness,
cursor_underline_thickness=cursor_underline_thickness, cell_width=cell_width,
cell_height=cell_height, dpi_x=dpi_x, dpi_y=dpi_y)
cells = f(1), f(2), f(3), f(0, True), f(missing=True), c(1), c(2), c(3)
return tuple(map(ctypes.addressof, cells)) + (cells,)

View File

@ -569,6 +569,7 @@ PYWRAP1(set_options) {
S(scrollback_pager_history_size, PyLong_AsUnsignedLong);
S(cursor_shape, PyLong_AsLong);
S(cursor_beam_thickness, PyFloat_AsFloat);
S(cursor_underline_thickness, PyFloat_AsFloat);
S(url_style, PyLong_AsUnsignedLong);
S(tab_bar_edge, PyLong_AsLong);
S(mouse_hide_wait, parse_s_double_to_monotonic_t);

View File

@ -21,6 +21,7 @@ typedef struct {
bool enable_audio_bell;
CursorShape cursor_shape;
float cursor_beam_thickness;
float cursor_underline_thickness;
unsigned int open_url_modifiers;
unsigned int rectangle_select_modifiers;
unsigned int terminal_select_modifiers;