Terminal::UI

A framework for building terminal interfaces

Terminal::UI

A framework for building terminal interfaces.

Example

Create a box in full screen with some text in it, wait for a key, then exit:

use Terminal::UI 'ui';
ui.setup(:1pane);
ui.pane.put("Hello world.");
ui.get-key;
ui.shutdown;

╔══════════════╗
β•‘Hello world.  β•‘
β•‘              β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Example 2

Make a screen split with a line in the middle, with scrollable text on the top and bottom, and a selected row in the top box. The arrow keys (or j,k) move the selected line up and down. Tab switches to the other box.

use Terminal::UI 'ui';
ui.setup(:2panes);
ui.panes[0].put("$_") for 1..10;
ui.panes[1].put("$_") for <hello world>;
ui.interact;
ui.shutdown;

╔══════════════╗
β•‘8             β•‘  <- selected in green, scrollable
β•‘9             β•‘
β•‘10            β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘hello         β•‘  <- selected in grey.
β•‘world         β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Example 3

Like example 2, but also -- pressing Enter in the top box will some text about add the currently selected row to the bottom box:

ui.setup(:2panes);
ui.panes[0].put("$_") for 1..10;

ui.panes[0].on: select => -> :$raw, :$meta {
  ui.panes[1].put("you chose $raw!")
}

ui.interact;
ui.shutdown;

╔══════════════╗
β•‘8             β•‘  <- press Enter, and…
β•‘9             β•‘
β•‘10            β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘you chose 8!  β•‘  <- …this appears!
β•‘              β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Features and design goals

  • Easy to quickly make a console interface with custom behavior, but practical defaults.

  • Scrolling with some optimization, such as using ANSI scroll region escape sequences.

  • Thread safe. Concurrency friendly. Unicode compatibile.

  • Dynamic geometry calculation, for smart handling of window resizing.

More examples

See the eg directory.

See also

https://blog.matatu.org/terminal-ui

Description

The best place for documentation is the examples directory.

There is also reference documentation with links to the source code -- see Terminal::UI. Other classes with documentation are:

BUGS

Probably!

If you find some bugs, or just have something to say, feel free to contact the author.

Author

Brian Duggan (bduggan at matatu.org)

Terminal::UI v0.1.13

A framework for building terminal interfaces

Authors

  • Brian Duggan

License

MIT

Dependencies

Terminal::ANSI:ver<0.0.24>Log::AsyncTerminal::ANSIParserUnicode::UTF8-Parser

Test Dependencies

Provides

  • Terminal::UI
  • Terminal::UI::Alerts
  • Terminal::UI::Frame
  • Terminal::UI::Input
  • Terminal::UI::Pane
  • Terminal::UI::Screen
  • Terminal::UI::Style
  • Terminal::UI::Utils

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.