diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-21 13:26:54 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-21 13:26:54 +0000 |
commit | e147a721736922db9f80f233e56dbd36e6e4a902 (patch) | |
tree | dbcf1d860e53dddd09ba5dc9c77fec892824c6aa /miscutils/less.c | |
parent | e865e81d34efb96417c549e9c326fb1c46dafbc7 (diff) | |
download | busybox-w32-e147a721736922db9f80f233e56dbd36e6e4a902.tar.gz busybox-w32-e147a721736922db9f80f233e56dbd36e6e4a902.tar.bz2 busybox-w32-e147a721736922db9f80f233e56dbd36e6e4a902.zip |
less: how many different kinds of status line we need, three?!
small fixes. [prev commit also added control char filtering
on input (e.g. regexp input, filename input for 'E' etc)]
Diffstat (limited to 'miscutils/less.c')
-rw-r--r-- | miscutils/less.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index 068c3f393..d56f38df5 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -263,73 +263,70 @@ static void m_status_print(void) | |||
263 | { | 263 | { |
264 | int percentage; | 264 | int percentage; |
265 | 265 | ||
266 | if (!line_pos) { | 266 | printf(HIGHLIGHT"%s", filename); |
267 | if (num_files > 1) { | 267 | if (num_files > 1) |
268 | printf(HIGHLIGHT"%s (file %i of %i) lines %i-%i/%i ", | 268 | printf(" (file %i of %i)", current_file, num_files); |
269 | filename, current_file, num_files, | 269 | printf(" lines %i-%i/%i ", |
270 | line_pos + 1, line_pos + height - 1, num_flines + 1); | 270 | line_pos + 1, line_pos + height - 1, |
271 | } else { | 271 | num_flines + 1); |
272 | printf(HIGHLIGHT"%s lines %i-%i/%i ", | ||
273 | filename, line_pos + 1, line_pos + height - 1, | ||
274 | num_flines + 1); | ||
275 | } | ||
276 | } else { | ||
277 | printf(HIGHLIGHT" %s lines %i-%i/%i ", filename, | ||
278 | line_pos + 1, line_pos + height - 1, num_flines + 1); | ||
279 | } | ||
280 | |||
281 | if (line_pos >= num_flines - height + 2) { | 272 | if (line_pos >= num_flines - height + 2) { |
282 | printf("(END) "NORMAL); | 273 | printf("(END) "NORMAL); |
283 | if (num_files > 1 && current_file != num_files) | 274 | if (num_files > 1 && current_file != num_files) |
284 | printf(HIGHLIGHT"- Next: %s"NORMAL, files[current_file]); | 275 | printf(HIGHLIGHT"- Next: %s "NORMAL, files[current_file]); |
285 | } else { | 276 | return; |
286 | percentage = calc_percent(); | ||
287 | printf("%i%% "NORMAL, percentage); | ||
288 | } | 277 | } |
278 | percentage = calc_percent(); | ||
279 | printf("%i%% "NORMAL, percentage); | ||
289 | } | 280 | } |
290 | 281 | ||
282 | #if 0 | ||
291 | /* Print a status line if -m was specified */ | 283 | /* Print a status line if -m was specified */ |
292 | static void medium_status_print(void) | 284 | static void medium_status_print(void) |
293 | { | 285 | { |
294 | int percentage; | 286 | int percentage; |
295 | percentage = calc_percent(); | ||
296 | 287 | ||
288 | percentage = calc_percent(); | ||
297 | if (!line_pos) | 289 | if (!line_pos) |
298 | printf(HIGHLIGHT"%s %i%%"NORMAL, filename, percentage); | 290 | printf(HIGHLIGHT"%s %i%% "NORMAL, filename, percentage); |
299 | else if (line_pos == num_flines - height + 2) | 291 | else if (line_pos >= num_flines - height + 2) |
300 | print_hilite("(END)"); | 292 | print_hilite("(END) "); |
301 | else | 293 | else |
302 | printf(HIGHLIGHT"%i%%"NORMAL, percentage); | 294 | printf(HIGHLIGHT"%i%% "NORMAL, percentage); |
303 | } | 295 | } |
304 | #endif | 296 | #endif |
305 | 297 | ||
298 | #endif | ||
299 | |||
306 | /* Print the status line */ | 300 | /* Print the status line */ |
307 | static void status_print(void) | 301 | static void status_print(void) |
308 | { | 302 | { |
303 | const char *p; | ||
304 | |||
309 | /* Change the status if flags have been set */ | 305 | /* Change the status if flags have been set */ |
310 | #if ENABLE_FEATURE_LESS_FLAGS | 306 | #if ENABLE_FEATURE_LESS_FLAGS |
311 | if (option_mask32 & FLAG_M) | 307 | if (option_mask32 & (FLAG_M|FLAG_m)) { |
312 | m_status_print(); | 308 | m_status_print(); |
313 | else if (option_mask32 & FLAG_m) | 309 | return; |
314 | medium_status_print(); | 310 | } |
311 | //if (option_mask32 & FLAG_m) { | ||
312 | // medium_status_print(); | ||
313 | // return; | ||
314 | //} | ||
315 | /* No flags set */ | 315 | /* No flags set */ |
316 | else { | ||
317 | #endif | 316 | #endif |
318 | if (!line_pos) { | 317 | if (line_pos && line_pos < num_flines - height + 2) { |
319 | print_hilite(filename); | 318 | putchar(':'); |
320 | if (num_files > 1) | 319 | return; |
321 | printf(HIGHLIGHT"(file %i of %i)"NORMAL, | ||
322 | current_file, num_files); | ||
323 | } else if (line_pos == num_flines - height + 2) { | ||
324 | print_hilite("(END) "); | ||
325 | if (num_files > 1 && current_file != num_files) | ||
326 | printf(HIGHLIGHT"- Next: %s"NORMAL, files[current_file]); | ||
327 | } else { | ||
328 | putchar(':'); | ||
329 | } | ||
330 | #if ENABLE_FEATURE_LESS_FLAGS | ||
331 | } | 320 | } |
332 | #endif | 321 | p = "(END) "; |
322 | if (!line_pos) | ||
323 | p = filename; | ||
324 | if (num_files > 1) { | ||
325 | printf(HIGHLIGHT"%s (file %i of %i) "NORMAL, | ||
326 | p, current_file, num_files); | ||
327 | return; | ||
328 | } | ||
329 | print_hilite(p); | ||
333 | } | 330 | } |
334 | 331 | ||
335 | static char controls[] = | 332 | static char controls[] = |
@@ -554,7 +551,7 @@ static void examine_file(void) | |||
554 | current_file = num_files + 1; | 551 | current_file = num_files + 1; |
555 | num_files++; */ | 552 | num_files++; */ |
556 | files[0] = filename; | 553 | files[0] = filename; |
557 | current_file = 1; | 554 | num_files = current_file = 1; |
558 | reinitialise(); | 555 | reinitialise(); |
559 | } | 556 | } |
560 | 557 | ||