termpty: very early support of Right/Left margins
This commit is contained in:
parent
91ce6e8960
commit
7ab925dc76
|
@ -135,7 +135,9 @@ struct _Termpty
|
|||
unsigned char charsetch;
|
||||
unsigned char chset[4];
|
||||
int top_margin, bottom_margin;
|
||||
int left_margin, right_margin;
|
||||
int had_cr_x, had_cr_y;
|
||||
unsigned int lr_margins : 1;
|
||||
unsigned int restrict_cursor : 1;
|
||||
unsigned int multibyte : 1;
|
||||
unsigned int alt_kp : 1;
|
||||
|
|
|
@ -210,6 +210,22 @@ _switch_to_alternative_screen(Termpty *ty, int mode)
|
|||
termpty_screen_swap(ty);
|
||||
}
|
||||
|
||||
static void
|
||||
_move_cursor_to_origin(Termpty *ty)
|
||||
{
|
||||
if (ty->termstate.restrict_cursor)
|
||||
{
|
||||
ty->cursor_state.cx = ty->termstate.left_margin;
|
||||
ty->cursor_state.cy = ty->termstate.top_margin;
|
||||
}
|
||||
else
|
||||
{
|
||||
ty->cursor_state.cx = 0;
|
||||
ty->cursor_state.cy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
|
||||
{
|
||||
|
@ -272,15 +288,12 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
|
|||
{
|
||||
/* set, within margins */
|
||||
ty->termstate.restrict_cursor = 1;
|
||||
ty->cursor_state.cx = 0;
|
||||
ty->cursor_state.cy = ty->termstate.top_margin;
|
||||
}
|
||||
else
|
||||
{
|
||||
ty->termstate.restrict_cursor = 0;
|
||||
ty->cursor_state.cx = 0;
|
||||
ty->cursor_state.cy = 0;
|
||||
}
|
||||
_move_cursor_to_origin(ty);
|
||||
DBG("DECOM: mode (%d): cursor is at 0,0"
|
||||
" cursor limited to screen/start point"
|
||||
" for line #'s depends on top margin",
|
||||
|
@ -349,6 +362,13 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
|
|||
ty->termstate.send_bs = mode;
|
||||
DBG("backspace send bs not del = %i", mode);
|
||||
break;
|
||||
case 69:
|
||||
ty->termstate.lr_margins = mode;
|
||||
if (!mode)
|
||||
{
|
||||
ty->termstate.left_margin = 0;
|
||||
ty->termstate.right_margin = 0;
|
||||
}
|
||||
case 1000:
|
||||
if (mode) ty->mouse_mode = MOUSE_NORMAL;
|
||||
else ty->mouse_mode = MOUSE_OFF;
|
||||
|
@ -750,6 +770,21 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_handle_esc_csi_decslrm(Termpty *ty, Eina_Unicode **b)
|
||||
{
|
||||
int left = _csi_arg_get(b);
|
||||
int right = _csi_arg_get(b);
|
||||
DBG("DECSLRM (%d;%d) Set Left and Right Margins", left, right);
|
||||
if (left < 1) left = 0;
|
||||
if (right < 1) right = 0;
|
||||
if (left >= right) return;
|
||||
if (right - left < 2) return;
|
||||
ty->termstate.left_margin = left;
|
||||
ty->termstate.right_margin = right;
|
||||
_move_cursor_to_origin(ty);
|
||||
}
|
||||
|
||||
static int
|
||||
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||
{
|
||||
|
@ -1107,13 +1142,19 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
|||
ty->termstate.bottom_margin = 0;
|
||||
}
|
||||
}
|
||||
ty->cursor_state.cx = 0;
|
||||
ty->cursor_state.cy = (ty->termstate.restrict_cursor) ?
|
||||
ty->termstate.top_margin : 0;
|
||||
_move_cursor_to_origin(ty);
|
||||
}
|
||||
break;
|
||||
case 's': // store cursor pos
|
||||
termpty_cursor_copy(ty, EINA_TRUE);
|
||||
case 's':
|
||||
if (ty->termstate.lr_margins)
|
||||
{
|
||||
_handle_esc_csi_decslrm(ty, &b);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("SCOSC: Save Current Cursor Position");
|
||||
termpty_cursor_copy(ty, EINA_TRUE);
|
||||
}
|
||||
break;
|
||||
case 't': // window manipulation
|
||||
arg = _csi_arg_get(&b);
|
||||
|
@ -1139,16 +1180,10 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
|||
/*
|
||||
case 'R': // report cursor
|
||||
break;
|
||||
case 's':
|
||||
break;
|
||||
case 't':
|
||||
break;
|
||||
case 'q': // set/clear led's
|
||||
break;
|
||||
case 'x': // request terminal parameters
|
||||
break;
|
||||
case 'r': // set top and bottom margins
|
||||
break;
|
||||
case 'y': // invoke confidence test
|
||||
break;
|
||||
*/
|
||||
|
|
|
@ -399,6 +399,9 @@ termpty_reset_state(Termpty *ty)
|
|||
ty->cursor_state.cy = 0;
|
||||
ty->termstate.top_margin = 0;
|
||||
ty->termstate.bottom_margin = 0;
|
||||
ty->termstate.left_margin = 0;
|
||||
ty->termstate.right_margin = 0;
|
||||
ty->termstate.lr_margins = 0;
|
||||
ty->termstate.had_cr_x = 0;
|
||||
ty->termstate.had_cr_y = 0;
|
||||
ty->termstate.restrict_cursor = 0;
|
||||
|
|
Loading…
Reference in New Issue