version 1.74, 2009/04/12 19:45:26 |
version 1.78, 2009/06/11 10:34:32 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 106 term_alloc(enum termenc enc) |
|
Line 106 term_alloc(enum termenc enc) |
|
if (NULL == (p = malloc(sizeof(struct termp)))) |
if (NULL == (p = malloc(sizeof(struct termp)))) |
err(1, "malloc"); |
err(1, "malloc"); |
bzero(p, sizeof(struct termp)); |
bzero(p, sizeof(struct termp)); |
p->maxrmargin = 78; |
p->maxrmargin = 80; |
p->enc = enc; |
p->enc = enc; |
return(p); |
return(p); |
} |
} |
Line 272 term_flushln(struct termp *p) |
|
Line 272 term_flushln(struct termp *p) |
|
vis = p->rmargin - p->offset; |
vis = p->rmargin - p->offset; |
} |
} |
|
|
/* |
/* |
* Write out the word and a trailing space. Omit the |
* Prepend a space if we're not already at the beginning |
* space if we're the last word in the line or beyond |
* of the line, then the word. |
* our breakpoint. |
|
*/ |
*/ |
|
|
|
if (0 < vis++) |
|
putchar(' '); |
|
|
for ( ; i < (int)p->col; i++) { |
for ( ; i < (int)p->col; i++) { |
if (' ' == p->buf[i]) |
if (' ' == p->buf[i]) |
break; |
break; |
putchar(p->buf[i]); |
putchar(p->buf[i]); |
} |
} |
vis += vsz; |
vis += vsz; |
if (i < (int)p->col && vis <= bp) { |
|
putchar(' '); |
|
vis++; |
|
} |
|
} |
} |
|
|
/* |
/* |
Line 295 term_flushln(struct termp *p) |
|
Line 293 term_flushln(struct termp *p) |
|
* cause a newline and offset at the right margin. |
* cause a newline and offset at the right margin. |
*/ |
*/ |
|
|
if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) { |
if ((TERMP_NOBREAK & p->flags) && vis > maxvis) { |
if ( ! (TERMP_NONOBREAK & p->flags)) { |
if ( ! (TERMP_NONOBREAK & p->flags)) { |
putchar('\n'); |
putchar('\n'); |
for (i = 0; i < (int)p->rmargin; i++) |
for (i = 0; i < (int)p->rmargin; i++) |
Line 312 term_flushln(struct termp *p) |
|
Line 310 term_flushln(struct termp *p) |
|
|
|
if (p->flags & TERMP_NOBREAK) { |
if (p->flags & TERMP_NOBREAK) { |
if ( ! (TERMP_NONOBREAK & p->flags)) |
if ( ! (TERMP_NONOBREAK & p->flags)) |
for ( ; vis < maxvis; vis++) |
for ( ; vis <= maxvis; vis++) |
putchar(' '); |
putchar(' '); |
} else |
} else |
putchar('\n'); |
putchar('\n'); |