version 1.81, 2009/06/22 12:04:05 |
version 1.84, 2009/07/14 15:16:41 |
Line 176 term_isopendelim(const char *p, int len) |
|
Line 176 term_isopendelim(const char *p, int len) |
|
* Specifically, a line is whatever's in p->buf of length p->col, which |
* Specifically, a line is whatever's in p->buf of length p->col, which |
* is zeroed after this function returns. |
* is zeroed after this function returns. |
* |
* |
* The variables TERMP_NOLPAD, TERMP_LITERAL and TERMP_NOBREAK are of |
* The usage of termp:flags is as follows: |
* critical importance here. Their behaviour follows: |
|
* |
* |
* - TERMP_NOLPAD: when beginning to write the line, don't left-pad the |
* - TERMP_NOLPAD: when beginning to write the line, don't left-pad the |
* offset value. This is useful when doing columnar lists where the |
* offset value. This is useful when doing columnar lists where the |
Line 187 term_isopendelim(const char *p, int len) |
|
Line 186 term_isopendelim(const char *p, int len) |
|
* columns. In short: don't print a newline and instead pad to the |
* columns. In short: don't print a newline and instead pad to the |
* right margin. Used in conjunction with TERMP_NOLPAD. |
* right margin. Used in conjunction with TERMP_NOLPAD. |
* |
* |
* - TERMP_NONOBREAK: don't newline when TERMP_NOBREAK is specified. |
* - TERMP_DANGLE: don't newline when TERMP_NOBREAK is specified and |
|
* the line is overrun, and don't pad-right if it's underrun. |
* |
* |
|
* - TERMP_HANG: like TERMP_DANGLE, but doesn't newline when |
|
* overruning, instead save the position and continue at that point |
|
* when the next invocation. |
|
* |
* In-line line breaking: |
* In-line line breaking: |
* |
* |
* If TERMP_NOBREAK is specified and the line overruns the right |
* If TERMP_NOBREAK is specified and the line overruns the right |
Line 200 term_isopendelim(const char *p, int len) |
|
Line 204 term_isopendelim(const char *p, int len) |
|
* Otherwise, the line will break at the right margin. Extremely long |
* Otherwise, the line will break at the right margin. Extremely long |
* lines will cause the system to emit a warning (TODO: hyphenate, if |
* lines will cause the system to emit a warning (TODO: hyphenate, if |
* possible). |
* possible). |
|
* |
|
* FIXME: newline breaks occur (in groff) also occur when a single |
|
* space follows a NOBREAK! |
*/ |
*/ |
void |
void |
term_flushln(struct termp *p) |
term_flushln(struct termp *p) |
{ |
{ |
int i, j; |
int i, j; |
size_t vbl, vsz, vis, maxvis, mmax, bp; |
size_t vbl, vsz, vis, maxvis, mmax, bp; |
|
static int sv = -1; |
|
|
/* |
/* |
* First, establish the maximum columns of "visible" content. |
* First, establish the maximum columns of "visible" content. |
Line 220 term_flushln(struct termp *p) |
|
Line 228 term_flushln(struct termp *p) |
|
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; |
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; |
vis = 0; |
vis = 0; |
|
|
|
if (sv >= 0) { |
|
vis = (size_t)sv; |
|
sv = -1; |
|
} |
|
|
/* |
/* |
* If in the standard case (left-justified), then begin with our |
* If in the standard case (left-justified), then begin with our |
* indentation, otherwise (columns, etc.) just start spitting |
* indentation, otherwise (columns, etc.) just start spitting |
Line 295 term_flushln(struct termp *p) |
|
Line 308 term_flushln(struct termp *p) |
|
*/ |
*/ |
|
|
if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) { |
if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) { |
if ( ! (TERMP_NONOBREAK & p->flags)) { |
if ( ! (TERMP_DANGLE & p->flags) && |
|
! (TERMP_HANG & p->flags)) { |
putchar('\n'); |
putchar('\n'); |
for (i = 0; i < (int)p->rmargin; i++) |
for (i = 0; i < (int)p->rmargin; i++) |
putchar(' '); |
putchar(' '); |
} |
} |
|
if (TERMP_HANG & p->flags) |
|
sv = vis - maxvis; |
p->col = 0; |
p->col = 0; |
return; |
return; |
} |
} |
Line 310 term_flushln(struct termp *p) |
|
Line 326 term_flushln(struct termp *p) |
|
*/ |
*/ |
|
|
if (p->flags & TERMP_NOBREAK) { |
if (p->flags & TERMP_NOBREAK) { |
if ( ! (TERMP_NONOBREAK & p->flags)) |
if ( ! (TERMP_DANGLE & p->flags)) |
for ( ; vis < maxvis; vis++) |
for ( ; vis < maxvis; vis++) |
putchar(' '); |
putchar(' '); |
} else |
} else |
Line 410 term_nescape(struct termp *p, const char *word, size_t |
|
Line 426 term_nescape(struct termp *p, const char *word, size_t |
|
size_t sz; |
size_t sz; |
int i; |
int i; |
|
|
if ((rhs = term_a2ascii(p->symtab, word, len, &sz))) |
rhs = term_a2ascii(p->symtab, word, len, &sz); |
|
if (rhs) |
for (i = 0; i < (int)sz; i++) |
for (i = 0; i < (int)sz; i++) |
term_encodea(p, rhs[i]); |
term_encodea(p, rhs[i]); |
} |
} |