mirror of
https://github.com/dvorka/hstr.git
synced 2025-09-10 14:34:21 +08:00
Fixing bug #238 - delete confirmation can be disabled by env variable e.g. export HH_CONFIG=noconfirm
This commit is contained in:
parent
079d8f9ac1
commit
85909ec588
2 changed files with 13 additions and 3 deletions
3
man/hh.1
3
man/hh.1
|
@ -95,6 +95,9 @@ Configuration options:
|
||||||
\fIprompt-bottom\fR
|
\fIprompt-bottom\fR
|
||||||
Show prompt at the bottom of the screen (default is prompt at the top).
|
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
|
\fIregexp\fR
|
||||||
Filter command history using regular expressions (substring match is default)
|
Filter command history using regular expressions (substring match is default)
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@
|
||||||
#define HH_CONFIG_KEYWORDS "keywords"
|
#define HH_CONFIG_KEYWORDS "keywords"
|
||||||
#define HH_CONFIG_SORTING "rawhistory"
|
#define HH_CONFIG_SORTING "rawhistory"
|
||||||
#define HH_CONFIG_FAVORITES "favorites"
|
#define HH_CONFIG_FAVORITES "favorites"
|
||||||
|
#define HH_CONFIG_NOCONFIRM "noconfirm"
|
||||||
// MVP: model is the same regardless prompt is top or bottom - view is different
|
// MVP: model is the same regardless prompt is top or bottom - view is different
|
||||||
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom"
|
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom"
|
||||||
#define HH_CONFIG_BLACKLIST "blacklist"
|
#define HH_CONFIG_BLACKLIST "blacklist"
|
||||||
|
@ -274,6 +275,7 @@ typedef struct {
|
||||||
|
|
||||||
unsigned char theme;
|
unsigned char theme;
|
||||||
bool keepPage; // do NOT clear page w/ selection on HH exit
|
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 bigKeys;
|
||||||
int debugLevel;
|
int debugLevel;
|
||||||
|
|
||||||
|
@ -383,6 +385,9 @@ void hstr_get_env_configuration(Hstr *hstr)
|
||||||
if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
|
if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
|
||||||
hstr->keepPage=true;
|
hstr->keepPage=true;
|
||||||
}
|
}
|
||||||
|
if(strstr(hstr_config,HH_CONFIG_NOCONFIRM)) {
|
||||||
|
hstr->noConfirm=true;
|
||||||
|
}
|
||||||
|
|
||||||
if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
|
if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
|
||||||
hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
|
hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
|
||||||
|
@ -1057,9 +1062,11 @@ void loop_to_select(Hstr *hstr)
|
||||||
msg=malloc(strlen(delete)+1);
|
msg=malloc(strlen(delete)+1);
|
||||||
strcpy(msg,delete);
|
strcpy(msg,delete);
|
||||||
|
|
||||||
|
if(!hstr->noConfirm) {
|
||||||
print_confirm_delete(msg, hstr);
|
print_confirm_delete(msg, hstr);
|
||||||
cc = wgetch(stdscr);
|
cc = wgetch(stdscr);
|
||||||
if(cc == 'y') {
|
}
|
||||||
|
if(hstr->noConfirm || cc == 'y') {
|
||||||
deletedOccurences=remove_from_history_model(msg, hstr);
|
deletedOccurences=remove_from_history_model(msg, hstr);
|
||||||
result=hstr_print_selection(maxHistoryItems, pattern, hstr);
|
result=hstr_print_selection(maxHistoryItems, pattern, hstr);
|
||||||
print_cmd_deleted_label(msg, deletedOccurences, hstr);
|
print_cmd_deleted_label(msg, deletedOccurences, hstr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue