aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-03 23:17:33 +0200
committerBoris Faure <billiob@gmail.com>2017-06-03 23:17:33 +0200
commit7ab925dc765204d21454d120b19e7638eff9d751 (patch)
tree483cb66c62996f5c88488a0d7e295f8f81b31772 /src
parenttermptyesc: correctly handle missing arguments in CUP/HVP (diff)
downloadterminology-7ab925dc765204d21454d120b19e7638eff9d751.tar.gz
termpty: very early support of Right/Left margins
Diffstat (limited to 'src')
-rw-r--r--src/bin/termpty.h2
-rw-r--r--src/bin/termptyesc.c65
-rw-r--r--src/bin/termptyops.c3
3 files changed, 55 insertions, 15 deletions
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 14f5873..aab9df5 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -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;
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 5b01606..88eefea 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -211,6 +211,22 @@ _switch_to_alternative_screen(Termpty *ty, int mode)
}
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)
{
int mode = 0, priv = 0, arg;
@@ -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;
*/
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index dfb3708..c6a93dd 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -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;