#include <termios.h>#include <sys/ioctl.h>#include <sys/poll.h>#include <unistd.h>#include <fcntl.h>#include <stdlib.h>#include <stdarg.h>#include <stdio.h>#include <errno.h>#include <string.h>#include <strings.h>#include <sys/types.h>#include "linenoise.h"#include "utf8.h"Classes | |
| struct | current |
| struct | ctx |
Macros | |
| #define | USE_TERMIOS |
| #define | HAVE_UNISTD_H |
| #define | LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 |
| #define | LINENOISE_MAX_LINE 4096 |
| #define | ctrl(C) ((C) - '@') |
| #define | IGNORE_RC(EXPR) if (EXPR) {} |
Enumerations | |
| enum | { SPECIAL_NONE, SPECIAL_UP = -20, SPECIAL_DOWN = -21, SPECIAL_LEFT = -22, SPECIAL_RIGHT = -23, SPECIAL_DELETE = -24, SPECIAL_HOME = -25, SPECIAL_END = -26 } |
Functions | |
| static int | fd_read (struct current *current) |
| Reads a complete utf-8 character and returns the unicode value, or -1 on error. | |
| static int | getWindowSize (struct current *current) |
| void | linenoiseHistoryFree (void) |
| static void | linenoiseAtExit (void) |
| static int | isUnsupportedTerm (void) |
| static int | enableRawMode (struct current *current) |
| static void | disableRawMode (struct current *current) |
| static void | fd_printf (int fd, const char *format,...) |
| static void | clearScreen (struct current *current) |
| static void | cursorToLeft (struct current *current) |
| static int | outputChars (struct current *current, const char *buf, int len) |
| static void | outputControlChar (struct current *current, char ch) |
| static void | eraseEol (struct current *current) |
| static void | setCursorPos (struct current *current, int x) |
| static int | fd_read_char (int fd, int timeout) |
| Reads a char from 'fd', waiting at most 'timeout' milliseconds. | |
| static int | check_special (int fd) |
| If escape (27) was received, reads subsequent chars to determine if this is a known special key. | |
| static int | utf8_getchars (char *buf, int c) |
| static int | get_char (struct current *current, int pos) |
| Returns the unicode character at the given offset, or -1 if none. | |
| static void | refreshLine (const char *prompt, struct current *current) |
| static void | set_current (struct current *current, const char *str) |
| static int | has_room (struct current *current, int bytes) |
| static int | remove_char (struct current *current, int pos) |
| Removes the char at 'pos'. | |
| static int | insert_char (struct current *current, int pos, int ch) |
| Insert 'ch' at position 'pos'. | |
| static int | remove_chars (struct current *current, int pos, int n) |
| Returns 0 if no chars were removed or non-zero otherwise. | |
| static void | beep () |
| static void | freeCompletions (linenoiseCompletions *lc) |
| static int | completeLine (struct current *current, int c) |
| void | linenoiseSetCompletionCallback (linenoiseCompletionCallback *fn) |
| void | linenoiseAddCompletion (linenoiseCompletions *lc, const char *str) |
| static int | linenoisePrompt (struct current *current) |
| static void | current_nonblock (struct current *current, int nonblock) |
| char * | linenoise_nb (const char *prompt) |
| void | linenoise_nb_clean (void) |
| int | linenoise_nb_eol (void) |
| char * | linenoise (const char *prompt) |
| int | linenoiseHistoryAdd (const char *line) |
| int | linenoiseHistorySetMaxLen (int len) |
| int | linenoiseHistorySave (const char *filename) |
| int | linenoiseHistoryLoad (const char *filename) |
| char ** | linenoiseHistory (int *len) |
Variables | |
| static int | history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN |
| static int | history_len = 0 |
| static char ** | history = NULL |
| static int | rawmode = 0 |
| static struct termios | orig_termios |
| static int | atexit_registered = 0 |
| static const char * | unsupported_term [] = {"dumb","cons25",NULL} |
| static linenoiseCompletionCallback * | completionCallback = NULL |
| static struct ctx | nb_ctx |
| #define ctrl | ( | C | ) | ((C) - '@') |
| #define HAVE_UNISTD_H |
| #define IGNORE_RC | ( | EXPR | ) | if (EXPR) {} |
| #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 |
| #define LINENOISE_MAX_LINE 4096 |
| #define USE_TERMIOS |
| anonymous enum |
|
static |
|
static |
If escape (27) was received, reads subsequent chars to determine if this is a known special key.
Returns SPECIAL_NONE if unrecognised, or -1 if EOF.
If no additional char is received within a short time, 27 is returned.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Reads a complete utf-8 character and returns the unicode value, or -1 on error.
|
static |
Reads a char from 'fd', waiting at most 'timeout' milliseconds.
A timeout of -1 means to wait forever.
Returns -1 if no char is received within the time or an error occurs.
|
static |
|
static |
Returns the unicode character at the given offset, or -1 if none.
|
static |
|
static |
|
static |
Insert 'ch' at position 'pos'.
Returns 1 if the line needs to be refreshed, 2 if not and 0 if nothing was inserted (no room)
|
static |
| char* linenoise | ( | const char * | prompt | ) |
| char* linenoise_nb | ( | const char * | prompt | ) |
| void linenoise_nb_clean | ( | void | ) |
| int linenoise_nb_eol | ( | void | ) |
| void linenoiseAddCompletion | ( | linenoiseCompletions * | lc, |
| const char * | str | ||
| ) |
|
static |
| char** linenoiseHistory | ( | int * | len | ) |
| int linenoiseHistoryAdd | ( | const char * | line | ) |
| void linenoiseHistoryFree | ( | void | ) |
| int linenoiseHistoryLoad | ( | const char * | filename | ) |
| int linenoiseHistorySave | ( | const char * | filename | ) |
| int linenoiseHistorySetMaxLen | ( | int | len | ) |
|
static |
| void linenoiseSetCompletionCallback | ( | linenoiseCompletionCallback * | fn | ) |
|
static |
|
static |
|
static |
|
static |
Removes the char at 'pos'.
Returns 1 if the line needs to be refreshed, 2 if not and 0 if nothing was removed
|
static |
Returns 0 if no chars were removed or non-zero otherwise.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
1.8.1.1