Tui Widgets

Tui Widgets is high-level widget based toolkit for terminal applications.

Tui Widgets is designed to be flexible and similar to use to Qt graphical widgets. Its look and feel is similar to graphical applications or classic full screen terminal applications from the PC world of the 90s.

Features

  • works with the Qt event loop and object model

  • ready to use user interface elements (text entry, checkboxes, buttons, layout managers, menu etc)

  • overlapping window support

  • robust input handling

  • 24-bit color, soft line breaks, explicit control of trailing whitespace

  • does not depend on correctly set $TERM or terminfo database

  • tagged paste

  • mostly utf-8 based, string width routines also handle utf-16 and utf-32

  • offscreen surfaces/layers

  • does not use global variables/singletons whenever possible and can handle multiple terminals in one process

  • permissively licensed: Boost Software License 1.0 (but Qt licensing is stricter)

Curent Status

Planned:

  • ABI stability is planned (but breaking changes are still happening)

Does not contain:

  • support for non utf-8 capable terminals

Minimal example

A “hello world”, with fixed widget positions and size:

See Getting started for full source.

UI Setup
Tui::ZWindow *win = new Tui::ZWindow("Hello World", this);
win->setGeometry({5, 3, 20, 10});
QObject::connect(new Tui::ZShortcut(Tui::ZKeySequence::forKey(Qt::Key_Escape),
                                    this,
                                    Qt::ApplicationShortcut),
                 &Tui::ZShortcut::activated,
                 this, &Root::quit);
Tui::ZButton *button = new Tui::ZButton(Tui::withMarkup, "<m>Q</m>uit", win);
QObject::connect(button, &Tui::ZButton::clicked, this, &Root::quit);
button->setGeometry({6, 7, 10, 1});
button->setFocus();
main code
int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);

    Tui::ZTerminal terminal;

    Root root;

    terminal.setMainWidget(&root);

    return app.exec();
}

Support

It’s known to work on
  • xterm

  • vte

  • rxvt-unicode

  • mintty

  • iTerm2

  • microsoft terminal

  • putty

  • konsole

  • linux

  • freebsd

  • and more.

Contents:

Indices and tables