Tui Widgets

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

Its designed to be flexible and similar to use to qt grahical widgets. Its look and feel is similar to graphical applications or classic full screen terminal applications from the PC world of the 90ies.

Features

  • works with the qt event loop and object model

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

  • overlapping window support

  • robust input handling, unknown key events are gracefully filtered out

  • truecolor, 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

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

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

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

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.

Curent Status

Known pending changes:
  • layout memory management is unflexible and crash prone.

Indices and tables