iPXE
|
Editable strings. More...
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <ipxe/keys.h>
#include <ipxe/editstring.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | insert_delete (struct edit_string *string, size_t delete_len, const char *insert_text) |
Insert and/or delete text within an editable string. More... | |
static void | insert_character (struct edit_string *string, unsigned int character) |
Insert character at current cursor position. More... | |
static void | delete_character (struct edit_string *string) |
Delete character at current cursor position. More... | |
static void | backspace (struct edit_string *string) |
Delete character to left of current cursor position. More... | |
static void | previous_word (struct edit_string *string) |
Move to start of previous word. More... | |
static void | kill_word (struct edit_string *string) |
Delete to end of previous word. More... | |
static void | kill_sol (struct edit_string *string) |
Delete to start of line. More... | |
static void | kill_eol (struct edit_string *string) |
Delete to end of line. More... | |
void | replace_string (struct edit_string *string, const char *replacement) |
Replace editable string. More... | |
int | edit_string (struct edit_string *string, int key) |
Edit editable string. More... | |
Editable strings.
Definition in file editstring.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Insert and/or delete text within an editable string.
string | Editable string |
delete_len | Length of text to delete from current cursor position |
insert_text | Text to insert at current cursor position, or NULL |
Definition at line 57 of file editstring.c.
References assert(), memcpy(), memmove(), string, and strlen().
Referenced by delete_character(), insert_character(), kill_eol(), kill_sol(), kill_word(), and replace_string().
|
static |
Insert character at current cursor position.
string | Editable string |
character | Character to insert |
Definition at line 93 of file editstring.c.
References insert_delete().
Referenced by edit_string().
|
static |
Delete character at current cursor position.
string | Editable string |
Definition at line 104 of file editstring.c.
References insert_delete(), and NULL.
Referenced by backspace(), and edit_string().
|
static |
Delete character to left of current cursor position.
string | Editable string |
Definition at line 113 of file editstring.c.
References delete_character(), and string.
Referenced by edit_string().
|
static |
Move to start of previous word.
string | Editable string |
Definition at line 125 of file editstring.c.
References isspace(), and string.
Referenced by kill_word().
|
static |
Delete to end of previous word.
string | Editable string |
Definition at line 141 of file editstring.c.
References insert_delete(), NULL, previous_word(), and string.
Referenced by edit_string().
|
static |
Delete to start of line.
string | Editable string |
Definition at line 152 of file editstring.c.
References insert_delete(), and NULL.
Referenced by edit_string().
|
static |
Delete to end of line.
string | Editable string |
Definition at line 163 of file editstring.c.
References insert_delete(), and NULL.
Referenced by edit_string().
void replace_string | ( | struct edit_string * | string, |
const char * | replacement | ||
) |
Replace editable string.
string | Editable string |
replacement | Replacement string |
Definition at line 173 of file editstring.c.
References insert_delete().
Referenced by readline_history().
int edit_string | ( | struct edit_string * | string, |
int | key | ||
) |
Edit editable string.
string | Editable string |
key | Key pressed by user |
key | Key returned to application, or zero |
Handles keypresses and updates the content of the editable string. Basic line editing facilities (delete/insert/cursor) are supported. If edit_string() understands and uses the keypress it will return zero, otherwise it will return the original key.
This function does not update the display in any way.
The string's edit history will be updated to allow the caller to efficiently bring the display into sync with the string content.
Definition at line 195 of file editstring.c.
References backspace(), CTRL_A, CTRL_B, CTRL_D, CTRL_E, CTRL_F, CTRL_K, CTRL_U, CTRL_W, delete_character(), insert_character(), key, KEY_BACKSPACE, KEY_DC, KEY_END, KEY_HOME, KEY_LEFT, KEY_RIGHT, kill_eol(), kill_sol(), kill_word(), len, retval, string, and strlen().
Referenced by edit_editbox(), and readline_history().