aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-01-30 21:44:47 +1000
committerDavid Walter Seikel2014-01-30 21:44:47 +1000
commitdb01665504f2ca03b11bc40a9bddb23ee8e87340 (patch)
tree3757f02dd8a72efc4adaac97292a6cb24ed3b5c2
parentFix up dumbsh so it all works. (diff)
downloadboxes-db01665504f2ca03b11bc40a9bddb23ee8e87340.zip
boxes-db01665504f2ca03b11bc40a9bddb23ee8e87340.tar.gz
boxes-db01665504f2ca03b11bc40a9bddb23ee8e87340.tar.bz2
boxes-db01665504f2ca03b11bc40a9bddb23ee8e87340.tar.xz
Actually scroll the terminal when we get to the end of it.
Diffstat (limited to '')
-rw-r--r--dumbsh.c11
1 files 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(
37 37
38static void updateLine() 38static void updateLine()
39{ 39{
40 if (0 > TT.y) TT.y = 0;
41 if (0 > TT.x) TT.x = 0; 40 if (0 > TT.x) TT.x = 0;
42 if (strlen(toybuf) <= TT.x) TT.x = strlen(toybuf); 41 if (strlen(toybuf) <= TT.x) TT.x = strlen(toybuf);
43 if (TT.h < TT.y) TT.y = TT.h;
44 if (TT.w < TT.x) TT.x = TT.w; 42 if (TT.w < TT.x) TT.x = TT.w;
43 if (0 > TT.y) TT.y = 0;
44 if (TT.h < TT.y)
45 {
46 printf("\x1B[%d;0H\n", TT.y + 1);
47 fflush(stdout);
48 TT.y = TT.h;
49 }
45 printf("\x1B[%d;0H%-*s\x1B[%d;%dH", TT.y + 1, TT.w, toybuf, TT.y + 1, TT.x + 1); 50 printf("\x1B[%d;0H%-*s\x1B[%d;%dH", TT.y + 1, TT.w, toybuf, TT.y + 1, TT.x + 1);
46 fflush(stdout); 51 fflush(stdout);
47} 52}
@@ -141,7 +146,7 @@ static void startOfLine()
141 updateLine(); 146 updateLine();
142} 147}
143 148
144// The key to command mappings. 149// The key to command mappings, Emacs style.
145static struct keyCommand simpleEmacsKeys[] = 150static struct keyCommand simpleEmacsKeys[] =
146{ 151{
147 {"BS", backSpaceChar}, 152 {"BS", backSpaceChar},