screw terminfo: have a config to decide whether erase is del or backspace
One day I'll have to dig into the terminfo/termcap mess :( Maybe get the O'Reilly book about it…
This commit is contained in:
parent
ed36063690
commit
f539eba7ca
|
@ -85,6 +85,8 @@ config_init(void)
|
|||
(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, "erase_is_del", erase_is_del, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd_base, Config, "custom_geometry", custom_geometry, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
|
@ -179,6 +181,7 @@ config_sync(const Config *config_src, Config *config)
|
|||
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->erase_is_del = config_src->erase_is_del;
|
||||
config->temporary = config_src->temporary;
|
||||
config->custom_geometry = config_src->custom_geometry;
|
||||
config->cg_width = config_src->cg_width;
|
||||
|
@ -438,6 +441,7 @@ config_load(const char *key)
|
|||
config->application_server = EINA_FALSE;
|
||||
config->application_server_restore_views = EINA_FALSE;
|
||||
config->xterm_256color = EINA_FALSE;
|
||||
config->erase_is_del = EINA_FALSE;
|
||||
config->custom_geometry = EINA_FALSE;
|
||||
config->cg_width = 80;
|
||||
config->cg_height = 24;
|
||||
|
@ -489,6 +493,7 @@ config_fork(Config *config)
|
|||
CPY(application_server);
|
||||
CPY(application_server_restore_views);
|
||||
CPY(xterm_256color);
|
||||
CPY(erase_is_del);
|
||||
CPY(custom_geometry);
|
||||
CPY(cg_width);
|
||||
CPY(cg_height);
|
||||
|
|
|
@ -43,6 +43,7 @@ struct _Config
|
|||
Eina_Bool application_server;
|
||||
Eina_Bool application_server_restore_views;
|
||||
Eina_Bool xterm_256color;
|
||||
Eina_Bool erase_is_del;
|
||||
Eina_Bool custom_geometry;
|
||||
Eina_Bool drag_links;
|
||||
int cg_width;
|
||||
|
|
|
@ -275,10 +275,27 @@ keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev)
|
|||
if (_key_try(ty, appcur_keyout, ev)) return;
|
||||
}
|
||||
|
||||
if ((ty->state.send_bs) && (!strcmp(ev->key, "BackSpace")))
|
||||
if (!strcmp(ev->key, "BackSpace"))
|
||||
{
|
||||
termpty_write(ty, "\b", 1);
|
||||
return;
|
||||
if (ty->state.send_bs)
|
||||
{
|
||||
termpty_write(ty, "\b", 1);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Config *cfg = termpty_config_get(ty);
|
||||
|
||||
if (cfg->erase_is_del)
|
||||
{
|
||||
termpty_write(ty, "\177", sizeof("\177") - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
termpty_write(ty, "\b", sizeof("\b") - 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_key_try(ty, keyout, ev)) return;
|
||||
if (ev->string)
|
||||
|
|
|
@ -153,6 +153,16 @@ _cb_op_behavior_xterm_256color_chg(void *data, Evas_Object *obj,
|
|||
config_save(config, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_op_behavior_erase_is_del_chg(void *data, Evas_Object *obj,
|
||||
void *event EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *term = data;
|
||||
Config *config = termio_config_get(term);
|
||||
config->erase_is_del = 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)
|
||||
{
|
||||
|
@ -366,6 +376,16 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
|
|||
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);
|
||||
elm_object_text_set(o, "BackArrow sends Del (instead of BackSpace)");
|
||||
elm_check_state_set(o, config->erase_is_del);
|
||||
elm_box_pack_end(bx, o);
|
||||
evas_object_show(o);
|
||||
evas_object_smart_callback_add(o, "changed",
|
||||
_cb_op_behavior_erase_is_del_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);
|
||||
|
|
|
@ -4173,7 +4173,7 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login
|
|||
#endif
|
||||
|
||||
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback,
|
||||
config->xterm_256color);
|
||||
config->xterm_256color, config->erase_is_del);
|
||||
if (!sd->pty)
|
||||
{
|
||||
ERR("Cannot allocate termpty");
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "termptyesc.h"
|
||||
#include "termptyops.h"
|
||||
#include "termptysave.h"
|
||||
#include "termio.h"
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
@ -13,6 +14,8 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
|
||||
/* specific log domain to help debug only terminal code parser */
|
||||
int _termpty_log_dom = -1;
|
||||
|
@ -268,7 +271,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, Eina_Bool xterm_256color)
|
||||
int w, int h, int backscroll, Eina_Bool xterm_256color,
|
||||
Eina_Bool erase_is_del)
|
||||
{
|
||||
Termpty *ty;
|
||||
const char *pty;
|
||||
|
@ -334,6 +338,23 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (erase_is_del)
|
||||
{
|
||||
struct termios t;
|
||||
|
||||
tcgetattr(ty->fd, &t);
|
||||
t.c_cc[VERASE] = 0x7f;
|
||||
tcsetattr(ty->fd, TCSANOW, &t);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct termios t;
|
||||
|
||||
tcgetattr(ty->fd, &t);
|
||||
t.c_cc[VERASE] = 0x8;
|
||||
tcsetattr(ty->fd, TCSANOW, &t);
|
||||
}
|
||||
|
||||
ty->hand_exe_exit = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
||||
_cb_exe_exit, ty);
|
||||
if (!ty->hand_exe_exit)
|
||||
|
@ -1502,3 +1523,9 @@ termpty_cell_codepoint_att_fill(Termpty *ty, int codepoint, Termatt att, Termcel
|
|||
dst[i].att = att;
|
||||
}
|
||||
}
|
||||
|
||||
Config *
|
||||
termpty_config_get(const Termpty *ty)
|
||||
{
|
||||
return termio_config_get(ty->obj);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
#ifndef _TERMPTY_H__
|
||||
#define _TERMPTY_H__ 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
typedef struct _Termpty Termpty;
|
||||
typedef struct _Termcell Termcell;
|
||||
typedef struct _Termatt Termatt;
|
||||
|
@ -192,7 +197,8 @@ 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, Eina_Bool xterm_256color);
|
||||
int w, int h, int backscroll, Eina_Bool xterm_256color,
|
||||
Eina_Bool erase_is_del);
|
||||
void termpty_free(Termpty *ty);
|
||||
void termpty_cellcomp_freeze(Termpty *ty);
|
||||
void termpty_cellcomp_thaw(Termpty *ty);
|
||||
|
@ -217,9 +223,13 @@ void termpty_cell_codepoint_att_fill(Termpty *ty, int codepoint, Termatt a
|
|||
|
||||
ssize_t termpty_line_length(const Termcell *cells, ssize_t nb_cells);
|
||||
|
||||
Config *termpty_config_get(const Termpty *ty);
|
||||
|
||||
extern int _termpty_log_dom;
|
||||
|
||||
#define TERMPTY_SCREEN(Tpty, X, Y) \
|
||||
Tpty->screen[X + (((Y + Tpty->circular_offset) % Tpty->h) * Tpty->w)]
|
||||
#define TERMPTY_FMTCLR(Tatt) \
|
||||
(Tatt).autowrapped = (Tatt).newline = (Tatt).tab = 0
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue