Changeset 118c919


Ignore:
Timestamp:
Sep 21, 2010, 5:33:11 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, 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.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rd2fd2f7 r118c919  
    25532553   
    25542554  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
    2555     owl_function_search_helper(OWL_SEARCH_CONTINUE, direction);
     2555    /* When continuing a search, don't consider the current message. */
     2556    owl_function_search_helper(false, direction);
    25562557  } else {
    25572558    owl_function_set_search(buffstart);
    2558     owl_function_search_helper(OWL_SEARCH_MATCH_CURRENT, direction);
     2559    owl_function_search_helper(true, direction);
    25592560  }
    25602561 
  • functions.c

    r4a41f16 r118c919  
    28942894}
    28952895
    2896 void owl_function_search_helper(int mode, int direction)
     2896void owl_function_search_helper(int consider_current, int direction)
    28972897{
    28982898  /* move to a message that contains the string.  If direction is
     
    29002900   * OWL_DIRECTION_UPWARDS then search backwards.
    29012901   *
    2902    * If mode is OWL_SEARCH_MATCH_CURRENT then it will stay on the
     2902   * If consider_current is true then it will stay on the
    29032903   * current message if it contains the string.
    29042904   */
     
    29172917  }
    29182918
    2919   if (mode == OWL_SEARCH_MATCH_CURRENT) {
     2919  if (consider_current) {
    29202920    start=curmsg;
    29212921  } else if (direction==OWL_DIRECTION_DOWNWARDS) {
  • owl.h

    r1b8c3f8 r118c919  
    138138#define OWL_DIRECTION_DOWNWARDS 1
    139139#define OWL_DIRECTION_UPWARDS   2
    140 
    141 #define OWL_SEARCH_MATCH_CURRENT 0
    142 #define OWL_SEARCH_CONTINUE      1
    143140
    144141#define OWL_LOGGING_DIRECTION_BOTH 0
  • 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.