Changing default behavior to clear page on exit + adding option allowing to change it.

This commit is contained in:
Martin Dvorak 2017-06-11 14:32:50 +02:00
parent 96e4fe403b
commit 4613e4ef62
3 changed files with 14 additions and 4 deletions

View file

@ -119,6 +119,9 @@ Configuration options:
\fIblacklist\fR
Load list of commands to skip when processing history from ~/.hh_blacklist (built-in blacklist used otherwise).
\fIkeepage\fR
Don't clear page with command selection on exit (page is cleared by default).
\fIbig-keys-skip\fR
Skip big history entries i.e. very long lines (default).

View file

@ -104,6 +104,7 @@
// 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"
#define HH_CONFIG_KEEP_PAGE "keepage"
#define HH_CONFIG_DEBUG "debug"
#define HH_CONFIG_WARN "warning"
#define HH_CONFIG_BIG_KEYS_SKIP "big-keys-skip"
@ -271,6 +272,7 @@ typedef struct {
bool unique;
unsigned char theme;
bool keepPage; // do NOT clear page w/ selection on HH exit
int bigKeys;
int debugLevel;
@ -377,6 +379,9 @@ void hstr_get_env_configuration(Hstr *hstr)
if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) {
hstr->blacklist.useFile=true;
}
if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
hstr->keepPage=true;
}
if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
@ -1330,7 +1335,7 @@ void loop_to_select(Hstr *hstr)
break;
}
}
hstr_curses_stop();
hstr_curses_stop(hstr->keepPage);
if(result!=NULL) {
if(fixCommand) {

View file

@ -26,7 +26,7 @@ void hstr_curses_start()
initscr();
keypad(stdscr, TRUE);
noecho();
nonl();
nonl(); // prevent carriage return from being mapped to newline
terminalHasColors=has_colors();
if(terminalHasColors) {
start_color();
@ -38,8 +38,10 @@ bool terminal_has_colors() {
return terminalHasColors;
}
void hstr_curses_stop() {
// removed to leave content in case of alternative page - clear();
void hstr_curses_stop(bool keepPage) {
if(!keepPage) {
clear();
}
refresh();
doupdate();
endwin();