| 238 |
long *p_line_offsets; |
long *p_line_offsets; |
| 239 |
int len; |
int len; |
| 240 |
int percentile; |
int percentile; |
| 241 |
|
int loop = 1; |
| 242 |
|
|
| 243 |
if ((fin = fopen(filename, "r")) == NULL) |
if ((fin = fopen(filename, "r")) == NULL) |
| 244 |
{ |
{ |
| 254 |
line = begin_line; |
line = begin_line; |
| 255 |
max_lines = screen_rows - 1; |
max_lines = screen_rows - 1; |
| 256 |
|
|
| 257 |
while (c_line_current < c_line_total) |
while (loop) |
| 258 |
{ |
{ |
| 259 |
|
if (c_line_current >= c_line_total) |
| 260 |
|
{ |
| 261 |
|
if (wait) |
| 262 |
|
{ |
| 263 |
|
ch = press_any_key(); |
| 264 |
|
} |
| 265 |
|
else |
| 266 |
|
{ |
| 267 |
|
iflush(); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
loop = 0; |
| 271 |
|
break; |
| 272 |
|
} |
| 273 |
|
|
| 274 |
if (line >= max_lines) |
if (line >= max_lines) |
| 275 |
{ |
{ |
| 276 |
percentile = (c_line_current - (line - 1) + (screen_rows - 2)) * 100 / c_line_total; |
if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total) |
| 277 |
|
{ |
| 278 |
|
percentile = (c_line_current - (line - 1) + (screen_rows - 2)) * 100 / c_line_total; |
| 279 |
|
} |
| 280 |
|
else |
| 281 |
|
{ |
| 282 |
|
log_error("P100 reached\n"); |
| 283 |
|
percentile = 100; |
| 284 |
|
} |
| 285 |
|
|
| 286 |
moveto(screen_rows, 0); |
moveto(screen_rows, 0); |
| 287 |
prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
| 355 |
case KEY_LEFT: |
case KEY_LEFT: |
| 356 |
case 'q': |
case 'q': |
| 357 |
case 'Q': |
case 'Q': |
| 358 |
c_line_current = c_line_total; |
loop = 0; |
|
wait = 0; |
|
| 359 |
break; |
break; |
| 360 |
case '?': |
case '?': |
| 361 |
case 'h': |
case 'h': |
| 399 |
line++; |
line++; |
| 400 |
} |
} |
| 401 |
|
|
|
iflush(); |
|
|
|
|
|
if (wait) |
|
|
{ |
|
|
ch = press_any_key(); |
|
|
} |
|
|
|
|
| 402 |
free(p_line_offsets); |
free(p_line_offsets); |
| 403 |
fclose(fin); |
fclose(fin); |
| 404 |
|
|