A headless terminal emulator (ANSI / VT100) in C89 with its Python wrapper.
Go to file
2011-10-22 18:35:42 +02:00
doc Adding a manpage 2011-10-15 14:28:31 +02:00
example Adding an example 2011-10-15 14:21:57 +02:00
src Adding support for Python via swig 2011-10-22 16:45:31 +02:00
hl_vt100.i Adding support for Python via swig 2011-10-22 16:45:31 +02:00
Makefile Adding -DNDEBUG to avoid flood during tests 2011-10-22 18:35:12 +02:00
README.rst Adding a good readme file 2011-10-16 13:49:40 +02:00
run_tests.sh Adding a test to check if swig is installed before running it 2011-10-22 18:35:42 +02:00
setup.py Adding support for Python via swig 2011-10-22 16:45:31 +02:00

Overview

lw_terminal_parser, lw_terminal_vt100, and hl_vt100 are three modules used to emulate a vt100 terminal:

-------------
|           |
| Your Code |
|           |
-------------
  |      ^
vt100 = vt100_headless_init()      |      |
vt100->changed = changed;          |      | hl_vt100 raises 'changed'
vt100_headless_fork(vt100, ...     |      | when the screen has changed.
  |      | You get the content of the screen
  |      | calling vt100_headless_getlines.
  V      |
-------------              -------------
Read from PTY master and write | |           |     PTY      |           |
to lw_terminal_vt100_read_str  | |  hl_vt100 |<------------>|  Program  |
V |           |Master   Slave|           |
-------------              -------------
 |        |^ hl_vt100 gets lw_terminal_vt100's
 |        || lines by calling
 |        || lw_terminal_vt100_getlines
 |        ||
 |        ||
 V        V|
----------------------
Got data from              | |                    | Recieve data from callbacks
lw_terminal_vt100_read_str | | lw_terminal_vt100  | And store an in-memory
give it to                 | |                    | state of the vt100 terminal
lw_terminal_read_str       V ----------------------
|              ^
|              |
|              |
|              |
|              |
|              | Callbacks
|              |
|              |
|              |
|              |
|              |
V              |
----------------------
Got data from                |                    |
lw_terminal_pasrser_read_str | lw_terminal_parser |
parses, and call callbacks   |                    |
----------------------

lw_terminal_parser

lw_terminal_parser parses terminal escape sequences, calling callbacks when a sequence is sucessfully parsed, read example/parse.c.

Provides :

  • struct lw_terminal *lw_terminal_parser_init(void);
  • void lw_terminal_parser_destroy(struct lw_terminal* this);
  • void lw_terminal_parser_default_unimplemented(struct lw_terminal* this, char *seq, char chr);
  • void lw_terminal_parser_read(struct lw_terminal *this, char c);
  • void lw_terminal_parser_read_str(struct lw_terminal *this, char *c);

lw_terminal_vt100

Hooks into a lw_terminal_parser and keep an in-memory state of the screen of a vt100.

Provides :
  • struct lw_terminal_vt100 *lw_terminal_vt100_init(void *user_data, void (*unimplemented)(struct lw_terminal* term_emul, char *seq, char chr));
  • char lw_terminal_vt100_get(struct lw_terminal_vt100 *vt100, unsigned int x, unsigned int y);
  • const char **lw_terminal_vt100_getlines(struct lw_terminal_vt100 *vt100);
  • void lw_terminal_vt100_destroy(struct lw_terminal_vt100 *this);
  • void lw_terminal_vt100_read_str(struct lw_terminal_vt100 *this, char *buffer);

hl_vt100

Forks a program, plug its io to a pseudo terminal and emulate a vt100 using lw_terminal_vt100.

Provides :
  • void vt100_headless_fork(struct vt100_headless *this, const char *progname, char *const argv[]);
  • struct vt100_headless *vt100_headless_init(void);
  • const char **vt100_headless_getlines(struct vt100_headless *this);