gh-151757: Support wide and combining characters in the curses module#151758
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-151757: Support wide and combining characters in the curses module#151758serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
…module The character-cell window methods now accept a full character cell -- a spacing character optionally followed by combining characters (up to CCHARW_MAX wide characters) -- in addition to a single int or byte character. This affects addch(), bkgd(), bkgdset(), border(), box(), echochar(), hline(), insch() and vline(); they dispatch to the ncursesw wide-character functions (wadd_wch(), wbkgrnd(), wborder_set(), wecho_wchar(), whline_set(), wins_wch(), wvline_set(), ...) when given a string. border() and box() cannot mix integer or byte characters with wide string characters in a single call. A cell is one spacing character optionally followed by combining characters, so an extra spacing or control character (such as "ab") is rejected with ValueError rather than being silently truncated by setcchar(). Also add the wide-character read methods get_wstr() and in_wstr(), the counterparts of getstr() and instr() that return a str rather than a bytes object, and the module functions erasewchar(), killwchar() and wunctrl(), the wide-character counterparts of erasechar(), killchar() and unctrl(). All of this is available only when built against the wide-character ncursesw library. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
The character-cell window methods now accept a full character cell -- a spacing character optionally followed by combining characters (up to
CCHARW_MAXwide characters) -- in addition to a singleintor byte character. This affectsaddch(),bkgd(),bkgdset(),border(),box(),echochar(),hline(),insch()andvline(), which dispatch to the ncursesw wide-character functions (wadd_wch(),wbkgrnd(),wborder_set(),wecho_wchar(),whline_set(),wins_wch(),wvline_set(), ...) when given a string.border()andbox()cannot mix integer or byte characters with wide-string characters in a single call.A cell is one spacing character optionally followed by combining characters, so an extra spacing or control character (for example
"ab", an emoji ZWJ sequence, or an emoji with a skin-tone modifier) is rejected withValueErrorrather than being silently truncated bysetcchar(). A single control character is still accepted (curses applies its usual control processing, e.g. backspace, tab and carriage return).Also added are the wide-character read methods
window.get_wstr()andwindow.in_wstr(), the counterparts ofwindow.getstr()andwindow.instr()that return astrrather thanbytes, and the module functionscurses.erasewchar(),curses.killwchar()andcurses.wunctrl(), the wide-character counterparts ofcurses.erasechar(),curses.killchar()andcurses.unctrl().All of this is available only when built against the wide-character ncursesw library.
🤖 Generated with Claude Code