#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <wchar.h>
#include <ncurses.h>
#include <termio.h>
#include <term.h>
#include <signal.h>
#include <dirent.h>
#include <wctype.h>
#include "fallback.h"
#include "util.h"
#include "wutil.h"
#include "reader.h"
#include "proc.h"
#include "common.h"
#include "sanity.h"
#include "input_common.h"
#include "input.h"
#include "parser.h"
#include "env.h"
#include "expand.h"
#include "event.h"
#include "output.h"
#include "intern.h"
#include "halloc.h"
#include "halloc_util.h"
Data Structures | |
| struct | input_mapping_t |
| Struct representing a keybinding. More... | |
| struct | terminfo_mapping_t |
| A struct representing the mapping from a terminfo key name to a terminfo character sequence. More... | |
Defines | |
| #define | TERMINFO_ADD(key) |
| Add a new terminfo mapping. | |
Functions | |
| static void | input_terminfo_init () |
| Initialize terminfo. | |
| static void | input_terminfo_destroy () |
| Deallocate memory used by terminfo. | |
| void | input_mapping_add (const wchar_t *sequence, const wchar_t *command) |
| Returns the function description for the given function code. | |
| static int | interrupt_handler () |
| Handle interruptions to key reading by reaping finshed jobs and propagating the interrupt to the reader. | |
| int | input_init () |
| Initialize the terminal by calling setupterm, and set up arrays used by readch to detect escape sequences for special keys. | |
| void | input_destroy () |
| free up memory used by terminal functions. | |
| static wint_t | input_exec_binding (input_mapping_t *m, const wchar_t *seq) |
| Perform the action of the specified binding. | |
| static wint_t | input_try_mapping (input_mapping_t *m) |
| Try reading the specified function mapping. | |
| void | input_unreadch (wint_t ch) |
| Push a character or a readline function onto the stack of unread characters that input_readch will return before actually reading from fd 0. | |
| wint_t | input_readch () |
| Read a character from fd 0. | |
| void | input_mapping_get_names (array_list_t *list) |
| Insert all mapping names into the specified array_list_t. | |
| int | input_mapping_erase (const wchar_t *sequence) |
| Erase binding for specified key sequence. | |
| const wchar_t * | input_mapping_get (const wchar_t *sequence) |
| Return the command bound to the specified key sequence. | |
| const wchar_t * | input_terminfo_get_sequence (const wchar_t *name) |
| Return the sequence for the terminfo variable of the specified name. | |
| const wchar_t * | input_terminfo_get_name (const wchar_t *seq) |
| Return the name of the terminfo variable with the specified sequence. | |
| void | input_terminfo_get_names (array_list_t *lst, int skip_null) |
| Return a list of all known terminfo names. | |
| void | input_function_get_names (array_list_t *lst) |
| Returns a list of all existing input function names. | |
| wchar_t | input_function_get_code (const wchar_t *name) |
| Returns the input function code for the given input function name. | |
Variables | |
| static const wchar_t * | name_arr [] |
| Names of all the input functions supported. | |
| static const wchar_t | code_arr [] |
| Description of each supported input function. | |
| static array_list_t | mappings = {0,0,0} |
| Mappings for the current input mode. | |
| static array_list_t * | terminfo_mappings = 0 |
| List of all terminfo mappings. | |
| static int | is_init = 0 |
| Set to one when the input subsytem has been initialized. | |
| #define TERMINFO_ADD | ( | key | ) |
Value:
{ \
terminfo_mapping_t *m = halloc( terminfo_mappings, sizeof( terminfo_mapping_t ) ); \
m->name = halloc_wcsdup( terminfo_mappings, (L ## #key)+4 ); \
m->seq = key; \
al_push( terminfo_mappings, m ); \
}
Referenced by input_terminfo_init().
| int input_init | ( | ) |
Initialize the terminal by calling setupterm, and set up arrays used by readch to detect escape sequences for special keys.
Before calling input_init, terminfo is not initialized and MUST not be used
References _, al_get_count(), debug(), env_get(), input_common_init(), input_mapping_add(), input_terminfo_init(), interrupt_handler, is_init, and output_set_term().
Referenced by input_terminfo_get_name(), input_terminfo_get_names(), input_terminfo_get_sequence(), and reader_interactive_init().
| void input_mapping_add | ( | const wchar_t * | sequence, | |
| const wchar_t * | command | |||
| ) |
Returns the function description for the given function code.
Add a key mapping from the specified sequence to the specified command.
References al_get(), al_get_count(), al_push(), CHECK, input_mapping_t::command, intern(), and input_mapping_t::seq.
Referenced by builtin_bind_add(), and input_init().
| wint_t input_readch | ( | ) |
Read a character from fd 0.
Try to convert some escape sequences into character constants, but do not permanently block the escape character.
This is performed in the same way vim does it, i.e. if an escape character is read, wait for more input for a short time (a few milliseconds). If more input is avaialable, it is assumed to be an escape sequence for a special character (such as an arrow key), and readch attempts to parse it. If no more input follows after the escape key, it is assumed to be an actual escape key press, and is returned as such.
References al_get(), al_get_count(), CHECK_BLOCK, input_common_readch(), input_exec_binding(), input_try_mapping(), R_NULL, reader_interrupted(), and input_mapping_t::seq.
Referenced by reader_readline().
| static void input_terminfo_destroy | ( | ) | [static] |
Deallocate memory used by terminfo.
Or at least try to. Terminfo leaks.
References halloc_free().
Referenced by input_destroy().
| const wchar_t* input_terminfo_get_sequence | ( | const wchar_t * | name | ) |
Return the sequence for the terminfo variable of the specified name.
If no terminfo variable of the specified name could be found, return 0 and set errno to ENOENT. If the terminfo variable does not have a value, return 0 and set errno to EILSEQ.
References al_get(), al_get_count(), buffer::buff, buff, CHECK, err(), global_context, input_init(), terminfo_mapping_t::name, sb_clear(), sb_halloc(), sb_printf(), and terminfo_mapping_t::seq.
Referenced by builtin_bind_add().
| static void input_terminfo_init | ( | ) | [static] |
Initialize terminfo.
Add all terminfo mappings.
References al_halloc(), and TERMINFO_ADD.
Referenced by input_init().
const wchar_t code_arr[] [static] |
Description of each supported input function.
Internal code for each supported input function
Referenced by input_function_get_code().
1.5.6