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 a121619bf730f95b502ad090e1201e03091dbd15

Fixed #194 so that case sensitivity is correctly handled for keywords.
Author: Martin Dvorak
Author date (UTC): 2016-11-11 21:37
Committer name: Martin Dvorak
Committer date (UTC): 2016-11-11 21:37
Parent(s): 7b4f6e30f29bacfbb86b5951c74e7de76b91b9cf
Signing key:
Tree: e8e197bac357eff292d961bf3d688bf734e80dcb
File Lines added Lines deleted
src/hstr.c 32 12
File src/hstr.c changed (mode: 100644) (index 9dfacfd..498176f)
... ... unsigned hstr_make_selection(char *prefix, HistoryItems *history, int maxSelecti
612 612 } }
613 613 break; break;
614 614 case HH_MATCH_KEYWORDS: case HH_MATCH_KEYWORDS:
615 // TODO differentiate between case-sensitive and insensitive
616 615 keywordsParsedLine = strdup(prefix); keywordsParsedLine = strdup(prefix);
617 616 keywordsAllMatch = true; keywordsAllMatch = true;
618 617 keywordsPointerToDelete = keywordsParsedLine; keywordsPointerToDelete = keywordsParsedLine;
619 618 while(true) { while(true) {
620 619 keywordsToken = strtok_r(keywordsParsedLine, " ", &keywordsSavePtr); keywordsToken = strtok_r(keywordsParsedLine, " ", &keywordsSavePtr);
621 keywordsParsedLine = NULL;
622 620 if (keywordsToken == NULL) { if (keywordsToken == NULL) {
623 621 break; break;
624 622 } }
625 if (strcasestr(source[i], keywordsToken) == NULL) {
626 keywordsAllMatch = false;
623 keywordsParsedLine = NULL;
624 switch(hstr->caseSensitive) {
625 case HH_CASE_SENSITIVE:
626 if(strstr(source[i], keywordsToken) == NULL) {
627 keywordsAllMatch = false;
628 }
629 break;
630 case HH_CASE_INSENSITIVE:
631 if(strcasestr(source[i], keywordsToken) == NULL) {
632 keywordsAllMatch = false;
633 }
634 break;
627 635 } }
628 636 } }
629 if (keywordsAllMatch) {
637 if(keywordsAllMatch) {
630 638 add_to_selection(hstr, source[i], &selectionCount); add_to_selection(hstr, source[i], &selectionCount);
631 639 } }
632 640 free(keywordsPointerToDelete); free(keywordsPointerToDelete);
 
... ... void print_selection_row(char *text, int y, int width, char *pattern)
682 690 if(hstr->theme & HH_THEME_COLOR) { if(hstr->theme & HH_THEME_COLOR) {
683 691 color_attr_on(COLOR_PAIR(HH_COLOR_MATCH)); color_attr_on(COLOR_PAIR(HH_COLOR_MATCH));
684 692 } }
685 char *p;
686 char *keywordsSavePtr;
687 char *keywordsToken;
688 char *keywordsParsedLine;
689 char *keywordsPointerToDelete;
693 char* p;
694 char* pp;
695 char* keywordsSavePtr;
696 char* keywordsToken;
697 char* keywordsParsedLine;
698 char* keywordsPointerToDelete;
690 699
691 700 switch(hstr->historyMatch) { switch(hstr->historyMatch) {
692 701 case HH_MATCH_SUBSTRING: case HH_MATCH_SUBSTRING:
 
... ... void print_selection_row(char *text, int y, int width, char *pattern)
715 724 if (keywordsToken == NULL) { if (keywordsToken == NULL) {
716 725 break; break;
717 726 } }
718 p=strstr(text, keywordsToken);
719 mvprintw(y, 1+(p-text), "%s", keywordsToken);
727 switch(hstr->caseSensitive) {
728 case HH_CASE_SENSITIVE:
729 p=strstr(text, keywordsToken);
730 mvprintw(y, 1+(p-text), "%s", keywordsToken);
731 break;
732 case HH_CASE_INSENSITIVE:
733 p=strcasestr(text, keywordsToken);
734 pp=strdup(p);
735 pp[strlen(keywordsToken)]=0;
736 mvprintw(y, 1+(p-text), "%s", pp);
737 free(pp);
738 break;
739 }
720 740 } }
721 741 free(keywordsPointerToDelete); free(keywordsPointerToDelete);
722 742
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