Library/VTY

From HaskellWiki
Jump to navigation Jump to search

A very simple terminal interface library.

In 150 non-blank non-comment lines of Haskell (and 7 lines of C) vty provides:

  • Automatic handling of suspend/resume (SIGTSTP+SIGCONT)
  • Automatic handling of window resizes
  • Automatic computation of minimal differences
  • Minimizes repaint area, thus virtually eliminating the flicker problem that plagues ncurses programs
  • Automatically decodes keyboard keys into (key,[modifier]) tuples
  • Automatically supports refresh on Ctrl-L.
  • Automatically supports timeout after 50ms for lone ESC (a barely noticable delay)
  • Extensive color scheme support: background colors, default colors, reverse-video, bold, underline, half-bright, and blinking attributes.
  • Unicode characters on output, automatically setting and resetting UTF-8 mode (beware double width and combining characters!)
  • Disables ISIG and IXOFF, allowing C-q, C-s, C-c, C-z, and C-\ to be received as input.
  • Interface is designed for relatively easy compatible extension.

Current disadvantages:

  • No current support for non-ANSI terminals.
  • Minimal support for special keys on terminals other than the linux-console. (F1-5 and arrow keys should work, but anything shifted isn't likely to.)
  • Uses the TIOCGWINSZ ioctl to find the current window size, which appears to be limited to Linux and *BSD.

http://members.cox.net/stefanor/vty/dist/vty-2.0.tar.gz

darcs get --tag=rel-2.0 http://members.cox.net/stefanor/vty

To compile the demonstration program: ghc --make Test.hs gwinsz.c