]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add back terminal detection for old libedits
authorTravis Cross <tc@traviscross.com>
Thu, 27 Mar 2014 17:05:20 +0000 (17:05 +0000)
committerTravis Cross <tc@traviscross.com>
Thu, 27 Mar 2014 17:19:55 +0000 (17:19 +0000)
Using the system libedit means that libedit will again make absolute
movements on certain kinds of terminals.  Older versions of libedit
without EL_PROMPT_ESC miscalculate the length of the prompt.
Combined, this results in the cursor ending up in the wrong place.

We knew this was a possibility when we moved to system libedit, and
we're OK with it.  We certainly lived without this fancy prompt
feature for a long time.

This change puts back in place detection of the terminal type when
EL_PROMPT_ESC isn't available.  On these older versions of libedit,
we'll only enable the fancy features when we know that libedit will
only make relative movements and not tickle the bug.

This partially reverts commit:
b9b77bd6156b4343f8baa9ca1a0c803108dbcdb4

libs/esl/fs_cli.c

index 56507853982f68af3770347900a763d9f2b11686..e3e98b1837fcb9333f4dc9242731cd43f6a2b94c 100644 (file)
@@ -1352,10 +1352,22 @@ int main(int argc, char *argv[])
        int loops = 2, reconnect = 0;
        char *ccheck;
 
-#ifdef WIN32
+#if HAVE_DECL_EL_PROMPT_ESC
        feature_level = 0;
 #else
-       feature_level = 1;
+       {
+               char *term = getenv("TERM");
+               if (term && (!strncasecmp("screen", term, 6) ||
+                                        !strncasecmp("vt100", term, 5))) {
+                       feature_level = 1;
+               } else {
+                       feature_level = 0;
+               }
+       }
+#endif
+
+#ifdef WIN32
+       feature_level = 0;
 #endif
 
        if ((ccheck = getenv("FS_CLI_COLOR"))) {