- Timestamp:
- Jul 24, 2009, 12:59:23 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 64c9165
- Parents:
- ab225e0
- git-author:
- Anders Kaseorg <andersk@mit.edu> (07/24/09 00:51:10)
- git-committer:
- Anders Kaseorg <andersk@mit.edu> (07/24/09 00:59:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmtext.c
r4d86e06 r41c9a96 285 285 char attr; 286 286 short fg, bg, pair; 287 int search_results, search_len;288 287 289 288 if (w==NULL) { … … 292 291 } 293 292 294 search_results = (do_search295 ? owl_fmtext_search(f, owl_global_get_search_string(&g))296 : 0);297 search_len = (search_results298 ? strlen(owl_global_get_search_string(&g))299 : 0);300 293 s = f->textbuff; 301 294 /* Set default attributes. */ … … 316 309 tmp = p[0]; 317 310 p[0] = '\0'; 318 if ( search_results) {311 if (owl_global_is_search_active(&g)) { 319 312 /* Search is active, so highlight search results. */ 320 char tmp2 , *ss;321 ss = stristr(s, owl_global_get_search_string(&g));322 while ( ss) {313 char tmp2; 314 int start, end; 315 while (owl_regex_compare(owl_global_get_search_re(&g), s, &start, &end) == 0) { 323 316 /* Found search string, highlight it. */ 324 317 325 tmp2 = s s[0];326 s s[0] = '\0';318 tmp2 = s[start]; 319 s[start] = '\0'; 327 320 waddstr(w, s); 328 s s[0] = tmp2;321 s[start] = tmp2; 329 322 330 323 _owl_fmtext_wattrset(w, attr ^ OWL_FMTEXT_ATTR_REVERSE); 331 324 _owl_fmtext_wcolor_set(w, pair); 332 325 333 tmp2 = s s[search_len];334 s s[search_len] = '\0';335 waddstr(w, s s);336 s s[search_len] = tmp2;326 tmp2 = s[end]; 327 s[end] = '\0'; 328 waddstr(w, s + start); 329 s[end] = tmp2; 337 330 338 331 _owl_fmtext_wattrset(w, attr); 339 332 _owl_fmtext_wcolor_set(w, pair); 340 333 341 s = ss + search_len; 342 ss = stristr(s, owl_global_get_search_string(&g)); 334 s += end; 343 335 } 344 336 } … … 563 555 * insensitive search. 564 556 */ 565 int owl_fmtext_search(owl_fmtext *f, char *string)566 { 567 if ( stristr(f->textbuff, string)) return(1);557 int owl_fmtext_search(owl_fmtext *f, owl_regex *re) 558 { 559 if (owl_regex_compare(re, f->textbuff, NULL, NULL) == 0) return(1); 568 560 return(0); 569 561 }
Note: See TracChangeset
for help on using the changeset viewer.