/**** message which is shown after closing joe (CTRL+x; CTRL+k) *****/ void genexmsg(BW *bw, int saved, char *name) { const char *s; if (bw->b->name && bw->b->name[0]) { s = bw->b->name; } else { s = joe_gettext(_("(Unnamed)")); } if (name) { if (saved) { joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("File %s saved")), name); } else { joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("File %s not saved")), name); } } else if (bw->b->changed && bw->b->count == 1) { joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("File %s not saved")), s); } else if (saved) { joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("File %s saved")), s); } else { joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("File %s not changed so no update needed")), s); } if (exmsg) vsrm(exmsg); exmsg = vsncpy(NULL,0,sz(msgbuf)); if (!noexmsg) { /* duplicate backslashes in file names because msgnw interprets escape sequences */ char *t = duplicate_backslashes(sz(msgbuf)); zcpy(msgbuf, t); vsrm(t); msgnw(bw->parent, msgbuf); } }
/* static */char *stagen(char *stalin, BW *bw, const char *s, char fill) { char buf[80]; int x; int field; W *w = bw->parent; time_t n=time(NULL); struct tm *cas; cas=localtime(&n); stalin = vstrunc(stalin, 0); while (*s) { if (*s == '%' && s[1]) { field = 0; ++s; while (*s >= '0' && *s <= '9' && s[1]) { field = field * 10 + *s - '0'; ++s; } switch (*s) { case 'v': /* Version of JOE */ { joe_snprintf_1(buf, SIZEOF(buf), "%s", VERSION); stalin = vsncpy(sv(stalin), sz(buf)); } break; case 'x': /* Context (but only if autoindent is enabled) */ { if ( bw->o.autoindent) { char *ts = get_context(bw); /* We need to translate between file's character set to locale */ my_iconv(stdbuf, SIZEOF(stdbuf), locale_map,ts,bw->o.charmap); stalin = vsncpy(sv(stalin), sz(stdbuf)); } } break; case 'y': { if (bw->o.syntax) { joe_snprintf_1(buf, SIZEOF(buf), "(%s)", bw->o.syntax->name); stalin = vsncpy(sv(stalin), sz(buf)); } } break; case 't': { time_t curtime = time(NULL); int l; char *d = ctime(&curtime); l = (d[11] - '0') * 10 + d[12] - '0'; if (l > 12) l -= 12; joe_snprintf_1(buf, SIZEOF(buf), "%2.2d", l); if (buf[0] == '0') buf[0] = fill; stalin = vsncpy(sv(stalin), buf, 2); stalin = vsncpy(sv(stalin), d + 13, 3); } break; case 'd': { if (s[1]) switch (*++s) { case 'd' : joe_snprintf_1(buf, SIZEOF(buf), "%02d",cas->tm_mday); break; case 'm' : joe_snprintf_1(buf, SIZEOF(buf), "%02d",cas->tm_mon + 1); break; case 'y' : joe_snprintf_1(buf, SIZEOF(buf), "%02d",cas->tm_year % 100); break; case 'Y' : joe_snprintf_1(buf, SIZEOF(buf), "%04d",cas->tm_year + 1900); break; case 'w' : joe_snprintf_1(buf, SIZEOF(buf), "%d",cas->tm_wday); break; case 'D' : joe_snprintf_1(buf, SIZEOF(buf), "%03d",cas->tm_yday); break; default : buf[0]='d'; buf[1]=*s; buf[2]=0; } else { buf[0]='d'; buf[1]=0; } stalin=vsncpy(sv(stalin),sz(buf)); } break; case 'E': { char *ch; int l; buf[0]=0; for(l=0;s[l+1] && s[l+1] != '%'; l++) buf[l]=s[l+1]; if (s[l+1]=='%' && buf[0]) { buf[l]=0; s+=l+1; ch=getenv(buf); if (ch) stalin=vsncpy(sv(stalin),sz(ch)); } } break; case 'Z': { const char *ch; int l; buf[0]=0; for(l=0;s[l+1] && s[l+1] != '%'; l++) buf[l]=s[l+1]; if (s[l+1]=='%' && buf[0]) { buf[l]=0; s+=l+1; ch=get_status(bw, buf); if (ch) stalin=vsncpy(sv(stalin),sz(ch)); } } break; case 'u': { time_t curtime = time(NULL); char *d = ctime(&curtime); stalin = vsncpy(sv(stalin), d + 11, 5); } break; case 'T': if (bw->o.overtype) stalin = vsadd(stalin, 'O'); else stalin = vsadd(stalin, 'I'); break; case 'W': if (bw->o.wordwrap) stalin = vsadd(stalin, 'W'); else stalin = vsadd(stalin, fill); break; case 'I': if (bw->o.autoindent) stalin = vsadd(stalin, 'A'); else stalin = vsadd(stalin, fill); break; case 'X': if (square) stalin = vsadd(stalin, 'X'); else stalin = vsadd(stalin, fill); break; case 'n': { if (bw->b->name) { char *tmp = simplify_prefix(bw->b->name); char *tmp1 = duplicate_backslashes(sv(tmp)); vsrm(tmp); stalin = vsncpy(sv(stalin), sv(tmp1)); vsrm(tmp1); } else { stalin = vsncpy(sv(stalin), sz(joe_gettext(_("Unnamed")))); } } break; case 'm': if (bw->b->changed) stalin = vsncpy(sv(stalin), sz(joe_gettext(_("(Modified)")))); break; case 'R': if (bw->b->rdonly) stalin = vsncpy(sv(stalin), sz(joe_gettext(_("(Read only)")))); break; case '*': if (bw->b->changed) stalin = vsadd(stalin, '*'); else stalin = vsadd(stalin, fill); break; case 'r': if (field) #ifdef HAVE_LONG_LONG joe_snprintf_1(buf, SIZEOF(buf), "%-4lld", (long long)(bw->cursor->line + 1)); #else joe_snprintf_1(buf, SIZEOF(buf), "%-4ld", (long)(bw->cursor->line + 1)); #endif else #ifdef HAVE_LONG_LONG joe_snprintf_1(buf, SIZEOF(buf), "%lld", (long long)(bw->cursor->line + 1)); #else joe_snprintf_1(buf, SIZEOF(buf), "%ld", (long)(bw->cursor->line + 1)); #endif for (x = 0; buf[x]; ++x) if (buf[x] == ' ') buf[x] = fill; stalin = vsncpy(sv(stalin), sz(buf)); break; case 'o': if (field) #ifdef HAVE_LONG_LONG joe_snprintf_1(buf, SIZEOF(buf), "%-4lld", (long long)bw->cursor->byte); #else joe_snprintf_1(buf, SIZEOF(buf), "%-4ld", (long)bw->cursor->byte); #endif else #ifdef HAVE_LONG_LONG joe_snprintf_1(buf, SIZEOF(buf), "%lld", (long long)bw->cursor->byte); #else joe_snprintf_1(buf, SIZEOF(buf), "%ld", (long)bw->cursor->byte); #endif for (x = 0; buf[x]; ++x) if (buf[x] == ' ') buf[x] = fill; stalin = vsncpy(sv(stalin), sz(buf)); break; case 'O': if (field) #ifdef HAVE_LONG_LONG joe_snprintf_1(buf, SIZEOF(buf), "%-4llX", (unsigned long long)bw->cursor->byte); #else joe_snprintf_1(buf, SIZEOF(buf), "%-4lX", (unsigned long)bw->cursor->byte); #endif else