awesome-menu: make autocomplete behaviour configurable (FS#336)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Hannes Schueller 2008-10-03 08:59:46 +02:00 committed by Julien Danjou
parent 84a2a34aa6
commit cdd673f6f4
2 changed files with 8 additions and 5 deletions

View File

@ -124,6 +124,8 @@ typedef struct
char *prompt;
/** String match mode */
Bool match_string;
/** Autocompletion mode */
Bool autocomplete;
} AwesomeMenuConf;
static AwesomeMenuConf globalconf;
@ -199,6 +201,7 @@ config_parse(int screen, const char *confpatharg,
if((i = cfg_getint(cfg_menu, "height")) > 0)
geometry->height = i;
globalconf.match_string = cfg_getbool(cfg_menu, "match_string");
globalconf.autocomplete = cfg_getbool(cfg_menu, "autocomplete");
}
if(cfg_screen
@ -552,7 +555,7 @@ handle_kpress(XKeyEvent *e)
while(i >= 0 && globalconf.text[i] != ' ')
globalconf.text[i--] = '\0';
matches = compute_match(get_last_word(globalconf.text));
if (matches == 1)
if (globalconf.autocomplete && matches == 1)
complete(False);
redraw();
}
@ -592,7 +595,7 @@ handle_kpress(XKeyEvent *e)
a_strncat(globalconf.text, globalconf.text_size, buf, num);
}
matches = compute_match(get_last_word(globalconf.text));
if (matches == 1)
if (globalconf.autocomplete && matches == 1)
complete(False);
redraw();
}
@ -602,8 +605,6 @@ handle_kpress(XKeyEvent *e)
{
globalconf.text[--len] = '\0';
matches = compute_match(get_last_word(globalconf.text));
if (matches == 1)
complete(False);
redraw();
}
break;
@ -820,7 +821,7 @@ main(int argc, char **argv)
}
matches = compute_match(NULL);
if (matches == 1)
if (globalconf.autocomplete && matches == 1)
complete(False);
redraw();

View File

@ -633,6 +633,8 @@ cfg_opt_t menu_opts[] =
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
/** String matching mode (true to complete string) */
CFG_BOOL((char *) "match_string", cfg_false, CFGF_NONE),
/** Autocompletion (true or false) */
CFG_BOOL((char *) "autocomplete", cfg_true, CFGF_NONE),
/** Styles to use for this menu. */
CFG_SEC((char *) "styles", styles_opts, CFGF_NONE),
CFG_AWESOME_END()