Changeset f7456bc for fmtext.c


Ignore:
Timestamp:
Sep 18, 2010, 3:17:27 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
dc9665a
Parents:
5b68c05
git-author:
David Benjamin <davidben@mit.edu> (07/31/10 19:09:41)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 15:17:27)
Message:
Add owl_fmtext_line_number and test.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r449c682 rf7456bc  
    580580}
    581581
     582/* Returns the line number, starting at 0, of the character which
     583 * contains the byte at 'offset'. Note that a trailing newline is part
     584 * of the line it ends. Also, while a trailing line of formatting
     585 * characters does not contribute to owl_fmtext_num_lines, those
     586 * characters are considered on a new line. */
     587int owl_fmtext_line_number(const owl_fmtext *f, int offset)
     588{
     589  int i, lineno = 0;
     590  if (offset >= f->textlen)
     591    offset = f->textlen - 1;
     592  for (i = 0; i < offset; i++) {
     593    if (f->textbuff[i] == '\n')
     594      lineno++;
     595  }
     596  return lineno;
     597}
     598
    582599const char *owl_fmtext_get_text(const owl_fmtext *f)
    583600{
Note: See TracChangeset for help on using the changeset viewer.