]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fs_cli: make enhanced fs_cli features work on all TERMs
authorTravis Cross <tc@traviscross.com>
Tue, 31 Jan 2012 18:42:27 +0000 (18:42 +0000)
committerTravis Cross <tc@traviscross.com>
Tue, 31 Jan 2012 18:42:47 +0000 (18:42 +0000)
FS-3815 --resolve

This is a workaround for the fact that libedit counts terminal control
characters when calculating the length of the prompt.  By not using
absolute positioning, we avoid the issue.

Thanks to Ivan Isaev for the workaround and testing.

libs/esl/fs_cli.c
libs/libedit/src/term.c

index cc3c5f08311246028ddbc4bec349802200ad7584..36651e49d8e8ce85d9051813f36c28a9e545318a 100644 (file)
@@ -1123,7 +1123,6 @@ int main(int argc, char *argv[])
        char dft_cfile[512] = "fs_cli.conf";
 #endif
        char *home = getenv("HOME");
-       char *term = getenv("TERM");
        /* Vars for optargs */
        int opt;
        static struct option options[] = {
@@ -1158,15 +1157,11 @@ int main(int argc, char *argv[])
        int argv_quiet = 0;
        int loops = 2, reconnect = 0, timeout = 0;
 
-       if (term && (!strncasecmp("screen", term, 6) ||
-               !strncasecmp("vt100", term, 5))) {
-               feature_level = 1;
-       } else {
-               feature_level = 0;
-       }
 
 #ifdef WIN32
        feature_level = 0;
+#else
+       feature_level = 1;
 #endif
 
        strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host));
index 34e4b23e5313f8e89049a6c164d9f548f978fc49..99e22e65255cbf5718bb687eda3bcbdd972fac46 100644 (file)
@@ -609,10 +609,15 @@ mc_again:
        }
        del = where - el->el_cursor.h;
 
+#if 0
+       /* workaround miscounting of control characters in prompt by
+          avoiding absolute horizontal positioning */
        if ((del < -4 || del > 4) && GoodStr(T_ch))
                /* go there directly */
                (void) tputs(tgoto(Str(T_ch), where, where), where, term__putc);
-       else {
+       else
+#endif
+         {
                if (del > 0) {  /* moving forward */
                        if ((del > 4) && GoodStr(T_RI))
                                (void) tputs(tgoto(Str(T_RI), del, del),