Skip to content

Commit

Permalink
Changing default behavior to clear page on exit + adding option allow…
Browse files Browse the repository at this point in the history
…ing to change it.
  • Loading branch information
dvorka committed Jun 11, 2017
1 parent 96e4fe4 commit 4613e4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions man/hh.1
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
7 changes: 6 additions & 1 deletion src/hstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1330,7 +1335,7 @@ void loop_to_select(Hstr *hstr)
break;
}
}
hstr_curses_stop();
hstr_curses_stop(hstr->keepPage);

if(result!=NULL) {
if(fixCommand) {
Expand Down
8 changes: 5 additions & 3 deletions src/hstr_curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 4613e4e

Please sign in to comment.