41 #define READLINE_MAX 1024 49 unsigned int mod_start =
string->mod_start;
50 unsigned int mod_end =
string->mod_end;
51 unsigned int cursor =
string->last_cursor;
59 if ( mod_end < string->cursor )
75 while ( cursor >
string->cursor ) {
94 sizeof ( history->
entries[0] ) ) );
106 unsigned int depth ) {
124 unsigned int depth,
const char *
string ) {
132 DBGC ( history,
"READLINE %p could not store string\n",
152 int offset,
const char *old_string ) {
153 unsigned int new_depth = ( history->
depth +
offset );
154 const char * new_string =
history_fetch ( history, new_depth );
166 history->
depth = new_depth;
179 const char *
string ) {
186 if ( !
entry->string ) {
188 DBGC ( history,
"READLINE %p could not append string\n",
212 for ( i = 0 ; i < (
sizeof ( history->
entries ) /
213 sizeof ( history->
entries[0] ) ) ; i++ ) {
237 for ( i = 0 ; i < (
sizeof ( history->
entries ) /
238 sizeof ( history->
entries[0] ) ) ; i++ ) {
265 const char *new_string;
284 memset ( &
string, 0,
sizeof (
string ) );
333 if ( move_by && history ) {
346 if ( *line && (*line)[0] )
int getkey(unsigned long timeout)
Get single keypress.
struct arbelprm_rc_send_wqe rc
int printf(const char *fmt,...)
Write a formatted string to the console.
unsigned int depth
Current depth within history buffer.
static void history_store(struct readline_history *history, unsigned int depth, const char *string)
Write temporary string copy to history buffer.
static struct readline_history_entry * history_entry(struct readline_history *history, unsigned int depth)
Locate history entry.
struct readline_history_entry entries[READLINE_HISTORY_MAX_DEPTH+1]
History entries.
static const char * history_move(struct readline_history *history, int offset, const char *old_string)
Move to new history depth.
void replace_string(struct edit_string *string, const char *replacement)
Replace editable string.
static void history_cleanup(struct readline_history *history)
Clean up history after editing.
int edit_string(struct edit_string *string, int key)
Edit editable string.
#define ECANCELED
Operation canceled.
char * temp
Temporary copy of string.
#define KEY_DOWN
Down arrow.
#define ENOMEM
Not enough space.
static void sync_console(struct edit_string *string)
Synchronise console with edited string.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void init_editstring(struct edit_string *string, char *buf, size_t len)
Initialise editable string.
#define READLINE_HISTORY_MAX_DEPTH
Maximum depth of a readline history buffer.
static userptr_t size_t offset
Offset of the first segment within the content.
unsigned int next
Position of next entry within buffer.
static void(* free)(struct refcnt *refcnt))
union aes_table_entry entry[256]
Table entries, indexed by S(N)
A readline history buffer.
void * zalloc(size_t size)
Allocate cleared memory.
char * strdup(const char *src)
Duplicate string.
size_t strlen(const char *src)
Get length of string.
int readline_history(const char *prompt, const char *prefill, struct readline_history *history, unsigned long timeout, char **line)
Read line from console (with history)
int prompt(const char *text, unsigned long timeout, int key)
Prompt for keypress.
char * readline(const char *prompt)
Read line from console.
void history_free(struct readline_history *history)
Free history buffer.
static void history_append(struct readline_history *history, const char *string)
Append new history entry.
static const char * history_fetch(struct readline_history *history, unsigned int depth)
Read string from history buffer.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
A readline history entry.
#define NULL
NULL pointer (VOID *)
int putchar(int character)
Write a single character to each console device.
#define ETIMEDOUT
Connection timed out.
struct bofm_section_header done
void * memset(void *dest, int character, size_t len) __nonnull
char * buf
Buffer for string.