summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-04 00:26:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-04 00:26:13 +0000
commit14d998f375784f87bcb3ead746173e151a5b6f46 (patch)
tree337fa7e1aad48ad6bb4e0a703a8e09cfe801e37e
parenteb3573d643154b73d487c67f238bf3ffad41f0a4 (diff)
Check for alternate screen support and if it exists, don't print stuff
that would mess up the existing contents. This fixes some ugliness when running commands from more on an xterm.
-rw-r--r--distrib/special/more/more.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/distrib/special/more/more.c b/distrib/special/more/more.c
index 294707bff6d..23b236778b7 100644
--- a/distrib/special/more/more.c
+++ b/distrib/special/more/more.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: more.c,v 1.18 2003/06/04 00:24:16 millert Exp $ */
+/* $OpenBSD: more.c,v 1.19 2003/06/04 00:26:12 millert Exp $ */
/*-
* Copyright (c) 1980 The Regents of the University of California.
@@ -39,7 +39,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)more.c 5.28 (Berkeley) 3/1/93";
#else
-static const char rcsid[] = "$OpenBSD: more.c,v 1.18 2003/06/04 00:24:16 millert Exp $";
+static const char rcsid[] = "$OpenBSD: more.c,v 1.19 2003/06/04 00:26:12 millert Exp $";
#endif
#endif /* not lint */
@@ -139,6 +139,7 @@ int Wrap = 1; /* set if automargins */
int soglitch; /* terminal has standout mode glitch */
int ulglitch; /* terminal has underline mode glitch */
int pstate = 0; /* current UL state */
+int altscr = 0; /* terminal supports an alternate screen */
volatile sig_atomic_t signo; /* signal received */
@@ -1058,7 +1059,9 @@ command(char *filename, FILE *f)
kill_line();
snprintf(cmdbuf, sizeof(cmdbuf), "+%d",
Currline);
- printf("%s %s %s", p, cmdbuf, fnames[fnum]);
+ if (!altscr)
+ printf("%s %s %s", p, cmdbuf,
+ fnames[fnum]);
execute(filename, editor, p, cmdbuf,
fnames[fnum]);
break;
@@ -1339,7 +1342,8 @@ execute(char *filename, char *cmd, char *av0, char *av1, char *av2)
} else
write(STDERR_FILENO, "can't fork\n", 11);
set_tty();
- fputs("------------------------\n", stdout);
+ if (!altscr)
+ fputs("------------------------\n", stdout);
prompt(filename);
}
@@ -1495,6 +1499,9 @@ retry:
EodClr = tgetstr("cd", &clearptr);
if ((chBS = tgetstr("bc", &clearptr)) == NULL)
chBS = "\b";
+ if (tgetstr("te", &clearptr) != NULL &&
+ tgetstr("ti", &clearptr) != NULL)
+ altscr = 1;
}
if ((shell = getenv("SHELL")) == NULL)
shell = _PATH_BSHELL;