Changeset 4d4f0ba for text.c


Ignore:
Timestamp:
Jul 20, 2011, 4:39:33 PM (14 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
ac919d96
Parents:
d8f22b6
git-author:
Jason Gross <jgross@mit.edu> (07/20/11 03:09:43)
git-committer:
Jason Gross <jgross@mit.edu> (07/20/11 16:39:33)
Message:
Give owl_text_indent an indent_first_line parameter

This is useful if you need to indent text that isn't broken into chunks
that end with newlines.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • text.c

    r6829afc r4d4f0ba  
    77/* Returns a copy of 'in' with each line indented 'n'
    88 * characters. Result must be freed with g_free. */
    9 CALLER_OWN char *owl_text_indent(const char *in, int n)
     9CALLER_OWN char *owl_text_indent(const char *in, int n, bool indent_first_line)
    1010{
    1111  const char *ptr1, *ptr2, *last;
    1212  GString *out = g_string_new("");
    1313  int i;
     14  bool indent_this_line = indent_first_line;
    1415
    1516  last=in+strlen(in)-1;
    1617  ptr1=in;
    1718  while (ptr1<=last) {
    18     for (i=0; i<n; i++) {
    19       g_string_append_c(out, ' ');
    20     }
     19    if (indent_this_line) {
     20      for (i = 0; i < n; i++) {
     21        g_string_append_c(out, ' ');
     22      }
     23    }
     24    indent_this_line = true;
    2125    ptr2=strchr(ptr1, '\n');
    2226    if (!ptr2) {
Note: See TracChangeset for help on using the changeset viewer.