Widget...omboBox(3pm)
π Widget...omboBox(3pm) β Curses::Widgets::ComboBox π
okay bestie, sit down, hydrate, because we're talking about Curses::Widgets::ComboBox β a lil Perl module from the User Contributed Perl Documentation corner of the manual. It's giving drop-down-menu realness for your terminal, and honestly? iconic. π
πΈ NAME πΈ
Curses::Widgets::ComboBox β Combo-Box Widgets. yes, that's it, that's the whole name. slay.
π¦ MODULE VERSION π¦
$Id: ComboBox.pm,v 1.103 2002/11/03 23:34:50 corliss Exp corliss $
literally the receipts. π
β¨ SYNOPSIS β¨
so here's the vibe β you make one like this:
use Curses::Widgets::ComboBox;
$cb = Curses::Widgets::ComboBox->new({
CAPTION => 'Select',
CAPTIONCOL => 'yellow',
COLUMNS => 10,
MAXLENGTH => 255,
MASK => undef,
VALUE => '',
INPUTFUNC => \&scankey,
FOREGROUND => 'white',
BACKGROUND => 'black',
BORDER => 1,
BORDERCOL => 'red',
FOCUSSWITCH => "\t\n",
CURSORPOS => 0,
TEXTSTART => 0,
PASSWORD => 0,
X => 1,
Y => 1,
READONLY => 0,
LISTITEMS => [qw(foo bar wop)],
});
$cb->draw($mwh, 1);
and then, yk, go read the Curses::Widgets pod for all the other methods, because that's where the rest of the lore lives. π
π«Ά REQUIREMENTS π«Ά
you're gonna need all of these, no skipping:
CursesCurses::WidgetsCurses::Widgets::TextFieldCurses::Widgets::ListBox
π DESCRIPTION π
Curses::Widgets::ComboBox gives you simplified OO access to Curses-based combo-boxes. periodt.
here's the tea on how it actually behaves: this widget is basically a text field widget at heart, BUT β and this is the main character moment β when you hit a KEY_DOWN or a "\n", a drop-down list pops up, and whatever item you pick gets dropped right into the text field as the value. it's giving "text field with a secret second personality". π
π METHODS π
β new (inherited from Curses::Widgets)
$cb = Curses::Widgets::ComboBox->new({
CAPTION => 'Select',
CAPTIONCOL => 'yellow',
COLUMNS => 10,
MAXLENGTH => 255,
MASK => undef,
VALUE => '',
INPUTFUNC => \&scankey,
FOREGROUND => 'white',
BACKGROUND => 'black',
BORDER => 1,
BORDERCOL => 'red',
FOCUSSWITCH => "\t\n",
CURSORPOS => 0,
TEXTSTART => 0,
PASSWORD => 0,
X => 1,
Y => 1,
READONLY => 0,
LISTITEMS => [qw(foo bar wop)],
});
new spins up a brand new ComboBox object for you. and listen β the only mandatory key/value pairs in that config hash are X and Y. everything else is optional and comes with defaults, which I am listing below because I love you:
CAPTIONβ defaultundefβ caption superimposed on borderCAPTIONCOLβ defaultundefβ foreground colour for caption textCOLUMNSβ default10β number of columns displayedMAXLENGTHβ default255β maximum string length allowedMASKβ defaultundefβ not yet implementedVALUEβ default''β current field textINPUTFUNCβ default\&scankeyβ function to use to scan for keystrokesFOREGROUNDβ defaultundefβ default foreground colourBACKGROUNDβ defaultundefβ default background colourBORDERβ default1β display a border around the fieldBORDERCOLβ defaultundefβ foreground colour for borderFOCUSSWITCHβ default"\t\n"β characters which signify end of inputCURSORPOSβ default0β starting position of the cursorTEXTSTARTβ default0β position in string to start displayingPASSWORDβ default0β substitutes'*'instead of charactersREADONLYβ default0β prevents alteration to contentLISTLINESβ default5β number of lines to display at a time in the drop-down listLISTCOLUMNS[COLUMNS]β width of the drop-down list; defaults to the same length specified for theCombBoxwidgetLISTITEMSβ default[]β items listed in drop-down list
some extra notes because details matter, bestie:
- the
CAPTIONis only valid when theBORDERis enabled. if the border is disabled, the field will be underlined β provided your terminal supports it. π - if
MAXLENGTHis undefined, no limit gets placed on the string length. go wild, I guess. π
π draw (inherited from Curses::Widgets::TextField)
$cb->draw($mwh, 1);
draw renders the text field in its current state. you must hand it a valid handle to a curses window, because that's where it's gonna render itself. the optional second argument β if it's true β makes the field's text cursor get rendered too. cute, right? β¨
π§ popup
$combo->popup;
popup makes the drop-down list show up. and since, theoretically, that list should never be seen unless somebody's actively using it, we always assume we need to draw a cursor on the list as well. no cap. π¦
π HISTORY π
2001/12/09β First version of the combo box
the origin story. πΌ
π AUTHOR/COPYRIGHT π
(c) 2001 Arthur Corliss (corliss@digitalmages.com)
okay that's the whole page, you ate it, you understood it, you're basically a Curses combo-box sommelier now. π
so like, this was page Widget...omboBox(3pm) from perl v5.34.0, dated 2022-06-12 β and yeah, that's the User Contributed Perl Documentation collection, so go forth and pop up them lists. mwah. ππ
π¦ where this page comes from
- debian bookworm: libcurses-widgets-perl 1.997-8
- debian trixie: libcurses-widgets-perl 1.997-8
- ubuntu noble: libcurses-widgets-perl 1.997-8
- ubuntu resolute: libcurses-widgets-perl 1.997-8
- ubuntu stonking: libcurses-widgets-perl 1.997-8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms