47 unsigned int mod_start =
string->mod_start;
48 unsigned int mod_end =
string->mod_end;
49 unsigned int cursor =
string->last_cursor;
50 const char *buf = *(
string->buf);
58 if ( mod_end < string->cursor )
69 putchar ( ( cursor >=
len ) ?
' ' : buf[cursor] );
74 while ( cursor >
string->cursor ) {
93 sizeof ( history->
entries[0] ) ) );
105 unsigned int depth ) {
123 unsigned int depth,
const char *
string ) {
131 DBGC ( history,
"READLINE %p could not store string\n",
151 int offset,
const char *old_string ) {
152 unsigned int new_depth = ( history->
depth +
offset );
153 const char * new_string =
history_fetch ( history, new_depth );
165 history->
depth = new_depth;
178 const char *
string ) {
187 DBGC ( history,
"READLINE %p could not append string\n",
211 for ( i = 0 ; i < (
sizeof ( history->
entries ) /
212 sizeof ( history->
entries[0] ) ) ; i++ ) {
236 for ( i = 0 ; i < (
sizeof ( history->
entries ) /
237 sizeof ( history->
entries[0] ) ) ; i++ ) {
263 const char *new_string;
275 memset ( &
string, 0,
sizeof (
string ) );
317 if ( move_by && history ) {
332 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