📄 libtecla.h
字号:
* of completions. * Output * return int 0 - Ignore this file. * 1 - Do include this file in the list * of completions. */#define CPL_CHECK_FN(fn) int (fn)(void *data, const char *pathname)typedef CPL_CHECK_FN(CplCheckFn);/* * You can use the following CplCheckFn callback function to only * have executables included in a list of completions. */CPL_CHECK_FN(cpl_check_exe);/* * cpl_file_completions() is the builtin filename completion callback * function. This can also be called by your own custom CPL_MATCH_FN() * callback functions. To do this pass on all of the arguments of your * custom callback function to cpl_file_completions(), with the exception * of the (void *data) argument. The data argument should either be passed * NULL to request the default behaviour of the file-completion function, * or be passed a pointer to a CplFileConf structure (see below). In the * latter case the contents of the structure modify the behavior of the * file-completer. */CPL_MATCH_FN(cpl_file_completions);/* * Objects of the following type can be used to change the default * behavior of the cpl_file_completions() callback function. */typedef struct CplFileConf CplFileConf;/* * If you want to change the behavior of the cpl_file_completions() * callback function, call the following function to allocate a * configuration object, then call one or more of the subsequent * functions to change any of the default configuration parameters * that you don't want. This function returns NULL when there is * insufficient memory. */CplFileConf *new_CplFileConf(void);/* * If backslashes in the prefix being passed to cpl_file_completions() * should be treated as literal characters, call the following function * with literal=1. Otherwise the default is to treat them as escape * characters which remove the special meanings of spaces etc.. */void cfc_literal_escapes(CplFileConf *cfc, int literal);/* * Before calling cpl_file_completions(), call this function if you * know the index at which the filename prefix starts in the input line. * Otherwise by default, or if you specify start_index to be -1, the * filename is taken to start after the first unescaped space preceding * the cursor, or the start of the line, which ever comes first. */void cfc_file_start(CplFileConf *cfc, int start_index);/* * If you only want certain types of files to be included in the * list of completions, use the following function to specify a * callback function which will be called to ask whether a given file * should be included. The chk_data argument is will be passed to the * callback function whenever it is called and can be anything you want. */void cfc_set_check_fn(CplFileConf *cfc, CplCheckFn *chk_fn, void *chk_data);/* * The following function deletes a CplFileConf objects previously * returned by new_CplFileConf(). It always returns NULL. */CplFileConf *del_CplFileConf(CplFileConf *cfc);/* * The following configuration structure is deprecated. Do not change * its contents, since this will break any programs that still use it, * and don't use it in new programs. Instead use opaque CplFileConf * objects as described above. cpl_file_completions() figures out * what type of structure you pass it, by virtue of a magic int code * placed at the start of CplFileConf object by new_CplFileConf(). */typedef struct { int escaped; /* Opposite to the argument of cfc_literal_escapes() */ int file_start; /* Equivalent to the argument of cfc_file_start() */} CplFileArgs;/* * This initializes the deprecated CplFileArgs structures. */void cpl_init_FileArgs(CplFileArgs *cfa);/*....................................................................... * When an error occurs while performing a completion, custom completion * callback functions should register a terse description of the error * by calling cpl_record_error(). This message will then be returned on * the next call to cpl_last_error() and used by getline to display an * error message to the user. * * Input: * cpl WordCompletion * The string-completion resource object that was * originally passed to the callback. * errmsg const char * The description of the error. */void cpl_record_error(WordCompletion *cpl, const char *errmsg);/*....................................................................... * This function can be used to replace the builtin filename-completion * function with one of the user's choice. The user's completion function * has the option of calling the builtin filename-completion function * if it believes that the token that it has been presented with is a * filename (see cpl_file_completions() above). * * Input: * gl GetLine * The resource object of the command-line input * module. * data void * This is passed to match_fn() whenever it is * called. It could, for example, point to a * symbol table that match_fn() would look up * matches in. * match_fn CplMatchFn * The function that will identify the prefix * to be completed from the input line, and * report matching symbols. * Output: * return int 0 - OK. * 1 - Error. */int gl_customize_completion(GetLine *gl, void *data, CplMatchFn *match_fn);/*....................................................................... * Change the terminal (or stream) that getline interacts with. * * Input: * gl GetLine * The resource object of the command-line input * module. * input_fp FILE * The stdio stream to read from. * output_fp FILE * The stdio stream to write to. * term const char * The terminal type. This can be NULL if * either or both of input_fp and output_fp don't * refer to a terminal. Otherwise it should refer * to an entry in the terminal information database. * Output: * return int 0 - OK. * 1 - Error. */int gl_change_terminal(GetLine *gl, FILE *input_fp, FILE *output_fp, const char *term);/*....................................................................... * The following functions can be used to save and restore the contents * of the history buffer. * * Input: * gl GetLine * The resource object of the command-line input * module. * filename const char * The name of the new file to write to. * comment const char * Extra information such as timestamps will * be recorded on a line started with this * string, the idea being that the file can * double as a command file. Specify "" if * you don't care. Be sure to specify the * same string to both functions. * max_lines int The maximum number of lines to save, or -1 * to save all of the lines in the history * list. * Output: * return int 0 - OK. * 1 - Error. */int gl_save_history(GetLine *gl, const char *filename, const char *comment, int max_lines);int gl_load_history(GetLine *gl, const char *filename, const char *comment);/* * Enumerate file-descriptor events that can be waited for. */typedef enum { GLFD_READ, /* Watch for data waiting to be read from a file descriptor */ GLFD_WRITE, /* Watch for ability to write to a file descriptor */ GLFD_URGENT /* Watch for urgent out-of-band data on the file descriptor */} GlFdEvent;/* * The following enumeration is used for the return status of file * descriptor event callbacks. */typedef enum { GLFD_ABORT, /* Cause gl_get_line() to abort with an error */ GLFD_REFRESH, /* Redraw the input line and continue waiting for input */ GLFD_CONTINUE /* Continue to wait for input, without redrawing the line */} GlFdStatus;/*....................................................................... * While gl_get_line() is waiting for terminal input, it can also be * asked to listen for activity on arbitrary file descriptors. * Callback functions of the following type can be registered to be * called when activity is seen. If your callback needs to write to * the terminal or use signals, please see the gl_get_line(3) man * page. * * Input: * gl GetLine * The gl_get_line() resource object. You can use * this safely to call gl_watch_fd() or * gl_watch_time(). The effect of calling other * functions that take a gl argument is undefined, * and must be avoided. * data void * A pointer to arbitrary callback data, as originally * registered with gl_watch_fd(). * fd int The file descriptor that has activity. * event GlFdEvent The activity seen on the file descriptor. The * inclusion of this argument allows the same * callback to be registered for multiple events. * Output: * return GlFdStatus GLFD_ABORT - Cause gl_get_line() to abort with * an error (set errno if you need it). * GLFD_REFRESH - Redraw the input line and continue * waiting for input. Use this if you * wrote something to the terminal. * GLFD_CONTINUE - Continue to wait for input, without * redrawing the line. */#define GL_FD_EVENT_FN(fn) GlFdStatus (fn)(GetLine *gl, void *data, int fd, \ GlFdEvent event)typedef GL_FD_EVENT_FN(GlFdEventFn);/*....................................................................... * Where possible, register a function and associated data to be called * whenever a specified event is seen on a file descriptor. * * Input: * gl GetLine * The resource object of the command-line input * module. * fd int The file descriptor to watch. * event GlFdEvent The type of activity to watch for. * callback GlFdEventFn * The function to call when the specified * event occurs. Setting this to 0 removes * any existing callback. * data void * A pointer to arbitrary data to pass to the * callback function. * Output: * return int 0 - OK. * 1 - Either gl==NULL, or this facility isn't * available on the the host system * (ie. select() isn't available). No * error message is generated in the latter * case. */int gl_watch_fd(GetLine *gl, int fd, GlFdEvent event, GlFdEventFn *callback, void *data);/*....................................................................... * Switch history streams. History streams represent separate history * lists recorded within a single history buffer. Different streams * are distinguished by integer identifiers chosen by the calling * appplicaton. Initially new_GetLine() sets the stream identifier to * 0. Whenever a new line is appended to the history list, the current * stream identifier is recorded with it, and history lookups only * consider lines marked with the current stream identifier. * * Input: * gl GetLine * The resource object of gl_get_line(). * id unsigned The new history stream identifier. * Output: * return int 0 - OK. * 1 - Error. */int gl_group_history(GetLine *gl, unsigned id);/*....................................................................... * Display the contents of the history list. * * Input: * gl GetLine * The resource object of gl_get_line(). * fp FILE * The stdio output stream to write to. * fmt const char * A format string. This containing characters to be * written verbatim, plus any of the following * format directives: * %D - The date, formatted like 2001-11-20 * %T - The time of day, formatted like 23:59:59 * %N - The sequential entry number of the * line in the history buffer. * %G - The number of the history group that * the line belongs to. * %% - A literal % character. * %H - The history line itself. * Note that a '\n' newline character is not * appended by default. * all_groups int If true, display history lines from all * history groups. Otherwise only display * those of the current history group. * max_lines int If max_lines is < 0, all available lines * are displayed. Otherwise only the most * recent max_lines lines will be displayed. * Output: * return int 0 - OK. * 1 - Error. */int gl_show_history(GetLine *gl, FILE *fp, const char *fmt, int all_groups, int max_lines);/*....................................................................... * Resize or delete the history buffer. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -