Curses(3)

๐Ÿ’– Curses(3) โ€” terminal screen handling and optimization ๐Ÿ’–

User Contributed Perl Documentation ยท okay bestie, this is the Curses Perl interface, and we're getting into it.


โœจ NAME โœจ

Curses โ€” terminal screen handling and optimization

๐ŸŒธ SYNOPSIS ๐ŸŒธ

use Curses;

initscr;
...
endwin;

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so Curses is literally the interface between Perl and your system's curses(3) library. For descriptions on how to use a given function, variable, or constant, consult your system's documentation, because that info invariably varies (:-) between different curses(3) libraries and operating systems. This document describes the interface itself, and assumes you already know how your system's curses(3) library works.

๐Ÿ’… Unified Functions

Many curses(3) functions have variants starting with the prefixes w-, mv-, and/or wmv-. These variants differ only by explicitly adding a window, or by adding two coordinates that are used to move the cursor first. For example, addch() has three other variants: waddch(), mvaddch(), and mvwaddch(). The variants aren't very interesting; in fact, we could roll all of the variants into the original function by allowing a variable number of arguments and analyzing the argument list for which variant the user wanted to call.

Unfortunately, curses(3) predates varargs(3), so in C we were stuck with all the variants. However, Curses is a Perl interface, so we are free to "unify" these variants into one function. The section "Available Functions" below lists all curses(3) functions Curses makes available as Perl equivalents, along with a column listing if it is unified. If so, it takes a varying number of arguments as follows:

"function( [win], [y, x], args );"

win is an optional window argument, defaulting to "stdscr" if not specified.

y, x is an optional coordinate pair used to move the cursor,
defaulting to no move if not specified.

args are the required arguments of the function.  These are the
arguments you would specify if you were just calling the base
function and not any of the variants.

This makes the variants obsolete, since their functionality has been merged into a single function, so Curses does not define them by default. You can still get them if you want, by setting the variable $Curses::OldCurses to a non-zero value before using the Curses package. See "Perl 4.X "cursperl" Compatibility" for an example of this.

๐Ÿซถ Wide-Character-Aware Functions

The following are the preferred functions for working with strings, though they don't follow the normal unified function naming convention (based on the names in the Curses library) described above. Despite the naming, each corresponds to a Curses library function. For example, a getchar call performs a Curses library function in the getch family.

In addition to these functions, the Curses module contains corresponding functions with the conventional naming (e.g. getch); the duplication is for historical reasons. The preferred functions were new in Curses 1.29 (April 2014). They use the wide character functions in the Curses library if available (falling back to using the traditional non-wide-character versions). They also have a more Perl-like interface, taking care of some gory details under the hood about which a Perl programmer shouldn't have to worry.

The reason for two sets of string-handling functions is historical. The original Curses Perl module predates Curses libraries that understand multiple byte character encodings. Moreover, the module was designed to have a Perl interface that closely resembles the C interface syntactically and directly passes the internal byte representation of Perl strings to C code. This was probably fine before Perl got Unicode function, but today, Perl stores strings internally in either Latin-1 or Unicode UTF-8 and the original module was not sensitive to which encoding was used.

While most of the problems could be worked around in Perl code using the traditional interface, it's hard to get right and you need a wide-character-aware curses library (e.g. ncursesw) anyway to make it work properly. Because existing consumers of the Curses module may be relying on the traditional behavior, Curses module designers couldn't simply modify the existing functions to understand wide characters and convert from and to Perl strings.

None of these functions exist if Perl is older than 5.6.

๐ŸŽ€ getchar

This calls wget_wch(). It returns a character -- more precisely, a one-character (not necessarily one-byte!) string holding the character -- for a normal key and a two-element list (undef, key-number) for a function key. It returns undef on error.

If you don't expect function keys (i.e. with keypad(0)), you can simply do

my $ch = getchar;
die "getchar failed" unless defined $ch;

If you do expect function keys (i.e. with keypad(1)), you can still assign the result to a scalar variable as above. Because of of the way the comma operator works, that variable will receive either undef or the string or the number, and you can decode it yourself.

my $ch = getchar;
die "getchar failed" unless defined $ch;
if (<$ch looks like a number >= 0x100>) {
        <handle function key>
} else {
        <handle normal key>
}

or do

my ($ch, $key) = getchar;
if (defined $key) {
        <handle function key $key>
} else if (defined $ch) {
        <handle normal key $ch>
} else {
        die "getchar failed";
}

If wget_wch() is not available (i.e. The Curses library does not understand wide characters), this calls wgetch(), but returns the values described above nonetheless. This can be a problem because with a multibyte character encoding like UTF-8, you will receive two one-character strings for a two-byte-character (e.g. รฏยฟยฝรฏยฟยฝรฏยฟยฝรฏยฟยฝ and รขยฝ for รขยฝ). If you append these characters to a Perl string, that string may internally contain a valid UTF-8 encoding of a character, but Perl will not interpret it that way. Perl may even try to convert what it believes to be two characters to UTF-8, giving you four bytes.

๐Ÿฆ‹ getstring

This calls wgetn_wstr and returns a string or undef. It cannot return a function key value; the Curses library will itself interpret KEY_LEFT and KEY_BACKSPACE.

If wgett_wstr() is unavailable, this calls wgetstr().

In both cases, the function allocates a buffer of fixed size to hold the result of the Curses library call.

my $s = getstring();
die "getstring failed" unless defined $s;

๐Ÿ“ addstring / insstring

This adds/inserts the Perl string passed as an argument to the Curses window using waddnwstr()/wins_nwstr() or, if unavailable, waddnstr()/winsnstr(). It returns a true value on success, false on failure.

addstring("Hรขยฝllรขยก, Wรขยกrld") || die "addstring failed";

๐ŸŒˆ instring

This returns a Perl string (or undef on failure) holding the characters from the current cursor position up to the end of the line. It uses winnwstr() if available, and otherwise innstr().

my $s = instring();
die "instring failed" unless defined $s;

๐Ÿ‘‘ ungetchar

This pushes one character (passed as a one-character Perl string) back to the input queue. It uses unget_wch() or ungetch(). It returns a true value on success, false on failure. It cannot push back a function key; the Curses library provides no way to push back function keys, only characters.

ungetchar("X") or die "ungetchar failed";

The Curses module provides no interface to the complex-character routines (wadd_wch(), wadd_wchnstr(), wecho_wchar(), win_wch(), win_wchnstr(), wins_wch()) because there is no sensible way of converting from Perl to a C cchar_t or back.

๐Ÿ’œ Objects

Objects work. Example:

$win = new Curses;
$win->addstr(10, 10, 'foo');
$win->refresh;
...

Any function that has been marked as unified (see "Available Functions" below and "Unified Functions" above) can be called as a method for a Curses object.

Do not use initscr() if using objects, as the first call to get a new Curses will do it for you.

๐Ÿšจ Security Concerns

It has always been the case with the curses functions, but please note that the following functions:

getstr()   (and optional wgetstr(), mvgetstr(), and mvwgetstr())
inchstr()  (and optional winchstr(), mvinchstr(), and mvwinchstr())
instr()    (and optional winstr(), mvinstr(), and mvwinstr())

are subject to buffer overflow attack. This is because you pass in the buffer to be filled in, which has to be of finite length, but there is no way to stop a bad guy from typing.

In order to avoid this problem, use the alternate functions:

getnstr()
inchnstr()
innstr()

which take an extra "size of buffer" argument or the wide-character-aware getstring() and instring() versions.


๐Ÿ’œ COMPATIBILITY ๐Ÿ’œ

๐ŸŒˆ Perl 4.X "cursperl" Compatibility

Curses was written to take advantage of features of Perl 5 and later. The author thought it was better to provide an improved curses programming environment than to be 100% compatible. However, many old "curseperl" applications will probably still work by starting the script with:

BEGIN { $Curses::OldCurses = 1; }
use Curses;

Any old application that still does not work should print an understandable error message explaining the problem.

Some functions and variables are not available through Curses, even with the BEGIN line. They are listed under "Curses items not available through Perl Curses".

The variables $stdscr and $curscr are also available as functions stdscr and curscr. This is because of a Perl bug. See the LIMITATIONS section for details.

๐Ÿงš Incompatibilities with previous versions of Curses

In previous versions of this software, some Perl functions took a different set of parameters than their C counterparts. This is not true in the current version. You should now use getstr($str) and getyx($y, $x) instead of $str = getstr() and ($y, $x) = getyx().

๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

okay so when stuff goes wrong, here's what Curses is gonna yell at you, bestie โ€” and what it actually means ๐Ÿ‘‡

  • Curses function '%s' called with too %s arguments at ... โ€” you called a Curses function with the wrong number of arguments fr. Count your args, babe ๐Ÿงฎ
  • argument %d to Curses function '%s' is not a Curses %s at ...
  • argument is not a Curses %s at ... โ€” the argument you handed over wasn't a valid type for the spot you put it in, no cap. lowkey this usually means you didn't give the right arguments to a unified function โ€” go peek at the DESCRIPTION section on "Unified Functions" for the tea โ˜•
  • Curses function '%s' is not defined in your Curses library at ... โ€” your code calls a Perl Curses function that your system's Curses library just doesn't provide ๐Ÿ™ˆ not your fault, the library's built different
  • Curses variable '%s' is not defined in your Curses library at ... โ€” same vibe but for a variable: your code wants a Perl Curses variable your system's Curses library doesn't have
  • Curses constant '%s' is not defined in your Curses library at ... โ€” you're referencing the specified Curses constant, and your system's Curses library doesn't provide it ๐Ÿ’€
  • Curses::Vars::FETCH called with bad index at ...
  • Curses::Vars::STORE called with bad index at ... โ€” ooh you've been messing with the tie interface to the Curses variables ๐Ÿ‘€ don't do that. :-) (iconic of the docs to include a smiley ngl)
  • Anything else โ€” check out the perldiag man page to see if the error's chilling in there ๐Ÿ“–

๐Ÿšง LIMITATIONS ๐Ÿšง

So here's the one gotcha, bestie โ€” if you use the variables $stdscr and $curscr instead of their functional counterparts (stdscr and curscr), you might hit a bug in Perl where the "magic" isn't called early enough ๐Ÿ˜ญ

What that looks like in practice? The Curses package straight-up tells you $stdscr isn't a window. Rude. ๐Ÿ’…

One workaround is to put a line like this near the front of your program:

$stdscr = $stdscr

weird-looking? yes. does it work? apparently. slay ๐Ÿซถ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

William Setzer <William_Setzer@ncsu.edu>

Available Functions

okay bestie, this is the big one โ€” the full roster of what's available, and there is a lot of it. Drink some water first ๐Ÿ’ง Two columns you gotta keep straight:

  • Unified? โ€” the column literally says Yes or No, and I'm handing it to you exactly as it's written. No editorialising, no vibes-based guessing.
  • Available via $OldCurses[*] โ€” the old-school spellings you can still reach through $OldCurses[*], like waddch and mvaddch. If that column's empty, then nothing's listed there, periodt.

Here we go ๐Ÿ’…

  • addch โ€” unified โœ… โ€” via $OldCurses[*]: waddch, mvaddch, mvwaddch
  • echochar โ€” unified โœ… โ€” via $OldCurses[*]: wechochar
  • addchstr โ€” unified โœ… โ€” via $OldCurses[*]: waddchstr, mvaddchstr, mvwaddchstr
  • addchnstr โ€” unified โœ… โ€” via $OldCurses[*]: waddchnstr, mvaddchnstr, mvwaddchnstr
  • addstr โ€” unified โœ… โ€” via $OldCurses[*]: waddstr, mvaddstr, mvwaddstr
  • addnstr โ€” unified โœ… โ€” via $OldCurses[*]: waddnstr, mvaddnstr, mvwaddnstr
  • attroff โ€” unified โœ… โ€” via $OldCurses[*]: wattroff
  • attron โ€” unified โœ… โ€” via $OldCurses[*]: wattron
  • attrset โ€” unified โœ… โ€” via $OldCurses[*]: wattrset
  • standend โ€” unified โœ… โ€” via $OldCurses[*]: wstandend
  • standout โ€” unified โœ… โ€” via $OldCurses[*]: wstandout
  • attr_get โ€” unified โœ… โ€” via $OldCurses[*]: wattr_get
  • attr_off โ€” unified โœ… โ€” via $OldCurses[*]: wattr_off
  • attr_on โ€” unified โœ… โ€” via $OldCurses[*]: wattr_on
  • attr_set โ€” unified โœ… โ€” via $OldCurses[*]: wattr_set
  • chgat โ€” unified โœ… โ€” via $OldCurses[*]: wchgat, mvchgat, mvwchgat
  • COLOR_PAIR โ€” not unified
  • PAIR_NUMBER โ€” not unified
  • beep โ€” not unified
  • flash โ€” not unified
  • bkgd โ€” unified โœ… โ€” via $OldCurses[*]: wbkgd
  • bkgdset โ€” unified โœ… โ€” via $OldCurses[*]: wbkgdset
  • getbkgd โ€” unified โœ… (no extra spellings listed)
  • border โ€” unified โœ… โ€” via $OldCurses[*]: wborder
  • box โ€” unified โœ… (no extra spellings listed)
  • hline โ€” unified โœ… โ€” via $OldCurses[*]: whline, mvhline, mvwhline
  • vline โ€” unified โœ… โ€” via $OldCurses[*]: wvline, mvvline, mvwvline
  • erase โ€” unified โœ… โ€” via $OldCurses[*]: werase
  • clear โ€” unified โœ… โ€” via $OldCurses[*]: wclear
  • clrtobot โ€” unified โœ… โ€” via $OldCurses[*]: wclrtobot
  • clrtoeol โ€” unified โœ… โ€” via $OldCurses[*]: wclrtoeol
  • start_color โ€” not unified
  • init_pair โ€” not unified
  • init_color โ€” not unified
  • has_colors โ€” not unified
  • can_change_color โ€” not unified
  • color_content โ€” not unified
  • pair_content โ€” not unified
  • delch โ€” unified โœ… โ€” via $OldCurses[*]: wdelch, mvdelch, mvwdelch
  • deleteln โ€” unified โœ… โ€” via $OldCurses[*]: wdeleteln
  • insdelln โ€” unified โœ… โ€” via $OldCurses[*]: winsdelln
  • insertln โ€” unified โœ… โ€” via $OldCurses[*]: winsertln
  • getch โ€” unified โœ… โ€” via $OldCurses[*]: wgetch, mvgetch, mvwgetch
  • ungetch โ€” not unified
  • has_key โ€” not unified
  • KEY_F โ€” not unified
  • getstr โ€” unified โœ… โ€” via $OldCurses[*]: wgetstr, mvgetstr, mvwgetstr
  • getnstr โ€” unified โœ… โ€” via $OldCurses[*]: wgetnstr, mvgetnstr, mvwgetnstr
  • getyx โ€” unified โœ… (no extra spellings listed)
  • getparyx โ€” unified โœ… (no extra spellings listed)
  • getbegyx โ€” unified โœ… (no extra spellings listed)
  • getmaxyx โ€” unified โœ… (no extra spellings listed)
  • inch โ€” unified โœ… โ€” via $OldCurses[*]: winch, mvinch, mvwinch
  • inchstr โ€” unified โœ… โ€” via $OldCurses[*]: winchstr, mvinchstr, mvwinchstr
  • inchnstr โ€” unified โœ… โ€” via $OldCurses[*]: winchnstr, mvinchnstr, mvwinchnstr
  • initscr โ€” not unified
  • endwin โ€” not unified
  • isendwin โ€” not unified
  • newterm โ€” not unified
  • set_term โ€” not unified
  • delscreen โ€” not unified
  • cbreak โ€” not unified
  • nocbreak โ€” not unified
  • echo โ€” not unified
  • noecho โ€” not unified
  • halfdelay โ€” not unified
  • intrflush โ€” unified โœ… (no extra spellings listed)
  • keypad โ€” unified โœ… (no extra spellings listed)
  • meta โ€” unified โœ… (no extra spellings listed)
  • nodelay โ€” unified โœ… (no extra spellings listed)
  • notimeout โ€” unified โœ… (no extra spellings listed)
  • raw โ€” not unified
  • noraw โ€” not unified
  • qiflush โ€” not unified
  • noqiflush โ€” not unified
  • timeout โ€” unified โœ… โ€” via $OldCurses[*]: wtimeout
  • typeahead โ€” not unified
  • insch โ€” unified โœ… โ€” via $OldCurses[*]: winsch, mvinsch, mvwinsch
  • insstr โ€” unified โœ… โ€” via $OldCurses[*]: winsstr, mvinsstr, mvwinsstr
  • insnstr โ€” unified โœ… โ€” via $OldCurses[*]: winsnstr, mvinsnstr, mvwinsnstr
  • instr โ€” unified โœ… โ€” via $OldCurses[*]: winstr, mvinstr, mvwinstr
  • innstr โ€” unified โœ… โ€” via $OldCurses[*]: winnstr, mvinnstr, mvwinnstr
  • def_prog_mode โ€” not unified
  • def_shell_mode โ€” not unified
  • reset_prog_mode โ€” not unified
  • reset_shell_mode โ€” not unified
  • resetty โ€” not unified
  • savetty โ€” not unified
  • getsyx โ€” not unified
  • setsyx โ€” not unified
  • curs_set โ€” not unified
  • napms โ€” not unified
  • move โ€” unified โœ… โ€” via $OldCurses[*]: wmove
  • clearok โ€” unified โœ… (no extra spellings listed)
  • idlok โ€” unified โœ… (no extra spellings listed)
  • idcok โ€” unified โœ… (no extra spellings listed)
  • immedok โ€” unified โœ… (no extra spellings listed)
  • leaveok โ€” unified โœ… (no extra spellings listed)
  • setscrreg โ€” unified โœ… โ€” via $OldCurses[*]: wsetscrreg
  • scrollok โ€” unified โœ… (no extra spellings listed)
  • nl โ€” not unified
  • nonl โ€” not unified
  • overlay โ€” not unified
  • overwrite โ€” not unified
  • copywin โ€” not unified
  • newpad โ€” not unified
  • subpad โ€” not unified
  • prefresh โ€” not unified
  • pnoutrefresh โ€” not unified
  • pechochar โ€” not unified
  • refresh โ€” unified โœ… โ€” via $OldCurses[*]: wrefresh
  • noutrefresh โ€” unified โœ… โ€” via $OldCurses[*]: wnoutrefresh
  • doupdate โ€” not unified
  • redrawwin โ€” unified โœ… (no extra spellings listed)
  • redrawln โ€” unified โœ… โ€” via $OldCurses[*]: wredrawln
  • scr_dump โ€” not unified
  • scr_restore โ€” not unified
  • scr_init โ€” not unified
  • scr_set โ€” not unified
  • scroll โ€” unified โœ… (no extra spellings listed)
  • scrl โ€” unified โœ… โ€” via $OldCurses[*]: wscrl
  • slk_init โ€” not unified
  • slk_set โ€” not unified
  • slk_refresh โ€” not unified
  • slk_noutrefresh โ€” not unified
  • slk_label โ€” not unified
  • slk_clear โ€” not unified
  • slk_restore โ€” not unified
  • slk_touch โ€” not unified
  • slk_attron โ€” not unified
  • slk_attrset โ€” not unified
  • slk_attr โ€” not unified
  • slk_attroff โ€” not unified
  • slk_color โ€” not unified
  • baudrate โ€” not unified
  • erasechar โ€” not unified
  • has_ic โ€” not unified
  • has_il โ€” not unified
  • killchar โ€” not unified
  • longname โ€” not unified
  • termattrs โ€” not unified
  • termname โ€” not unified
  • touchwin โ€” unified โœ… (no extra spellings listed)
  • touchline โ€” unified โœ… (no extra spellings listed)
  • untouchwin โ€” unified โœ… (no extra spellings listed)
  • touchln โ€” unified โœ… โ€” via $OldCurses[*]: wtouchln
  • is_linetouched โ€” unified โœ… (no extra spellings listed)
  • is_wintouched โ€” unified โœ… (no extra spellings listed)
  • unctrl โ€” not unified
  • keyname โ€” not unified
  • filter โ€” not unified
  • use_env โ€” not unified
  • putwin โ€” not unified
  • getwin โ€” not unified
  • delay_output โ€” not unified
  • flushinp โ€” not unified
  • newwin โ€” not unified
  • delwin โ€” unified โœ… (no extra spellings listed)
  • mvwin โ€” unified โœ… (no extra spellings listed)
  • subwin โ€” unified โœ… (no extra spellings listed)
  • derwin โ€” unified โœ… (no extra spellings listed)
  • mvderwin โ€” unified โœ… (no extra spellings listed)
  • dupwin โ€” unified โœ… (no extra spellings listed)
  • syncup โ€” unified โœ… โ€” via $OldCurses[*]: wsyncup
  • syncok โ€” unified โœ… (no extra spellings listed)
  • cursyncup โ€” unified โœ… โ€” via $OldCurses[*]: wcursyncup
  • syncdown โ€” unified โœ… โ€” via $OldCurses[*]: wsyncdown
  • getmouse โ€” not unified
  • ungetmouse โ€” not unified
  • mousemask โ€” not unified
  • enclose โ€” unified โœ… โ€” via $OldCurses[*]: wenclose
  • mouse_trafo โ€” unified โœ… โ€” via $OldCurses[*]: wmouse_trafo
  • mouseinterval โ€” not unified
  • BUTTON_RELEASE โ€” not unified
  • BUTTON_PRESS โ€” not unified
  • BUTTON_CLICK โ€” not unified
  • BUTTON_DOUBLE_CLICK โ€” not unified
  • BUTTON_TRIPLE_CLICK โ€” not unified
  • BUTTON_RESERVED_EVENT โ€” not unified
  • use_default_colors โ€” not unified
  • assume_default_colors โ€” not unified
  • define_key โ€” not unified
  • keybound โ€” not unified
  • keyok โ€” not unified
  • resizeterm โ€” not unified
  • resize โ€” unified โœ… โ€” via $OldCurses[*]: wresize
  • getmaxy โ€” unified โœ… (no extra spellings listed)
  • getmaxx โ€” unified โœ… (no extra spellings listed)
  • flusok โ€” unified โœ… (no extra spellings listed)
  • getcap โ€” not unified
  • touchoverlap โ€” not unified

okay that was the screen/window chunk, and now we're sliding into panels, then menus, then forms โ€” three whole libraries stacked up like a little cursed matryoshka ๐Ÿช† lock in, we're not done ๐Ÿ’€

panels, bestie (all of these say No btw, not a single one is unified)

  • new_panel โ€” not unified
  • bottom_panel โ€” not unified
  • top_panel โ€” not unified
  • show_panel โ€” not unified
  • update_panels โ€” not unified
  • hide_panel โ€” not unified
  • panel_window โ€” not unified
  • replace_panel โ€” not unified
  • move_panel โ€” not unified
  • panel_hidden โ€” not unified
  • panel_above โ€” not unified
  • panel_below โ€” not unified
  • set_panel_userptr โ€” not unified
  • panel_userptr โ€” not unified
  • del_panel โ€” not unified

and now menus (same situation, all No ๐ŸŒธ)

  • set_menu_fore โ€” not unified
  • menu_fore โ€” not unified
  • set_menu_back โ€” not unified
  • menu_back โ€” not unified
  • set_menu_grey โ€” not unified
  • menu_grey โ€” not unified
  • set_menu_pad โ€” not unified
  • menu_pad โ€” not unified
  • pos_menu_cursor โ€” not unified
  • menu_driver โ€” not unified
  • set_menu_format โ€” not unified
  • menu_format โ€” not unified
  • set_menu_items โ€” not unified
  • menu_items โ€” not unified
  • item_count โ€” not unified
  • set_menu_mark โ€” not unified
  • menu_mark โ€” not unified
  • new_menu โ€” not unified
  • free_menu โ€” not unified
  • menu_opts โ€” not unified
  • set_menu_opts โ€” not unified
  • menu_opts_on โ€” not unified
  • menu_opts_off โ€” not unified
  • set_menu_pattern โ€” not unified
  • menu_pattern โ€” not unified
  • post_menu โ€” not unified
  • unpost_menu โ€” not unified
  • set_menu_userptr โ€” not unified
  • menu_userptr โ€” not unified
  • set_menu_win โ€” not unified
  • menu_win โ€” not unified
  • set_menu_sub โ€” not unified
  • menu_sub โ€” not unified
  • scale_menu โ€” not unified
  • set_current_item โ€” not unified
  • current_item โ€” not unified
  • set_top_row โ€” not unified
  • top_row โ€” not unified
  • item_index โ€” not unified
  • item_name โ€” not unified
  • item_description โ€” not unified
  • new_item โ€” not unified
  • free_item โ€” not unified
  • set_item_opts โ€” not unified
  • item_opts_on โ€” not unified
  • item_opts_off โ€” not unified
  • item_opts โ€” not unified
  • item_userptr โ€” not unified
  • set_item_userptr โ€” not unified
  • set_item_value โ€” not unified
  • item_value โ€” not unified
  • item_visible โ€” not unified
  • menu_request_name โ€” not unified
  • menu_request_by_name โ€” not unified
  • set_menu_spacing โ€” not unified
  • menu_spacing โ€” not unified

finally forms ๐Ÿฆ‹ (you guessed it โ€” every single one No)

  • pos_form_cursor โ€” not unified
  • data_ahead โ€” not unified
  • data_behind โ€” not unified
  • form_driver โ€” not unified
  • set_form_fields โ€” not unified
  • form_fields โ€” not unified
  • field_count โ€” not unified
  • move_field โ€” not unified
  • new_form โ€” not unified
  • free_form โ€” not unified
  • set_new_page โ€” not unified
  • new_page โ€” not unified
  • set_form_opts โ€” not unified
  • form_opts_on โ€” not unified
  • form_opts_off โ€” not unified

okay so we're picking up mid-table, bestie โ€” no re-intros, just vibes and facts. here's the rest of the availability chart, and every single one of these is a hard No ๐Ÿ™… โ€” like, not available through Perl "Curses", at all, don't even try:

  • form_opts โ€” No
  • set_current_field โ€” No
  • current_field โ€” No
  • set_form_page โ€” No
  • form_page โ€” No
  • field_index โ€” No
  • post_form โ€” No
  • unpost_form โ€” No
  • set_form_userptr โ€” No
  • form_userptr โ€” No
  • set_form_win โ€” No
  • form_win โ€” No
  • set_form_sub โ€” No
  • form_sub โ€” No
  • scale_form โ€” No
  • set_field_fore โ€” No
  • field_fore โ€” No
  • set_field_back โ€” No
  • field_back โ€” No
  • set_field_pad โ€” No
  • field_pad โ€” No
  • set_field_buffer โ€” No
  • field_buffer โ€” No
  • set_field_status โ€” No
  • field_status โ€” No
  • set_max_field โ€” No
  • field_info โ€” No
  • dynamic_field_info โ€” No
  • set_field_just โ€” No
  • field_just โ€” No
  • new_field โ€” No
  • dup_field โ€” No
  • link_field โ€” No
  • free_field โ€” No
  • set_field_opts โ€” No
  • field_opts_on โ€” No
  • field_opts_off โ€” No
  • field_opts โ€” No
  • set_field_userptr โ€” No
  • field_userptr โ€” No
  • field_arg โ€” No
  • form_request_name โ€” No
  • form_request_by_name โ€” No
๐ŸŽ€ footnote time: [*] To use any functions in this column, the program must set the variable $Curses::OldCurses variable to a non-zero value before using the "Curses" package. See "Perl 4.X cursperl Compatibility" for an example of this.

โœจ Available Wide-Character-Aware Functions โœจ

okay this next bit is lowkey iconic โ€” some functions have a wide-character version, and if you don't have that, they just slide back to the legacy call. it's giving "have you tried both" energy:

Function    Uses wide-character call  Reverts to legacy call
--------    ------------------------  ----------------------
getchar     wget_wch                  wgetch
getstring   wgetn_wstr                wgetnstr
ungetchar   unget_wch                 ungetch
instring    winnwtr                   winnstr
addstring   waddnwstr                 waddnstr
insstring   wins_nwstr                winsnstr

so, spelling it out one by one, no cap:

  • getchar โ€” wide call is wget_wch, reverts to wgetch
  • getstring โ€” wide call is wgetn_wstr, reverts to wgetnstr
  • ungetchar โ€” wide call is unget_wch, reverts to ungetch
  • instring โ€” wide call is winnwtr, reverts to winnstr
  • addstring โ€” wide call is waddnwstr, reverts to waddnstr
  • insstring โ€” wide call is wins_nwstr, reverts to winsnstr

๐ŸŒธ Available Variables ๐ŸŒธ

the whole roster, bestie, and yes these are the actual ones you get:

LINES                   COLS                    stdscr
curscr                  COLORS                  COLOR_PAIRS

so: LINES, COLS, stdscr, curscr, COLORS, COLOR_PAIRS. that's the set. periodt. ๐Ÿ’…

๐Ÿ‘‘ Available Constants ๐Ÿ‘‘

okay this is the big one โ€” the constants list ate and left no crumbs. every single name, exactly as spelled, because one wrong character and it's not the same symbol:

ERR                     OK                      ACS_BLOCK
ACS_BOARD               ACS_BTEE                ACS_BULLET
ACS_CKBOARD             ACS_DARROW              ACS_DEGREE
ACS_DIAMOND             ACS_HLINE               ACS_LANTERN
ACS_LARROW              ACS_LLCORNER            ACS_LRCORNER
ACS_LTEE                ACS_PLMINUS             ACS_PLUS
ACS_RARROW              ACS_RTEE                ACS_S1
ACS_S9                  ACS_TTEE                ACS_UARROW
ACS_ULCORNER            ACS_URCORNER            ACS_VLINE
A_ALTCHARSET            A_ATTRIBUTES            A_BLINK
A_BOLD                  A_CHARTEXT              A_COLOR
A_DIM                   A_INVIS                 A_NORMAL
A_PROTECT               A_REVERSE               A_STANDOUT
A_UNDERLINE             A_ITALIC
COLOR_BLACK             COLOR_BLUE
COLOR_CYAN              COLOR_GREEN             COLOR_MAGENTA
COLOR_RED               COLOR_WHITE             COLOR_YELLOW
KEY_A1                  KEY_A3                  KEY_B2
KEY_BACKSPACE           KEY_BEG                 KEY_BREAK
KEY_BTAB                KEY_C1                  KEY_C3
KEY_CANCEL              KEY_CATAB               KEY_CLEAR
KEY_CLOSE               KEY_COMMAND             KEY_COPY
KEY_CREATE              KEY_CTAB                KEY_DC
KEY_DL                  KEY_DOWN                KEY_EIC
KEY_END                 KEY_ENTER               KEY_EOL
KEY_EOS                 KEY_EVENT               KEY_EXIT
KEY_F0
KEY_FIND                KEY_HELP                KEY_HOME
KEY_IC                  KEY_IL                  KEY_LEFT
KEY_LL                  KEY_MARK                KEY_MAX
KEY_MESSAGE             KEY_MIN                 KEY_MOVE
KEY_NEXT                KEY_NPAGE               KEY_OPEN
KEY_OPTIONS             KEY_PPAGE               KEY_PREVIOUS
KEY_PRINT               KEY_REDO                KEY_REFERENCE
KEY_REFRESH             KEY_REPLACE             KEY_RESET
KEY_RESIZE              KEY_RESTART             KEY_RESUME
KEY_RIGHT
KEY_SAVE                KEY_SBEG                KEY_SCANCEL
KEY_SCOMMAND            KEY_SCOPY               KEY_SCREATE
KEY_SDC                 KEY_SDL                 KEY_SELECT
KEY_SEND                KEY_SEOL                KEY_SEXIT
KEY_SF                  KEY_SFIND               KEY_SHELP
KEY_SHOME               KEY_SIC                 KEY_SLEFT
KEY_SMESSAGE            KEY_SMOVE               KEY_SNEXT
KEY_SOPTIONS            KEY_SPREVIOUS           KEY_SPRINT
KEY_SR                  KEY_SREDO               KEY_SREPLACE
KEY_SRESET              KEY_SRIGHT              KEY_SRSUME
KEY_SSAVE               KEY_SSUSPEND            KEY_STAB
KEY_SUNDO               KEY_SUSPEND             KEY_UNDO
KEY_UP                  KEY_MOUSE               BUTTON1_RELEASED
BUTTON1_PRESSED         BUTTON1_CLICKED         BUTTON1_DOUBLE_CLICKED
BUTTON1_TRIPLE_CLICKED  BUTTON1_RESERVED_EVENT  BUTTON2_RELEASED
BUTTON2_PRESSED         BUTTON2_CLICKED         BUTTON2_DOUBLE_CLICKED
BUTTON2_TRIPLE_CLICKED  BUTTON2_RESERVED_EVENT  BUTTON3_RELEASED
BUTTON3_PRESSED         BUTTON3_CLICKED         BUTTON3_DOUBLE_CLICKED
BUTTON3_TRIPLE_CLICKED  BUTTON3_RESERVED_EVENT  BUTTON4_RELEASED
BUTTON4_PRESSED         BUTTON4_CLICKED         BUTTON4_DOUBLE_CLICKED
BUTTON4_TRIPLE_CLICKED  BUTTON4_RESERVED_EVENT  BUTTON_CTRL
BUTTON_SHIFT            BUTTON_ALT              ALL_MOUSE_EVENTS
REPORT_MOUSE_POSITION   NCURSES_MOUSE_VERSION   E_OK
E_SYSTEM_ERROR          E_BAD_ARGUMENT          E_POSTED
E_CONNECTED             E_BAD_STATE             E_NO_ROOM
E_NOT_POSTED            E_UNKNOWN_COMMAND       E_NO_MATCH
E_NOT_SELECTABLE        E_NOT_CONNECTED         E_REQUEST_DENIED
E_INVALID_FIELD         E_CURRENT               REQ_LEFT_ITEM
REQ_RIGHT_ITEM          REQ_UP_ITEM             REQ_DOWN_ITEM
REQ_SCR_ULINE           REQ_SCR_DLINE           REQ_SCR_DPAGE
REQ_SCR_UPAGE           REQ_FIRST_ITEM          REQ_LAST_ITEM
REQ_NEXT_ITEM           REQ_PREV_ITEM           REQ_TOGGLE_ITEM
REQ_CLEAR_PATTERN       REQ_BACK_PATTERN        REQ_NEXT_MATCH
REQ_PREV_MATCH          MIN_MENU_COMMAND        MAX_MENU_COMMAND
O_ONEVALUE              O_SHOWDESC              O_ROWMAJOR
O_IGNORECASE            O_SHOWMATCH             O_NONCYCLIC
O_SELECTABLE            REQ_NEXT_PAGE           REQ_PREV_PAGE
REQ_FIRST_PAGE          REQ_LAST_PAGE           REQ_NEXT_FIELD
REQ_PREV_FIELD          REQ_FIRST_FIELD         REQ_LAST_FIELD
REQ_SNEXT_FIELD         REQ_SPREV_FIELD         REQ_SFIRST_FIELD
REQ_SLAST_FIELD         REQ_LEFT_FIELD          REQ_RIGHT_FIELD
REQ_UP_FIELD            REQ_DOWN_FIELD          REQ_NEXT_CHAR
REQ_PREV_CHAR           REQ_NEXT_LINE           REQ_PREV_LINE
REQ_NEXT_WORD           REQ_PREV_WORD           REQ_BEG_FIELD
REQ_END_FIELD           REQ_BEG_LINE            REQ_END_LINE
REQ_LEFT_CHAR           REQ_RIGHT_CHAR          REQ_UP_CHAR
REQ_DOWN_CHAR           REQ_NEW_LINE            REQ_INS_CHAR
REQ_INS_LINE            REQ_DEL_CHAR            REQ_DEL_PREV
REQ_DEL_LINE            REQ_DEL_WORD            REQ_CLR_EOL
REQ_CLR_EOF             REQ_CLR_FIELD           REQ_OVL_MODE
REQ_INS_MODE            REQ_SCR_FLINE           REQ_SCR_BLINE
REQ_SCR_FPAGE           REQ_SCR_BPAGE           REQ_SCR_FHPAGE
REQ_SCR_BHPAGE          REQ_SCR_FCHAR           REQ_SCR_BCHAR
REQ_SCR_HFLINE          REQ_SCR_HBLINE          REQ_SCR_HFHALF
REQ_SCR_HBHALF          REQ_VALIDATION          REQ_NEXT_CHOICE
REQ_PREV_CHOICE         MIN_FORM_COMMAND        MAX_FORM_COMMAND
NO_JUSTIFICATION        JUSTIFY_LEFT            JUSTIFY_CENTER
JUSTIFY_RIGHT           O_VISIBLE               O_ACTIVE
O_PUBLIC                O_EDIT                  O_WRAP
O_BLANK                 O_AUTOSKIP              O_NULLOK
O_PASSOK                O_STATIC                O_NL_OVERLOAD
O_BS_OVERLOAD

that's the whole set โ€” ERR, OK, every ACS_*, every A_*, every COLOR_*, every KEY_*, every BUTTON* / BUTTON_*, ALL_MOUSE_EVENTS, REPORT_MOUSE_POSITION, NCURSES_MOUSE_VERSION, all the E_* errors, all the REQ_*, MIN_MENU_COMMAND, MAX_MENU_COMMAND, all the O_*, NO_JUSTIFICATION, JUSTIFY_*, and MIN_FORM_COMMAND / MAX_FORM_COMMAND. copy them exactly, bestie, character for character. ๐Ÿ”ฅ


๐Ÿ’€ Curses functions not available through Perl "Curses" ๐Ÿ’€

these ones? nope, not in the package. gatekept. ๐Ÿ™ˆ

tstp _putchar fullname scanw wscanw mvscanw mvwscanw ripoffline
setupterm setterm set_curterm del_curterm restartterm tparm tputs
putp vidputs vidattr mvcur tigetflag tigetnum tigetstr tgetent
tgetflag tgetnum tgetstr tgoto tputs

(yes, tputs shows up twice in there โ€” that's literally how it's written, I'm not fixing it. ๐Ÿ˜ญ)

๐Ÿ’€ Curses menu functions not available through Perl "Curses" ๐Ÿ’€

also not invited to the party:

set_item_init item_init set_item_term item_term set_menu_init
menu_init set_menu_term menu_term

๐Ÿ’€ Curses form functions not available through Perl "Curses" ๐Ÿ’€

and these too โ€” same energy, same answer:

new_fieldtype free_fieldtype set_fieldtype_arg
set_fieldtype_choice link_fieldtype set_form_init form_init
set_form_term form_term set_field_init field_init set_field_term
field_term set_field_type field_type

aaand that's the whole page, bestie ๐Ÿซถ you made it to the end, main character behaviour fr fr. this copy is from perl v5.42.0, dated 2025-02-06 โ€” go build something iconic with it. slay, no cap. ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from