| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Wrap the X/Open Curses soft-label-key functions: slk_init, slk_set, slk_label, slk_refresh, slk_noutrefresh, slk_clear, slk_restore, slk_touch, the chtype attribute functions slk_attron, slk_attroff, slk_attrset and slk_attr, and the attr_t functions slk_attr_on, slk_attr_off, slk_attr_set and slk_color. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Documentation build overview27 files changed · ± 26 modified · - 1 deleted ± Modified
- Deleted |
Sorry, something went wrong.
|
I didn't know soft-label-key functions. Is it commonly used? I'm not sure that it's worth it to expose these functions.
Would you be able to write a short demo so I can see how it does look like? (I don't understand well the purpose of these functions.) |
Sorry, something went wrong.
|
No, they are not often used. But they are the part of the Posix standard. Demo: import curses
LABELS = ["Help", "Save", "Open", "Find", "Run", "Stop", "Setup", "Quit"]
def main(stdscr):
for i, text in enumerate(LABELS):
curses.slk_set(i + 1, text, 1) # 1 - center
curses.slk_refresh()
stdscr.addstr(0, 0, "Soft labels are on the bottom line. Press any key.")
stdscr.getkey()
curses.slk_init(0) # 3-2-3 layout
curses.wrapper(main) |
Sorry, something went wrong.
# Conflicts: # Doc/whatsnew/3.16.rst # Modules/clinic/_cursesmodule.c.h
refresh is a window method, not a module function; reference it as window.refresh so the documentation builds without warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # Doc/whatsnew/3.16.rst # Modules/clinic/_cursesmodule.c.h
# Conflicts: # Modules/clinic/_cursesmodule.c.h
Sorry, something went wrong.
|
|
||
| fmt: int = 0 | ||
| Label layout: 0 = 3-2-3, 1 = 4-4 (8 labels each); 2 = 4-4-4, | ||
| 3 = 4-4-4 with an index line (12 labels each, ncurses extensions). |
There was a problem hiding this comment.
3 is only supported on ncurses? If yes, can we reject 3 if the Python _curses module is not linked to ncurses?
Sorry, something went wrong.
There was a problem hiding this comment.
I will test how out-of-range values are handled. Most likely you will get a curses.error.
Other implementations can also support them.
Sorry, something went wrong.
|
|
||
| .. _curses-slk: | ||
|
|
||
| The following functions manage *soft-label keys*, a row of labels displayed |
There was a problem hiding this comment.
Would it be possible to move these functions in a new "Soft-label keys" section?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes. I just reorganized the docs (#152584), these functions will be in a separate section.
Sorry, something went wrong.
Co-authored-by: Victor Stinner <vstinner@python.org>
There was a problem hiding this comment.
LGTM.
For slk_init(), I'm fine with not rejecting fmt=3 but just pass the value to curses.
For the doc, I didn't see the reorganized doc. Nice.
Sorry, something went wrong.
|
Ah, and good luck to solve the merge conflicts :-) |
Sorry, something went wrong.
# Conflicts: # Doc/library/curses.rst # Doc/whatsnew/3.16.rst # Modules/clinic/_cursesmodule.c.h
…es curses Soft-label formats 2 and 3 are ncurses extensions; other curses implementations (such as NetBSD curses) reject them with an error. Require every format to work on ncurses, but tolerate the extended formats being unsupported elsewhere. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thank you. This was peanuts in comparison with five PRs fighting for the same place in What's New, with flaky CI tests. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Wrap the X/Open Curses soft-label-key functions in the curses module. Soft labels are a row of labels along the bottom line of the screen, conventionally labelling a row of function keys, managed and refreshed independently of the standard window.
Added module-level functions:
slk_set uses slk_wset for wide-character labels when built against ncursesw. Tests drive their own pseudo-terminals (soft labels must be initialised before newterm()), and pass under UTF-8, Latin-1 and C locales.