more tty-status updates
This commit is contained in:
135
src/mapglyph.c
135
src/mapglyph.c
@@ -247,6 +247,77 @@ int glyph;
|
||||
return encbuf;
|
||||
}
|
||||
|
||||
char *
|
||||
decode_mixed(buf, str)
|
||||
char *buf;
|
||||
const char *str;
|
||||
{
|
||||
static const char hex[] = "00112233445566778899aAbBcCdDeEfF";
|
||||
char *put = buf;
|
||||
|
||||
if (!put || !str)
|
||||
return "";
|
||||
|
||||
while (*str) {
|
||||
if (*str == '\\') {
|
||||
int rndchk, dcount, so, gv, ch = 0, oc = 0;
|
||||
unsigned os = 0;
|
||||
const char *dp, *save_str;
|
||||
|
||||
save_str = str++;
|
||||
switch (*str) {
|
||||
case 'G': /* glyph value \GXXXXNNNN*/
|
||||
rndchk = dcount = 0;
|
||||
for (++str; *str && ++dcount <= 4; ++str)
|
||||
if ((dp = index(hex, *str)) != 0)
|
||||
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
if (rndchk == context.rndencode) {
|
||||
gv = dcount = 0;
|
||||
for (; *str && ++dcount <= 4; ++str)
|
||||
if ((dp = index(hex, *str)) != 0)
|
||||
gv = (gv * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
|
||||
*put++ = showsyms[so];
|
||||
/* 'str' is ready for the next loop iteration and '*str'
|
||||
should not be copied at the end of this iteration */
|
||||
continue;
|
||||
} else {
|
||||
/* possible forgery - leave it the way it is */
|
||||
str = save_str;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case 'S': /* symbol offset */
|
||||
so = rndchk = dcount = 0;
|
||||
for (++str; *str && ++dcount <= 4; ++str)
|
||||
if ((dp = index(hex, *str)) != 0)
|
||||
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
if (rndchk == context.rndencode) {
|
||||
dcount = 0;
|
||||
for (; *str && ++dcount <= 2; ++str)
|
||||
if ((dp = index(hex, *str)) != 0)
|
||||
so = (so * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
}
|
||||
*put++ = showsyms[so];
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
break;
|
||||
}
|
||||
}
|
||||
*put++ = *str++;
|
||||
}
|
||||
*put = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* This differs from putstr() because the str parameter can
|
||||
* contain a sequence of characters representing:
|
||||
@@ -265,71 +336,9 @@ winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
static const char hex[] = "00112233445566778899aAbBcCdDeEfF";
|
||||
char buf[BUFSZ];
|
||||
const char *cp = str;
|
||||
char *put = buf;
|
||||
|
||||
while (*cp) {
|
||||
if (*cp == '\\') {
|
||||
int rndchk, dcount, so, gv, ch = 0, oc = 0;
|
||||
unsigned os = 0;
|
||||
const char *dp, *save_cp;
|
||||
|
||||
save_cp = cp++;
|
||||
switch (*cp) {
|
||||
case 'G': /* glyph value \GXXXXNNNN*/
|
||||
rndchk = dcount = 0;
|
||||
for (++cp; *cp && ++dcount <= 4; ++cp)
|
||||
if ((dp = index(hex, *cp)) != 0)
|
||||
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
if (rndchk == context.rndencode) {
|
||||
gv = dcount = 0;
|
||||
for (; *cp && ++dcount <= 4; ++cp)
|
||||
if ((dp = index(hex, *cp)) != 0)
|
||||
gv = (gv * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
|
||||
*put++ = showsyms[so];
|
||||
/* 'cp' is ready for the next loop iteration and '*cp'
|
||||
should not be copied at the end of this iteration */
|
||||
continue;
|
||||
} else {
|
||||
/* possible forgery - leave it the way it is */
|
||||
cp = save_cp;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case 'S': /* symbol offset */
|
||||
so = rndchk = dcount = 0;
|
||||
for (++cp; *cp && ++dcount <= 4; ++cp)
|
||||
if ((dp = index(hex, *cp)) != 0)
|
||||
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
if (rndchk == context.rndencode) {
|
||||
dcount = 0;
|
||||
for (; *cp && ++dcount <= 2; ++cp)
|
||||
if ((dp = index(hex, *cp)) != 0)
|
||||
so = (so * 16) + ((int) (dp - hex) / 2);
|
||||
else
|
||||
break;
|
||||
}
|
||||
*put++ = showsyms[so];
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
break;
|
||||
}
|
||||
}
|
||||
*put++ = *cp++;
|
||||
}
|
||||
*put = '\0';
|
||||
/* now send it to the normal putstr */
|
||||
putstr(window, attr, buf);
|
||||
putstr(window, attr, decode_mixed(buf, str));
|
||||
}
|
||||
|
||||
/*mapglyph.c*/
|
||||
|
||||
Reference in New Issue
Block a user