--- screen.c.orig 2004-07-28 11:22:04.000000000 -0700
+++ screen.c 2004-07-28 11:35:02.000000000 -0700
@@ -225,6 +225,8 @@
extern int no_back_scroll;
extern int swindow;
extern int no_init;
+extern int quit_at_eof;
+extern int more_mode;
extern int no_keypad;
extern int sigs;
extern int wscroll;
@@ -1181,12 +1183,20 @@
sc_e_keypad = ltgetstr("ke", &sp);
if (sc_e_keypad == NULL)
sc_e_keypad = "";
+
+ /*
+ * This loses for terminals with termcap entries with ti/te strings
+ * that switch to/from an alternate screen, and we're in quit_at_eof
+ * (eg, more(1)).
+ */
+ if (!quit_at_eof && !more_mode) {
+ sc_init = ltgetstr("ti", &sp);
+ sc_deinit = ltgetstr("te", &sp);
+ }
- sc_init = ltgetstr("ti", &sp);
if (sc_init == NULL)
sc_init = "";
- sc_deinit= ltgetstr("te", &sp);
if (sc_deinit == NULL)
sc_deinit = "";