aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-05 21:04:29 +0200
committerBoris Faure <billiob@gmail.com>2017-06-05 21:04:29 +0200
commitbbfa60120ea6978982e95ef12f77e4b98fa1a02a (patch)
tree277d9b3d52fe959ec0267441bc0caa42d47bc1fe
parenttermptyesc: handle DECFRA (diff)
downloadterminology-bbfa60120ea6978982e95ef12f77e4b98fa1a02a.tar.gz
termpty: handle DECERA
-rw-r--r--src/bin/termptyesc.c77
1 files changed, 63 insertions, 14 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index cb2aa21..cead2ce 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -825,21 +825,17 @@ bad:
ty->termstate.bottom_margin = 0;
}
-static void
-_handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
+static int
+_clean_up_rect_coordinates(Termpty *ty,
+ int *top_ptr,
+ int *left_ptr,
+ int *bottom_ptr,
+ int *right_ptr)
{
- int c = _csi_arg_get(b);
-
- int top = _csi_arg_get(b);
- int left = _csi_arg_get(b);
- int bottom = _csi_arg_get(b);
- int right = _csi_arg_get(b);
- int len;
-
- DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
- c, top, left, bottom, right);
- if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
- return;
+ int top = *top_ptr;
+ int left = *left_ptr;
+ int bottom = *bottom_ptr;
+ int right = *right_ptr;
TERMPTY_RESTRICT_FIELD(top, 1, ty->h);
top--;
@@ -871,6 +867,33 @@ _handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
bottom--;
if ((bottom < top) || (right < left))
+ return -1;
+
+ *top_ptr = top;
+ *left_ptr = left;
+ *bottom_ptr = bottom;
+ *right_ptr = right;
+
+ return 0;
+}
+
+static void
+_handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
+{
+ int c = _csi_arg_get(b);
+
+ int top = _csi_arg_get(b);
+ int left = _csi_arg_get(b);
+ int bottom = _csi_arg_get(b);
+ int right = _csi_arg_get(b);
+ int len;
+
+ DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
+ c, top, left, bottom, right);
+ if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
+ return;
+
+ if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0)
return;
len = right - left;
@@ -883,6 +906,29 @@ _handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
}
static void
+_handle_esc_csi_decera(Termpty *ty, Eina_Unicode **b)
+{
+ int top = _csi_arg_get(b);
+ int left = _csi_arg_get(b);
+ int bottom = _csi_arg_get(b);
+ int right = _csi_arg_get(b);
+ int len;
+
+ DBG("DECERA (%d;%d;%d;%d) Erase Rectangular Area",
+ top, left, bottom, right);
+
+ if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0)
+ return;
+
+ len = right - left;
+ for (; top <= bottom; top++)
+ {
+ Termcell *cells = &(TERMPTY_SCREEN(ty, left, top));
+ termpty_cells_clear(ty, cells, len);
+ }
+}
+
+static void
_handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
const Eina_Unicode *cc)
{
@@ -1296,6 +1342,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
}
break;
+ case 'z':
+ _handle_esc_csi_decera(ty, &b);
+ break;
case 'I':
arg = _csi_arg_get(&b);
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);