| 82 |
} |
} |
| 83 |
|
|
| 84 |
void |
void |
| 85 |
set_input_echo(int echo) |
set_input_echo (int echo) |
| 86 |
{ |
{ |
| 87 |
char temp[256]; |
char temp[256]; |
| 88 |
|
|
| 89 |
if (echo) |
if (echo) |
| 90 |
{ |
{ |
| 91 |
outc ('\x83'); // ASCII code 131 |
outc ('\x83'); // ASCII code 131 |
| 92 |
iflush (); |
iflush (); |
| 93 |
} |
} |
| 94 |
else |
else |
| 95 |
{ |
{ |
| 96 |
// outc ('\x85'); // ASCII code 133 |
// outc ('\x85'); // ASCII code 133 |
| 97 |
prints ("\xff\xfb\x01\xff\xfb\x03"); |
prints ("\xff\xfb\x01\xff\xfb\x03"); |
| 98 |
iflush (); |
iflush (); |
| 99 |
igetch (); |
igetch (); |
| 100 |
igetch (); |
igetch (); |
| 101 |
} |
} |
| 102 |
} |
} |
| 103 |
|
|
| 104 |
int |
int |
| 114 |
if (c == CR) |
if (c == CR) |
| 115 |
break; |
break; |
| 116 |
if (c == LF) |
if (c == LF) |
| 117 |
continue; |
continue; |
| 118 |
if (c == BACKSPACE) |
if (c == BACKSPACE) |
| 119 |
{ |
{ |
| 120 |
if (offset > 0) |
if (offset > 0) |
| 169 |
FILE *fin; |
FILE *fin; |
| 170 |
int i; |
int i; |
| 171 |
|
|
| 172 |
if ((fin = fopen (filename, "r")) != NULL) |
if ((fin = fopen (filename, "r")) == NULL) |
| 173 |
{ |
{ |
| 174 |
while (fgets (buffer, 255, fin)) |
return -1; |
| 175 |
{ |
} |
| 176 |
i = strlen (buffer); |
|
| 177 |
if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r') |
while (fgets (buffer, 255, fin)) |
| 178 |
{ |
{ |
| 179 |
buffer[i - 1] = '\r'; |
i = strlen (buffer); |
| 180 |
buffer[i] = '\n'; |
if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r') |
| 181 |
buffer[i + 1] = '\0'; |
{ |
| 182 |
} |
buffer[i - 1] = '\r'; |
| 183 |
prints (buffer); |
buffer[i] = '\n'; |
| 184 |
iflush (); |
buffer[i + 1] = '\0'; |
| 185 |
} |
} |
| 186 |
fclose(fin); |
prints (buffer); |
| 187 |
return 0; |
iflush (); |
| 188 |
} |
} |
| 189 |
|
fclose (fin); |
| 190 |
return -1; |
|
| 191 |
|
return 0; |
| 192 |
} |
} |
| 193 |
|
|
| 194 |
int |
int |
| 196 |
{ |
{ |
| 197 |
char buffer[260], temp[256]; |
char buffer[260], temp[256]; |
| 198 |
int i, ch, input_ok; |
int i, ch, input_ok; |
| 199 |
long int line, c_line_begin = 0, c_line_total=0; |
long int line, c_line_begin = 0, c_line_total = 0; |
| 200 |
long int f_line, f_size, f_offset; |
long int f_line, f_size, f_offset; |
| 201 |
FILE *fin; |
FILE *fin; |
| 202 |
struct stat f_stat; |
struct stat f_stat; |
| 215 |
f_size = f_stat.st_size; |
f_size = f_stat.st_size; |
| 216 |
|
|
| 217 |
while (fgets (buffer, 255, fin)) |
while (fgets (buffer, 255, fin)) |
| 218 |
c_line_total ++; |
c_line_total++; |
| 219 |
rewind (fin); |
rewind (fin); |
| 220 |
|
|
| 221 |
while (fgets (buffer, 255, fin)) |
while (fgets (buffer, 255, fin)) |
| 227 |
moveto (screen_lines, 0); |
moveto (screen_lines, 0); |
| 228 |
prints |
prints |
| 229 |
("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
| 230 |
(f_offset-strlen(buffer)) * 100 / f_size); |
(f_offset - strlen (buffer)) * 100 / f_size); |
| 231 |
iflush (); |
iflush (); |
| 232 |
|
|
| 233 |
input_ok = 0; |
input_ok = 0; |
| 279 |
} |
} |
| 280 |
break; |
break; |
| 281 |
case KEY_RIGHT: |
case KEY_RIGHT: |
| 282 |
case KEY_PGDOWN: |
case KEY_PGDN: |
| 283 |
case Ctrl ('F'): |
case Ctrl ('F'): |
| 284 |
case KEY_SPACE: |
case KEY_SPACE: |
| 285 |
c_line_begin += (screen_lines - begin_line - 1); |
c_line_begin += (screen_lines - begin_line - 1); |
| 286 |
if (c_line_begin + (screen_lines - begin_line) > c_line_total) |
if (c_line_begin + (screen_lines - begin_line) > |
| 287 |
c_line_begin = c_line_total - (screen_lines - begin_line); |
c_line_total) |
| 288 |
|
c_line_begin = |
| 289 |
|
c_line_total - (screen_lines - begin_line); |
| 290 |
rewind (fin); |
rewind (fin); |
| 291 |
for (f_line = 0; f_line < c_line_begin; f_line++) |
for (f_line = 0; f_line < c_line_begin; f_line++) |
| 292 |
{ |
{ |
| 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); |