#define FREV '7'
enum {
- NORMAL = 0, /* Must be zero, see initbuf() */
- ALTSET = 1 << 0, /* Reverse */
- SUPERSC = 1 << 1, /* Dim */
- SUBSC = 1 << 2, /* Dim | Ul */
- UNDERL = 1 << 3, /* Ul */
- BOLD = 1 << 4, /* Bold */
+ NORMAL_CHARSET = 0, /* Must be zero, see initbuf() */
+ ALTERNATIVE_CHARSET = 1 << 0, /* Reverse */
+ SUPERSCRIPT = 1 << 1, /* Dim */
+ SUBSCRIPT = 1 << 2, /* Dim | Ul */
+ UNDERLINE = 1 << 3, /* Ul */
+ BOLD = 1 << 4, /* Bold */
};
struct term_caps {
ctl->obuflen = BUFSIZ;
ctl->obuf = xcalloc(ctl->obuflen, sizeof(struct ul_char));
} else
- /* assumes NORMAL == 0 */
+ /* assumes NORMAL_CHARSET == 0 */
memset(ctl->obuf, 0, sizeof(struct ul_char) * ctl->maxcol);
setcol(ctl, 0);
ctl->maxcol = 0;
- ctl->mode &= ALTSET;
+ ctl->mode &= ALTERNATIVE_CHARSET;
}
static void initinfo(struct ul_ctl *ctl, struct term_caps *const tcs)
static void xsetmode(struct ul_ctl *ctl, struct term_caps const *const tcs, int newmode)
{
if (!ctl->iflag) {
- if (ctl->curmode != NORMAL && newmode != NORMAL)
- xsetmode(ctl, tcs, NORMAL);
+ if (ctl->curmode != NORMAL_CHARSET && newmode != NORMAL_CHARSET)
+ xsetmode(ctl, tcs, NORMAL_CHARSET);
switch (newmode) {
- case NORMAL:
+ case NORMAL_CHARSET:
switch (ctl->curmode) {
- case NORMAL:
+ case NORMAL_CHARSET:
break;
- case UNDERL:
+ case UNDERLINE:
print_out(tcs->exit_underline);
break;
default:
break;
}
break;
- case ALTSET:
+ case ALTERNATIVE_CHARSET:
print_out(tcs->enter_reverse);
break;
- case SUPERSC:
+ case SUPERSCRIPT:
/*
* This only works on a few terminals.
* It should be fixed.
print_out(tcs->enter_underline);
print_out(tcs->enter_dim);
break;
- case SUBSC:
+ case SUBSCRIPT:
print_out(tcs->enter_dim);
break;
- case UNDERL:
+ case UNDERLINE:
print_out(tcs->enter_underline);
break;
case BOLD:
for (i = 0; i < ctl->maxcol; i++)
switch (ctl->obuf[i].c_mode) {
- case NORMAL: *cp++ = ' '; break;
- case ALTSET: *cp++ = 'g'; break;
- case SUPERSC: *cp++ = '^'; break;
- case SUBSC: *cp++ = 'v'; break;
- case UNDERL: *cp++ = '_'; break;
- case BOLD: *cp++ = '!'; break;
- default: *cp++ = 'X'; break;
+ case NORMAL_CHARSET: *cp++ = ' '; break;
+ case ALTERNATIVE_CHARSET: *cp++ = 'g'; break;
+ case SUPERSCRIPT: *cp++ = '^'; break;
+ case SUBSCRIPT: *cp++ = 'v'; break;
+ case UNDERLINE: *cp++ = '_'; break;
+ case BOLD: *cp++ = '!'; break;
+ default: *cp++ = 'X'; break;
}
for (*cp = ' '; *cp == ' '; cp--)
*cp = 0;
int i;
putwchar(c);
- if (ctl->must_use_uc && (ctl->curmode & UNDERL)) {
+ if (ctl->must_use_uc && (ctl->curmode & UNDERLINE)) {
for (i = 0; i < width; i++)
print_out(tcs->curs_left);
for (i = 0; i < width; i++)
/* Set up overstrike buffer */
for (i = 0; i < ctl->maxcol; i++)
switch (ctl->obuf[i].c_mode) {
- case NORMAL:
+ case NORMAL_CHARSET:
default:
*cp++ = ' ';
break;
- case UNDERL:
+ case UNDERLINE:
*cp++ = '_';
break;
case BOLD:
int i;
int hadmodes = 0;
- lastmode = NORMAL;
+ lastmode = NORMAL_CHARSET;
for (i = 0; i < ctl->maxcol; i++) {
if (ctl->obuf[i].c_mode != lastmode) {
hadmodes++;
if (ctl->obuf[i].c_width > 1)
i += ctl->obuf[i].c_width - 1;
}
- if (lastmode != NORMAL)
- xsetmode(ctl, tcs, NORMAL);
+ if (lastmode != NORMAL_CHARSET)
+ xsetmode(ctl, tcs, NORMAL_CHARSET);
if (ctl->must_overstrike && hadmodes)
overstrike(ctl);
putwchar('\n');
switch (c = getwc(f)) {
case HREV:
if (ctl->halfpos == 0) {
- ctl->mode |= SUPERSC;
+ ctl->mode |= SUPERSCRIPT;
ctl->halfpos--;
} else if (ctl->halfpos > 0) {
- ctl->mode &= ~SUBSC;
+ ctl->mode &= ~SUBSCRIPT;
ctl->halfpos--;
} else {
ctl->halfpos = 0;
return 0;
case HFWD:
if (ctl->halfpos == 0) {
- ctl->mode |= SUBSC;
+ ctl->mode |= SUBSCRIPT;
ctl->halfpos++;
} else if (ctl->halfpos < 0) {
- ctl->mode &= ~SUPERSC;
+ ctl->mode &= ~SUPERSCRIPT;
ctl->halfpos++;
} else {
ctl->halfpos = 0;
setcol(ctl, 0);
continue;
case SO:
- ctl->mode |= ALTSET;
+ ctl->mode |= ALTERNATIVE_CHARSET;
continue;
case SI:
- ctl->mode &= ~ALTSET;
+ ctl->mode &= ~ALTERNATIVE_CHARSET;
continue;
case IESC:
if (handle_escape(ctl, tcs, f)) {
ctl->col--;
w = ctl->obuf[ctl->col].c_width;
for (i = 0; i < w; i++)
- ctl->obuf[ctl->col++].c_mode |= UNDERL | ctl->mode;
+ ctl->obuf[ctl->col++].c_mode |= UNDERLINE | ctl->mode;
setcol(ctl, ctl->col);
continue;
}
} else if (ctl->obuf[ctl->col].c_char == '_') {
ctl->obuf[ctl->col].c_char = c;
for (i = 0; i < w; i++)
- ctl->obuf[ctl->col + i].c_mode |= UNDERL | ctl->mode;
+ ctl->obuf[ctl->col + i].c_mode |= UNDERLINE | ctl->mode;
ctl->obuf[ctl->col].c_width = w;
for (i = 1; i < w; i++)
ctl->obuf[ctl->col + i].c_width = -1;
int c, ret, tflag = 0;
char *termtype;
struct term_caps tcs = { 0 };
- struct ul_ctl ctl = { .curmode = NORMAL };
+ struct ul_ctl ctl = { .curmode = NORMAL_CHARSET };
FILE *f;
static const struct option longopts[] = {