106 lines
4.1 KiB
Diff
106 lines
4.1 KiB
Diff
From 1eeffba2d72b68bfe626533e95c3989489767efe Mon Sep 17 00:00:00 2001
|
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
|
Date: Fri, 21 Oct 2022 12:32:54 -0700
|
|
Subject: [PATCH 30/48] lesstest: Clear screen at end of maketest in case
|
|
terminal doesn't have "te" cap.
|
|
|
|
---
|
|
lesstest/env.c | 12 ++++++------
|
|
lesstest/run.c | 2 +-
|
|
lesstest/term.c | 37 +++++++++++++++++++++----------------
|
|
3 files changed, 28 insertions(+), 23 deletions(-)
|
|
|
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
|
index 72c2023..56685f8 100644
|
|
--- a/lesstest/env.c
|
|
+++ b/lesstest/env.c
|
|
@@ -81,12 +81,12 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
|
{ "LESS_TERMCAP_ue", "\33[24m" },
|
|
{ "LESS_TERMCAP_us", "\33[4m" },
|
|
{ "LESS_TERMCAP_vb", "\33g" },
|
|
- { "LESS_TERMCAP_kr", terminfo.key_right ? terminfo.key_right : "" },
|
|
- { "LESS_TERMCAP_kl", terminfo.key_left ? terminfo.key_left : "" },
|
|
- { "LESS_TERMCAP_ku", terminfo.key_up ? terminfo.key_up : "" },
|
|
- { "LESS_TERMCAP_kd", terminfo.key_down ? terminfo.key_down : "" },
|
|
- { "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "" },
|
|
- { "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "" },
|
|
+ { "LESS_TERMCAP_kr", terminfo.key_right },
|
|
+ { "LESS_TERMCAP_kl", terminfo.key_left },
|
|
+ { "LESS_TERMCAP_ku", terminfo.key_up },
|
|
+ { "LESS_TERMCAP_kd", terminfo.key_down },
|
|
+ { "LESS_TERMCAP_kh", terminfo.key_home },
|
|
+ { "LESS_TERMCAP_@7", terminfo.key_end },
|
|
};
|
|
for (int i = 0; i < countof(tcvars); ++i) {
|
|
struct tcvar* tc = &tcvars[i];
|
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
|
index f35781f..3ad18da 100644
|
|
--- a/lesstest/run.c
|
|
+++ b/lesstest/run.c
|
|
@@ -113,7 +113,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
|
read_and_display_screen(pipeline);
|
|
}
|
|
log_test_footer();
|
|
- printf("%s%s", terminfo.exit_keypad, terminfo.deinit_term);
|
|
+ printf("%s%s%s", terminfo.clear_screen, terminfo.exit_keypad, terminfo.deinit_term);
|
|
raw_mode(ttyin, 0);
|
|
destroy_less_pipeline(pipeline);
|
|
set_intr_handler(0);
|
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
|
index b244f3e..a6ffe25 100644
|
|
--- a/lesstest/term.c
|
|
+++ b/lesstest/term.c
|
|
@@ -36,6 +36,12 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
|
if (*exit_str == NULL) *exit_str = "";
|
|
}
|
|
|
|
+static char* ltgetstr(char* id, char** area) {
|
|
+ char* str = tgetstr(id, area);
|
|
+ if (str == NULL) str = "";
|
|
+ return str;
|
|
+}
|
|
+
|
|
int setup_term(void) {
|
|
static char termbuf[4096];
|
|
static char sbuf[4096];
|
|
@@ -51,21 +57,20 @@ int setup_term(void) {
|
|
setup_mode("md", "me", &terminfo.enter_bold, &terminfo.exit_bold, &sp);
|
|
setup_mode("mb", "me", &terminfo.enter_blink, &terminfo.exit_blink, &sp);
|
|
terminfo.exit_all_modes = terminfo.exit_bold;
|
|
- terminfo.cursor_move = tgetstr("cm", &sp);
|
|
- if (terminfo.cursor_move == NULL) terminfo.cursor_move = "";
|
|
- terminfo.clear_screen = tgetstr("cl", &sp);
|
|
- if (terminfo.clear_screen == NULL) terminfo.clear_screen = "";
|
|
- char* bs = tgetstr("kb", &sp);
|
|
- terminfo.backspace_key = (bs != NULL && strlen(bs) == 1) ? *bs : '\b';
|
|
- terminfo.init_term = tgetstr("ti", &sp);
|
|
- terminfo.deinit_term = tgetstr("te", &sp);
|
|
- terminfo.enter_keypad = tgetstr("ks", &sp);
|
|
- terminfo.exit_keypad = tgetstr("ke", &sp);
|
|
- terminfo.key_right = tgetstr("kr", &sp);
|
|
- terminfo.key_left = tgetstr("kl", &sp);
|
|
- terminfo.key_up = tgetstr("ku", &sp);
|
|
- terminfo.key_down = tgetstr("kd", &sp);
|
|
- terminfo.key_home = tgetstr("kh", &sp);
|
|
- terminfo.key_end = tgetstr("@7", &sp);
|
|
+
|
|
+ char* bs = ltgetstr("kb", &sp);
|
|
+ terminfo.backspace_key = (strlen(bs) == 1) ? *bs : '\b';
|
|
+ terminfo.cursor_move = ltgetstr("cm", &sp);
|
|
+ terminfo.clear_screen = ltgetstr("cl", &sp);
|
|
+ terminfo.init_term = ltgetstr("ti", &sp);
|
|
+ terminfo.deinit_term = ltgetstr("te", &sp);
|
|
+ terminfo.enter_keypad = ltgetstr("ks", &sp);
|
|
+ terminfo.exit_keypad = ltgetstr("ke", &sp);
|
|
+ terminfo.key_right = ltgetstr("kr", &sp);
|
|
+ terminfo.key_left = ltgetstr("kl", &sp);
|
|
+ terminfo.key_up = ltgetstr("ku", &sp);
|
|
+ terminfo.key_down = ltgetstr("kd", &sp);
|
|
+ terminfo.key_home = ltgetstr("kh", &sp);
|
|
+ terminfo.key_end = ltgetstr("@7", &sp);
|
|
return 1;
|
|
}
|
|
--
|
|
2.27.0
|
|
|