Changeset 118c919 for viewwin.c


Ignore:
Timestamp:
Sep 21, 2010, 5:33:11 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
b120bd3
Parents:
4a41f16
git-author:
David Benjamin <davidben@mit.edu> (09/18/10 17:35:30)
git-committer:
David Benjamin <davidben@mit.edu> (09/21/10 17:33:11)
Message:
Name search argument consider_current

Adding yet another enum for a boolean value is overkill.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • viewwin.c

    r4a41f16 r118c919  
    144144char *owl_viewwin_command_search(owl_viewwin *v, int argc, const char *const *argv, const char *buff)
    145145{
    146   int direction, mode;
     146  int direction, consider_current;
    147147  const char *buffstart;
    148148
     
    155155
    156156  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
    157     mode = OWL_SEARCH_CONTINUE;
     157    consider_current = false;
    158158  } else {
    159159    owl_function_set_search(buffstart);
    160     mode = OWL_SEARCH_MATCH_CURRENT;
    161   }
    162 
    163   if (!owl_viewwin_search(v, owl_global_get_search_re(&g), mode, direction))
     160    consider_current = true;
     161  }
     162
     163  if (!owl_viewwin_search(v, owl_global_get_search_re(&g), consider_current, direction))
    164164    owl_function_error("No more matches");
    165165  return NULL;
     
    177177  owl_function_set_search(line);
    178178  if (!owl_viewwin_search(data->v, owl_global_get_search_re(&g),
    179                           OWL_SEARCH_MATCH_CURRENT, data->direction))
     179                          true, data->direction))
    180180    owl_function_error("No matches");
    181181}
     
    368368 * found.
    369369 *
    370  * If mode is OWL_SEARCH_MATCH_CURRENT then stay on the current line
     370 * If consider_current is true then stay on the current line
    371371 * if it matches.
    372372 */
    373 int owl_viewwin_search(owl_viewwin *v, const owl_regex *re, int mode, int direction)
     373int owl_viewwin_search(owl_viewwin *v, const owl_regex *re, int consider_current, int direction)
    374374{
    375375  int start, end, offset;
     
    379379  if (direction == OWL_DIRECTION_DOWNWARDS) {
    380380    offset = owl_fmtext_search(&v->fmtext, re,
    381                                (mode == OWL_SEARCH_CONTINUE) ? end : start);
     381                               consider_current ? start : end);
    382382    if (offset < 0)
    383383      return 0;
     
    391391     * them. */
    392392    buf = owl_fmtext_get_text(&v->fmtext);
    393     lineend = (mode == OWL_SEARCH_CONTINUE) ? start : end;
     393    lineend = consider_current ? end : start;
    394394    while (lineend > 0) {
    395395      linestartp = memrchr(buf, '\n', lineend - 1);
Note: See TracChangeset for help on using the changeset viewer.