diff options
author | David Walter Seikel | 2014-01-30 21:44:47 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-30 21:44:47 +1000 |
commit | db01665504f2ca03b11bc40a9bddb23ee8e87340 (patch) | |
tree | 3757f02dd8a72efc4adaac97292a6cb24ed3b5c2 | |
parent | Fix up dumbsh so it all works. (diff) | |
download | boxes-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.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -37,11 +37,16 @@ GLOBALS( | |||
37 | 37 | ||
38 | static void updateLine() | 38 | static 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. |
145 | static struct keyCommand simpleEmacsKeys[] = | 150 | static struct keyCommand simpleEmacsKeys[] = |
146 | { | 151 | { |
147 | {"BS", backSpaceChar}, | 152 | {"BS", backSpaceChar}, |