termptyesc: handle window manipulations that resizes the terminal
only for testing purpose
This commit is contained in:
parent
4d89080d71
commit
1c9c2a19ed
|
@ -3011,10 +3011,75 @@ _handle_esc_csi_decswbv(Termpty *ty, Eina_Unicode **ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_resize_by_chars(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
w = _csi_arg_get(ty, &b);
|
||||||
|
h = _csi_arg_get(ty, &b);
|
||||||
|
|
||||||
|
if ((w == -CSI_ARG_ERROR) || (h == -CSI_ARG_ERROR))
|
||||||
|
return;
|
||||||
|
if (w == -CSI_ARG_NO_VALUE)
|
||||||
|
{
|
||||||
|
w = ty->w;
|
||||||
|
}
|
||||||
|
if (h == -CSI_ARG_NO_VALUE)
|
||||||
|
{
|
||||||
|
h = ty->h;
|
||||||
|
}
|
||||||
|
if ((w == ty->w) && (h == ty->h))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DBG("Window manipulation: resize to %dx%d", w, h);
|
||||||
|
|
||||||
|
/* ONLY FOR TESTING PURPOSE FTM */
|
||||||
|
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
|
||||||
|
{
|
||||||
|
#if defined(ENABLE_TEST_UI)
|
||||||
|
Evas_Object *wn;
|
||||||
|
int step_w = 0, step_h = 0, base_w = 0, base_h = 0;
|
||||||
|
|
||||||
|
wn = termio_win_get(ty->obj);
|
||||||
|
elm_win_size_base_get(wn, &base_w, &base_h);
|
||||||
|
elm_win_size_step_get(wn, &step_w, &step_h);
|
||||||
|
evas_object_resize(wn,
|
||||||
|
base_w + step_w * w,
|
||||||
|
base_h + step_h * h);
|
||||||
|
#endif
|
||||||
|
termpty_resize(ty, w, h);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int arg = _csi_arg_get(ty, &b);
|
||||||
|
|
||||||
|
if (arg == -CSI_ARG_ERROR)
|
||||||
|
return;
|
||||||
|
DBG("Window manipulation: %d", arg);
|
||||||
|
switch (arg)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
_handle_resize_by_chars(ty, &b);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// many others
|
||||||
|
WRN("unhandled window manipulation %d", arg);
|
||||||
|
ty->decoding_error = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
{
|
{
|
||||||
int arg;
|
|
||||||
const Eina_Unicode *cc, *be;
|
const Eina_Unicode *cc, *be;
|
||||||
Eina_Unicode buf[4096], *b;
|
Eina_Unicode buf[4096], *b;
|
||||||
|
|
||||||
|
@ -3218,11 +3283,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
arg = _csi_arg_get(ty, &b);
|
_handle_window_manipulation(ty, &b);
|
||||||
if (arg == -CSI_ARG_ERROR)
|
|
||||||
goto error;
|
|
||||||
WRN("TODO: window operation %d not supported", arg);
|
|
||||||
ty->decoding_error = EINA_TRUE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'u': // restore cursor pos
|
case 'u': // restore cursor pos
|
||||||
|
@ -3282,7 +3343,6 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
cc++;
|
cc++;
|
||||||
return cc - c;
|
return cc - c;
|
||||||
unhandled:
|
unhandled:
|
||||||
error:
|
|
||||||
#if !defined(ENABLE_FUZZING) && !defined(ENABLE_TESTS)
|
#if !defined(ENABLE_FUZZING) && !defined(ENABLE_TESTS)
|
||||||
if (eina_log_domain_level_check(_termpty_log_dom, EINA_LOG_LEVEL_WARN))
|
if (eina_log_domain_level_check(_termpty_log_dom, EINA_LOG_LEVEL_WARN))
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,14 +19,6 @@
|
||||||
#define INF(...) EINA_LOG_DOM_INFO(_termpty_log_dom, __VA_ARGS__)
|
#define INF(...) EINA_LOG_DOM_INFO(_termpty_log_dom, __VA_ARGS__)
|
||||||
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
|
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
#if defined(ENABLE_TESTS)
|
|
||||||
#define WITH_TESTS 1
|
|
||||||
#else
|
|
||||||
#define WITH_TESTS 0
|
|
||||||
#endif
|
|
||||||
// Uncomment following to enable testing escape codes within terminology
|
|
||||||
//#define WITH_TESTS 1
|
|
||||||
|
|
||||||
//// extended terminology escape handling goes in here
|
//// extended terminology escape handling goes in here
|
||||||
//
|
//
|
||||||
// this is where escapes get handled *IF* the termpty layer needs to interpret
|
// this is where escapes get handled *IF* the termpty layer needs to interpret
|
||||||
|
@ -59,7 +51,7 @@ _handle_op_a(Termpty *_ty EINA_UNUSED,
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_TESTS
|
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_tytest_arg_get(const Eina_Unicode *buf, int *value)
|
_tytest_arg_get(const Eina_Unicode *buf, int *value)
|
||||||
|
@ -377,7 +369,7 @@ termpty_ext_handle(Termpty *ty,
|
||||||
return _handle_op_a(ty, buf + 1, blen - 1);
|
return _handle_op_a(ty, buf + 1, blen - 1);
|
||||||
break;
|
break;
|
||||||
// room here for more major opcode chars like 'b', 'c' etc.
|
// room here for more major opcode chars like 'b', 'c' etc.
|
||||||
#if WITH_TESTS
|
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
|
||||||
case 't':
|
case 't':
|
||||||
tytest_handle_escape_codes(ty, buf + 1);
|
tytest_handle_escape_codes(ty, buf + 1);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
Loading…
Reference in New Issue