Cleanup previous PR

This commit is contained in:
Kovid Goyal
2023-05-24 13:12:09 +05:30
parent 7dd06cf134
commit 53073f34d7
9 changed files with 26 additions and 30 deletions

View File

@@ -40,6 +40,8 @@ Detailed list of changes
- A new escape code ``<ESC>[22J`` that moves the current contents of the screen into the scrollback before clearing it
- A new option :opt:`text_fg_override_threshold` to force text colors to have high contrast regardless of color scheme (:pull:`6283`)
- unicode_input kitten: Fix a regression in 0.28.0 that caused the order of recent and favorites entries to not be respected (:iss:`6214`)
- unicode_input kitten: Fix a regression in 0.28.0 that caused editing of favorites to sometimes hang

View File

@@ -391,7 +391,7 @@ def generate_c_conversion(loc: str, ctypes: List[Union[Option, MultiOption]]) ->
lines: List[str] = []
basic_converters = {
'int': 'PyLong_AsLong', 'uint': 'PyLong_AsUnsignedLong', 'bool': 'PyObject_IsTrue',
'float': 'PyFloat_AsFloat', 'double': 'PyFloat_AsDouble',
'float': 'PyFloat_AsFloat', 'double': 'PyFloat_AsDouble', 'percent': 'percent',
'time': 'parse_s_double_to_monotonic_t', 'time-ms': 'parse_ms_long_to_monotonic_t'
}

View File

@@ -269,15 +269,15 @@ Then adjust the second parameter until it looks good. Then switch to a light the
and adjust the first parameter until the perceived thickness matches the dark theme.
''')
opt('text_fg_override_threshold', 0,
ctype='!text_fg_override_threshold',
long_text='''
opt('text_fg_override_threshold', 0, option_type='float', ctype='percent', long_text='''
The minimum accepted difference in luminance between the foreground and background
color, below which kitty will override the foreground color. It is percentage
ranging from :code:`0` to :code:`100`. If the difference in luminance of the
foreground and background is below this threshold, the foreground color will be set
to white if the background is dark or black if the background is light. The default
value is :code:`0`.
value is :code:`0`, which means no overriding is performed. Useful when working with applications
that use colors that do not contrast well with your preferred color scheme. Changing this option
from zero to a non-zero value or vice versa requires a restart of kitty.
''')
egr() # }}}

View File

@@ -1285,7 +1285,7 @@ class Parser:
ans['text_composition_strategy'] = str(val)
def text_fg_override_threshold(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['text_fg_override_threshold'] = str(val)
ans['text_fg_override_threshold'] = float(val)
def touch_scroll_multiplier(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['touch_scroll_multiplier'] = float(val)

View File

@@ -72,7 +72,7 @@ convert_from_opts_text_composition_strategy(PyObject *py_opts, Options *opts) {
static void
convert_from_python_text_fg_override_threshold(PyObject *val, Options *opts) {
text_fg_override_threshold(val, opts);
opts->text_fg_override_threshold = percent(val);
}
static void

View File

@@ -14,6 +14,13 @@ PyFloat_AsFloat(PyObject *o) {
return (float)PyFloat_AsDouble(o);
}
static inline float
percent(PyObject *o) {
float ans = PyFloat_AsFloat(o);
return MAX(0.f, MIN(ans, 100.f)) * 0.01f;
}
static inline color_type
color_as_int(PyObject *color) {
if (!PyObject_TypeCheck(color, &Color_Type)) { PyErr_SetString(PyExc_TypeError, "Not a Color object"); return 0; }
@@ -211,18 +218,6 @@ text_composition_strategy(PyObject *val, Options *opts) {
}
}
static void
text_fg_override_threshold(PyObject *val, Options *opts) {
if (!PyUnicode_Check(val)) { PyErr_SetString(PyExc_TypeError, "text_fg_override_threshold must be a string"); return; }
opts->text_fg_override_threshold = 0.f;
DECREF_AFTER_FUNCTION PyObject *text_fg_override_threshold = PyFloat_FromString(val);
if (PyErr_Occurred()) return;
opts->text_fg_override_threshold = MAX(0.f, PyFloat_AsFloat(text_fg_override_threshold));
opts->text_fg_override_threshold = MIN(100.f, PyFloat_AsFloat(text_fg_override_threshold));
}
static char_type*
list_of_chars(PyObject *chars) {
if (!PyUnicode_Check(chars)) { PyErr_SetString(PyExc_TypeError, "list_of_chars must be a string"); return NULL; }

View File

@@ -599,7 +599,7 @@ class Options:
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{title}'
term: str = 'xterm-kitty'
text_composition_strategy: str = 'platform'
text_fg_override_threshold: str = '0'
text_fg_override_threshold: float = 0.0
touch_scroll_multiplier: float = 1.0
undercurl_style: choices_for_undercurl_style = 'thin-sparse'
update_check_interval: float = 24.0

View File

@@ -576,9 +576,8 @@ set_cell_uniforms(float current_inactive_text_alpha, bool force) {
S(CELL_PROGRAM, text_contrast, text_contrast, 1f); S(CELL_FG_PROGRAM, text_contrast, text_contrast, 1f);
float text_gamma_adjustment = OPT(text_gamma_adjustment) < 0.01f ? 1.0f : 1.0f / OPT(text_gamma_adjustment);
S(CELL_PROGRAM, text_gamma_adjustment, text_gamma_adjustment, 1f); S(CELL_FG_PROGRAM, text_gamma_adjustment, text_gamma_adjustment, 1f);
float text_fg_override_threshold = OPT(text_fg_override_threshold) * 0.01f;
S(CELL_PROGRAM, text_fg_override_threshold, text_fg_override_threshold, 1f); S(CELL_FG_PROGRAM, text_fg_override_threshold, text_fg_override_threshold, 1f);
S(CELL_PROGRAM, text_fg_override_threshold, OPT(text_fg_override_threshold), 1f);
S(CELL_FG_PROGRAM, text_fg_override_threshold, OPT(text_fg_override_threshold), 1f);
#undef S
#define SV(prog, name, num, val, type) { bind_program(prog); glUniform##type(glGetUniformLocation(program_id(prog), #name), num, val); }
SV(CELL_PROGRAM, gamma_lut, 256, srgb_lut, 1fv); SV(CELL_FG_PROGRAM, gamma_lut, 256, srgb_lut, 1fv);

View File

@@ -397,7 +397,7 @@ class LoadShaderPrograms:
DECORATION_MASK=DECORATION_MASK,
STRIKE_SPRITE_INDEX=NUM_UNDERLINE_STYLES + 1,
)
if get_options().text_fg_override_threshold != '0':
if get_options().text_fg_override_threshold != 0.:
ff = ff.replace('#define NO_FG_OVERRIDE', '#define FG_OVERRIDE')
if semi_transparent:
vv = vv.replace('#define NOT_TRANSPARENT', '#define TRANSPARENT')