Search code examples
dtui

TUI (text user interface) for D?


I would like to write a console app with text UI in D. I looked at curses, but it seems that it works only on unix. Are there any cross-patform alternatives?


Solution

  • My terminal.d could be used as a foundation for a TUI library.

    https://github.com/adamdruppe/arsd/blob/master/terminal.d

    It has no required dependencies, so you can simply download that one file and start building with dmd yourfile.d terminal.d. Here's an example program getting input: http://arsdnet.net/dcode/book/chapter_12/07/input.d

    You can also use terminal.moveTo(x, y); terminal.color(Color.green, Color.black); terminal.writef("something"); terminal.flush(); and such to move and draw.

    Look for version(Demo) in terminal.d itself for a main which handles all kinds of input events, including mouse events.

    While terminal.d mostly offers lower-level functions (its main high level function is terminal.getline, great for line based apps but not TUIs), it should give all the foundation needed to write a little text widget library.

    and I think someone might have done that once but I don't recall where.

    terminal.d works on Windows and Posix systems, for the most common terminals like xterm. ncurses is more comprehensive and probably has fewer bugs on more obscure targets but terminal.d, being a single file, is easier to build.