Module | RbReadline |
In: |
lib/rbreadline/version.rb
lib/rbreadline.rb |
RB_READLINE_VERSION | = | "0.5.1" | ||
RL_LIBRARY_VERSION | = | "5.2" | ||
RL_READLINE_VERSION | = | 0x0502 | ||
EOF | = | "\xFF" | ||
ESC | = | "\C-[" | ||
PAGE | = | "\C-L" | ||
SPACE | = | "\x20" | ||
RETURN | = | "\C-M" | ||
ABORT_CHAR | = | "\C-G" | ||
TAB | = | "\t" | ||
RUBOUT | = | "\x7f" | ||
NEWLINE | = | "\n" | ||
DEFAULT_BUFFER_SIZE | = | 256 | ||
DEFAULT_MAX_KILLS | = | 10 | ||
MB_FIND_NONZERO | = | 1 | ||
MB_FIND_ANY | = | 0 | ||
MB_LEN_MAX | = | 4 | ||
DEFAULT_INPUTRC | = | "~/.inputrc" | ||
SYS_INPUTRC | = | "/etc/inputrc" | ||
UpCase | = | 1 | ||
DownCase | = | 2 | ||
CapCase | = | 3 | ||
EVENT_NOT_FOUND | = | 0 | Possible history errors passed to hist_error. | |
BAD_WORD_SPEC | = | 1 | ||
SUBST_FAILED | = | 2 | ||
BAD_MODIFIER | = | 3 | ||
NO_PREV_SUBST | = | 4 | ||
ANCHORED_SEARCH | = | 1 | Possible definitions for history starting point specification. | |
NON_ANCHORED_SEARCH | = | 0 | ||
HISTORY_APPEND | = | 0 | Possible definitions for what style of writing the history file we want. | |
HISTORY_OVERWRITE | = | 1 | ||
READERR | = | 0xFE.chr |
Input error; can be returned by (*rl_getc_function) if readline is reading
a top-level command (RL_ISSTATE (RL_STATE_READCMD)). |
|
RL_PROMPT_START_IGNORE | = | 1.chr | Definitions available for use by readline clients. | |
RL_PROMPT_END_IGNORE | = | 2.chr | ||
NO_MATCH | = | 0 |
Possible values for do_replace argument to rl_filename_quoting_function,
called by rl_complete_internal. |
|
SINGLE_MATCH | = | 1 | ||
MULT_MATCH | = | 2 | ||
NUM_SAWMINUS | = | 0x01 | Callback data for reading numeric arguments | |
NUM_SAWDIGITS | = | 0x02 | ||
NUM_READONE | = | 0x04 | ||
KSEQ_DISPATCHED | = | 0x01 |
A context for reading key sequences longer than a single character when
using the callback interface. |
|
KSEQ_SUBSEQ | = | 0x02 | ||
KSEQ_RECURSIVE | = | 0x04 | ||
RL_STATE_NONE | = | 0x000000 | Possible state values for rl_readline_state | |
RL_STATE_INITIALIZING | = | 0x000001 | ||
RL_STATE_INITIALIZED | = | 0x000002 | ||
RL_STATE_TERMPREPPED | = | 0x000004 | ||
RL_STATE_READCMD | = | 0x000008 | ||
RL_STATE_METANEXT | = | 0x000010 | ||
RL_STATE_DISPATCHING | = | 0x000020 | ||
RL_STATE_MOREINPUT | = | 0x000040 | ||
RL_STATE_ISEARCH | = | 0x000080 | ||
RL_STATE_NSEARCH | = | 0x000100 | ||
RL_STATE_SEARCH | = | 0x000200 | ||
RL_STATE_NUMERICARG | = | 0x000400 | ||
RL_STATE_MACROINPUT | = | 0x000800 | ||
RL_STATE_MACRODEF | = | 0x001000 | ||
RL_STATE_OVERWRITE | = | 0x002000 | ||
RL_STATE_COMPLETING | = | 0x004000 | ||
RL_STATE_SIGHANDLER | = | 0x008000 | ||
RL_STATE_UNDOING | = | 0x010000 | ||
RL_STATE_INPUTPENDING | = | 0x020000 | ||
RL_STATE_TTYCSAVED | = | 0x040000 | ||
RL_STATE_CALLBACK | = | 0x080000 | ||
RL_STATE_VIMOTION | = | 0x100000 | ||
RL_STATE_MULTIKEY | = | 0x200000 | ||
RL_STATE_VICMDONCE | = | 0x400000 | ||
RL_STATE_DONE | = | 0x800000 | ||
NO_BELL | = | 0 | ||
AUDIBLE_BELL | = | 1 | ||
VISIBLE_BELL | = | 2 | ||
UNDO_END | = | 0,1,2,3 | ||
FTO | = | 1 | Definitions used when searching the line for characters. NOTE: it is necessary that opposite directions are inverses | |
BTO | = | -1 | ||
FFIND | = | 2 | ||
BFIND | = | -2 | ||
RL_QF_SINGLE_QUOTE | = | 0x01 |
Possible values for the found_quote flags word used by the completion
functions. It says what kind of (shell-like) quoting we found anywhere in the line. |
|
RL_QF_DOUBLE_QUOTE | = | 0x02 | ||
RL_QF_BACKSLASH | = | 0x04 | ||
RL_QF_OTHER_QUOTE | = | 0x08 | ||
KEYMAP_SIZE | = | 257 | ||
ANYOTHERKEY | = | KEYMAP_SIZE-1 | ||
RL_IM_INSERT | = | 1 | ||
RL_IM_OVERWRITE | = | 0 | ||
RL_IM_DEFAULT | = | RL_IM_INSERT | ||
ISFUNC | = | 0 | ||
ISKMAP | = | 1 | ||
ISMACR | = | 2 | ||
HISTORY_WORD_DELIMITERS | = | " \t\n;&()|<>" | ||
HISTORY_QUOTE_CHARACTERS | = | "\"'`" | ||
RL_SEARCH_ISEARCH | = | 0x01 | ||
RL_SEARCH_NSEARCH | = | 0x02 | ||
RL_SEARCH_CSEARCH | = | 0x04 | ||
SF_REVERSE | = | 0x01 | search flags | |
SF_FOUND | = | 0x02 | ||
SF_FAILED | = | 0x04 | ||
XOK | = | 1 | ||
STD_OUTPUT_HANDLE | = | -11 | ||
STD_INPUT_HANDLE | = | -10 | ||
KEY_EVENT | = | 1 | ||
VK_SHIFT | = | 0x10 | ||
VK_MENU | = | 0x12 | ||
VK_LMENU | = | 0xA4 | ||
VK_RMENU | = | 0xA5 | ||
LEFT_CTRL_PRESSED | = | 0x0008 | ||
RIGHT_CTRL_PRESSED | = | 0x0004 | ||
LEFT_ALT_PRESSED | = | 0x0002 | ||
RIGHT_ALT_PRESSED | = | 0x0001 |
history_base | [RW] | |
history_length | [RW] | |
rl_attempted_completion_function | [RW] | |
rl_attempted_completion_over | [RW] | |
rl_basic_quote_characters | [RW] | |
rl_basic_word_break_characters | [RW] | |
rl_completer_quote_characters | [RW] | |
rl_completer_word_break_characters | [RW] | |
rl_completion_append_character | [RW] | |
rl_deprep_term_function | [RW] | |
rl_event_hook | [RW] | |
rl_filename_quote_characters | [RW] | |
rl_instream | [RW] | |
rl_library_version | [RW] | |
rl_outstream | [RW] | |
rl_point | [RW] | |
rl_readline_name | [RW] |
Fix up point so that it is within the line boundaries after killing
text. If FIX_MARK_TOO is non-zero, the mark is forced within line boundaries also.
adjust pointed byte and find mbstate of the point of string.
adjusted point will be point <= adjusted_point, and returns differences of the byte(adjusted_point - point). if point is invalied (point < 0 || more than string length), it returns -1
Process C as part of the current numeric argument. Return -1 if the
argument should be aborted, 0 if we should not read any more chars, and 1 if we should continue to read chars.
compare the specified two characters. If the characters matched,
return true. Otherwise return false.
Add TEXT to the kill ring, allocating a new kill ring slot as necessary.
This uses TEXT directly, so the caller must not free it. If APPEND is non-zero, and the last command was a kill, the text is appended to the current kill ring slot, otherwise prepended.
return the `current display line’ of the cursor — the number of lines to
move up to get to the first screen line of the current readline line.
Do the command associated with KEY in MAP.
If the associated command is really a keymap, then read another key, and dispatch into that map.
Find next `count’ characters started byte point of the specified seed.
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte characters.
Find previous character started byte point of the specified seed.
Returned point will be point <= seed. If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte characters.
return the number of bytes parsed from the multibyte sequence starting at src, if a non-L’\0’ wide character was recognized. It returns 0, if a L’\0’ wide character was recognized. It returns (size_t)(-1), if an invalid multibyte sequence was encountered. It returns (size_t)(-2) if it couldn‘t parse a complete multibyte character.
Get readline‘s idea of the screen size. TTY is a file descriptor open
to the terminal. If IGNORE_ENV is true, we do not pay attention to the values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being non-null serve to check whether or not we have initialized termcap.
Insert the character C at the current location, moving point forward.
If C introduces a multibyte sequence, we read the whole sequence and then insert the multibyte char into the line buffer.
Process just-read character C according to isearch context CXT. Return
-1 if the caller should just free the context and return, 0 if we should break out of the loop, and 1 if we should continue to read characters.
Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.
(Well, when we don't have multibyte characters, _rl_last_c_pos is a buffer index.) DATA is the contents of the screen line of interest; i.e., where the movement is being done.
Process just-read character C according to search context CXT. Return -1
if the caller should abort the search, 0 if we should break out of the loop, and 1 if we should continue to read characters.
Perform one search according to CXT, using NONINC_SEARCH_STRING. Return
-1 if the search should be aborted, any other value means to clean up using _rl_nsearch_cleanup (). Returns 1 if the search was successful, 0 otherwise.
Overwrite the character at point (or next COUNT characters) with C.
If C introduces a multibyte character sequence, read the entire sequence before starting the overwrite loop.
This is different from what vi does, so the code‘s not shared. Emacs
rubout in overwrite mode has one oddity: it replaces a control character that's displayed as two characters (^X) with two spaces.
Read a multibyte-character string whose first character is FIRST into
the buffer MB of length MLEN. Returns the last character read, which may be FIRST. Used by the search functions, among others. Very similar to _rl_read_mbchar.
Replace the contents of the line buffer between START and END with
TEXT. The operation is undoable. To replace the entire line in an undoable mode, use _rl_replace_text(text, 0, rl_end)
Stuff KEY into the front of the input buffer.
Returns non-zero if successful, zero if there is no space left in the buffer.
Append any necessary closing quote and a separator character to the just-inserted match. If the user has specified that directories should be marked by a trailing `/’, append one of those instead. The default trailing character is a space. Returns the number of characters appended. If NONTRIVIAL_MATCH is set, we test for a symlink (if the OS has them) and don‘t add a suffix for a symlink to a directory. A nontrivial match is one that actually adds to the word being completed. The variable rl_completion_mark_symlink_dirs controls this behavior (it‘s initially set to the what the user has chosen, indicated by the value of _rl_complete_mark_symlink_dirs, but may be modified by an application‘s completion function).
Try and bind the common arrow key prefixes after giving termcap and
the inputrc file a chance to bind them and create `real' keymaps for the arrow key prefix.
Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer.
Display MATCHES, a list of matching filenames in argv format. This handles the simple case — a single match — first. If there is more than one match, we compute the number of strings in the list and the length of the longest string, which will be needed by the display function. If the application wants to handle displaying the list of matches itself, it sets RL_COMPLETION_DISPLAY_MATCHES_HOOK to the address of a function, and we just call it. If we‘re handling the display ourselves, we just call rl_display_match_list. We also check that the list of matches doesn‘t exceed the user-settable threshold, and ask the user if he wants to see the list if there are more matches than RL_COMPLETION_QUERY_ITEMS.
Current implementation:
\001 (^A) start non-visible characters \002 (^B) end non-visible characters all characters except \001 and \002 (following a \001) are copied to the returned string all characters except those between \001 and \002 are assumed to be `visible'.
Return the history entry which is logically at OFFSET in the history array.
OFFSET is relative to history_base.
Search for STRING in the history list. DIR is < 0 for searching
backwards. POS is an absolute index into the history list at which point to begin searching.
Make the current history item be the one at POS, an absolute index.
Returns zero if POS is out of range, else non-zero.
Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is increased. If the lines have already been allocated, this ensures that they can hold at least MINSIZE characters.
Make the data from the history entry ENTRY be the contents of the
current line. This doesn't do anything with rl_point; the caller must set it.
Move history_offset forward to the next history entry, and return
a pointer to that entry. If there is no next entry then return a NULL pointer.
Search for a line in the history containing STRING. If DIR is < 0, the
search is backwards through previous entries, else through subsequent entries. Returns 1 if the search was successful, 0 otherwise.
Search non-interactively through the history list. DIR < 0 means to
search backwards through the history of previous commands; otherwise the search is for commands subsequent to the current position in the history list. PCHAR is the character to use for prompting when reading the search string; if not specified (0), it defaults to `:'.
Search the history list for STRING starting at absolute history position
POS. If STRING begins with `^', the search must match STRING at the beginning of a history line, otherwise a full substring match is performed for STRING. DIR < 0 means to search backwards through the history list, DIR >= 0 means to search forward.
Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry then return a NULL pointer.
Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and we
are using it, check for and output a single character for `special' filenames. Return the number of characters we output.
Return the portion of PATHNAME that should be output when listing
possible completions. If we are hacking filename completion, we are only interested in the basename, the portion following the final slash. Otherwise, we return what we were passed. Since printing empty strings is not very informative, if we're doing filename completion, and the basename is the empty string, we look for the previous slash and return the portion following that. If there's no previous slash, we just return what we were passed.
buffer index in others. This macro is used when deciding whether the current cursor position is in the middle of a prompt string containing invisible characters.
Read a line of input. Prompt with PROMPT. An empty PROMPT means
none. A return value of NULL means that EOF was encountered.
If this system allows us to look at the values of the regular
input editing characters, then bind them to their readline equivalents, iff the characters are not bound to keymaps.
Read a line of input from the global rl_instream, doing output on
the global rl_outstream. If rl_prompt is non-null, then that is our prompt.
Redraw the last line of a multi-line prompt that may possibly contain terminal escape sequences. Called with the cursor at column 0 of the line to draw the prompt on.
Remove history element WHICH from the history. The removed
element is returned to you so you can free the line, data, and containing structure.
Replace the DATA in the specified history entries, replacing OLD with
NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace all of the history entries where entry->data == OLD; WHICH == -2 means to replace the `newest' history entry where entry->data == OLD; and WHICH >= 0 means to replace that particular history entry's data, as long as it matches OLD.
Make the history entry at WHICH have LINE and DATA. This returns
the old entry so you can dispose of the data. In the case of an invalid WHICH, a NULL pointer is returned.
Kill backwards to the start of the line. If DIRECTION is negative, kill
forwards to the line end instead.
Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
now, this is always used to attempt to bind the arrow keys, hence the check for rl_vi_movement_mode.
Bind the key sequence represented by the string KEYSEQ to
FUNCTION. This makes new keymaps as necessary. The initial place to do bindings is in MAP.
The meaty function.
Change the case of COUNT words, performing OP on them. OP is one of UpCase, DownCase, or CapCase. If a negative argument is given, leave point where it started, otherwise, leave it where it moves to.
Clean up the terminal and readline state after catching a signal, before
resending it to the calling application.
C-l typed to a line without quoting clears the screen, and then reprints
the prompt and the current input line. Given a numeric arg, redraw only the current line.
Complete the word at or before point. You have supplied the function
that does the initial simple matching selection algorithm (see rl_completion_matches ()). The default is to do filename completion.
Complete the word at or before point.
WHAT_TO_DO says what to do with the completion. `?' means list the possible completions. TAB means do standard completion. `*' means insert all of the possible completions. `!' means to do standard completion, and list all possible completions if there is more than one. `@' means to do standard completion, and list all possible completions if there is more than one and partial completion is not possible.
Return an array of (char *) which is a list of completions for TEXT.
If there are no completions, return a NULL pointer. The first entry in the returned array is the substitution for TEXT. The remaining entries are the possible completions. The array is terminated with a NULL pointer. ENTRY_FUNCTION is a function of two args, and returns a (char *). The first argument is TEXT. The second is a state argument it should be zero on the first call, and non-zero on subsequent calls. It returns a NULL pointer to the caller when there are no more matches.
Like the tcsh editing function delete-char-or-list. The eof character
is caught before this is invoked, so this really does the same thing as delete-char-or-list-or-eof, as long as it's bound to the eof character.
Delete the string between FROM and TO. FROM is inclusive, TO is not.
Returns the number of characters deleted.
A convenience function for displaying a list of strings in
columnar format on readline's output stream. MATCHES is the list of strings, in argv format, LEN is the number of strings in MATCHES, and MAX is the length of the longest string in MATCHES.
Display the current state of the search in the echo-area.
SEARCH_STRING contains the string that is being searched for, DIRECTION is zero for forward, or non-zero for reverse, WHERE is the history list number of the current line. If it is -1, then this line is the starting one.
What to do for some uppercase characters, like meta characters,
and some characters appearing in emacs_ctlx_keymap. This function is just a stub, you bind keys to it and the code in _rl_dispatch () is special cased.
*
*
*
*
*
Okay, now we write the entry_function for filename completion. In the general case. Note that completion in the shell is a little different because of all the pathnames that must be followed when looking up the completion for a command.
Search forwards through the history looking for a string which is typed
interactively. Start with the current line.
Return the function (or macro) definition which would be invoked via
KEYSEQ if executed in MAP. If MAP is NULL, then the current keymap is used. TYPE, if non-NULL, is a pointer to an int which will receive the type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), or ISMACR (macro).
Bind the key sequence represented by the string KEYSEQ to
the arbitrary pointer DATA. TYPE says what kind of data is pointed to by DATA, right now this can be a function (ISFUNC), a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps as necessary. The initial place to do bindings is in MAP.
Get a key from the buffer of characters to be read.
Return the key in KEY. Result is KEY if there was a key, or 0 if there wasn't.
Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding.
Insert a string of text into the line at point. This is the only
way that you should do insertion. _rl_insert_char () calls this function. Returns the number of characters inserted.
Kill from here to the end of the line. If DIRECTION is negative, kill
back to the line start instead.
The way to kill something. This appends or prepends to the last
kill, if the last command was a kill command. if FROM is less than TO, then the text is appended, otherwise prepended. If the last command was not a kill command, then a new slot is made for this kill.
What to do when a NEWLINE is pressed. We accept the whole line.
KEY is the key that invoked this command. I guess it could have meaning in the future.
Search forward through the history list for a string. If the vi-mode
code calls this, KEY will be `?'.
Tell the update routines that we have moved onto a new line with the
prompt already displayed. Code originally from the version of readline distributed with CLISP. rl_expand_prompt must have already been called (explicitly or implicitly). This still doesn't work exactly right.
Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode.
Read the binding command from STRING and perform it.
A key binding command looks like: Keyname: function-name\0, a variable binding command looks like: set variable value. A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark.
List the possible completions. See description of rl_complete ().
Do key bindings from a file. If FILENAME is NULL it defaults
to the first non-null filename from this list: 1. the filename used for the previous call 2. the value of the shell variable `INPUTRC' 3. ~/.inputrc 4. /etc/inputrc If the file existed and could be opened and read, 0 is returned, otherwise errno is returned.
Replace the current line buffer contents with TEXT. If CLEAR_UNDO is
non-zero, we free the current undo list.
Search backwards through the history looking for a string which is typed
interactively. Start with the current line.
Delete the character under the cursor, unless the insertion
point is at the end of the line, in which case the character behind the cursor is deleted. COUNT is obeyed and may be used to delete forward or backward that many characters.
Search through the history looking for an interactively typed string.
This is analogous to i-search. We start the search in the current line. DIRECTION is which direction to search; >= 0 means forward, < 0 means backwards.
Set up the prompt and expand it. Called from readline() and
rl_callback_handler_install ().
Add KEY to the buffer of characters to be read. Returns 1 if the
character was stuffed correctly; 0 otherwise.
Transpose the characters at point. If point is at the end of the line,
then transpose the characters before point.
Transpose the words at point. If point is at the end of the line,
transpose the two words before point.
New public way to set the system default editing chars to their readline
equivalents.
Rebind all of the tty special chars that readline worries about back
to self-insert. Call this before saving the current terminal special chars with save_tty_chars(). This only works on POSIX termios or termio systems.
This deletes one filename component in a Unix pathname. That is, it
deletes backward to directory separator (`/') or whitespace.
Here is C-u doing what Unix does. You don‘t have to use these key-bindings. We have a choice of killing the entire line, or killing from where we are to the start of the line. We choose the latter, because if you are a Unix weenie, then you haven‘t backspaced into the line at all, and if you aren‘t, then you know what you are doing.
A completion function for usernames.
TEXT contains a partial username preceded by a random character (usually `~').
Yank the COUNTh argument from the previous history line, skipping
HISTORY_SKIP lines before looking for the `previous line'.
If the last command was yank, or yank_pop, and the text just
before point is identical to the current kill item, then delete that text from the line, rotate the index down, and yank back some other text.
Set default values for readline word completion. These are the variables
that application completion functions can change or inspect.
Clear to the end of the line using spaces. COUNT is the minimum
number of character spaces to clear,
Return the character which best describes FILENAME.
`@' for symbolic links `/' for directories `*' for executables `=' for sockets `|' for FIFOs `%' for character special devices `#' for block special devices
Stop stifling the history. This returns the previous maximum
number of history entries. The value is positive if the history was stifled, negative if it wasn't.
PWP: update_line() is based on finding the middle difference of each
line on the screen; vis: /old first difference /beginning of line | /old last same /old EOL v v v v
old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as new: eddie> Oh, my little buggy says to me, as lurgid as
^ ^ ^ ^ \beginning of line | \new last same \new end of line \new first difference All are character pointers for the sake of speed. Special cases for no differences, as well as for end of line additions must be handled. Could be made even smarter, but this works well enough