Fixing bug #238 - delete confirmation can be disabled by env variable e.g. export HH_CONFIG=noconfirm

This commit is contained in:
Martin Dvorak 2018-01-03 12:40:20 +01:00
parent 079d8f9ac1
commit 85909ec588
2 changed files with 13 additions and 3 deletions

View file

@ -95,6 +95,9 @@ Configuration options:
\fIprompt-bottom\fR
Show prompt at the bottom of the screen (default is prompt at the top).
\fInoconfirm\fR
Do not ask for confirmation on a history entry delete (default is with confirmation).
\fIregexp\fR
Filter command history using regular expressions (substring match is default)

View file

@ -103,6 +103,7 @@
#define HH_CONFIG_KEYWORDS "keywords"
#define HH_CONFIG_SORTING "rawhistory"
#define HH_CONFIG_FAVORITES "favorites"
#define HH_CONFIG_NOCONFIRM "noconfirm"
// MVP: model is the same regardless prompt is top or bottom - view is different
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom"
#define HH_CONFIG_BLACKLIST "blacklist"
@ -274,6 +275,7 @@ typedef struct {
unsigned char theme;
bool keepPage; // do NOT clear page w/ selection on HH exit
bool noConfirm; // do NOT ask for confirmation on history entry delete
int bigKeys;
int debugLevel;
@ -383,6 +385,9 @@ void hstr_get_env_configuration(Hstr *hstr)
if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
hstr->keepPage=true;
}
if(strstr(hstr_config,HH_CONFIG_NOCONFIRM)) {
hstr->noConfirm=true;
}
if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
@ -1057,9 +1062,11 @@ void loop_to_select(Hstr *hstr)
msg=malloc(strlen(delete)+1);
strcpy(msg,delete);
print_confirm_delete(msg, hstr);
cc = wgetch(stdscr);
if(cc == 'y') {
if(!hstr->noConfirm) {
print_confirm_delete(msg, hstr);
cc = wgetch(stdscr);
}
if(hstr->noConfirm || cc == 'y') {
deletedOccurences=remove_from_history_model(msg, hstr);
result=hstr_print_selection(maxHistoryItems, pattern, hstr);
print_cmd_deleted_label(msg, deletedOccurences, hstr);