| 78 |
prints (" \033[1;33m按任意键继续...\033[0;37m"); |
prints (" \033[1;33m按任意键继续...\033[0;37m"); |
| 79 |
iflush (); |
iflush (); |
| 80 |
|
|
| 81 |
return igetch (); |
return igetch_t (60); |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
void |
void |
| 85 |
set_input_echo(int echo) |
set_input_echo (int echo) |
| 86 |
{ |
{ |
|
char temp[256]; |
|
|
|
|
| 87 |
if (echo) |
if (echo) |
| 88 |
{ |
{ |
| 89 |
outc ('\x83'); // ASCII code 131 |
outc ('\x83'); // ASCII code 131 |
| 90 |
iflush (); |
iflush (); |
| 91 |
} |
} |
| 92 |
else |
else |
| 93 |
{ |
{ |
| 94 |
// outc ('\x85'); // ASCII code 133 |
// outc ('\x85'); // ASCII code 133 |
| 95 |
prints ("\xff\xfb\x01\xff\xfb\x03"); |
prints ("\xff\xfb\x01\xff\xfb\x03"); |
| 96 |
iflush (); |
iflush (); |
| 97 |
igetch (); |
igetch_t (60); |
| 98 |
igetch (); |
igetch_t (60); |
| 99 |
} |
} |
| 100 |
} |
} |
| 101 |
|
|
| 102 |
int |
int |
| 107 |
|
|
| 108 |
memset (buffer, '\0', buffer_length); |
memset (buffer, '\0', buffer_length); |
| 109 |
|
|
| 110 |
while (c = igetch ()) |
while (c = igetch_t (60)) |
| 111 |
{ |
{ |
| 112 |
if (c == CR) |
if (c == KEY_NULL || c == KEY_TIMEOUT || c == CR) |
| 113 |
break; |
break; |
| 114 |
if (c == LF) |
if (c == LF) |
| 115 |
continue; |
continue; |
| 116 |
if (c == BACKSPACE) |
if (c == BACKSPACE) |
| 117 |
{ |
{ |
| 118 |
if (offset > 0) |
if (offset > 0) |
| 168 |
int i; |
int i; |
| 169 |
|
|
| 170 |
if ((fin = fopen (filename, "r")) == NULL) |
if ((fin = fopen (filename, "r")) == NULL) |
| 171 |
{ |
{ |
| 172 |
return -1; |
return -1; |
| 173 |
} |
} |
| 174 |
|
|
| 175 |
while (fgets (buffer, 255, fin)) |
while (fgets (buffer, 255, fin)) |
| 176 |
{ |
{ |
| 177 |
i = strlen (buffer); |
i = strlen (buffer); |
| 178 |
if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r') |
if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r') |
| 179 |
{ |
{ |
| 180 |
buffer[i - 1] = '\r'; |
buffer[i - 1] = '\r'; |
| 181 |
buffer[i] = '\n'; |
buffer[i] = '\n'; |
| 182 |
buffer[i + 1] = '\0'; |
buffer[i + 1] = '\0'; |
| 184 |
prints (buffer); |
prints (buffer); |
| 185 |
iflush (); |
iflush (); |
| 186 |
} |
} |
| 187 |
fclose(fin); |
fclose (fin); |
| 188 |
|
|
| 189 |
return 0; |
return 0; |
| 190 |
} |
} |
| 194 |
{ |
{ |
| 195 |
char buffer[260], temp[256]; |
char buffer[260], temp[256]; |
| 196 |
int i, ch, input_ok; |
int i, ch, input_ok; |
| 197 |
long int line, c_line_begin = 0, c_line_total=0; |
long int line, c_line_begin = 0, c_line_total = 0; |
| 198 |
long int f_line, f_size, f_offset; |
long int f_line, f_size, f_offset; |
| 199 |
FILE *fin; |
FILE *fin; |
| 200 |
struct stat f_stat; |
struct stat f_stat; |
| 213 |
f_size = f_stat.st_size; |
f_size = f_stat.st_size; |
| 214 |
|
|
| 215 |
while (fgets (buffer, 255, fin)) |
while (fgets (buffer, 255, fin)) |
| 216 |
c_line_total ++; |
c_line_total++; |
| 217 |
rewind (fin); |
rewind (fin); |
| 218 |
|
|
| 219 |
while (fgets (buffer, 255, fin)) |
while (fgets (buffer, 255, fin)) |
| 225 |
moveto (screen_lines, 0); |
moveto (screen_lines, 0); |
| 226 |
prints |
prints |
| 227 |
("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
| 228 |
(f_offset-strlen(buffer)) * 100 / f_size); |
(f_offset - strlen (buffer)) * 100 / f_size); |
| 229 |
iflush (); |
iflush (); |
| 230 |
|
|
| 231 |
input_ok = 0; |
input_ok = 0; |
| 232 |
while (!input_ok) |
while (!input_ok) |
| 233 |
{ |
{ |
| 234 |
ch = igetch (); |
ch = igetch_t (MAX_DELAY_TIME); |
| 235 |
input_ok = 1; |
input_ok = 1; |
| 236 |
switch (ch) |
switch (ch) |
| 237 |
{ |
{ |
| 277 |
} |
} |
| 278 |
break; |
break; |
| 279 |
case KEY_RIGHT: |
case KEY_RIGHT: |
| 280 |
case KEY_PGDOWN: |
case KEY_PGDN: |
| 281 |
case Ctrl ('F'): |
case Ctrl ('F'): |
| 282 |
case KEY_SPACE: |
case KEY_SPACE: |
| 283 |
c_line_begin += (screen_lines - begin_line - 1); |
c_line_begin += (screen_lines - begin_line - 1); |
| 284 |
if (c_line_begin + (screen_lines - begin_line) > c_line_total) |
if (c_line_begin + (screen_lines - begin_line) > |
| 285 |
c_line_begin = c_line_total - (screen_lines - begin_line); |
c_line_total) |
| 286 |
|
c_line_begin = |
| 287 |
|
c_line_total - (screen_lines - begin_line); |
| 288 |
rewind (fin); |
rewind (fin); |
| 289 |
for (f_line = 0; f_line < c_line_begin; f_line++) |
for (f_line = 0; f_line < c_line_begin; f_line++) |
| 290 |
{ |
{ |
| 292 |
goto exit; |
goto exit; |
| 293 |
} |
} |
| 294 |
break; |
break; |
| 295 |
|
case KEY_NULL: |
| 296 |
|
case KEY_TIMEOUT: |
| 297 |
case KEY_LEFT: |
case KEY_LEFT: |
| 298 |
case 'q': |
case 'q': |
| 299 |
case 'Q': |
case 'Q': |
| 341 |
line++; |
line++; |
| 342 |
} |
} |
| 343 |
if (wait) |
if (wait) |
| 344 |
ch = press_any_key(); |
ch = press_any_key (); |
| 345 |
else |
else |
| 346 |
ch = 0; |
ch = 0; |
| 347 |
|
|
| 348 |
exit: |
exit: |
| 349 |
fclose (fin); |
fclose (fin); |