have a config to choose whether to set TERM to xterm-256color

This commit is contained in:
Boris Faure 2013-06-16 22:32:50 +02:00
parent 02e42a747b
commit ef543aa753
7 changed files with 43 additions and 7 deletions

View File

@ -83,6 +83,8 @@ config_init(void)
(edd_base, Config, "urg_bell", urg_bell, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
(edd_base, Config, "multi_instance", multi_instance, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
(edd_base, Config, "xterm_256color", xterm_256color, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
(edd_base, Config, "custom_geometry", custom_geometry, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
@ -176,6 +178,7 @@ config_sync(const Config *config_src, Config *config)
config->multi_instance = config_src->multi_instance;
config->application_server = config_src->application_server;
config->application_server_restore_views = config_src->application_server_restore_views;
config->xterm_256color = config_src->xterm_256color;
config->temporary = config_src->temporary;
config->custom_geometry = config_src->custom_geometry;
config->cg_width = config_src->cg_width;
@ -434,6 +437,7 @@ config_load(const char *key)
config->multi_instance = EINA_FALSE;
config->application_server = EINA_FALSE;
config->application_server_restore_views = EINA_FALSE;
config->xterm_256color = EINA_FALSE;
config->custom_geometry = EINA_FALSE;
config->cg_width = 80;
config->cg_height = 24;
@ -484,6 +488,7 @@ config_fork(Config *config)
CPY(multi_instance);
CPY(application_server);
CPY(application_server_restore_views);
CPY(xterm_256color);
CPY(custom_geometry);
CPY(cg_width);
CPY(cg_height);

View File

@ -42,6 +42,7 @@ struct _Config
Eina_Bool multi_instance;
Eina_Bool application_server;
Eina_Bool application_server_restore_views;
Eina_Bool xterm_256color;
Eina_Bool custom_geometry;
Eina_Bool drag_links;
int cg_width;

View File

@ -143,6 +143,16 @@ _cb_op_behavior_application_server_chg(void *data, Evas_Object *obj, void *event
config_save(config, NULL);
}
static void
_cb_op_behavior_xterm_256color_chg(void *data, Evas_Object *obj,
void *event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
config->xterm_256color = elm_check_state_get(obj);
config_save(config, NULL);
}
static void
_cb_op_behavior_wsep_chg(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{
@ -345,7 +355,17 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_behavior_multi_instance_chg, term);
o = elm_check_add(bx);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_object_text_set(o, "set TERM to xterm-256color");
elm_check_state_set(o, config->xterm_256color);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_behavior_xterm_256color_chg, term);
o = elm_check_add(bx);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);

View File

@ -4172,7 +4172,8 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login
_smart_cb_drop, obj);
#endif
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback);
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback,
config->xterm_256color);
if (!sd->pty)
{
ERR("Cannot allocate termpty");

View File

@ -31,5 +31,6 @@ const char *termio_title_get(Evas_Object *obj);
const char *termio_icon_name_get(Evas_Object *obj);
void termio_debugwhite_set(Evas_Object *obj, Eina_Bool dbg);
void termio_config_set(Evas_Object *obj, Config *config);
Config *termio_config_get(const Evas_Object *obj);
#endif

View File

@ -267,7 +267,8 @@ _limit_coord(Termpty *ty, Termstate *state)
}
Termpty *
termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h, int backscroll)
termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
int w, int h, int backscroll, Eina_Bool xterm_256color)
{
Termpty *ty;
const char *pty;
@ -399,9 +400,15 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h
/* TODO: should we reset signals here? */
// pretend to be xterm
putenv("TERM=xterm");
// putenv("TERM=xterm-256color");
/* pretend to be xterm */
if (xterm_256color)
{
putenv("TERM=xterm-256color");
}
else
{
putenv("TERM=xterm");
}
putenv("XTERM_256_COLORS=1");
if (!login_shell)
execvp(args[0], (char *const *)args);

View File

@ -191,7 +191,8 @@ struct _Termexp
void termpty_init(void);
void termpty_shutdown(void);
Termpty *termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h, int backscroll);
Termpty *termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
int w, int h, int backscroll, Eina_Bool xterm_256color);
void termpty_free(Termpty *ty);
void termpty_cellcomp_freeze(Termpty *ty);
void termpty_cellcomp_thaw(Termpty *ty);