diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-22 00:22:46 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-22 00:22:46 +0000 |
| commit | ffd226c8dd3c188074cd5fa950920db33248b7bc (patch) | |
| tree | 1a952fac04a1d18f9f11ebb5d561bff16f19c31c /util-linux | |
| parent | 9d875e324878ed28b7d04126189dd0001f18f0fd (diff) | |
| download | busybox-w32-ffd226c8dd3c188074cd5fa950920db33248b7bc.tar.gz busybox-w32-ffd226c8dd3c188074cd5fa950920db33248b7bc.tar.bz2 busybox-w32-ffd226c8dd3c188074cd5fa950920db33248b7bc.zip | |
Adjust the terminal height for any overlap, so that no lines
get lost off the top
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1877 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/more.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/util-linux/more.c b/util-linux/more.c index 298e1cfb1..77e0c2f7e 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
| @@ -71,6 +71,7 @@ extern int more_main(int argc, char **argv) | |||
| 71 | int please_display_more_prompt = 0; | 71 | int please_display_more_prompt = 0; |
| 72 | struct stat st; | 72 | struct stat st; |
| 73 | FILE *file; | 73 | FILE *file; |
| 74 | int len; | ||
| 74 | 75 | ||
| 75 | #if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS | 76 | #if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS |
| 76 | struct winsize win = { 0, 0, 0, 0 }; | 77 | struct winsize win = { 0, 0, 0, 0 }; |
| @@ -112,12 +113,12 @@ extern int more_main(int argc, char **argv) | |||
| 112 | (void) signal(SIGTERM, gotsig); | 113 | (void) signal(SIGTERM, gotsig); |
| 113 | 114 | ||
| 114 | #endif | 115 | #endif |
| 116 | len = 0; | ||
| 115 | while ((c = getc(file)) != EOF) { | 117 | while ((c = getc(file)) != EOF) { |
| 116 | if (please_display_more_prompt) { | ||
| 117 | int len = 0; | ||
| 118 | 118 | ||
| 119 | please_display_more_prompt = 0; | 119 | if (please_display_more_prompt) { |
| 120 | lines = 0; | 120 | lines = 0; |
| 121 | please_display_more_prompt = 0; | ||
| 121 | len = printf("--More-- "); | 122 | len = printf("--More-- "); |
| 122 | if (file != stdin) { | 123 | if (file != stdin) { |
| 123 | #if _FILE_OFFSET_BITS == 64 | 124 | #if _FILE_OFFSET_BITS == 64 |
| @@ -160,7 +161,7 @@ extern int more_main(int argc, char **argv) | |||
| 160 | putc('\b', stdout); | 161 | putc('\b', stdout); |
| 161 | fflush(stdout); | 162 | fflush(stdout); |
| 162 | #endif | 163 | #endif |
| 163 | 164 | len=0; | |
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | /* | 167 | /* |
| @@ -183,14 +184,24 @@ extern int more_main(int argc, char **argv) | |||
| 183 | please_display_more_prompt = 1; | 184 | please_display_more_prompt = 1; |
| 184 | break; | 185 | break; |
| 185 | } | 186 | } |
| 186 | if (++lines == terminal_height) | 187 | /* Adjust the terminal height for any overlap, so that |
| 188 | * no lines get lost off the top. */ | ||
| 189 | if (len) { | ||
| 190 | div_t result = div( len, terminal_width); | ||
| 191 | if (result.quot) | ||
| 192 | terminal_height-=(result.quot-1); | ||
| 193 | } | ||
| 194 | if (++lines == terminal_height) { | ||
| 187 | please_display_more_prompt = 1; | 195 | please_display_more_prompt = 1; |
| 196 | } | ||
| 197 | len=0; | ||
| 188 | } | 198 | } |
| 189 | /* | 199 | /* |
| 190 | * If we just read a newline from the file being 'mored' and any | 200 | * If we just read a newline from the file being 'mored' and any |
| 191 | * key other than a return is hit, scroll by one page | 201 | * key other than a return is hit, scroll by one page |
| 192 | */ | 202 | */ |
| 193 | putc(c, stdout); | 203 | putc(c, stdout); |
| 204 | len++; | ||
| 194 | } | 205 | } |
| 195 | fclose(file); | 206 | fclose(file); |
| 196 | fflush(stdout); | 207 | fflush(stdout); |
