summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-05 11:54:26 +0200
committerBoris Faure <billiob@gmail.com>2017-06-05 16:49:36 +0200
commite117ff9153e491222754e9b835963ad660831e92 (patch)
treecf746c0ae9bfe69abb847c021a27d591dbf082b4
parent7d497c08c6ea74450c153d5fd9431e8412dd7454 (diff)
termptyesc: correctly handle cursor wrt right/left margins
-rw-r--r--src/bin/termptyesc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index c808669..78c2e36 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -788,7 +788,7 @@ _handle_esc_csi_decslrm(Termpty *ty, Eina_Unicode **b)
788 right = 0; 788 right = 0;
789 789
790 ty->termstate.left_margin = left - 1; 790 ty->termstate.left_margin = left - 1;
791 ty->termstate.right_margin = right - 1; 791 ty->termstate.right_margin = right;
792 _move_cursor_to_origin(ty); 792 _move_cursor_to_origin(ty);
793 793
794 return; 794 return;
@@ -838,6 +838,8 @@ _handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
838 cx, cy); 838 cx, cy);
839 cx--; 839 cx--;
840 cy--; 840 cy--;
841 if (ty->termstate.restrict_cursor)
842 cx += ty->termstate.left_margin;
841 TERMPTY_RESTRICT_FIELD(cx, 0, ty->w); 843 TERMPTY_RESTRICT_FIELD(cx, 0, ty->w);
842 if (ty->termstate.restrict_cursor) 844 if (ty->termstate.restrict_cursor)
843 cy += ty->termstate.top_margin; 845 cy += ty->termstate.top_margin;
@@ -918,9 +920,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
918 ty->cursor_state.cy = MIN(ty->h - 1, ty->cursor_state.cy + arg); 920 ty->cursor_state.cy = MIN(ty->h - 1, ty->cursor_state.cy + arg);
919 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h); 921 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
920 if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin != 0) 922 if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin != 0)
921 && (ty->cursor_state.cy > ty->termstate.bottom_margin)) 923 && (ty->cursor_state.cy >= ty->termstate.bottom_margin))
922 { 924 {
923 ty->cursor_state.cy = ty->termstate.bottom_margin; 925 ty->cursor_state.cy = ty->termstate.bottom_margin - 1;
924 } 926 }
925 break; 927 break;
926 case 'D': // cursor left N 928 case 'D': // cursor left N
@@ -930,6 +932,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
930 ty->termstate.wrapnext = 0; 932 ty->termstate.wrapnext = 0;
931 ty->cursor_state.cx -= arg; 933 ty->cursor_state.cx -= arg;
932 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w); 934 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
935 if (ty->termstate.restrict_cursor && (ty->termstate.left_margin != 0)
936 && (ty->cursor_state.cx < ty->termstate.left_margin))
937 {
938 ty->cursor_state.cx = ty->termstate.left_margin;
939 }
933 break; 940 break;
934 case 'C': // cursor right N 941 case 'C': // cursor right N
935 case 'a': // cursor right N 942 case 'a': // cursor right N
@@ -939,6 +946,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
939 ty->termstate.wrapnext = 0; 946 ty->termstate.wrapnext = 0;
940 ty->cursor_state.cx += arg; 947 ty->cursor_state.cx += arg;
941 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w); 948 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
949 if (ty->termstate.restrict_cursor && (ty->termstate.right_margin != 0)
950 && (ty->cursor_state.cx >= ty->termstate.right_margin))
951 {
952 ty->cursor_state.cx = ty->termstate.right_margin - 1;
953 }
942 break; 954 break;
943 case 'H': // cursor pos set (CUP) 955 case 'H': // cursor pos set (CUP)
944 case 'f': // cursor pos set (HVP) 956 case 'f': // cursor pos set (HVP)