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 |
|
|