lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

I'd like to introduce lua-rote, Lua binding to ROTE.

ROTE is a simple C library for VT102 terminal emulation. It is
extremely useful to programmatically interact with curses applications
(e.g., for unit testing).

Website: http://starius.github.io/lua-rote/
Version: 1.0.1
License: Lesser GPL 2.1

Installation:
 * install curses, luaposix and ROTE
 * luarocks install lua-rote

lua-rote has almost all functions of ROTE, namely:
 * create a virtual terminal
 * read contents of the virtual terminal
 * fork a child process
 * feed data to the child process
 * draw contents of the virtual terminal on curses window

Most of ROTE functions are represented as class RoteTerm on Lua side.

All functions are covered with unit tests.

Example demo/boxshell.c from ROTE was implemented in pure Lua using
luaposix and lua-rote. Both programs include the following steps:
 * start curses,
 * fill the screen with blue,
 * create curses window in the middle of the screen,
 * start ROTE terminal, fork bash inside,
 * do in a loop until child process dies:
   - redraw curses window accorsing to ROTE terminal,
   - getch(), results of which are passed to ROTE terminal.

I use lua-rote for unit tests of my other project, alnbox [1]. Alnbox is
alignment viewer based on the curses library. It is used to view an
alignment of biological sequences from FASTA file in terminal.
Scrolling through alignment is provided by arrow buttons, quit with
button 'q'. Unit tests include the following steps: starting alnbox
under lua-rote, "pressing" arrow keys, validating contents of the
terminal [2]. Unit testing framework Busted is used [3]. Test coverage
of both lua-rote and alnbox is 100%.


[1] https://github.com/starius/alnbox
[2] https://github.com/starius/alnbox/blob/master/spec/show-fasta_spec.lua
[3] http://olivinelabs.com/busted/

Best regards,
Boris Nagaev