From 16e143f970e540b048aab3e1f7883f91d407f1a7 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Mon, 22 Apr 2013 22:27:52 +0200 Subject: [PATCH] compat: add margin top support on Origin mode --- src/bin/termpty.h | 1 + src/bin/termptyesc.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/bin/termpty.h b/src/bin/termpty.h index 6db0a3f6..b4adcba7 100644 --- a/src/bin/termpty.h +++ b/src/bin/termpty.h @@ -77,6 +77,7 @@ struct _Termstate unsigned char chset[4]; int scroll_y1, scroll_y2; int had_cr_x, had_cr_y; + int margin_top; // soon, more to come... unsigned int multibyte : 1; unsigned int alt_kp : 1; unsigned int insert : 1; diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 93891d06..2962ccb4 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -361,9 +361,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) arg--; if (arg < 0) arg = 0; else if (arg >= ty->h) arg = ty->h - 1; - if (b) ty->state.cy = arg; if (b) { + ty->state.cy = arg; arg = _csi_arg_get(&b); if (arg < 1) arg = 1; arg--; @@ -373,6 +373,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) else if (arg >= ty->w) arg = ty->w - 1; if (b) ty->state.cx = arg; } + ty->state.cy += ty->state.margin_top; break; case 'G': // to column N arg = _csi_arg_get(&b); @@ -566,6 +567,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) 2 + (mode ? 132 : 80) * w, 2 + 24 * h); termpty_resize(ty, mode ? 132 : 80, 24); + _termpty_reset_state(ty); + _termpty_clear_screen(ty, TERMPTY_CLR_ALL); } #endif break; @@ -579,9 +582,20 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) break; case 6: handled = 1; - ERR("TODO: origin mode: cursor is at 0,0" + if (mode) + { + ty->state.margin_top = ty->state.cy; + ty->state.cx = 0; + } + else + { + ty->state.cx = 0; + ty->state.margin_top = 0; + } + DBG("XXX: origin mode (%d): cursor is at 0,0" "cursor limited to screen/start point" - " for line #'s depends on top margin"); + " for line #'s depends on top margin", + mode); break; case 7: handled = 1;