Add an option :opt:cursor_text_color to render text under the cursor in a fixed color.
See #126
This commit is contained in:
parent
d6a603d536
commit
55fc5c4358
@ -3,6 +3,12 @@ Changelog
|
|||||||
|
|
||||||
|kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator.
|
|kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator.
|
||||||
|
|
||||||
|
0.12.0 [future]
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
- Add an option :opt:`cursor_text_color` to render text under the cursor in a
|
||||||
|
fixed color. (:iss:`126`)
|
||||||
|
|
||||||
0.11.3 [2018-07-10]
|
0.11.3 [2018-07-10]
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#define REVERSE_SHIFT {REVERSE_SHIFT}
|
#define REVERSE_SHIFT {REVERSE_SHIFT}
|
||||||
#define STRIKE_SHIFT {STRIKE_SHIFT}
|
#define STRIKE_SHIFT {STRIKE_SHIFT}
|
||||||
#define DIM_SHIFT {DIM_SHIFT}
|
#define DIM_SHIFT {DIM_SHIFT}
|
||||||
|
#define CURSOR_TEXT_COLOR {CURSOR_TEXT_COLOR}
|
||||||
|
|
||||||
// Inputs {{{
|
// Inputs {{{
|
||||||
layout(std140) uniform CellRenderData {
|
layout(std140) uniform CellRenderData {
|
||||||
@ -166,8 +167,8 @@ void main() {
|
|||||||
strike_pos = to_sprite_pos(pos, ((text_attrs >> STRIKE_SHIFT) & ONE) * FOUR, ZERO, ZERO);
|
strike_pos = to_sprite_pos(pos, ((text_attrs >> STRIKE_SHIFT) & ONE) * FOUR, ZERO, ZERO);
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
foreground = choose_color(cursor, bg, foreground);
|
foreground = choose_color(cursor, CURSOR_TEXT_COLOR, foreground);
|
||||||
decoration_fg = choose_color(cursor, bg, decoration_fg);
|
decoration_fg = choose_color(cursor, CURSOR_TEXT_COLOR, decoration_fg);
|
||||||
#endif
|
#endif
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
|||||||
@ -266,7 +266,17 @@ def to_cursor_shape(x):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def cursor_text_color(x):
|
||||||
|
if x.lower() == 'background':
|
||||||
|
return
|
||||||
|
return to_color(x)
|
||||||
|
|
||||||
|
|
||||||
o('cursor', '#cccccc', _('Default cursor color'), option_type=to_color)
|
o('cursor', '#cccccc', _('Default cursor color'), option_type=to_color)
|
||||||
|
o('cursor_text_color', 'background', option_type=cursor_text_color, long_text=_('''
|
||||||
|
Choose the color of text under the cursor. By default, text under the cursor is
|
||||||
|
rendered using the background color. If, instead you want it rendered using a
|
||||||
|
fixed color, you can specify that color here.'''))
|
||||||
o('cursor_shape', 'block', option_type=to_cursor_shape, long_text=_(
|
o('cursor_shape', 'block', option_type=to_cursor_shape, long_text=_(
|
||||||
'The cursor shape can be one of (block, beam, underline)'))
|
'The cursor shape can be one of (block, beam, underline)'))
|
||||||
o('cursor_blink_interval', 0.5, option_type=positive_float, long_text=_('''
|
o('cursor_blink_interval', 0.5, option_type=positive_float, long_text=_('''
|
||||||
|
|||||||
@ -82,10 +82,13 @@ def talk_to_instance(args):
|
|||||||
|
|
||||||
|
|
||||||
def load_all_shaders(semi_transparent=0):
|
def load_all_shaders(semi_transparent=0):
|
||||||
load_shader_programs(semi_transparent)
|
load_shader_programs(semi_transparent, load_all_shaders.cursor_text_color)
|
||||||
load_borders_program()
|
load_borders_program()
|
||||||
|
|
||||||
|
|
||||||
|
load_all_shaders.cursor_text_color = None
|
||||||
|
|
||||||
|
|
||||||
def init_glfw(debug_keyboard=False):
|
def init_glfw(debug_keyboard=False):
|
||||||
glfw_module = 'cocoa' if is_macos else ('wayland' if is_wayland else 'x11')
|
glfw_module = 'cocoa' if is_macos else ('wayland' if is_wayland else 'x11')
|
||||||
if not glfw_init(glfw_path(glfw_module), debug_keyboard):
|
if not glfw_init(glfw_path(glfw_module), debug_keyboard):
|
||||||
@ -118,6 +121,7 @@ def _run_app(opts, args):
|
|||||||
new_os_window_trigger = get_new_os_window_trigger(opts)
|
new_os_window_trigger = get_new_os_window_trigger(opts)
|
||||||
if is_macos:
|
if is_macos:
|
||||||
set_custom_ibeam_cursor()
|
set_custom_ibeam_cursor()
|
||||||
|
load_all_shaders.cursor_text_color = opts.cursor_text_color
|
||||||
with cached_values_for(run_app.cached_values_name) as cached_values:
|
with cached_values_for(run_app.cached_values_name) as cached_values:
|
||||||
with startup_notification_handler(extra_callback=run_app.first_window_callback) as pre_show_callback:
|
with startup_notification_handler(extra_callback=run_app.first_window_callback) as pre_show_callback:
|
||||||
window_id = create_os_window(
|
window_id = create_os_window(
|
||||||
|
|||||||
@ -56,9 +56,14 @@ def calculate_gl_geometry(window_geometry, viewport_width, viewport_height, cell
|
|||||||
return ScreenGeometry(xstart, ystart, window_geometry.xnum, window_geometry.ynum, dx, dy)
|
return ScreenGeometry(xstart, ystart, window_geometry.xnum, window_geometry.ynum, dx, dy)
|
||||||
|
|
||||||
|
|
||||||
def load_shader_programs(semi_transparent=0):
|
def load_shader_programs(semi_transparent=0, cursor_text_color=None):
|
||||||
compile_program(BLIT_PROGRAM, *load_shaders('blit'))
|
compile_program(BLIT_PROGRAM, *load_shaders('blit'))
|
||||||
v, f = load_shaders('cell')
|
v, f = load_shaders('cell')
|
||||||
|
|
||||||
|
def color_as_vec3(x):
|
||||||
|
return 'vec3({}, {}, {})'.format(x.red / 255, x.green / 255, x.blue / 255)
|
||||||
|
|
||||||
|
cursor_text_color = color_as_vec3(cursor_text_color) if cursor_text_color else 'bg'
|
||||||
for which, p in {
|
for which, p in {
|
||||||
'SIMPLE': CELL_PROGRAM,
|
'SIMPLE': CELL_PROGRAM,
|
||||||
'BACKGROUND': CELL_BG_PROGRAM,
|
'BACKGROUND': CELL_BG_PROGRAM,
|
||||||
@ -66,7 +71,13 @@ def load_shader_programs(semi_transparent=0):
|
|||||||
'FOREGROUND': CELL_FG_PROGRAM,
|
'FOREGROUND': CELL_FG_PROGRAM,
|
||||||
}.items():
|
}.items():
|
||||||
vv, ff = v.replace('WHICH_PROGRAM', which), f.replace('WHICH_PROGRAM', which)
|
vv, ff = v.replace('WHICH_PROGRAM', which), f.replace('WHICH_PROGRAM', which)
|
||||||
for gln, pyn in {'REVERSE_SHIFT': REVERSE, 'STRIKE_SHIFT': STRIKETHROUGH, 'DIM_SHIFT': DIM, 'DECORATION_SHIFT': DECORATION}.items():
|
for gln, pyn in {
|
||||||
|
'REVERSE_SHIFT': REVERSE,
|
||||||
|
'STRIKE_SHIFT': STRIKETHROUGH,
|
||||||
|
'DIM_SHIFT': DIM,
|
||||||
|
'DECORATION_SHIFT': DECORATION,
|
||||||
|
'CURSOR_TEXT_COLOR': cursor_text_color,
|
||||||
|
}.items():
|
||||||
vv = vv.replace('{{{}}}'.format(gln), str(pyn), 1)
|
vv = vv.replace('{{{}}}'.format(gln), str(pyn), 1)
|
||||||
if semi_transparent:
|
if semi_transparent:
|
||||||
vv = vv.replace('#define NOT_TRANSPARENT', '#define TRANSPARENT')
|
vv = vv.replace('#define NOT_TRANSPARENT', '#define TRANSPARENT')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user