mirror of
https://git.savannah.gnu.org/git/screen.git
synced 2026-02-10 17:31:59 +02:00
Create TERMCAP entries limited to 1023 bytes by default.
TERMCAP_BUF defaults to 1023 to create TERMCAP entries that work on most systems. To save space, TERMCAP is unwrapped, and vt220 extra keys are skipped (unless TERMCAP_BUF > 1023); navigation keys are still included. Entries larger than TERMCAP_BUF are now truncated, and no longer Panic screen. Termcap entries are still wrapped when saved to a file. Signed-off-by: Scott Shambarger <devel@shambarger.net>
This commit is contained in:
committed by
Amadeusz Sławiński
parent
fa4f88614d
commit
11a1fc82fb
6
src/dumptermcap.h
Normal file
6
src/dumptermcap.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef SCREEN_DUMPTERMCAP_H
|
||||
#define SCREEN_DUMPTERMCAP_H
|
||||
|
||||
void DumpTermcap (int, FILE *);
|
||||
|
||||
#endif /* SCREEN_DUMPTERMCAP_H */
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "misc.h"
|
||||
#include "process.h"
|
||||
#include "termcap.h"
|
||||
#include "dumptermcap.h"
|
||||
#include "encoding.h"
|
||||
|
||||
static char *CatExtra(char *, char *);
|
||||
@@ -438,10 +439,7 @@ void WriteFile(struct acluser *user, char *fn, int dump)
|
||||
}
|
||||
break;
|
||||
case DUMP_TERMCAP:
|
||||
if ((c = strchr(MakeTermcap(fore->w_aflag), '=')) != NULL) {
|
||||
fputs(++c, f);
|
||||
putc('\n', f);
|
||||
}
|
||||
DumpTermcap(fore->w_aflag, f);
|
||||
break;
|
||||
case DUMP_EXCHANGE:
|
||||
c = user->u_plop.buf;
|
||||
|
||||
2
src/os.h
2
src/os.h
@@ -148,7 +148,7 @@ typedef char* slot_t; /* used internally in utmp.c */
|
||||
*/
|
||||
|
||||
#ifndef TERMCAP_BUFSIZE
|
||||
# define TERMCAP_BUFSIZE 2048
|
||||
# define TERMCAP_BUFSIZE 1023
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -201,6 +201,7 @@ struct term term[T_N] =
|
||||
{ "F1", T_STR }, KMAPDEF("\033[23~")
|
||||
{ "F2", T_STR }, KMAPDEF("\033[24~")
|
||||
/* extra keys for vt220 (David.Leonard@it.uq.edu.au) */
|
||||
/* define T_FEXTRA */
|
||||
{ "F3", T_STR },
|
||||
{ "F4", T_STR },
|
||||
{ "F5", T_STR },
|
||||
|
||||
@@ -62,11 +62,10 @@ char screenterm[MAXTERMLEN + 1]; /* new $TERM, usually "screen" */
|
||||
|
||||
char *extra_incap, *extra_outcap;
|
||||
|
||||
static const char TermcapConst[] = "\\\n\
|
||||
\t:DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:UP=\\E[%dA:bs:bt=\\E[Z:\\\n\
|
||||
\t:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:ct=\\E[3g:\\\n\
|
||||
\t:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\\\n\
|
||||
\t:le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:";
|
||||
static const char TermcapConst[] = "DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:\
|
||||
UP=\\E[%dA:bs:bt=\\E[Z:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:\
|
||||
ct=\\E[3g:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\
|
||||
le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:";
|
||||
|
||||
char *gettermcapstring(char *s)
|
||||
{
|
||||
@@ -641,17 +640,12 @@ static void AddCap(char *s)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (tcLineLen + (n = strlen(s)) > 55 && Termcaplen < TERMCAP_BUFSIZE - 4 - 1) {
|
||||
strcpy(Termcap + Termcaplen, "\\\n\t:");
|
||||
Termcaplen += 4;
|
||||
tcLineLen = 0;
|
||||
}
|
||||
n = strlen(s);
|
||||
if (Termcaplen + n < TERMCAP_BUFSIZE - 1) {
|
||||
strcpy(Termcap + Termcaplen, s);
|
||||
Termcaplen += n;
|
||||
tcLineLen += n;
|
||||
} else
|
||||
Panic(0, "TERMCAP overflow - sorry.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -809,6 +803,12 @@ char *MakeTermcap(bool aflag)
|
||||
if (i < T_OCAPS) {
|
||||
if (i >= T_KEYPAD) /* don't put keypad codes in TERMCAP */
|
||||
continue; /* - makes it too big */
|
||||
#if (TERMCAP_BUF < 1024)
|
||||
if (i >= T_FEXTRA && i < T_BACKTAB) /* also skip extra vt220 keys */
|
||||
continue;
|
||||
if (i > T_BACKTAB && i < T_NAVIGATE) /* more vt220 keys */
|
||||
continue;
|
||||
#endif
|
||||
if (i >= T_CURSOR && i < T_OCAPS) {
|
||||
act = &umtab[i - (T_CURSOR - T_OCAPS + T_CAPS)];
|
||||
if (act->nr == RC_ILLEGAL)
|
||||
@@ -854,6 +854,33 @@ char *MakeTermcap(bool aflag)
|
||||
return Termcap;
|
||||
}
|
||||
|
||||
#define TERMCAP_MAX_WIDTH 63
|
||||
void DumpTermcap(int aflag, FILE *f)
|
||||
{
|
||||
const char *p, *pe;
|
||||
int n, col = 0;
|
||||
|
||||
if ((p = index(MakeTermcap(aflag), '=')) == NULL)
|
||||
return;
|
||||
p++;
|
||||
/* write termcap entry with wrapping */
|
||||
while ((pe = index(p, ':')))
|
||||
{
|
||||
n = pe - p + 1;
|
||||
if ((col > 8) && ((col + n) > TERMCAP_MAX_WIDTH))
|
||||
{
|
||||
fwrite("\\\n\t:", 1, 4, f);
|
||||
col = 8;
|
||||
}
|
||||
fwrite(p, 1, n, f);
|
||||
col += n;
|
||||
p = ++pe;
|
||||
}
|
||||
if(*p)
|
||||
fwrite(p, 1, strlen(p), f);
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
static void MakeString(char *cap, char *buf, int buflen, char *s)
|
||||
{
|
||||
char *p, *pmax;
|
||||
|
||||
Reference in New Issue
Block a user