Tickit::Console(3pm)

πŸ“¦
version 0.12 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… Tickit::Console β€” the manual page, but make it cute

okay bestie, so this is Tickit::Console(3pm) from the User Contributed Perl Documentation ✨ and it is literally the blueprint for building full-screen console-style apps. like, terminal apps that look like a whole vibe. let's get into it 🫢


✨ NAME ✨

Tickit::Console β€” build full-screen console-style applications πŸ’–


🌸 SYNOPSIS 🌸

my $console = Tickit::Console->new;

Tickit->new( root => $console )->run;

that's it. that's the whole flex. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so a Tickit::Console instance is a subclass of Tickit::Widget::VBox, and its whole purpose in life is helping you build a full-screen console-style application. think: one or more scrollable text areas presented to the user, selectable as tabs on a ribbon (yes, a ribbon, iconic), plus a text entry area at the bottom of the screen for typing commands or whatever other data you need. πŸ’…

and because it's a Tickit::Widget subclass, it can be dropped anywhere inside a widget tree β€” though ngl, normally you'd use it as the root widget for a Tickit instance. that's its main character moment. ✨


πŸŽ€ CONSTRUCTOR πŸŽ€

new

$console = Tickit::Console->new( %args );

returns a fresh new instance of a Tickit::Console. it takes these named arguments:

  • on_line => CODE β€” the callback to invoke when a line of text gets entered in the entry widget. it goes a little something like:
$on_line->( $active_tab, $text );
  • tab_class => STRING β€” optional, bestie. if you set it, it gives a class name (and it should be a subclass of Tickit::Console::Tab, okay?) that newly-added tabs get constructed with. this setting lets an application provide new methods in tabs to change behaviours. lowkey powerful.
  • timestamp_format, datestamp_format β€” optional too. if you supply these, they get stored as default values to pass along to the tab constructor in the add_tab method. πŸ’–

πŸ”₯ METHODS πŸ”₯

add_tab

$tab = $console->add_tab( %args );

adds a new tab to the console, and returns a Tickit::Console::Tab object representing it. slay.

it takes these named arguments:

  • name => STRING β€” name for the tab.
  • on_line => CODE β€” optional. provides a different callback to invoke when a line of text is entered while this tab is active. invoked the same way as above. πŸ™ˆ
  • make_widget => CODE β€” optional. gives a piece of code used to construct the actual Tickit::Widget used as this tab's child in the ribbon. a Tickit::Widget::Scroller to hold the tab's content gets passed in to this code, and it should construct some sort of widget tree with that inside it, then return it. this is your moment to apply a decorative frame, place the scroller in a split box or other layout along with other widgets, or do various other effects. go off. πŸŽ€
$tab_widget = $make_widget->( $scroller );

any other named arguments are passed to the tab's constructor. periodt.

active_tab_index

$index = $console->active_tab_index;

active_tab

$tab = $console->active_tab;

remove_tab

$console->remove_tab( $tab_or_index );

move_tab

$console->move_tab( $tab_or_index, $delta );

activate_tab

$console->activate_tab( $tab_or_index );

next_tab

$console->next_tab;

prev_tab

$console->prev_tab;

okay so all of these methods above? they're all passed through to the underlying Tickit::Widget::Tabbed object. so if you know that one, you already know these. iykyk. πŸ’œ

bind_key

$console->bind_key( $key, $code );

installs a callback to invoke if the given key is pressed β€” and heads up, it overwrites any previous callback for the same key. the code block is invoked as:

$code->( $console, $key );

if $code is missing or undef, any existing callback gets removed. clean. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the icon, the legend, the moment. πŸ’–


and that's a wrap bestie!! this page is from perl v5.36.0, dated 2024-01-01, and yes it really is Tickit::Console(3pm). go build something gorgeous with it. πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from