gh-152233: Add curses complexstr type and wide-character cell-array methods#152262
Merged
Merged
Conversation
…rray methods Add the immutable curses.complexstr type, an array of styled wide-character cells -- the string counterpart of complexchar. It is constructible from an iterable of cells (each a complexchar or a str) or from a string split into cells, with optional attr and pair applied to every cell. It is an immutable sequence (indexing yields a complexchar, slicing and concatenation yield a complexstr), is hashable, and str() returns its cells' text. Add the window method in_wchstr(), the wide-character counterpart of instr() and in_wstr() that keeps each cell's attributes and color pair instead of stripping them; it returns a complexstr. The methods addstr(), addnstr(), insstr() and insnstr() now also accept a complexstr, so a run read with in_wchstr() can be written back unchanged. The cells carry their own rendition, so combining one with an explicit attr raises TypeError. This is the second step of the cchar_t API (cell arrays), after the single-cell complexchar type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the immutable
curses.complexstrtype, an array of styled wide-character cells -- the string counterpart ofcomplexchar(asstris to a single character). It is constructible from an iterable of cells (each acomplexcharor astr) or from a string split into cells, with optionalattrandpairapplied to every cell. It is an immutable sequence (indexing yields acomplexchar, slicing and concatenation yield acomplexstr), is hashable, andstr()returns its cells' text.Add the window method
in_wchstr(), the wide-character counterpart ofinstr()andin_wstr()that keeps each cell's attributes and color pair instead of stripping them; it returns acomplexstr.The methods
addstr(),addnstr(),insstr()andinsnstr()now also accept acomplexstr, so a run read within_wchstr()can be written back unchanged. The cells carry their own rendition, so combining one with an explicitattrraisesTypeError.This is the second and final part of the cchar_t API (gh-152233); the first (GH-152250) added the single-cell
complexchartype.