summaryrefslogtreecommitdiff
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
parent64d7150252c77b58a64a07d7e6043c5c01641bf4 (diff)
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,
942 DBG("cursor pos set (%s) (%d;%d)", (*cc == 'H') ? "CUP" : "HVP", 942 DBG("cursor pos set (%s) (%d;%d)", (*cc == 'H') ? "CUP" : "HVP",
943 cx, cy); 943 cx, cy);
944 cx--; 944 cx--;
945 cy--; 945 if (cx < 0)
946 if (ty->termstate.restrict_cursor) 946 cx = 0;
947 cx += ty->termstate.left_margin;
948 TERMPTY_RESTRICT_FIELD(cx, 0, ty->w);
949 if (ty->termstate.restrict_cursor) 947 if (ty->termstate.restrict_cursor)
950 cy += ty->termstate.top_margin; 948 {
951 TERMPTY_RESTRICT_FIELD(cy, 0, ty->h); 949 cx += ty->termstate.left_margin;
952 950 if (ty->termstate.right_margin && cx >= ty->termstate.right_margin)
951 cx = ty->termstate.right_margin - 1;
952 }
953 if (cx >= ty->w)
954 cx = ty->w -1;
953 ty->cursor_state.cx = cx; 955 ty->cursor_state.cx = cx;
956
957
958 cy--;
959 if (cy < 0)
960 cy = 0;
961 if (ty->termstate.restrict_cursor)
962 {
963 cy += ty->termstate.top_margin;
964 if (ty->termstate.bottom_margin && cy >= ty->termstate.bottom_margin)
965 cy = ty->termstate.bottom_margin - 1;
966 }
967 if (cy >= ty->h)
968 cy = ty->h - 1;
954 ty->cursor_state.cy = cy; 969 ty->cursor_state.cy = cy;
955} 970}
956 971