File src/hstr.c changed (mode: 100644) (index 51dedbf..03e7fe5) |
... |
... |
char *hstr_print_selection(unsigned maxHistoryItems, char *pattern, Hstr *hstr) |
507 |
507 |
move(Y_OFFSET_ITEMS, 0); |
move(Y_OFFSET_ITEMS, 0); |
508 |
508 |
clrtobot(); |
clrtobot(); |
509 |
509 |
|
|
510 |
|
char buffer[CMDLINE_LNG]; |
|
511 |
510 |
int start, end; |
int start, end; |
512 |
|
|
|
|
511 |
|
char buffer[CMDLINE_LNG]; |
513 |
512 |
for (i = 0; i<height; ++i) { |
for (i = 0; i<height; ++i) { |
514 |
513 |
if(i<hstr->selectionSize) { |
if(i<hstr->selectionSize) { |
515 |
514 |
if(pattern && strlen(pattern)) { |
if(pattern && strlen(pattern)) { |
|
... |
... |
char *hstr_print_selection(unsigned maxHistoryItems, char *pattern, Hstr *hstr) |
536 |
535 |
return result; |
return result; |
537 |
536 |
} |
} |
538 |
537 |
|
|
539 |
|
void highlight_selection(int selectionCursorPosition, int previousSelectionCursorPosition, char *prefix, Hstr *hstr) |
|
|
538 |
|
void highlight_selection(int selectionCursorPosition, int previousSelectionCursorPosition, char *pattern, Hstr *hstr) |
540 |
539 |
{ |
{ |
541 |
540 |
if(previousSelectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
if(previousSelectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
542 |
|
// TODO regexp match instead of prefix one level up |
|
|
541 |
|
char buffer[CMDLINE_LNG]; |
|
542 |
|
if(pattern && strlen(pattern) && hstr->historyMatch==HH_MATCH_REGEXP) { |
|
543 |
|
int start=hstr->selectionRegexpMatch[previousSelectionCursorPosition].rm_so; |
|
544 |
|
int end=hstr->selectionRegexpMatch[previousSelectionCursorPosition].rm_eo-start; |
|
545 |
|
strncpy(buffer, |
|
546 |
|
hstr->selection[previousSelectionCursorPosition]+start, |
|
547 |
|
end); |
|
548 |
|
buffer[end]=0; |
|
549 |
|
} else { |
|
550 |
|
strcpy(buffer, pattern); |
|
551 |
|
} |
543 |
552 |
print_selection_row( |
print_selection_row( |
544 |
553 |
hstr->selection[previousSelectionCursorPosition], |
hstr->selection[previousSelectionCursorPosition], |
545 |
554 |
Y_OFFSET_ITEMS+previousSelectionCursorPosition, |
Y_OFFSET_ITEMS+previousSelectionCursorPosition, |
546 |
555 |
getmaxx(stdscr), |
getmaxx(stdscr), |
547 |
|
prefix); |
|
|
556 |
|
buffer); |
548 |
557 |
} |
} |
549 |
558 |
if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
550 |
559 |
hstr_print_highlighted_selection_row( |
hstr_print_highlighted_selection_row( |