static gboolean ex_shellcmd(const ExArg *arg);
static gboolean ex_shortcut(const ExArg *arg);
-static gboolean ex_complete(short direction);
-static void ex_completion_select(char *match);
-static gboolean ex_history(gboolean prev);
-static void ex_history_rewind(void);
+static gboolean complete(short direction);
+static void completion_select(char *match);
+static gboolean history(gboolean prev);
+static void history_rewind(void);
/* The order of following command names is significant. If there exists
* ambiguous commands matching to the users input, the first defined will be
switch (key) {
case CTRL('I'): /* Tab */
- ex_complete(1);
+ complete(1);
break;
case CTRL('O'): /* S-Tab */
- ex_complete(-1);
+ complete(-1);
break;
case CTRL('['):
break;
case CTRL('P'): /* up */
- ex_history(true);
+ history(true);
break;
case CTRL('N'): /* down */
- ex_history(false);
+ history(false);
break;
/* basic command line editing */
* put hte matched data back to inputbox, and prepares the tree list store
* model containing matched values.
*/
-static gboolean ex_complete(short direction)
+static gboolean complete(short direction)
{
char *input; /* input read from inputbox */
const char *in; /* pointer to input that we move */
in = before_cmdname;
/* backup the parsed data so we can access them in
- * ex_completion_select function */
+ * completion_select function */
excomp.count = arg->count;
if (ex_fill_completion(store, in)) {
);
}
if (found
- && completion_create(GTK_TREE_MODEL(store), ex_completion_select, direction < 0)
+ && completion_create(GTK_TREE_MODEL(store), completion_select, direction < 0)
) {
/* set the submode flag */
vb.mode->flags |= FLAG_COMPLETION;
* matche item accordings with previously saved prefix and command name to the
* inputbox.
*/
-static void ex_completion_select(char *match)
+static void completion_select(char *match)
{
OVERWRITE_STRING(excomp.current, NULL);
vb_set_input_text(excomp.current);
}
-static gboolean ex_history(gboolean prev)
+static gboolean history(gboolean prev)
{
- int type;
- char *input, prefix[2] = {0};
- const char *in;
+ char *input;
GList *new = NULL;
input = vb_get_input_text();
* rewind the history to recreate it later new */
char *current = g_strconcat(exhist.prefix, (char*)exhist.active->data, NULL);
if (strcmp(input, current)) {
- ex_history_rewind();
+ history_rewind();
}
g_free(current);
}
/* create the history list if the lookup is started or input was changed */
if (!exhist.active) {
- in = (const char*)input;
+ int type;
+ char prefix[2] = {0};
+ const char *in = (const char*)input;
skip_whitespace(&in);
/* check which type of history we should use */
if (*in == ':') {
type = VB_INPUT_COMMAND;
- in++;
} else if (*in == '/' || *in == '?') {
/* the history does not distinguish between forward and backward
* search, so we don't need the backward search here too */
type = VB_INPUT_SEARCH_FORWARD;
- in++;
+ } else {
+ goto failed;
}
- exhist.active = history_get_list(type, in);
- if (!exhist.active) {
- g_free(input);
- return false;
+ exhist.active = history_get_list(type, in + 1);
+ if (!exhist.active) {
+ goto failed;
}
OVERWRITE_STRING(exhist.prefix, prefix);
}
- g_free(input);
if (prev) {
if ((new = g_list_next(exhist.active))) {
vb_echo_force(VB_MSG_NORMAL, false, "%s%s", exhist.prefix, (char*)exhist.active->data);
+ g_free(input);
return true;
+
+failed:
+ g_free(input);
+ return false;
}
-static void ex_history_rewind(void)
+static void history_rewind(void)
{
if (exhist.active) {
/* free temporary used history list */
char showbuf[10]; /* buffer to shw ambiguous key sequence */
} map;
-static char *map_convert_keys(char *in, int inlen, int *len);
-static char *map_convert_keylabel(char *in, int inlen, int *len);
-static gboolean map_timeout(gpointer data);
+static char *convert_keys(char *in, int inlen, int *len);
+static char *convert_keylabel(char *in, int inlen, int *len);
+static gboolean do_timeout(gpointer data);
static void showcmd(char *keys, int keylen);
static char* transchar(char c);
static void free_map(Map *map);
if (map.timout_id) {
g_source_remove(map.timout_id);
}
- map.timout_id = g_timeout_add(vb.config.timeoutlen, (GSourceFunc)map_timeout, NULL);
+ map.timout_id = g_timeout_add(vb.config.timeoutlen, (GSourceFunc)do_timeout, NULL);
}
/* copy the keys onto the end of queue */
void map_insert(char *in, char *mapped, char mode)
{
int inlen, mappedlen;
- char *lhs = map_convert_keys(in, strlen(in), &inlen);
- char *rhs = map_convert_keys(mapped, strlen(mapped), &mappedlen);
+ char *lhs = convert_keys(in, strlen(in), &inlen);
+ char *rhs = convert_keys(mapped, strlen(mapped), &mappedlen);
/* TODO replace keysymbols in 'in' and 'mapped' string */
Map *new = g_new(Map, 1);
gboolean map_delete(char *in, char mode)
{
int len;
- char *lhs = map_convert_keys(in, strlen(in), &len);
+ char *lhs = convert_keys(in, strlen(in), &len);
for (GSList *l = map.list; l != NULL; l = l->next) {
Map *m = (Map*)l->data;
* Converts a keysequence into a internal raw keysequence.
* Returned keyseqence must be freed if not used anymore.
*/
-static char *map_convert_keys(char *in, int inlen, int *len)
+static char *convert_keys(char *in, int inlen, int *len)
{
int symlen, rawlen;
char *p, *dest, *raw;
/* if we could not convert it jet - try to translate the label */
if (!rawlen) {
- raw = map_convert_keylabel(p, symlen, &rawlen);
+ raw = convert_keylabel(p, symlen, &rawlen);
}
}
* Translate given key string into a internal representation <cr> -> \n.
* The len of the translated key sequence is put into given *len pointer.
*/
-static char *map_convert_keylabel(char *in, int inlen, int *len)
+static char *convert_keylabel(char *in, int inlen, int *len)
{
static struct {
char *label;
/**
* Timeout function to signalize a key timeout to the map.
*/
-static gboolean map_timeout(gpointer data)
+static gboolean do_timeout(gpointer data)
{
/* signalize the timeout to the key handler */
map_handle_keys("", 0);