projects
/
selector.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f18a442
)
The highlight for regexp match seems to work.
author
Francois Fleuret
<francois@fleuret.org>
Fri, 10 Feb 2012 10:25:38 +0000
(11:25 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Fri, 10 Feb 2012 10:25:38 +0000
(11:25 +0100)
selector.c
patch
|
blob
|
history
diff --git
a/selector.c
b/selector.c
index
a4d9ee5
..
81286d6
100644
(file)
--- a/
selector.c
+++ b/
selector.c
@@
-389,6
+389,7
@@
int add_interval(int n, int *switches, int start, int end) {
int match(struct matcher *matcher, char *string, int *nb_switches, int *switches) {
int n;
char *where;
int match(struct matcher *matcher, char *string, int *nb_switches, int *switches) {
int n;
char *where;
+ regmatch_t matches;
if(nb_switches) { *nb_switches = 0; }
if(nb_switches) { *nb_switches = 0; }
@@
-432,7
+433,16
@@
int match(struct matcher *matcher, char *string, int *nb_switches, int *switches
}
return 1;
} else {
}
return 1;
} else {
- return regexec(&matcher->preg, string, 0, 0, 0) == 0;
+ if(regexec(&matcher->preg, string, 1, &matches, 0) == 0) {
+ if(switches) {
+ *nb_switches = 2;
+ switches[0] = matches.rm_so;
+ switches[1] = matches.rm_eo;
+ }
+ return 1;
+ } else {
+ return 0;
+ }
}
}
}
}
@@
-630,10
+640,10
@@
void update_screen(int *current_focus_line, int *displayed_focus_line,
initialize_matcher(&matcher, use_regexp, case_sensitive, pattern);
initialize_matcher(&matcher, use_regexp, case_sensitive, pattern);
- if(show_hits && matcher.nb_patterns > 0) {
+ if(show_hits && matcher.nb_patterns >
=
0) {
switches = safe_malloc(sizeof(int) * matcher.nb_patterns * 2);
} else {
switches = safe_malloc(sizeof(int) * matcher.nb_patterns * 2);
} else {
- switches =
0
;
+ switches =
safe_malloc(sizeof(int) * 2)
;
}
console_width = getmaxx(stdscr);
}
console_width = getmaxx(stdscr);
@@
-769,6
+779,7
@@
void update_screen(int *current_focus_line, int *displayed_focus_line,
buffer[k++] = '\n';
buffer[k++] = '\0';
}
buffer[k++] = '\n';
buffer[k++] = '\0';
}
+
print_string_with_switches(buffer, k, console_width,
nb_switches / 2, switches);
}
print_string_with_switches(buffer, k, console_width,
nb_switches / 2, switches);
}