summaryrefslogtreecommitdiff
path: root/termcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'termcap.c')
-rw-r--r--termcap.c90
1 files changed, 55 insertions, 35 deletions
diff --git a/termcap.c b/termcap.c
index 1ebaccf..f09e6ac 100644
--- a/termcap.c
+++ b/termcap.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1993
+/* Copyright (c) 1993-2002
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
* Copyright (c) 1987 Oliver Laumann
@@ -33,7 +33,7 @@ extern struct display *display, *displays;
extern int real_uid, real_gid, eff_uid, eff_gid;
extern struct term term[]; /* terminal capabilities */
extern struct NewWindow nwin_undef, nwin_default, nwin_options;
-extern int force_vt, assume_LP;
+extern int force_vt;
extern int Z0width, Z1width;
extern int hardstatusemu;
#ifdef MAPKEYS
@@ -202,7 +202,7 @@ int he;
{
/* standard fixes for xterms etc */
/* assume color for everything that looks ansi-compatible */
- if (!D_CAF && D_ME && InStr(D_ME, "\033[m"))
+ if (!D_CAF && D_ME && (InStr(D_ME, "\033[m") || InStr(D_ME, "\033[0m")))
{
#ifdef TERMINFO
D_CAF = "\033[3%p1%dm";
@@ -214,17 +214,22 @@ int he;
}
if (D_OP && InStr(D_OP, "\033[39;49m"))
D_CAX = 1;
- if (strcmp(D_termname, "xterm-color") == 0)
- D_BE = 1;
+ if (D_OP && (InStr(D_OP, "\033[m") || InStr(D_OP, "\033[0m")))
+ D_OP = 0;
/* ISO2022 */
if ((D_EA && InStr(D_EA, "\033(B")) || (D_AS && InStr(D_AS, "\033(0")))
D_CG0 = 1;
+ if (InStr(D_termname, "xterm") || InStr(D_termname, "rxvt"))
+ D_CXT = 1;
+ /* "be" seems to be standard for xterms... */
+ if (D_CXT)
+ D_BE = 1;
}
if (nwin_options.flowflag == nwin_undef.flowflag)
nwin_default.flowflag = D_CNF ? FLOW_NOW * 0 :
D_NX ? FLOW_NOW * 1 :
FLOW_AUTOFLAG;
- D_CLP |= (assume_LP || !D_AM || D_XV || D_XN);
+ D_CLP |= (!D_AM || D_XV || D_XN);
if (!D_BL)
D_BL = "\007";
if (!D_BC)
@@ -320,14 +325,10 @@ int he;
t = D_attrtyp[i];
}
}
- if (D_CAF == 0 && D_CAB == 0)
- {
- /* hmm, where's the difference? */
- D_CAF = D_CSF;
- D_CAB = D_CSB;
- }
- if (D_BE)
- D_UT = 1; /* screen erased with background color */
+ if (D_CAF || D_CAB || D_CSF || D_CSB)
+ D_hascolor = 1;
+ if (D_UT)
+ D_BE = 1; /* screen erased with background color */
if (!D_DO)
D_DO = D_NL;
@@ -413,21 +414,19 @@ int he;
if (D_HS)
{
debug("oy! we have a hardware status line, says termcap\n");
- if (D_WS <= 0)
- D_WS = D_width;
+ if (D_WS < 0)
+ D_WS = 0;
}
D_has_hstatus = hardstatusemu & ~HSTATUS_ALWAYS;
if (D_HS && !(hardstatusemu & HSTATUS_ALWAYS))
D_has_hstatus = HSTATUS_HS;
-#ifdef KANJI
- D_kanji = 0;
+#ifdef ENCODINGS
if (D_CKJ)
{
- if (strcmp(D_CKJ, "euc") == 0)
- D_kanji = EUC;
- else if (strcmp(D_CKJ, "sjis") == 0)
- D_kanji = SJIS;
+ int enc = FindEncoding(D_CKJ);
+ if (enc != -1)
+ D_encoding = enc;
}
#endif
if (!D_tcs[T_NAVIGATE].str && D_tcs[T_NAVIGATE + 1].str)
@@ -457,6 +456,17 @@ int he;
D_obufmax = D_COL;
D_obuflenmax = D_obuflen - D_obufmax;
}
+
+ /* Some xterm entries set F0 and F10 to the same string. Nuke F0. */
+ if (D_tcs[T_CAPS].str && D_tcs[T_CAPS + 10].str && !strcmp(D_tcs[T_CAPS].str, D_tcs[T_CAPS + 10].str))
+ D_tcs[T_CAPS].str = 0;
+ /* Some xterm entries set kD to ^?. Nuke it. */
+ if (D_tcs[T_NAVIGATE_DELETE].str && !strcmp(D_tcs[T_NAVIGATE_DELETE].str, "\0177"))
+ D_tcs[T_NAVIGATE_DELETE].str = 0;
+ /* wyse52 entries have kcub1 == kb == ^H. Nuke... */
+ if (D_tcs[T_CURSOR + 3].str && !strcmp(D_tcs[T_CURSOR + 3].str, "\008"))
+ D_tcs[T_CURSOR + 3].str = 0;
+
#ifdef MAPKEYS
D_nseqs = 0;
for (i = 0; i < T_OCAPS - T_CAPS; i++)
@@ -561,7 +571,7 @@ CheckEscape()
display = odisplay;
return;
}
- ParseEscape((struct user *)0, "^aa");
+ ParseEscape((struct acluser *)0, "^aa");
if (odisplay->d_user->u_Esc == -1)
odisplay->d_user->u_Esc = DefaultEsc;
if (odisplay->d_user->u_MetaEsc == -1)
@@ -721,7 +731,7 @@ int aflag;
{
char buf[TERMCAP_BUFSIZE];
register char *p, *cp, *s, ch, *tname;
- int i, wi, he;
+ int i, wi, he, found;
if (display)
{
@@ -751,6 +761,7 @@ int aflag;
debug("MakeTermcap sets screenterm=screen\n");
strcpy(screenterm, "screen");
}
+ found = 1;
do
{
strcpy(Term, "TERM=");
@@ -771,21 +782,23 @@ int aflag;
if (e_tgetent(buf, p) == 1)
break;
strcpy(p, "vt100");
+ found = 0;
}
while (0); /* Goto free programming... */
+#if 0
+#ifndef TERMINFO
/* check for compatibility problems, displays == 0 after fork */
- {
- char xbuf[TERMCAP_BUFSIZE], *xbp = xbuf;
- if (tgetstr("im", &xbp) && tgetstr("ic", &xbp) && displays)
- {
-#ifdef TERMINFO
- Msg(0, "Warning: smir and ich1 set in %s terminfo entry", p);
-#else
- Msg(0, "Warning: im and ic set in %s termcap entry", p);
+ if (found)
+ {
+ char xbuf[TERMCAP_BUFSIZE], *xbp = xbuf;
+ if (tgetstr("im", &xbp) && tgetstr("ic", &xbp) && displays)
+ {
+ Msg(0, "Warning: im and ic set in %s termcap entry", p);
+ }
+ }
+#endif
#endif
- }
- }
tcLineLen = 100; /* Force NL */
if (strlen(Term) > TERMCAP_BUFSIZE - 40)
@@ -875,7 +888,7 @@ int aflag;
AddCap("mr=\\E[7m:");
if (D_MB || D_MD || D_MH || D_MR)
AddCap("me=\\E[m:ms:");
- if (D_CAF || D_CAB)
+ if (D_hascolor)
AddCap("Co#8:pa#64:AF=\\E[3%dm:AB=\\E[4%dm:op=\\E[39;49m:AX:");
if (D_VB)
AddCap("vb=\\Eg:");
@@ -933,6 +946,13 @@ int aflag;
if (act->nr == RC_ILLEGAL)
act = &dmtab[i - T_CAPS];
}
+ if (act->nr == RC_ILLEGAL && (i == T_NAVIGATE + 1 || i == T_NAVIGATE + 3))
+ {
+ /* kh -> @1, kH -> @7 */
+ act = &umtab[i - T_CAPS - 1];
+ if (act->nr == RC_ILLEGAL)
+ act = &dmtab[i - T_CAPS - 1];
+ }
if (act->nr != RC_ILLEGAL)
{
if (act->nr == RC_STUFF)