aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.1.in4
-rw-r--r--doc/sciteco.7.template2
-rw-r--r--src/interface-curses.cpp20
3 files changed, 24 insertions, 2 deletions
diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in
index 7212a08..1d21ecf 100644
--- a/doc/sciteco.1.in
+++ b/doc/sciteco.1.in
@@ -245,8 +245,8 @@ Additionally \*(ST may be influenced by the
environment variables accessed by glib
.UE .
On a Curses UI, there are other important environment variables
-like \fBTERM\fP, \fBLINES\fP and \fBCOLUMNS\fP that may be
-accessed when \*(ST enters interactive mode.
+like \fBTERM\fP, \fBLINES\fP, \fBCOLUMNS\fP and \fBESCDELAY\fP
+that may be accessed when \*(ST enters interactive mode.
For ncurses, see section \fBENVIRONMENT\fP in
.BR ncurses (3NCURSES)
for details.
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index 30d6c76..bdb25bc 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -137,6 +137,8 @@ With certain interfaces (curses) after enabling function keys,
the Escape key might only be handled after a short delay.
This is because it might be used by the terminal to transmit
Escape Sequences.
+This delay is minimized by \*(ST, so using the escape key
+should not be a problem even on ncurses/UNIX.
.LP
Enabling function keys also enables Function Key Macros.
These are Q-Register strings inserted into the command stream
diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp
index 93fe923..8c6af7f 100644
--- a/src/interface-curses.cpp
+++ b/src/interface-curses.cpp
@@ -803,6 +803,26 @@ InterfaceCurses::init_interactive(void)
QRegisters::globals.update_environ();
/*
+ * On UNIX terminals, the escape key is usually
+ * delivered as the escape character even though function
+ * keys are delivered as escape sequences as well.
+ * That's why there has to be a timeout for detecting
+ * escape presses if function key handling is enabled.
+ * This timeout can be controlled using $ESCDELAY on
+ * ncurses but its default is much too long.
+ * We set it to 25ms as Vim does. In the very rare cases
+ * this won't suffice, $ESCDELAY can still be set explicitly.
+ *
+ * NOTE: The only terminal emulator I'm aware of that lets
+ * us send an escape sequence for the escape key is Mintty
+ * (see "\e[?7727h").
+ */
+#ifdef NCURSES_UNIX
+ if (!g_getenv("ESCDELAY"))
+ set_escdelay(25);
+#endif
+
+ /*
* $TERM must be unset or "#win32con" for the win32
* driver to load.
* So we always ignore any $TERM changes by the user.