48 unsigned int mod_start =
string->mod_start;
49 unsigned int mod_end =
string->mod_end;
50 unsigned int cursor =
string->last_cursor;
51 const char *buf = *(
string->buf);
59 if ( mod_end < string->cursor )
70 putchar ( ( cursor >=
len ) ?
' ' : buf[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 ) {
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++ ) {
264 const char *new_string;
276 memset ( &
string, 0,
sizeof (
string ) );
318 if ( move_by && history ) {
333 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.
int replace_string(struct edit_string *string, const char *replacement)
Replace editable string.
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.
struct arbelprm_completion_with_error error
static const char * history_move(struct readline_history *history, int offset, const char *old_string)
Move to new history depth.
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.
static void sync_console(struct edit_string *string)
Synchronise console with edited string.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static __nonnull void init_editstring(struct edit_string *string, char **buf)
Initialise editable string.
#define READLINE_HISTORY_MAX_DEPTH
Maximum depth of a readline history buffer.
unsigned int next
Position of next entry within buffer.
static void(* free)(struct refcnt *refcnt))
A readline history buffer.
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 * string
Persistent copy of string.
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)
uint16_t offset
Offset to command line.
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