From 129186761c554f8695afce46db84b5dbfaaf396d Mon Sep 17 00:00:00 2001 From: rexy712 Date: Fri, 12 May 2023 21:06:00 -0700 Subject: [PATCH] Update patches from https://github.com/KittyPatch/kitty to work on current kitty --- .github/FUNDING.yml | 4 +- docs/binary.rst | 2 +- docs/build.rst | 10 +- docs/conf.py | 8 +- docs/support.rst | 16 +++ kitty/cell_vertex.glsl | 23 +++- kitty/fast_data_types.pyi | 1 + kitty/options/definition.py | 4 + kitty/options/parse.py | 3 + kitty/options/to-c-generated.h | 15 +++ kitty/options/types.py | 2 + kitty/shaders.c | 2 + kitty/state.c | 1 + kitty/state.h | 1 + kitty/window.py | 2 + logo/kitty-framed.svg | 196 ++++++++++++++++++++++++++++++- logo/kitty.svg | 207 ++++++++++++++++++++++++++++++++- publish.py | 4 +- 18 files changed, 482 insertions(+), 19 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c64877153..ed2930008 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,2 @@ -github: kovidgoyal -patreon: kovidgoyal -liberapay: kovidgoyal +custom: https://my.fsf.org/donate custom: https://sw.kovidgoyal.net/kitty/support.html diff --git a/docs/binary.rst b/docs/binary.rst index 4b60736fe..4a4da9614 100644 --- a/docs/binary.rst +++ b/docs/binary.rst @@ -31,7 +31,7 @@ Manually installing If something goes wrong or you simply do not want to run the installer, you can manually download and install |kitty| from the `GitHub releases page -`__. If you are on macOS, download +`__. If you are on macOS, download the :file:`.dmg` and install as normal. If you are on Linux, download the tarball and extract it into a directory. The |kitty| executable will be in the :file:`bin` sub-directory. diff --git a/docs/build.rst b/docs/build.rst index 66b08689f..646dff087 100644 --- a/docs/build.rst +++ b/docs/build.rst @@ -1,9 +1,9 @@ Build from source ================== -.. image:: https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg +.. image:: https://gitea.rexy712.xyz/KittyPatch/kitty/workflows/CI/badge.svg :alt: Build status - :target: https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI + :target: https://gitea.rexy712.xyz/KittyPatch/kitty/actions?query=workflow%3ACI .. highlight:: sh @@ -71,7 +71,7 @@ Install and run from source .. code-block:: sh - git clone https://github.com/kovidgoyal/kitty && cd kitty + git clone https://gitea.rexy712.xyz/KittyPatch/kitty && cd kitty Now build the native code parts of |kitty| with the following command:: @@ -106,7 +106,7 @@ dependencies you might have to rebuild the app. .. note:: The released :file:`kitty.dmg` includes all dependencies, unlike the :file:`kitty.app` built above and is built automatically by using the - `bypy framework `__ however, that is + `bypy framework `__ however, that is designed to run on Linux and is not for the faint of heart. .. note:: @@ -155,7 +155,7 @@ Notes for Linux/macOS packagers ---------------------------------- The released |kitty| source code is available as a `tarball`_ from -`the GitHub releases page `__. +`the GitHub releases page `__. While |kitty| does use Python, it is not a traditional Python package, so please do not install it in site-packages. diff --git a/docs/conf.py b/docs/conf.py index 721ce7d60..5ee64a092 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,8 +33,8 @@ from kitty.constants import str_version, website_url # noqa # -- Project information ----------------------------------------------------- project = 'kitty' -copyright = time.strftime('%Y, Kovid Goyal') -author = 'Kovid Goyal' +copyright = time.strftime('%Y, Kovid Goyal, KittyPatch') +author = 'Kovid Goyal, KittyPatch' building_man_pages = 'man' in sys.argv # The short X.Y version @@ -100,7 +100,7 @@ exclude_patterns = [ rst_prolog = ''' .. |kitty| replace:: *kitty* .. |version| replace:: VERSION -.. _tarball: https://github.com/kovidgoyal/kitty/releases/download/vVERSION/kitty-VERSION.tar.xz +.. _tarball: https://gitea.rexy712.xyz/KittyPatch/kitty/releases/download/vVERSION/kitty-VERSION.tar.xz .. role:: italic '''.replace('VERSION', str_version) @@ -215,7 +215,7 @@ def commit_role( f'GitHub commit id "{text}" not recognized.', line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] - url = f'https://github.com/kovidgoyal/kitty/commit/{commit_id}' + url = f'https://gitea.rexy712.xyz/KittyPatch/kitty/commit/{commit_id}' set_classes(options) short_id = subprocess.check_output( f'git rev-list --max-count=1 --abbrev-commit --skip=# {commit_id}'.split()).decode('utf-8').strip() diff --git a/docs/support.rst b/docs/support.rst index 373714812..c0ff06981 100644 --- a/docs/support.rst +++ b/docs/support.rst @@ -1,5 +1,21 @@ +A message from us at KittyPatch +=============================== + +KittyPatch was created as a home for useful features that are unavailable +in the kitty main branch. To this end, we do not accept donations directly. + +If you wish to support KittyPatch: share your ideas and spread the word. + +If you still wish to donate, please `support the Free Software Foundation +`. + + + +A message from the maintainer of Kitty +====================================== Support kitty development ❤️ ============================== +>>>>>>> upstream/master My goal with |kitty| is to move the stagnant terminal ecosystem forward. To that end kitty has many foundational features, such as: :doc:`image support diff --git a/kitty/cell_vertex.glsl b/kitty/cell_vertex.glsl index 0eda08295..aa84d4d7a 100644 --- a/kitty/cell_vertex.glsl +++ b/kitty/cell_vertex.glsl @@ -3,6 +3,7 @@ #define {WHICH_PROGRAM} #define NOT_TRANSPARENT +#define BOLD_SHIFT {BOLD_SHIFT} #define DECORATION_SHIFT {DECORATION_SHIFT} #define REVERSE_SHIFT {REVERSE_SHIFT} #define STRIKE_SHIFT {STRIKE_SHIFT} @@ -17,6 +18,7 @@ layout(std140) uniform CellRenderData { float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, use_cell_bg_for_selection_fg, use_cell_fg_for_selection_fg, use_cell_for_selection_bg; uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_fg, cursor_bg, url_color, url_style, inverted; + uint bold_is_bright; uint xnum, ynum, cursor_fg_sprite_idx; float cursor_x, cursor_y, cursor_w; @@ -93,6 +95,22 @@ vec3 color_to_vec(uint c) { return vec3(gamma_lut[r], gamma_lut[g], gamma_lut[b]); } +uint byte_to_bool(uint n) { + uint n1 = (n >> 1) | n; + uint n2 = (n1 >> 2) | n1; + uint n3 = (n2 >> 4) | n2; + return n3 & 1u; +} + +uint brighten_color(uint c, uint is_bold) { + uint table_idx = (c >> 8) & 0xFFu; + uint is_table_color = c & 1u; + uint is_rgb_color = byte_to_bool(c & 0xFEu); + uint is_8bit_color = byte_to_bool(table_idx & 0xF8u); + uint should_brighten = bold_is_bright * is_bold * (1u >> (is_rgb_color + is_8bit_color)) * is_table_color; + return c | (0x800u * should_brighten); +} + uint resolve_color(uint c, uint defval) { // Convert a cell color to an actual color based on the color table int t = int(c & BYTE_MASK); @@ -161,6 +179,7 @@ void main() { // set cell color indices {{{ uvec2 default_colors = uvec2(default_fg, default_bg); uint text_attrs = sprite_coords[3]; + uint is_bold = ((text_attrs >> BOLD_SHIFT) & ONE); uint is_reversed = ((text_attrs >> REVERSE_SHIFT) & ONE); uint is_inverted = is_reversed + inverted; int fg_index = fg_index_map[is_inverted]; @@ -170,10 +189,10 @@ void main() { 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]); + uint bg_as_uint = resolve_color(brighten_color(colors[bg_index], is_bold), 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); - uint fg_as_uint = resolve_color(colors[fg_index], default_colors[fg_index]); + uint fg_as_uint = resolve_color(brighten_color(colors[fg_index], is_bold), default_colors[fg_index]); // }}} // Foreground {{{ diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 5d0b39bea..c4253a4b6 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -265,6 +265,7 @@ CELL_FG_PROGRAM: int CELL_PROGRAM: int CELL_SPECIAL_PROGRAM: int CSI: int +BOLD: int DCS: int DECORATION: int DIM: int diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 435e1c7cc..7d75e6071 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1328,6 +1328,10 @@ color is chosen to match the background color of the neighboring tab. ) egr() # }}} +opt('bold_is_bright', 'no', + option_type='to_bool', ctype='bool', + long_text='Display bold text with bright colors' + ) # colors {{{ agr('colors', 'Color scheme') diff --git a/kitty/options/parse.py b/kitty/options/parse.py index d4a607f15..1ce4bfe5a 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -100,6 +100,9 @@ class Parser: def bold_font(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['bold_font'] = str(val) + def bold_is_bright(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: + ans['bold_is_bright'] = to_bool(val) + def bold_italic_font(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['bold_italic_font'] = str(val) diff --git a/kitty/options/to-c-generated.h b/kitty/options/to-c-generated.h index c1ea350a2..249ea38e9 100644 --- a/kitty/options/to-c-generated.h +++ b/kitty/options/to-c-generated.h @@ -837,6 +837,19 @@ convert_from_opts_dim_opacity(PyObject *py_opts, Options *opts) { Py_DECREF(ret); } +static void +convert_from_python_bold_is_bright(PyObject *val, Options *opts) { + opts->bold_is_bright = PyObject_IsTrue(val); +} + +static void +convert_from_opts_bold_is_bright(PyObject *py_opts, Options *opts) { + PyObject *ret = PyObject_GetAttrString(py_opts, "bold_is_bright"); + if (ret == NULL) return; + convert_from_python_bold_is_bright(ret, opts); + Py_DECREF(ret); +} + static void convert_from_python_mark1_foreground(PyObject *val, Options *opts) { opts->mark1_foreground = color_as_int(val); @@ -1188,6 +1201,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) { if (PyErr_Occurred()) return false; convert_from_opts_dim_opacity(py_opts, opts); if (PyErr_Occurred()) return false; + convert_from_opts_bold_is_bright(py_opts, opts); + if (PyErr_Occurred()) return false; convert_from_opts_mark1_foreground(py_opts, opts); if (PyErr_Occurred()) return false; convert_from_opts_mark1_background(py_opts, opts); diff --git a/kitty/options/types.py b/kitty/options/types.py index dde02d82f..3ab3b0c65 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -71,6 +71,7 @@ option_names = ( # {{{ 'bell_on_tab', 'bell_path', 'bold_font', + 'bold_is_bright', 'bold_italic_font', 'box_drawing_scale', 'clear_all_mouse_actions', @@ -490,6 +491,7 @@ class Options: bell_on_tab: str = '🔔 ' bell_path: typing.Optional[str] = None bold_font: str = 'auto' + bold_is_bright: bool = False bold_italic_font: str = 'auto' box_drawing_scale: typing.Tuple[float, float, float, float] = (0.001, 1.0, 1.5, 2.0) clear_all_mouse_actions: bool = False diff --git a/kitty/shaders.c b/kitty/shaders.c index d9b8005f2..b1a71a3b7 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -303,6 +303,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, use_cell_bg_for_selection_fg, use_cell_fg_for_selection_color, use_cell_for_selection_bg; GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_fg, cursor_bg, url_color, url_style, inverted; + GLuint bold_is_bright; GLuint xnum, ynum, cursor_fg_sprite_idx; GLfloat cursor_x, cursor_y, cursor_w; @@ -374,6 +375,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c rd->sprite_dx = 1.0f / (float)x; rd->sprite_dy = 1.0f / (float)y; rd->inverted = inverted ? 1 : 0; rd->background_opacity = os_window->is_semi_transparent ? os_window->background_opacity : 1.0f; + rd->bold_is_bright = OPT(bold_is_bright) ? 1 : 0; #undef COLOR rd->url_color = OPT(url_color); rd->url_style = OPT(url_style); diff --git a/kitty/state.c b/kitty/state.c index d06767266..f08b8bd3e 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -1130,6 +1130,7 @@ PYWRAP1(patch_global_colors) { P(background); P(url_color); P(mark1_background); P(mark1_foreground); P(mark2_background); P(mark2_foreground); P(mark3_background); P(mark3_foreground); + P(bold_is_bright); } if (PyErr_Occurred()) return NULL; Py_RETURN_NONE; diff --git a/kitty/state.h b/kitty/state.h index 454aa90d0..7353f5197 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -39,6 +39,7 @@ typedef struct { char_type *select_by_word_characters_forward; color_type url_color, background, foreground, active_border_color, inactive_border_color, bell_border_color, tab_bar_background, tab_bar_margin_color; color_type mark1_foreground, mark1_background, mark2_foreground, mark2_background, mark3_foreground, mark3_background; + bool bold_is_bright; monotonic_t repaint_delay, input_delay; bool focus_follows_mouse; unsigned int hide_window_decorations; diff --git a/kitty/window.py b/kitty/window.py index 732c8d051..0111bb32c 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -49,6 +49,7 @@ from .fast_data_types import ( CELL_PROGRAM, CELL_SPECIAL_PROGRAM, CURSOR_BEAM, + BOLD, CURSOR_BLOCK, CURSOR_UNDERLINE, DCS, @@ -392,6 +393,7 @@ class LoadShaderPrograms: STRIKE_SHIFT=STRIKETHROUGH, DIM_SHIFT=DIM, DECORATION_SHIFT=DECORATION, + BOLD_SHIFT=BOLD, MARK_SHIFT=MARK, MARK_MASK=MARK_MASK, DECORATION_MASK=DECORATION_MASK, diff --git a/logo/kitty-framed.svg b/logo/kitty-framed.svg index 310ea8a29..461f08320 100644 --- a/logo/kitty-framed.svg +++ b/logo/kitty-framed.svg @@ -1 +1,195 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/logo/kitty.svg b/logo/kitty.svg index dc4b6e42c..32d06f031 100644 --- a/logo/kitty.svg +++ b/logo/kitty.svg @@ -1 +1,206 @@ - \ No newline at end of file + + + + + + + + + + + + + image/svg+xml + + + + + Kovid Goyal + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publish.py b/publish.py index 4013051ad..16caf3120 100755 --- a/publish.py +++ b/publish.py @@ -25,7 +25,7 @@ from urllib.parse import urlencode, urlparse os.chdir(os.path.dirname(os.path.abspath(__file__))) docs_dir = os.path.abspath('docs') -publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty')) +publish_dir = os.path.abspath(os.path.join('..', 'kittypatch.github.io', 'kitty')) building_nightly = False with open('kitty/constants.py') as f: raw = f.read() @@ -101,7 +101,7 @@ def run_man(args: Any) -> None: def run_html(args: Any) -> None: - call('make FAIL_WARN=1 "OPTS=-D analytics_id=G-XTJK3R7GF2" dirhtml', cwd=docs_dir) + call('make FAIL_WARN=1 "OPTS=-D analytics_id=G-XXXXXXXXXX" dirhtml', cwd=docs_dir) add_old_redirects('docs/_build/dirhtml')