Widget...tField(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

πŸŽ€ Widget...tField(3pm) β€” bestie edition πŸ’…

okay so this is a page from the User Contributed Perl Documentation collection, and we're talking about Curses::Widgets::TextField. yes it's a real manual page. yes it's from 2002. yes it still slays. come sit with me 🫢


✨ NAME ✨

Curses::Widgets::TextField β€” Text Field Widgets. that's it, that's the name, she's simple and she knows it πŸ’–


🌸 MODULE VERSION 🌸

$Id: TextField.pm,v 1.103 2002/11/04 00:35:44 corliss Exp corliss $

look at that version string. 1.103. iconic. no notes. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole vibe, bestie β€” copy it, paste it, live your truth:

use Curses::Widgets::TextField;

$tf = Curses::Widgets::TextField->new({
  CAPTION     => 'Name',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  MAXLENGTH   => 255,
  MASK        => undef,
  VALUE       => '',
  INPUTFUNC   => \&scankey,
  FOREGROUND  => undef,
  BACKGROUND  => 'black',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t\n",
  CURSORPOS   => 0,
  TEXTSTART   => 0,
  PASSWORD    => 0,
  X           => 1,
  Y           => 1,
  READONLY    => 0,
  });

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

and then, because we don't gatekeep:

See the Curses::Widgets pod for other methods.

that's where the rest of the methods live. go look. i'll wait. πŸ’œ


πŸ’œ REQUIREMENTS πŸ’œ

  • Curses
  • Curses::Widgets

that's the whole list. two things. low maintenance queen. πŸ‘‘


🌈 DESCRIPTION 🌈

so Curses::Widgets::TextField gives you simplified OO access to Curses-based single line text fields. and the way that each object maintains its own state information? obsessed. every field is its own little main character with its own memory. no sharing, no chaos, just vibes ✨


πŸ’… METHODS πŸ’…

πŸ“ new (inherited from Curses::Widgets)

$tf = Curses::Widgets::TextField->new({
  CAPTION     => 'Name',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  MAXLENGTH   => 255,
  MASK        => undef,
  VALUE       => '',
  INPUTFUNC   => \&scankey,
  FOREGROUND  => undef,
  BACKGROUND  => 'black',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t\n",
  CURSORPOS   => 0,
  TEXTSTART   => 0,
  PASSWORD    => 0,
  X           => 1,
  Y           => 1,
  READONLY    => 0,
  });

new instantiates a brand new TextField object, fr fr. now listen β€” the only mandatory key/value pairs in that config hash are X and Y. that's it. everything else? optional, babes, and here's what they all default to:

  • CAPTION β€” default undef β€” caption superimposed on the border
  • CAPTIONCOL β€” default undef β€” foreground colour for caption text
  • COLUMNS β€” default 10 β€” number of columns displayed
  • MAXLENGTH β€” default 255 β€” maximum string length allowed
  • MASK β€” default undef β€” not yet implemented
  • VALUE β€” default '' β€” current field text
  • INPUTFUNC β€” default \&scankey β€” function to use to scan for keystrokes
  • FOREGROUND β€” default undef β€” default foreground colour
  • BACKGROUND β€” default undef β€” default background colour
  • BORDER β€” default 1 β€” display a border around the field
  • BORDERCOL β€” default undef β€” foreground colour for border
  • FOCUSSWITCH β€” default "\t\n" β€” characters which signify end of input
  • CURSORPOS β€” default 0 β€” starting position of the cursor
  • TEXTSTART β€” default 0 β€” position in string to start displaying
  • PASSWORD β€” default 0 β€” subsitutes '*' instead of characters
  • READONLY β€” default 0 β€” prevents alteration to content

a few little lore drops for you, bestie:

  • 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, terminal-dependent, iykyk 🧚
  • if MAXLENGTH is undefined, no limit will be placed on the string length. go off, type forever, no one's stopping you πŸ’€
  • if BORDER is true, the widget will be enlarged to three columns and two more columns to make room for the border. she's taking up space because she deserves it πŸ’…

⭐ draw ⭐

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

draw renders the text field in its current state. this requires a valid handle to a curses window in which it will render itself. and that optional second argument? if it's true, the field's text cursor gets rendered as well. cursor said "i'm here too" 🫢


πŸ‘‘ HISTORY πŸ‘‘

  • 1999/12/29 β€” original text field widget in functional model
  • 2001/07/05 β€” first incarnation in OO architecture

she's been evolving since '99. a glow-up arc for the ages. ✨


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

respect the author, bestie. 🫑


okay and for the cute sign-off β€” this was perl v5.34.0, dated 2022-06-12, and the page header/footer said Widget...tField(3pm) all along. that's the whole thing! go build a text field, you've got this πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά