aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-06 23:00:22 +0200
committerBoris Faure <billiob@gmail.com>2017-06-06 23:00:22 +0200
commit400b675fc975c1458f0ceeab3e82fe5f92921584 (patch)
tree2807220a5be2a76d784c8c7ac3a7af5a688d8142
parentfix stupid segfault (diff)
downloadterminology-400b675fc975c1458f0ceeab3e82fe5f92921584.tar.gz
termptyesc: restrict CUP/HVP to right/bottom margins
-rw-r--r--src/bin/termptyesc.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 52bc1c4..284dd09 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -942,15 +942,30 @@ _handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
DBG("cursor pos set (%s) (%d;%d)", (*cc == 'H') ? "CUP" : "HVP",
cx, cy);
cx--;
- cy--;
- if (ty->termstate.restrict_cursor)
- cx += ty->termstate.left_margin;
- TERMPTY_RESTRICT_FIELD(cx, 0, ty->w);
+ if (cx < 0)
+ cx = 0;
if (ty->termstate.restrict_cursor)
- cy += ty->termstate.top_margin;
- TERMPTY_RESTRICT_FIELD(cy, 0, ty->h);
-
+ {
+ cx += ty->termstate.left_margin;
+ if (ty->termstate.right_margin && cx >= ty->termstate.right_margin)
+ cx = ty->termstate.right_margin - 1;
+ }
+ if (cx >= ty->w)
+ cx = ty->w -1;
ty->cursor_state.cx = cx;
+
+
+ cy--;
+ if (cy < 0)
+ cy = 0;
+ if (ty->termstate.restrict_cursor)
+ {
+ cy += ty->termstate.top_margin;
+ if (ty->termstate.bottom_margin && cy >= ty->termstate.bottom_margin)
+ cy = ty->termstate.bottom_margin - 1;
+ }
+ if (cy >= ty->h)
+ cy = ty->h - 1;
ty->cursor_state.cy = cy;
}