...except ncurses prevents using escape sequences. Grh.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@616 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2011-10-09 18:01:59 +00:00
parent 6bce15fd41
commit acfbf2781d
2 changed files with 0 additions and 52 deletions

View File

@ -369,55 +369,6 @@ idle_alarm_reset(void)
/* ************************************************************* */ /* ************************************************************* */
char *
bannerfuncmangle(char *buf, char *fromstr, char *(*strmangler)(char *))
{
static char bufnew[81];
char *loc;
char *b = buf;
char *bnpos = bufnew;
memset(bufnew, 0, 80);
if (strstr(b, fromstr)) {
while ((loc = strstr(b, fromstr)) != NULL) {
char *fn = loc + strlen(fromstr);
if (*fn == '(') {
char *fn_end = strchr(fn, ')');
if (fn_end) {
char funcparam[81];
char *funcout;
fn++;
memset(funcparam, 0, 80);
memcpy(funcparam, fn, (fn_end - fn));
funcout = (*strmangler)(funcparam);
memcpy(bnpos, b, (loc - b));
bnpos += strlen(bnpos);
b = fn_end;
b++;
memcpy(bnpos, funcout, strlen(funcout));
bnpos += strlen(funcout);
}
}
}
}
strcpy(bnpos, b);
return bufnew;
}
char *
bannermangler_func_esc(char *str)
{
static char buf[11];
int len = strlen(str);
if (len > 7) len = 7;
buf[0] = '\x1b';
buf[1] = '[';
strncpy((buf + 2), str, len);
buf[len+2] = 'm';
buf[len+3] = '\0';
return buf;
}
char * char *
bannerstrmangle(char *buf, char *fromstr, char *tostr) bannerstrmangle(char *buf, char *fromstr, char *tostr)
@ -576,7 +527,6 @@ loadbanner (char *fname, struct dg_banner *ban)
} else { } else {
strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", "[Anonymous]"), 80); strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", "[Anonymous]"), 80);
} }
strncpy(bufnew, bannerfuncmangle(bufnew, "$ESC", bannermangler_func_esc), 80);
banner_addline(ban, bufnew); banner_addline(ban, bufnew);
} }

View File

@ -58,8 +58,6 @@ bannervars = [ "$MOTDTIME" = "2011.10.08",
# - $VERSION replaced with "dgamelaunch v" + dgl version number. # - $VERSION replaced with "dgamelaunch v" + dgl version number.
# - $USERNAME replaced with logged-in user's name, or with "[Anonymous]" # - $USERNAME replaced with logged-in user's name, or with "[Anonymous]"
# - $INCLUDE(filename) the named file will be inserted here. # - $INCLUDE(filename) the named file will be inserted here.
# - $ESC(code) Allows to use ECMA-48 SGR escape sequences, setting
# text color and attributes. will output "ESC [ code m"
banner = "/dgl-banner" banner = "/dgl-banner"
# The following two options are fairly insecure. They will force us to # The following two options are fairly insecure. They will force us to