xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit ae1cd1c96c4727307cab6b414d542045fb21ee82

Added prompt to delete action.
Author: Martin Dvorak
Author date (UTC): 2016-11-11 22:21
Committer name: Martin Dvorak
Committer date (UTC): 2016-11-11 22:21
Parent(s): a121619bf730f95b502ad090e1201e03091dbd15
Signing key:
Tree: ca6601f7feaf6e9c23d695036b4e4823d9981351
File Lines added Lines deleted
src/hstr.c 29 4
File src/hstr.c changed (mode: 100644) (index 498176f..b394c26)
... ... void print_help_label()
431 431 refresh(); refresh();
432 432 } }
433 433
434 void print_confirm_delete(const char *cmd, Hstr *hstr)
435 {
436 char screenLine[CMDLINE_LNG];
437 snprintf(screenLine, getmaxx(stdscr), "Do you want to delete all occurrences of '%s'? y/n", cmd);
438 // TODO make this function
439 if(hstr->theme & HH_THEME_COLOR) {
440 color_attr_on(COLOR_PAIR(HH_COLOR_DELETE));
441 color_attr_on(A_BOLD);
442 }
443 mvprintw(hstr->promptYHelp, 0, "%s", screenLine);
444 if(hstr->theme & HH_THEME_COLOR) {
445 color_attr_off(A_BOLD);
446 color_attr_on(COLOR_PAIR(1));
447 }
448 clrtoeol();
449 refresh();
450 }
451
434 452 void print_cmd_deleted_label(const char *cmd, int occurences, Hstr *hstr) void print_cmd_deleted_label(const char *cmd, int occurences, Hstr *hstr)
435 453 { {
436 454 char screenLine[CMDLINE_LNG]; char screenLine[CMDLINE_LNG];
 
... ... void loop_to_select(Hstr *hstr)
963 981 bool done=FALSE, skip=TRUE, executeResult=FALSE, lowercase=TRUE; bool done=FALSE, skip=TRUE, executeResult=FALSE, lowercase=TRUE;
964 982 bool printDefaultLabel=TRUE, fixCommand=FALSE, editCommand=FALSE; bool printDefaultLabel=TRUE, fixCommand=FALSE, editCommand=FALSE;
965 983 int basex=print_prompt(); int basex=print_prompt();
966 int x=basex, c, cursorX=0, cursorY=0, maxHistoryItems, deletedOccurences;
984 int x=basex, c, cc, cursorX=0, cursorY=0, maxHistoryItems, deletedOccurences;
967 985 int width=getmaxx(stdscr); int width=getmaxx(stdscr);
968 986 int selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; int selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT;
969 987 int previousSelectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; int previousSelectionCursorPosition=SELECTION_CURSOR_IN_PROMPT;
 
... ... void loop_to_select(Hstr *hstr)
1010 1028 delete=getResultFromSelection(selectionCursorPosition, hstr, result); delete=getResultFromSelection(selectionCursorPosition, hstr, result);
1011 1029 msg=malloc(strlen(delete)+1); msg=malloc(strlen(delete)+1);
1012 1030 strcpy(msg,delete); strcpy(msg,delete);
1013 deletedOccurences=remove_from_history_model(msg, hstr);
1014 result=hstr_print_selection(maxHistoryItems, pattern, hstr);
1015 print_cmd_deleted_label(msg, deletedOccurences, hstr);
1031
1032 print_confirm_delete(msg, hstr);
1033 cc = wgetch(stdscr);
1034 if(cc == 'y') {
1035 deletedOccurences=remove_from_history_model(msg, hstr);
1036 result=hstr_print_selection(maxHistoryItems, pattern, hstr);
1037 print_cmd_deleted_label(msg, deletedOccurences, hstr);
1038 } else {
1039 print_help_label();
1040 }
1016 1041 free(msg); free(msg);
1017 1042 move(hstr->promptY, basex+strlen(pattern)); move(hstr->promptY, basex+strlen(pattern));
1018 1043 printDefaultLabel=TRUE; printDefaultLabel=TRUE;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master