aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2026-02-28 14:52:34 +0200
committerDylan Araps <dylan.araps@gmail.com>2026-02-28 14:52:34 +0200
commit4fb29c95c61256f78e4b501a3c550b4c92a92a4e (patch)
treed521d540befe26339a3482efdcbf78c27d5be965
parentebeb9d5b2757fd6cd238aa8e67c309929366d232 (diff)
misc: Add fallback for no XTerm alternate screen
This cannot be determined at runtime without terminfo.
-rw-r--r--README.txt3
-rw-r--r--config.h.in6
-rw-r--r--lib/vt.h5
3 files changed, 14 insertions, 0 deletions
diff --git a/README.txt b/README.txt
index bdb0e43..50a13ae 100644
--- a/README.txt
+++ b/README.txt
@@ -93,6 +93,9 @@ Bonus example:
-DDFM_NO_COLOR \
-DDFM_COL_NAV="VT_SGR(34,7)"
+NOTE: If you are building for an environment without support for the XTerm
+alternate screen, add -DDFM_CLEAR_EDIT to your configure flags.
+
CONFIGURATION
________________________________________________________________________________
diff --git a/config.h.in b/config.h.in
index ece0ddc..d4f1218 100644
--- a/config.h.in
+++ b/config.h.in
@@ -63,6 +63,12 @@
#define DFM_SHOW_HIDDEN 0
//
+// Clear screen on exit.
+// Useful when XTerm alt screen is unavailable.
+//
+// #define DFM_CLEAR_EXIT
+
+//
// Disable colors.
// Uncomment to disable all colors.
//
diff --git a/lib/vt.h b/lib/vt.h
index 9248a6c..cb29e0b 100644
--- a/lib/vt.h
+++ b/lib/vt.h
@@ -63,8 +63,13 @@
// XTerm Alternate Screen.
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
//
+#ifdef DFM_CLEAR_EXIT
+#define VT_ALT_SCREEN_Y VT_ED0
+#define VT_ALT_SCREEN_N VT_ED0
+#else
#define VT_ALT_SCREEN_Y VT_ESC "[?1049h"
#define VT_ALT_SCREEN_N VT_ESC "[?1049l"
+#endif
//
// Synchronized Updates.