Changeset b8742ba


Ignore:
Timestamp:
Sep 18, 2010, 5:07:39 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
2640b63
Parents:
9116936
git-author:
David Benjamin <davidben@mit.edu> (08/01/10 13:28:02)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:39)
Message:
Add half an implementation of owl_viewwin_search
File:
1 edited

Legend:

Unmodified
Added
Removed
  • viewwin.c

    r9116936 rb8742ba  
    197197}
    198198
     199/* Scroll in 'direction' to the next line containing 're' in 'v',
     200 * starting from the current line. Returns 0 if no occurrence is
     201 * found.
     202 *
     203 * If mode==0 then stay on the current line if it matches.
     204 */
     205int owl_viewwin_search(owl_viewwin *v, const owl_regex *re, int mode, int direction)
     206{
     207  int start, end, offset;
     208  owl_fmtext_line_extents(&v->fmtext, v->topline, &start, &end);
     209  if (direction == OWL_DIRECTION_DOWNWARDS) {
     210    offset = owl_fmtext_search(&v->fmtext, re, mode ? end : start);
     211    if (offset < 0)
     212      return 0;
     213    v->topline = owl_fmtext_line_number(&v->fmtext, offset);
     214    owl_viewwin_dirty(v);
     215    return 1;
     216  } else {
     217    /* FIXME */
     218    owl_function_error("Upwards searching is not implemented in viewwin.");
     219    return 1;
     220  }
     221}
     222
    199223void owl_viewwin_delete(owl_viewwin *v)
    200224{
Note: See TracChangeset for help on using the changeset viewer.