提交 26cd927c authored 作者: Travis Cross's avatar Travis Cross

fs_cli: only enable new features on supported terminals

This is a workaround to an issue where editline counts non-printable
control characters.  See issue FS-3606.
上级 2f786a07
...@@ -71,6 +71,7 @@ static char prompt_str[512] = ""; ...@@ -71,6 +71,7 @@ static char prompt_str[512] = "";
static char prompt_color[12] = {ESL_SEQ_DEFAULT_COLOR}; static char prompt_color[12] = {ESL_SEQ_DEFAULT_COLOR};
static char input_text_color[12] = {ESL_SEQ_DEFAULT_COLOR}; static char input_text_color[12] = {ESL_SEQ_DEFAULT_COLOR};
static char output_text_color[12] = {ESL_SEQ_DEFAULT_COLOR}; static char output_text_color[12] = {ESL_SEQ_DEFAULT_COLOR};
static int feature_level = 0;
static cli_profile_t profiles[128] = {{{0}}}; static cli_profile_t profiles[128] = {{{0}}};
static cli_profile_t internal_profile = {{ 0 }}; static cli_profile_t internal_profile = {{ 0 }};
static int pcount = 0; static int pcount = 0;
...@@ -679,9 +680,10 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) ...@@ -679,9 +680,10 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
} }
#ifndef WIN32 #ifndef WIN32
if (aok) { if (aok) {
clear_line(); if (feature_level) clear_line();
printf("%s%s", colors[level], handle->last_event->body); printf("%s%s", colors[level], handle->last_event->body);
redisplay(); if (!feature_level) printf("%s", ESL_SEQ_DEFAULT_COLOR);
if (feature_level) redisplay();
} }
#else #else
if (aok) { if (aok) {
...@@ -1122,6 +1124,7 @@ int main(int argc, char *argv[]) ...@@ -1122,6 +1124,7 @@ int main(int argc, char *argv[])
char dft_cfile[512] = "fs_cli.conf"; char dft_cfile[512] = "fs_cli.conf";
#endif #endif
char *home = getenv("HOME"); char *home = getenv("HOME");
char *term = getenv("TERM");
/* Vars for optargs */ /* Vars for optargs */
int opt; int opt;
static struct option options[] = { static struct option options[] = {
...@@ -1156,6 +1159,17 @@ int main(int argc, char *argv[]) ...@@ -1156,6 +1159,17 @@ int main(int argc, char *argv[])
int argv_quiet = 0; int argv_quiet = 0;
int loops = 2, reconnect = 0, timeout = 0; int loops = 2, reconnect = 0, timeout = 0;
if (!strncasecmp("screen", term, 6) ||
!strncasecmp("vt100", term, 5)) {
feature_level = 1;
} else {
feature_level = 0;
}
#ifdef WIN32
feature_level = 0;
#endif
strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host)); strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host));
strncpy(internal_profile.pass, "ClueCon", sizeof(internal_profile.pass)); strncpy(internal_profile.pass, "ClueCon", sizeof(internal_profile.pass));
strncpy(internal_profile.name, "internal", sizeof(internal_profile.name)); strncpy(internal_profile.name, "internal", sizeof(internal_profile.name));
...@@ -1289,11 +1303,11 @@ int main(int argc, char *argv[]) ...@@ -1289,11 +1303,11 @@ int main(int argc, char *argv[])
snprintf(bare_prompt_str, sizeof(bare_prompt_str), "freeswitch@%s> ", profile->name); snprintf(bare_prompt_str, sizeof(bare_prompt_str), "freeswitch@%s> ", profile->name);
} }
bare_prompt_str_len = (int)strlen(bare_prompt_str); bare_prompt_str_len = (int)strlen(bare_prompt_str);
#ifdef WIN32 if (feature_level) {
snprintf(prompt_str, sizeof(prompt_str), "%s", bare_prompt_str); /* Not supporting this for now */ snprintf(prompt_str, sizeof(prompt_str), "%s%s%s", prompt_color, bare_prompt_str, input_text_color);
#else } else {
snprintf(prompt_str, sizeof(prompt_str), "%s%s%s", prompt_color, bare_prompt_str, input_text_color); snprintf(prompt_str, sizeof(prompt_str), "%s", bare_prompt_str);
#endif }
connect: connect:
connected = 0; connected = 0;
while (--loops > 0) { while (--loops > 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论