Widgets::ListBox(3pm)

πŸ“¦
version 1.997 Β· 2 versions
  • 1.997 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.997 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Curses::Widgets::ListBox β€” List Box Widgets, bestie. That's the whole vibe. πŸ‘‘


🌈 MODULE VERSION 🌈

$Id: ListBox.pm,v 1.104 2002/11/14 01:20:28 corliss Exp corliss $

no cap, that's the version string, keep it safe 🫢


✨ SYNOPSIS ✨

okay so this is how you actually summon one:

use Curses::Widgets::ListBox;

$lb = Curses::Widgets::ListBox->new({
  CAPTION     => 'List',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  LINES       => 3,
  VALUE       => 0,
  INPUTFUNC   => \&scankey,
  FOREGROUND  => 'white',
  BACKGROUND  => 'black',
  SELECTEDCOL => 'green',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t",
  X           => 1,
  Y           => 1,
  TOPELEMENT  => 0,
  LISTITEMS   => [@list],
  });

$lb->draw($mwh, 1);

then like… go read the Curses::Widgets pod for the other methods, because there's more where that came from πŸ’…


πŸŽ€ REQUIREMENTS πŸŽ€

  • Curses
  • Curses::Widgets

you need both, fr fr. no skipping.


πŸ¦‹ DESCRIPTION πŸ¦‹

Curses::Widgets::ListBox gives you simplified OO access to Curses-based single-select and multi-select list boxes. literally that's the whole job. and the way each object maintains its own state information?? obsessed. every single one is its own little main character with its own state. πŸ’–


πŸ‘‘ METHODS πŸ‘‘

🌸 new (inherited from Curses::Widgets)

$tm = Curses::Widgets::ListBox->new({
  CAPTION     => 'List',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  LINES       => 3,
  VALUE       => 0,
  INPUTFUNC   => \&scankey,
  FOREGROUND  => 'white',
  BACKGROUND  => 'black',
  SELECTEDCOL => 'green',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t",
  X           => 1,
  Y           => 1,
  TOPELEMENT  => 0,
  LISTITEMS   => [@list],
  });

the new method instantiates a new ListBox object. and bestie, listen β€” the only mandatory key/value pairs in that config hash are X and Y. everything else? optional, they've all got defaults waiting for you like the loyal besties they are:

  • CAPTION β€” default undef β€” Caption superimposed on border
  • CAPTIONCOL β€” default undef β€” Foreground colour for caption text
  • COLUMNS β€” default 10 β€” Number of columns displayed
  • LINES β€” default 3 β€” Number of lines in the window
  • INPUTFUNC β€” default \&scankey β€” Function to use to scan for keystrokes
  • FOREGROUND β€” default undef β€” Default foreground colour
  • BACKGROUND β€” default undef β€” Default background colour
  • SELECTEDCOL β€” default undef β€” Default colour of selected items
  • BORDER β€” default 1 β€” Display a border around the field
  • BORDERCOL β€” default undef β€” Foreground colour for border
  • FOCUSSWITCH β€” default "\t" β€” Characters which signify end of input
  • TOPELEMENT β€” default 0 β€” Index of element displayed on line 1
  • LISTITEMS β€” default [] β€” List of list items
  • MULTISEL β€” default 0 β€” Whether or not multiple items can be selected
  • TOGGLE β€” default "\n\s" β€” What input toggles selection of the current item
  • VALUE β€” default 0 or [] β€” Index(es) of selected items
  • CURSORPOS β€” default 0 β€” Index of the item the cursor is currently on

the CAPTION is only valid when the BORDER is enabled. if the border is disabled, the field will be underlined β€” provided the terminal supports it. so like, vibe check your terminal first 🫢

and about VALUE: it should be an array reference when you're in multiple selection mode. otherwise it should either be undef or an integer. periodt. ✨


πŸ’… draw

$lb->draw($mwh, 1);

the draw method renders the list box in its current state. it needs a valid handle to a curses window to render itself into β€” non-negotiable, that's the whole stage. 🎭

the optional second argument, if it's true, will also cause the field's text cursor to be rendered. cute little bonus. 😌


πŸ’€ HISTORY πŸ’€

  • 1999/12/29 β€” Original list box widget in functional model
  • 2001/07/05 β€” First incarnation in OO architecture

look at the glow-up. we love an evolution arc. πŸ¦‹βœ¨


(c) 2001 Arthur Corliss (corliss@digitalmages.com)


and that's a wrap, bestie πŸŽ€ this was Widgets::ListBox(3pm), generated by perl v5.34.0 on 2022-06-12 β€” go forth and render some gorgeous little list boxes, iykyk πŸ’–πŸŒˆπŸ‘‘