From db01665504f2ca03b11bc40a9bddb23ee8e87340 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 30 Jan 2014 21:44:47 +1000 Subject: Actually scroll the terminal when we get to the end of it. --- dumbsh.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dumbsh.c b/dumbsh.c index fe184dd..a4a475f 100644 --- a/dumbsh.c +++ b/dumbsh.c @@ -37,11 +37,16 @@ GLOBALS( static void updateLine() { - if (0 > TT.y) TT.y = 0; if (0 > TT.x) TT.x = 0; if (strlen(toybuf) <= TT.x) TT.x = strlen(toybuf); - if (TT.h < TT.y) TT.y = TT.h; if (TT.w < TT.x) TT.x = TT.w; + if (0 > TT.y) TT.y = 0; + if (TT.h < TT.y) + { + printf("\x1B[%d;0H\n", TT.y + 1); + fflush(stdout); + TT.y = TT.h; + } printf("\x1B[%d;0H%-*s\x1B[%d;%dH", TT.y + 1, TT.w, toybuf, TT.y + 1, TT.x + 1); fflush(stdout); } @@ -141,7 +146,7 @@ static void startOfLine() updateLine(); } -// The key to command mappings. +// The key to command mappings, Emacs style. static struct keyCommand simpleEmacsKeys[] = { {"BS", backSpaceChar}, -- cgit v1.1