From dcebf9c7f954a55350b68d0ead1935612c4e2e05 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 13:04:01 +0300 Subject: Rename the library to wsap_vtcore ncurses installs and defines struct term. In a file that includes both headers, an ncurses TERMINAL * and this library's terminal are silently the same type. The name wsap_vtcore avoids the clash. The public header is now . Every global symbol uses the wsap_vtcore_ prefix, every macro uses WSAP_VTCORE_, and the shared library is libwsap_vtcore.so.0. The default terminal name is now "wsap_vtcore". The ISA override variable is WSAP_VTCORE_ISA. No other behavior changes. The amalgamation writes wsap_vtcore.c and wsap_vtcore.h. Co-Authored-By: Claude Haiku 5.5 --- tests/extern/kitty/screen.py | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'tests/extern/kitty/screen.py') diff --git a/tests/extern/kitty/screen.py b/tests/extern/kitty/screen.py index a3336d8..1b66234 100644 --- a/tests/extern/kitty/screen.py +++ b/tests/extern/kitty/screen.py @@ -1,9 +1,9 @@ """ctypes wrapper providing the Kitty ``Screen`` API on top of our C terminal. -The shared library ``libterm.so`` is loaded via :mod:`ctypes`. Python calls -only the ``kitty_*`` functions of ``screen_bridge.c``, which wrap the public -API (declared in ``src/term/term.h``). Python classes on top of them match the -subset of Kitty's test API used by ``parser.py``. +The bridge library ``libkitty_bridge.so`` is loaded via :mod:`ctypes`. Python +calls only the ``kitty_*`` functions of ``screen_bridge.c``, which wrap the +public API (declared in ``include/wsap_vtcore/wsap_vtcore.h``). Python classes +on top of them match the subset of Kitty's test API used by ``parser.py``. """ import ctypes @@ -15,7 +15,7 @@ import os _lib = ctypes.CDLL(os.environ.get('WSAP_KITTY_LIB', os.path.join(os.path.dirname(__file__), 'libkitty_bridge.so'))) -# struct term_cell { uint32_t text, fg, bg; uint16_t attrs; uint8_t width, reserved; } +# struct wsap_vtcore_cell { uint32_t text, fg, bg; uint16_t attrs; uint8_t width, reserved; } class TermCell(ctypes.Structure): _fields_ = [ ('text', ctypes.c_uint32), @@ -65,19 +65,19 @@ for _name, _type in { # Constants # --------------------------------------------------------------------------- -TERM_DEFAULT_FG = 0xFFFFFFFF -TERM_DEFAULT_BG = 0xFF1E1E2E +WSAP_VTCORE_DEFAULT_FG = 0xFFFFFFFF +WSAP_VTCORE_DEFAULT_BG = 0xFF1E1E2E -# Cell attributes (must match enum term_attr in term.h) -TERM_ATTR_BOLD = 1 << 0 -TERM_ATTR_ITALIC = 1 << 1 -TERM_ATTR_FAINT = 1 << 10 -TERM_ATTR_STRIKE = 1 << 3 -TERM_ATTR_OVERLINE = 1 << 4 -TERM_ATTR_LINK = 1 << 15 -TERM_ATTR_EMOJI = 1 << 5 -TERM_ATTR_TEXT = 1 << 6 -TERM_UNDERLINE_FLAGS = (1 << 2, 1 << 11, 1 << 12, 1 << 13, 1 << 14) +# Cell attributes (must match enum wsap_vtcore_attr in wsap_vtcore.h) +WSAP_VTCORE_ATTR_BOLD = 1 << 0 +WSAP_VTCORE_ATTR_ITALIC = 1 << 1 +WSAP_VTCORE_ATTR_FAINT = 1 << 10 +WSAP_VTCORE_ATTR_STRIKE = 1 << 3 +WSAP_VTCORE_ATTR_OVERLINE = 1 << 4 +WSAP_VTCORE_ATTR_LINK = 1 << 15 +WSAP_VTCORE_ATTR_EMOJI = 1 << 5 +WSAP_VTCORE_ATTR_TEXT = 1 << 6 +WSAP_VTCORE_UNDERLINE_FLAGS = (1 << 2, 1 << 11, 1 << 12, 1 << 13, 1 << 14) # The longest grapheme cluster that a cell's text is read with. _CLUSTER_CAP = 32 @@ -105,7 +105,7 @@ _lib.kitty_screen_cell_is_tab.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes. _lib.kitty_screen_cell_is_tab.restype = ctypes.c_bool # ANSI color table from escape.c — used for reverse-mapping to Kitty indices. -# Must match the built-in default palette in src/term/palette.c. +# Must match the built-in default palette in src/palette.c. _ANSI_COLORS = [ 0xFF585B70, 0xFFCC6666, 0xFFB5BD68, 0xFFF0C674, 0xFF81A2BE, 0xFFB294BB, 0xFF8ABEB7, 0xFFC5C8C6, @@ -135,7 +135,7 @@ def _build_color_table(): _COLOR_TO_KITTY = _build_color_table() -TERM_COLOR_REF = 0x01000000 +WSAP_VTCORE_COLOR_REF = 0x01000000 def _convert_color(color): @@ -149,10 +149,10 @@ def _convert_color(color): index<<8|1 = indexed (0-255) r<<24|g<<16|b<<8|2 = RGB """ - if (color >> 24) == (TERM_COLOR_REF >> 24): + if (color >> 24) == (WSAP_VTCORE_COLOR_REF >> 24): slot = color & 0x1FF return 0 if slot >= 0x100 else (slot << 8) | 1 - if color == TERM_DEFAULT_FG or color == TERM_DEFAULT_BG: + if color == WSAP_VTCORE_DEFAULT_FG or color == WSAP_VTCORE_DEFAULT_BG: return 0 kitty = _COLOR_TO_KITTY.get(color) if kitty is not None: @@ -251,15 +251,15 @@ class CellCursor: @property def bold(self): - return bool(self._cell.attrs & TERM_ATTR_BOLD) + return bool(self._cell.attrs & WSAP_VTCORE_ATTR_BOLD) @property def italic(self): - return bool(self._cell.attrs & TERM_ATTR_ITALIC) + return bool(self._cell.attrs & WSAP_VTCORE_ATTR_ITALIC) @property def dim(self): - return bool(self._cell.attrs & TERM_ATTR_FAINT) + return bool(self._cell.attrs & WSAP_VTCORE_ATTR_FAINT) @property def reverse(self): @@ -269,13 +269,13 @@ class CellCursor: @property def strikethrough(self): - return bool(self._cell.attrs & TERM_ATTR_STRIKE) + return bool(self._cell.attrs & WSAP_VTCORE_ATTR_STRIKE) @property def decoration(self): - # enum term_underline uses Kitty's numbers: 0=none, 1=straight, + # enum wsap_vtcore_underline uses Kitty's numbers: 0=none, 1=straight, # 2=double, 3=curly, 4=dotted, 5=dashed. - return next((i for i, flag in enumerate(TERM_UNDERLINE_FLAGS, 1) + return next((i for i, flag in enumerate(WSAP_VTCORE_UNDERLINE_FLAGS, 1) if self._cell.attrs & flag), 0) @property -- cgit v1.2.3