Adding undercurl patch ref. #20
This commit is contained in:
parent
ce05a34de1
commit
79278e3d32
6 changed files with 187 additions and 2 deletions
67
st.c
67
st.c
|
|
@ -42,6 +42,9 @@
|
|||
#define UTF_SIZ 4
|
||||
#define ESC_BUF_SIZ (128*UTF_SIZ)
|
||||
#define ESC_ARG_SIZ 16
|
||||
#if UNDERCURL_PATCH
|
||||
#define CAR_PER_ARG 4
|
||||
#endif // UNDERCURL_PATCH
|
||||
#define STR_BUF_SIZ ESC_BUF_SIZ
|
||||
#define STR_ARG_SIZ ESC_ARG_SIZ
|
||||
|
||||
|
|
@ -126,6 +129,9 @@ typedef struct {
|
|||
int arg[ESC_ARG_SIZ];
|
||||
int narg; /* nb of args */
|
||||
char mode[2];
|
||||
#if UNDERCURL_PATCH
|
||||
int carg[ESC_ARG_SIZ][CAR_PER_ARG]; /* colon args */
|
||||
#endif // UNDERCURL_PATCH
|
||||
} CSIEscape;
|
||||
|
||||
/* STR Escape sequence structs */
|
||||
|
|
@ -146,6 +152,9 @@ static void ttywriteraw(const char *, size_t);
|
|||
|
||||
static void csidump(void);
|
||||
static void csihandle(void);
|
||||
#if UNDERCURL_PATCH
|
||||
static void readcolonargs(char **, int, int[][CAR_PER_ARG]);
|
||||
#endif // UNDERCURL_PATCH
|
||||
static void csiparse(void);
|
||||
static void csireset(void);
|
||||
static int eschandle(uchar);
|
||||
|
|
@ -1286,6 +1295,30 @@ tnewline(int first_col)
|
|||
tmoveto(first_col ? 0 : term.c.x, y);
|
||||
}
|
||||
|
||||
#if UNDERCURL_PATCH
|
||||
void
|
||||
readcolonargs(char **p, int cursor, int params[][CAR_PER_ARG])
|
||||
{
|
||||
int i = 0;
|
||||
for (; i < CAR_PER_ARG; i++)
|
||||
params[cursor][i] = -1;
|
||||
|
||||
if (**p != ':')
|
||||
return;
|
||||
|
||||
char *np = NULL;
|
||||
i = 0;
|
||||
|
||||
while (**p == ':' && i < CAR_PER_ARG) {
|
||||
while (**p == ':')
|
||||
(*p)++;
|
||||
params[cursor][i] = strtol(*p, &np, 10);
|
||||
*p = np;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#endif // UNDERCURL_PATCH
|
||||
|
||||
void
|
||||
csiparse(void)
|
||||
{
|
||||
|
|
@ -1308,6 +1341,9 @@ csiparse(void)
|
|||
v = -1;
|
||||
csiescseq.arg[csiescseq.narg++] = v;
|
||||
p = np;
|
||||
#if UNDERCURL_PATCH
|
||||
readcolonargs(&p, csiescseq.narg-1, csiescseq.carg);
|
||||
#endif // UNDERCURL_PATCH
|
||||
if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
|
||||
break;
|
||||
p++;
|
||||
|
|
@ -1537,6 +1573,12 @@ tsetattr(int *attr, int l)
|
|||
ATTR_STRUCK );
|
||||
term.c.attr.fg = defaultfg;
|
||||
term.c.attr.bg = defaultbg;
|
||||
#if UNDERCURL_PATCH
|
||||
term.c.attr.ustyle = -1;
|
||||
term.c.attr.ucolor[0] = -1;
|
||||
term.c.attr.ucolor[1] = -1;
|
||||
term.c.attr.ucolor[2] = -1;
|
||||
#endif // UNDERCURL_PATCH
|
||||
break;
|
||||
case 1:
|
||||
term.c.attr.mode |= ATTR_BOLD;
|
||||
|
|
@ -1548,7 +1590,18 @@ tsetattr(int *attr, int l)
|
|||
term.c.attr.mode |= ATTR_ITALIC;
|
||||
break;
|
||||
case 4:
|
||||
#if UNDERCURL_PATCH
|
||||
term.c.attr.ustyle = csiescseq.carg[i][0];
|
||||
|
||||
if (term.c.attr.ustyle != 0)
|
||||
term.c.attr.mode |= ATTR_UNDERLINE;
|
||||
else
|
||||
term.c.attr.mode &= ~ATTR_UNDERLINE;
|
||||
|
||||
term.c.attr.mode ^= ATTR_DIRTYUNDERLINE;
|
||||
#else
|
||||
term.c.attr.mode |= ATTR_UNDERLINE;
|
||||
#endif // UNDERCURL_PATCH
|
||||
break;
|
||||
case 5: /* slow blink */
|
||||
/* FALLTHROUGH */
|
||||
|
|
@ -1607,6 +1660,20 @@ tsetattr(int *attr, int l)
|
|||
case 49:
|
||||
term.c.attr.bg = defaultbg;
|
||||
break;
|
||||
#if UNDERCURL_PATCH
|
||||
case 58:
|
||||
term.c.attr.ucolor[0] = csiescseq.carg[i][1];
|
||||
term.c.attr.ucolor[1] = csiescseq.carg[i][2];
|
||||
term.c.attr.ucolor[2] = csiescseq.carg[i][3];
|
||||
term.c.attr.mode ^= ATTR_DIRTYUNDERLINE;
|
||||
break;
|
||||
case 59:
|
||||
term.c.attr.ucolor[0] = -1;
|
||||
term.c.attr.ucolor[1] = -1;
|
||||
term.c.attr.ucolor[2] = -1;
|
||||
term.c.attr.mode ^= ATTR_DIRTYUNDERLINE;
|
||||
break;
|
||||
#endif // UNDERCURL_PATCH
|
||||
default:
|
||||
if (BETWEEN(attr[i], 30, 37)) {
|
||||
#if MONOCHROME_PATCH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue