Part of the CCNx C Library. More...
Go to the source code of this file.
Defines | |
#define | MAX_TERM_WIDTH 256 |
#define | CTL(x) ((x)-'@') |
Functions | |
static int | fillout (char ch, int k) |
Write k instances of ch. | |
static int | takedown (int n, int r) |
Erase n chars to the left of the cursor, and r to the right. | |
static int | term_width (int fd) |
Get the terminal width, if possible. | |
static int | shuttle (int peer, const char *prompt) |
Copy from the peer fd to stdout, and from stdin to peer. | |
int | lned_run (int argc, char **argv, const char *prompt, int(*worker)(int, char **)) |
Interpose a simple line editor in front of a command-line utility. |
Part of the CCNx C Library.
Definition in file lned.c.
#define MAX_TERM_WIDTH 256 |
Definition at line 35 of file lned.c.
Referenced by shuttle(), and term_width().
static int fillout | ( | char | ch, | |
int | k | |||
) | [static] |
Write k instances of ch.
Definition at line 273 of file lned.c.
Referenced by shuttle(), and takedown().
int lned_run | ( | int | argc, | |
char ** | argv, | |||
const char * | prompt, | |||
int(*)(int, char **) | worker | |||
) |
Interpose a simple line editor in front of a command-line utility.
This should be called early in the application's main program, in particular before the creation of threads or the use of stdio.
If both stdin and stdout are tty devices, worker() is called in a forked process, and it may use the standard file descriptors in a conventional fashion. Otherwise worker() is just called directly.
Definition at line 316 of file lned.c.
Referenced by main().
static int shuttle | ( | int | peer, | |
const char * | prompt | |||
) | [static] |
Copy from the peer fd to stdout, and from stdin to peer.
A very basic line editor is provided on the input side. The peer will get a line at a time (unless the input is oversize, in which case the input will arrive in chunks). The peer is responsible for echoing the input lines, if appropriate for the application.
Definition at line 76 of file lned.c.
Referenced by lned_run().
static int takedown | ( | int | n, | |
int | r | |||
) | [static] |