Actually apply mark colors when rendering
This commit is contained in:
parent
51c4737a29
commit
624dd78460
@ -5,7 +5,10 @@
|
||||
#define REVERSE_SHIFT {REVERSE_SHIFT}
|
||||
#define STRIKE_SHIFT {STRIKE_SHIFT}
|
||||
#define DIM_SHIFT {DIM_SHIFT}
|
||||
#define MARK_SHIFT {MARK_SHIFT}
|
||||
#define MARK_MASK {MARK_MASK}
|
||||
#define USE_SELECTION_FG
|
||||
#define NUM_COLORS 256
|
||||
|
||||
// Inputs {{{
|
||||
layout(std140) uniform CellRenderData {
|
||||
@ -16,7 +19,7 @@ layout(std140) uniform CellRenderData {
|
||||
uint xnum, ynum, cursor_fg_sprite_idx;
|
||||
float cursor_x, cursor_y, cursor_w;
|
||||
|
||||
uint color_table[256];
|
||||
uint color_table[NUM_COLORS + MARK_MASK + MARK_MASK + 2];
|
||||
};
|
||||
#ifdef BACKGROUND
|
||||
uniform uint draw_bg_bitfield;
|
||||
@ -162,7 +165,10 @@ void main() {
|
||||
float cell_has_cursor = is_cursor(c, r);
|
||||
float is_block_cursor = step(float(cursor_fg_sprite_idx), 0.5);
|
||||
float cell_has_block_cursor = cell_has_cursor * is_block_cursor;
|
||||
int mark = int(text_attrs >> MARK_SHIFT) & MARK_MASK;
|
||||
uint has_mark = uint(step(1, float(mark)));
|
||||
uint bg_as_uint = resolve_color(colors[bg_index], default_colors[bg_index]);
|
||||
bg_as_uint = has_mark * color_table[NUM_COLORS + mark] + (ONE - has_mark) * bg_as_uint;
|
||||
vec3 bg = color_to_vec(bg_as_uint);
|
||||
// }}}
|
||||
|
||||
@ -174,12 +180,13 @@ void main() {
|
||||
colored_sprite = float((sprite_coords.z & COLOR_MASK) >> 14);
|
||||
|
||||
// Foreground
|
||||
uint resolved_fg = resolve_color(colors[fg_index], default_colors[fg_index]);
|
||||
foreground = color_to_vec(resolved_fg);
|
||||
uint fg_as_uint = resolve_color(colors[fg_index], default_colors[fg_index]);
|
||||
fg_as_uint = has_mark * color_table[NUM_COLORS + MARK_MASK + 1 + mark] + (ONE - has_mark) * fg_as_uint;
|
||||
foreground = color_to_vec(fg_as_uint);
|
||||
float has_dim = float((text_attrs >> DIM_SHIFT) & ONE);
|
||||
effective_text_alpha = inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
|
||||
float in_url = float((is_selected & TWO) >> 1);
|
||||
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], resolved_fg));
|
||||
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], fg_as_uint));
|
||||
#ifdef USE_SELECTION_FG
|
||||
// Selection
|
||||
vec3 selection_color = color_to_vec(highlight_fg);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#define EXTRA_INIT if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
#include "data-types.h"
|
||||
#include "state.h"
|
||||
#include <structmember.h>
|
||||
|
||||
PyTypeObject ColorProfile_Type;
|
||||
@ -282,9 +282,12 @@ void
|
||||
copy_color_table_to_buffer(ColorProfile *self, color_type *buf, int offset, size_t stride) {
|
||||
size_t i;
|
||||
stride = MAX(1u, stride);
|
||||
for (i = 0, buf = buf + offset; i < sizeof(self->color_table)/sizeof(self->color_table[0]); i++, buf += stride) {
|
||||
*buf = self->color_table[i];
|
||||
}
|
||||
for (i = 0, buf = buf + offset; i < arraysz(self->color_table); i++, buf += stride) *buf = self->color_table[i];
|
||||
// Copy the mark colors
|
||||
#define C(val) *buf = val; buf += stride;
|
||||
C(0); C(OPT(mark1_background)); C(OPT(mark2_background)); C(OPT(mark3_background));
|
||||
C(0); C(OPT(mark1_foreground)); C(OPT(mark2_foreground)); C(OPT(mark3_foreground));
|
||||
#undef C
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
|
||||
@ -267,7 +267,7 @@ def add_marker(func, rest):
|
||||
flags |= re.IGNORECASE
|
||||
ftype = 'regex'
|
||||
try:
|
||||
spec = re.compile(spec, flgas=flags)
|
||||
spec = re.compile(spec, flags=flags)
|
||||
except Exception:
|
||||
raise ValueError('{} is not a valid regular expression'.format(spec))
|
||||
elif ftype == 'function':
|
||||
|
||||
@ -857,6 +857,12 @@ o('color14', '#14ffff', option_type=to_color)
|
||||
o('color7', '#dddddd', long_text=_('white'), option_type=to_color)
|
||||
o('color15', '#ffffff', option_type=to_color)
|
||||
|
||||
o('mark1_foreground', 'black', long_text=_('Color for marks of type 1'), option_type=to_color)
|
||||
o('mark1_background', '#cdc8ca', long_text=_('Color for marks of type 1 (light gray)'), option_type=to_color)
|
||||
o('mark2_foreground', 'black', long_text=_('Color for marks of type 2'), option_type=to_color)
|
||||
o('mark2_background', '#f2dcd3', long_text=_('Color for marks of type 1 (beige)'), option_type=to_color)
|
||||
o('mark3_foreground', 'black', long_text=_('Color for marks of type 3'), option_type=to_color)
|
||||
o('mark3_background', '#f274bc', long_text=_('Color for marks of type 1 (violet)'), option_type=to_color)
|
||||
dfctl = defines.default_color_table()
|
||||
for i in range(16, 256):
|
||||
o('color{}'.format(i), color_as_sharp(color_from_int(dfctl[i])), option_type=to_color, add_to_docs=False)
|
||||
|
||||
@ -251,6 +251,8 @@ PyInit_fast_data_types(void) {
|
||||
PyModule_AddIntConstant(m, "STRIKETHROUGH", STRIKE_SHIFT);
|
||||
PyModule_AddIntConstant(m, "DIM", DIM_SHIFT);
|
||||
PyModule_AddIntConstant(m, "DECORATION", DECORATION_SHIFT);
|
||||
PyModule_AddIntConstant(m, "MARK", MARK_SHIFT);
|
||||
PyModule_AddIntConstant(m, "MARK_MASK", MARK_MASK);
|
||||
PyModule_AddStringMacro(m, ERROR_PREFIX);
|
||||
#ifdef KITTY_VCS_REV
|
||||
PyModule_AddStringMacro(m, KITTY_VCS_REV);
|
||||
|
||||
@ -2274,10 +2274,11 @@ screen_mark_all(Screen *self) {
|
||||
linebuf_init_line(self->alt_linebuf, y);
|
||||
mark_text_in_line(self->markers.items, self->markers.count, self->alt_linebuf->line);
|
||||
}
|
||||
for (index_type y = 0; y < self->historybuf->ynum; y++) {
|
||||
for (index_type y = 0; y < self->historybuf->count; y++) {
|
||||
historybuf_init_line(self->historybuf, y, self->historybuf->line);
|
||||
mark_text_in_line(self->markers.items, self->markers.count, self->historybuf->line);
|
||||
}
|
||||
self->is_dirty = true;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
@ -2291,6 +2292,7 @@ add_marker(Screen *self, PyObject *args) {
|
||||
}
|
||||
for (size_t i = 0; i < self->markers.count; i++) {
|
||||
if (strcmp(self->markers.items[i].name, name) == 0) {
|
||||
if (self->markers.items[i].callback == marker) Py_RETURN_NONE;
|
||||
Py_DECREF(self->markers.items[i].callback);
|
||||
self->markers.items[i].callback = marker;
|
||||
Py_INCREF(marker);
|
||||
|
||||
@ -499,6 +499,12 @@ PYWRAP1(set_options) {
|
||||
S(terminal_select_modifiers, convert_mods);
|
||||
S(click_interval, parse_s_double_to_monotonic_t);
|
||||
S(resize_debounce_time, parse_s_double_to_monotonic_t);
|
||||
S(mark1_foreground, color_as_int);
|
||||
S(mark1_background, color_as_int);
|
||||
S(mark2_foreground, color_as_int);
|
||||
S(mark2_background, color_as_int);
|
||||
S(mark3_foreground, color_as_int);
|
||||
S(mark3_background, color_as_int);
|
||||
S(url_color, color_as_int);
|
||||
S(background, color_as_int);
|
||||
S(foreground, color_as_int);
|
||||
|
||||
@ -26,6 +26,7 @@ typedef struct {
|
||||
unsigned int scrollback_pager_history_size;
|
||||
char_type select_by_word_characters[256]; size_t select_by_word_characters_count;
|
||||
color_type url_color, background, foreground, active_border_color, inactive_border_color, bell_border_color;
|
||||
color_type mark1_foreground, mark1_background, mark2_foreground, mark2_background, mark3_foreground, mark3_background;
|
||||
monotonic_t repaint_delay, input_delay;
|
||||
bool focus_follows_mouse, hide_window_decorations;
|
||||
bool macos_hide_from_tasks, macos_quit_when_last_window_closed, macos_window_resizable, macos_traditional_fullscreen;
|
||||
|
||||
@ -12,17 +12,17 @@ from itertools import chain
|
||||
|
||||
from .config import build_ansi_color_table
|
||||
from .constants import (
|
||||
ScreenGeometry, WindowGeometry, appname, get_boss, wakeup, config_dir
|
||||
ScreenGeometry, WindowGeometry, appname, config_dir, get_boss, wakeup
|
||||
)
|
||||
from .fast_data_types import (
|
||||
BLIT_PROGRAM, CELL_BG_PROGRAM, CELL_FG_PROGRAM, CELL_PROGRAM,
|
||||
CELL_SPECIAL_PROGRAM, CSI, DCS, DECORATION, DIM,
|
||||
GRAPHICS_ALPHA_MASK_PROGRAM, GRAPHICS_PREMULT_PROGRAM, GRAPHICS_PROGRAM,
|
||||
OSC, REVERSE, SCROLL_FULL, SCROLL_LINE, SCROLL_PAGE, STRIKETHROUGH, Screen,
|
||||
add_window, cell_size_for_window, compile_program, get_clipboard_string,
|
||||
init_cell_program, set_clipboard_string, set_titlebar_color,
|
||||
set_window_render_data, update_window_title, update_window_visibility,
|
||||
viewport_for_window
|
||||
MARK, MARK_MASK, OSC, REVERSE, SCROLL_FULL, SCROLL_LINE, SCROLL_PAGE,
|
||||
STRIKETHROUGH, Screen, add_window, cell_size_for_window, compile_program,
|
||||
get_clipboard_string, init_cell_program, set_clipboard_string,
|
||||
set_titlebar_color, set_window_render_data, update_window_title,
|
||||
update_window_visibility, viewport_for_window
|
||||
)
|
||||
from .keys import defines, extended_key_event, keyboard_mode_name
|
||||
from .rgb import to_color
|
||||
@ -72,6 +72,8 @@ def load_shader_programs(semi_transparent=False):
|
||||
'STRIKE_SHIFT': STRIKETHROUGH,
|
||||
'DIM_SHIFT': DIM,
|
||||
'DECORATION_SHIFT': DECORATION,
|
||||
'MARK_SHIFT': MARK,
|
||||
'MARK_MASK': MARK_MASK,
|
||||
}.items():
|
||||
vv = vv.replace('{{{}}}'.format(gln), str(pyn), 1)
|
||||
if semi_transparent:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user