iPXE
|
Editable strings. More...
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.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 | __attribute__ ((nonnull(1))) |
static int | 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... | |
int | 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 |
Definition at line 40 of file editstring.c.
References assert(), ENOMEM, memcpy(), memmove(), realloc(), string, strlen(), and tmp.
|
static |
Insert character at current cursor position.
string | Editable string |
character | Character to insert |
rc | Return status code |
Definition at line 118 of file editstring.c.
Referenced by edit_string().
|
static |
Delete character at current cursor position.
string | Editable string |
Definition at line 130 of file editstring.c.
References assert(), NULL, rc, and string.
Referenced by backspace(), and edit_string().
|
static |
Delete character to left of current cursor position.
string | Editable string |
Definition at line 142 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 155 of file editstring.c.
References isspace().
Referenced by kill_word().
|
static |
Delete to end of previous word.
string | Editable string |
Definition at line 173 of file editstring.c.
References assert(), NULL, previous_word(), rc, and string.
Referenced by edit_string().
|
static |
Delete to start of line.
string | Editable string |
Definition at line 187 of file editstring.c.
References assert(), NULL, rc, and string.
Referenced by edit_string().
|
static |
Delete to end of line.
string | Editable string |
Definition at line 201 of file editstring.c.
References assert(), NULL, rc, and string.
Referenced by edit_string().
int replace_string | ( | struct edit_string * | string, |
const char * | replacement | ||
) |
Replace editable string.
string | Editable string |
replacement | Replacement string, or NULL to empty the string |
rc | Return status code |
Replace the entire content of the editable string and update the edit history to allow the caller to bring the display into sync with the string content.
This function does not itself update the display in any way.
Upon success, the string buffer is guaranteed to be non-NULL (even if the replacement string is NULL or empty).
Errors may safely be ignored if it is deemed that subsequently failing to update the display will provide sufficient feedback to the user.
Definition at line 228 of file editstring.c.
References replacement.
Referenced by editstring_okx(), and 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, zero, or negative error |
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.
The string's edit history will be updated to allow the caller to efficiently bring the display into sync with the string content.
This function does not itself update the display in any way.
Errors may safely be ignored if it is deemed that subsequently failing to update the display will provide sufficient feedback to the user.
Definition at line 255 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().