diff --git a/src/hstr.c b/src/hstr.c index 3e66a11..f8c2a43 100644 --- a/src/hstr.c +++ b/src/hstr.c @@ -21,8 +21,9 @@ #include "include/hstr_history.h" #define LABEL_HISTORY " HISTORY " -#define LABEL_HELP "Type to filter, arrows to move, Ctrl-r to remove, ENTER to select, Ctrl-x to exit" +#define FILE_BASHRC ".bashrc" #define SELECTION_CURSOR_IN_PROMPT -1 +#define SELECTION_PREFIX_MAX_LNG 500 #define Y_OFFSET_PROMPT 0 #define Y_OFFSET_HELP 2 @@ -53,9 +54,13 @@ static const char *INSTALL_STRING= "\nbind '\"\\C-r\": \"\\C-k\\C-uhh\\C-j\"'" "\n\n"; +static char *LABEL_HELP= + "Type to filter, UP/DOWN to move, Ctrl-r to remove, ENTER to select, Ctrl-x to exit"; + static char **selection=NULL; static unsigned selectionSize=0; static bool terminalHasColors=FALSE; +static char screenLine[1000]; int print_prompt(WINDOW *win) { char hostname[128]; @@ -70,12 +75,14 @@ int print_prompt(WINDOW *win) { } void print_help_label(WINDOW *win) { - mvwprintw(win, Y_OFFSET_HELP, 0, LABEL_HELP); + snprintf(screenLine, getmaxx(win), "%s", LABEL_HELP); + mvwprintw(win, Y_OFFSET_HELP, 0, screenLine); refresh(); } void print_cmd_deleted_label(WINDOW *win, char *cmd, int occurences) { - mvwprintw(win, Y_OFFSET_HELP, 0, "History item '%s' deleted (%d occurrence%s)", cmd, occurences, (occurences==1?"":"s")); + snprintf(screenLine, getmaxx(win), "History item '%s' deleted (%d occurrence%s)", cmd, occurences, (occurences==1?"":"s")); + mvwprintw(win, Y_OFFSET_HELP, 0, screenLine); clrtoeol(); refresh(); } @@ -100,7 +107,7 @@ void print_history_label(WINDOW *win) { } unsigned get_max_history_items(WINDOW *win) { - return (getmaxy(win)-(Y_OFFSET_ITEMS+2)); + return (getmaxy(win)-Y_OFFSET_ITEMS); } @@ -152,6 +159,7 @@ char *print_selection(WINDOW *win, unsigned maxHistoryItems, char *prefix, Histo } int height=get_max_history_items(win); + int width=getmaxx(win); unsigned i; int y=Y_OFFSET_ITEMS; @@ -160,7 +168,8 @@ char *print_selection(WINDOW *win, unsigned maxHistoryItems, char *prefix, Histo for (i = 0; i