| 1 |
/* $Id: esc.c,v 1.119 2024/12/05 00:44:52 tom Exp $ */ |
| 2 |
|
| 3 |
#include <vttest.h> |
| 4 |
#include <esc.h> |
| 5 |
|
| 6 |
/* This was needed for Solaris 2.5, whose standard I/O was broken */ |
| 7 |
#define FLUSH fflush(stdout) |
| 8 |
|
| 9 |
#define VA_OUT(fp, fmt, ap) do { \ |
| 10 |
va_start(ap, fmt); \ |
| 11 |
va_out(fp, fmt, ap); \ |
| 12 |
va_end(ap); \ |
| 13 |
} while (0) |
| 14 |
|
| 15 |
static int soft_scroll; |
| 16 |
|
| 17 |
/******************************************************************************/ |
| 18 |
|
| 19 |
static int pending_decstbm; |
| 20 |
static int pending_decslrm; |
| 21 |
static int putting_data; |
| 22 |
|
| 23 |
static const char csi_7[] = |
| 24 |
{ESC, '[', 0}; |
| 25 |
|
| 26 |
static const unsigned char csi_8[] = |
| 27 |
{0x9b, 0}; |
| 28 |
|
| 29 |
const char * |
| 30 |
csi_input(void) |
| 31 |
{ |
| 32 |
return input_8bits ? (const char *) csi_8 : csi_7; |
| 33 |
} |
| 34 |
|
| 35 |
const char * |
| 36 |
csi_output(void) |
| 37 |
{ |
| 38 |
return output_8bits ? (const char *) csi_8 : csi_7; |
| 39 |
} |
| 40 |
|
| 41 |
/******************************************************************************/ |
| 42 |
|
| 43 |
static const char dcs_7[] = |
| 44 |
{ESC, 'P', 0}; |
| 45 |
|
| 46 |
static const unsigned char dcs_8[] = |
| 47 |
{0x90, 0}; |
| 48 |
|
| 49 |
const char * |
| 50 |
dcs_input(void) |
| 51 |
{ |
| 52 |
return input_8bits ? (const char *) dcs_8 : dcs_7; |
| 53 |
} |
| 54 |
|
| 55 |
const char * |
| 56 |
dcs_output(void) |
| 57 |
{ |
| 58 |
return output_8bits ? (const char *) dcs_8 : dcs_7; |
| 59 |
} |
| 60 |
|
| 61 |
/******************************************************************************/ |
| 62 |
|
| 63 |
static const char osc_7[] = |
| 64 |
{ESC, ']', 0}; |
| 65 |
static const unsigned char osc_8[] = |
| 66 |
{0x9d, 0}; |
| 67 |
|
| 68 |
const char * |
| 69 |
osc_input(void) |
| 70 |
{ |
| 71 |
return input_8bits ? (const char *) osc_8 : osc_7; |
| 72 |
} |
| 73 |
|
| 74 |
const char * |
| 75 |
osc_output(void) |
| 76 |
{ |
| 77 |
return output_8bits ? (const char *) osc_8 : osc_7; |
| 78 |
} |
| 79 |
|
| 80 |
/******************************************************************************/ |
| 81 |
|
| 82 |
static char ss2_7[] = |
| 83 |
{ESC, 'N', 0}; |
| 84 |
static unsigned char ss2_8[] = |
| 85 |
{0x8e, 0}; |
| 86 |
|
| 87 |
char * |
| 88 |
ss2_input(void) |
| 89 |
{ |
| 90 |
return input_8bits ? (char *) ss2_8 : ss2_7; |
| 91 |
} |
| 92 |
|
| 93 |
char * |
| 94 |
ss2_output(void) |
| 95 |
{ |
| 96 |
return output_8bits ? (char *) ss2_8 : ss2_7; |
| 97 |
} |
| 98 |
|
| 99 |
/******************************************************************************/ |
| 100 |
|
| 101 |
static char ss3_7[] = |
| 102 |
{ESC, 'O', 0}; |
| 103 |
static unsigned char ss3_8[] = |
| 104 |
{0x8f, 0}; |
| 105 |
|
| 106 |
char * |
| 107 |
ss3_input(void) |
| 108 |
{ |
| 109 |
return input_8bits ? (char *) ss3_8 : ss3_7; |
| 110 |
} |
| 111 |
|
| 112 |
char * |
| 113 |
ss3_output(void) |
| 114 |
{ |
| 115 |
return output_8bits ? (char *) ss3_8 : ss3_7; |
| 116 |
} |
| 117 |
|
| 118 |
/******************************************************************************/ |
| 119 |
|
| 120 |
static char st_7[] = |
| 121 |
{ESC, '\\', 0}; |
| 122 |
static unsigned char st_8[] = |
| 123 |
{0x9c, 0}; |
| 124 |
|
| 125 |
char * |
| 126 |
st_input(void) |
| 127 |
{ |
| 128 |
return input_8bits ? (char *) st_8 : st_7; |
| 129 |
} |
| 130 |
|
| 131 |
char * |
| 132 |
st_output(void) |
| 133 |
{ |
| 134 |
return output_8bits ? (char *) st_8 : st_7; |
| 135 |
} |
| 136 |
|
| 137 |
/******************************************************************************/ |
| 138 |
|
| 139 |
/* |
| 140 |
* The actual number of nulls for padding is an estimate; it's working at |
| 141 |
* 9600bd. |
| 142 |
*/ |
| 143 |
void |
| 144 |
padding(int msecs) |
| 145 |
{ |
| 146 |
if (use_padding) { |
| 147 |
int count = (3 * msecs * tty_speed + DEFAULT_SPEED - 1) / DEFAULT_SPEED; |
| 148 |
while (count-- > 0) |
| 149 |
putchar(0); |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
void |
| 154 |
extra_padding(int msecs) |
| 155 |
{ |
| 156 |
if (use_padding) |
| 157 |
padding(soft_scroll ? (msecs * 4) : msecs); |
| 158 |
} |
| 159 |
|
| 160 |
/* |
| 161 |
* Print ordinary text, ensuring that the logged text has a newlne. |
| 162 |
*/ |
| 163 |
int |
| 164 |
printxx(const char *fmt, ...) |
| 165 |
{ |
| 166 |
va_list ap; |
| 167 |
|
| 168 |
va_start(ap, fmt); |
| 169 |
vfprintf(stdout, fmt, ap); |
| 170 |
va_end(ap); |
| 171 |
|
| 172 |
if (LOG_ENABLED) { |
| 173 |
int endl = (strchr(fmt, '\n') != NULL ? 0 : 1); |
| 174 |
|
| 175 |
fprintf(log_fp, TELL_STR); |
| 176 |
|
| 177 |
va_start(ap, fmt); |
| 178 |
vfprintf(log_fp, fmt, ap); |
| 179 |
va_end(ap); |
| 180 |
|
| 181 |
if (endl) |
| 182 |
fputs("\n", log_fp); |
| 183 |
} |
| 184 |
return 1; |
| 185 |
} |
| 186 |
|
| 187 |
/* |
| 188 |
* Print a ordinary line of text, logging it. |
| 189 |
*/ |
| 190 |
int |
| 191 |
println(const char *s) |
| 192 |
{ |
| 193 |
printf("%s\r\n", s); |
| 194 |
if (LOG_ENABLED) { |
| 195 |
fprintf(log_fp, "%s%s\n", TELL_STR, s); |
| 196 |
} |
| 197 |
return 1; |
| 198 |
} |
| 199 |
|
| 200 |
void |
| 201 |
put_char(FILE *fp, int c) |
| 202 |
{ |
| 203 |
c &= 0xff; |
| 204 |
if (fp == stdout) { |
| 205 |
if (parse_7bits && (putting_data > 0) && (c >= 32)) { |
| 206 |
/* |
| 207 |
* Construct two different tests, according to whether the locale hints |
| 208 |
* that the terminal uses UTF-8. |
| 209 |
*/ |
| 210 |
if (assume_utf8) { |
| 211 |
/* |
| 212 |
* In the first case, we are told that the parser expects C2 where the |
| 213 |
* test sends a C1 character. Unicode.org inverted ECMA-48 to do away |
| 214 |
* with the possibility of using non-UTF-8 codes in C1. Since that |
| 215 |
* disagrees with the standard (by substituting a multibyte character |
| 216 |
* for a single byte), and because the first of those bytes is a 0xC2, |
| 217 |
* it is appropriate to refer to this situation as a C2 character. |
| 218 |
* |
| 219 |
* Progressing through the range 128..255, if the test happens to be |
| 220 |
* using ISO Latin-1 (ISO-8859-1), then the UTF-8 encoding happens to |
| 221 |
* look correct. That will not work for other character sets. |
| 222 |
*/ |
| 223 |
if (parse_7bits == 2 && allows_utf8 && c >= 128 && c <= 255) { |
| 224 |
unsigned char buffer[10]; |
| 225 |
int rc = conv_to_utf8(buffer, (unsigned) c, sizeof(buffer)); |
| 226 |
if (rc > 1) { /* rc should be 0, 1 or 2 */ |
| 227 |
fwrite(buffer, (size_t) (rc - 1), 1, fp); |
| 228 |
c = buffer[rc - 1]; /* fall-thru with the last byte */ |
| 229 |
} |
| 230 |
} |
| 231 |
} else { |
| 232 |
/* |
| 233 |
* The second case is relevant to ECMA-48 in contrast to the above. |
| 234 |
* ECMA-48 makes it clear that both 7-bit controls and 8-bit control |
| 235 |
* are parsed using a 7-bit table. We can demonstrate whether the |
| 236 |
* terminal actually does this by mapping printable 7-bit characters |
| 237 |
* (32 to 126) to the 160..254 range. |
| 238 |
* |
| 239 |
* Because an ECMA-48 parser looks for the final character (or the |
| 240 |
* string terminator for APC, etc.) using a 7-bit table, it is possible |
| 241 |
* to match the final/terminating character in the 160..254 range. |
| 242 |
* Unicode.org could improve its documentation to clarify how it |
| 243 |
* differs from ECMA-48, and in doing so might state that the data |
| 244 |
* stream need not comply with ECMA-48 in this regard. |
| 245 |
* |
| 246 |
* ECMA-48 and ISO 6429 provide the same information; the former is |
| 247 |
* preferred because it is freely available. Unicode.org mentions ISO |
| 248 |
* 6429 in ~10 places without providing any information on control |
| 249 |
* sequences. |
| 250 |
*/ |
| 251 |
if (parse_7bits == 1 && c <= 126) { |
| 252 |
c |= 128; |
| 253 |
} |
| 254 |
} |
| 255 |
} |
| 256 |
putchar(c); |
| 257 |
} else { |
| 258 |
c &= 0xff; |
| 259 |
if (putting_data < 0 && c == ESC) |
| 260 |
fprintf(fp, "BUG:"); |
| 261 |
if (c <= ' ' || c >= '\177') |
| 262 |
fprintf(fp, "<%d> ", c); |
| 263 |
else |
| 264 |
fprintf(fp, "%c ", c); |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
void |
| 269 |
put_string(FILE *fp, const char *s) |
| 270 |
{ |
| 271 |
while (*s != '\0') |
| 272 |
put_char(fp, (int) *s++); |
| 273 |
} |
| 274 |
|
| 275 |
#define CHECK_FORMAT() \ |
| 276 |
if (form_len + 2 >= (int) sizeof(real_fmt)) { \ |
| 277 |
done = 2; \ |
| 278 |
break; \ |
| 279 |
} |
| 280 |
|
| 281 |
#define ADD_TO_FORMAT(c) \ |
| 282 |
real_fmt[form_len++] = (char) (c); \ |
| 283 |
real_fmt[form_len] = 0 |
| 284 |
|
| 285 |
#define PUT_FORMATTED(c,arg_type) \ |
| 286 |
CHECK_FORMAT(); \ |
| 287 |
ADD_TO_FORMAT(c); \ |
| 288 |
if (size_arg) { \ |
| 289 |
size_arg = va_arg(ap, int); \ |
| 290 |
sprintf(real_arg, real_fmt, size_arg, va_arg(ap, arg_type)); \ |
| 291 |
} else { \ |
| 292 |
sprintf(real_arg, real_fmt, va_arg(ap, arg_type)); \ |
| 293 |
} \ |
| 294 |
put_string(fp, real_arg); \ |
| 295 |
real_fmt[form_len = 0] = 0 |
| 296 |
|
| 297 |
/* |
| 298 |
* Do our own vfprintf, so that we can reformat and log the output. |
| 299 |
*/ |
| 300 |
static void |
| 301 |
va_out(FILE *fp, const char *fmt, va_list ap) |
| 302 |
{ |
| 303 |
while (*fmt != '\0') { |
| 304 |
if (*fmt == '%') { |
| 305 |
char real_fmt[20]; |
| 306 |
char real_arg[1024]; |
| 307 |
int form_len = 0; |
| 308 |
int size_arg = 0; |
| 309 |
int done = 0; |
| 310 |
|
| 311 |
real_fmt[0] = 0; |
| 312 |
ADD_TO_FORMAT(*fmt); |
| 313 |
do { |
| 314 |
int ch = *++fmt; |
| 315 |
|
| 316 |
done = 1; |
| 317 |
switch (ch) { |
| 318 |
case 'c': |
| 319 |
ch = va_arg(ap, int); |
| 320 |
/* FALLTHRU */ |
| 321 |
case '%': |
| 322 |
put_char(fp, ch); |
| 323 |
break; |
| 324 |
case 'd': |
| 325 |
PUT_FORMATTED(ch, int); |
| 326 |
break; |
| 327 |
case 'u': |
| 328 |
PUT_FORMATTED(ch, unsigned); |
| 329 |
break; |
| 330 |
case 's': |
| 331 |
PUT_FORMATTED(ch, char *); |
| 332 |
break; |
| 333 |
case 0: |
| 334 |
done = 2; |
| 335 |
break; |
| 336 |
default: |
| 337 |
/* provide for "%20s", etc. */ |
| 338 |
CHECK_FORMAT(); |
| 339 |
ADD_TO_FORMAT(ch); |
| 340 |
done = 0; |
| 341 |
if (ch == '*') { |
| 342 |
/* provide for "%.*s", etc. */ |
| 343 |
if (++size_arg > 1) { |
| 344 |
done = 2; |
| 345 |
} |
| 346 |
} |
| 347 |
break; |
| 348 |
} |
| 349 |
} while (!done); |
| 350 |
if (done > 1) { |
| 351 |
put_string(fp, real_fmt); /* bug */ |
| 352 |
} |
| 353 |
} else { |
| 354 |
put_char(fp, (int) *fmt); |
| 355 |
} |
| 356 |
fmt++; |
| 357 |
} |
| 358 |
} |
| 359 |
|
| 360 |
/* |
| 361 |
* Print ordinary (non-control) text, formatted. |
| 362 |
*/ |
| 363 |
int |
| 364 |
tprintf(const char *fmt, ...) |
| 365 |
{ |
| 366 |
va_list ap; |
| 367 |
|
| 368 |
putting_data = -1; /* check for unexpected controls */ |
| 369 |
|
| 370 |
VA_OUT(stdout, fmt, ap); |
| 371 |
FLUSH; |
| 372 |
|
| 373 |
if (LOG_ENABLED) { |
| 374 |
fputs(DATA_STR, log_fp); |
| 375 |
VA_OUT(log_fp, fmt, ap); |
| 376 |
fputs("\n", log_fp); |
| 377 |
} |
| 378 |
|
| 379 |
putting_data = 0; |
| 380 |
return 1; |
| 381 |
} |
| 382 |
|
| 383 |
/* |
| 384 |
* Print control text, formatted. |
| 385 |
*/ |
| 386 |
int |
| 387 |
cprintf(const char *fmt, ...) |
| 388 |
{ |
| 389 |
va_list ap; |
| 390 |
|
| 391 |
putting_data = 1; |
| 392 |
|
| 393 |
VA_OUT(stdout, fmt, ap); |
| 394 |
FLUSH; |
| 395 |
|
| 396 |
if (LOG_ENABLED) { |
| 397 |
fputs(SEND_STR, log_fp); |
| 398 |
VA_OUT(log_fp, fmt, ap); |
| 399 |
fputs("\n", log_fp); |
| 400 |
} |
| 401 |
|
| 402 |
putting_data = 0; |
| 403 |
return 1; |
| 404 |
} |
| 405 |
|
| 406 |
/* CSI xxx */ |
| 407 |
void |
| 408 |
do_csi(const char *fmt, ...) |
| 409 |
{ |
| 410 |
va_list ap; |
| 411 |
|
| 412 |
putting_data = 1; |
| 413 |
|
| 414 |
put_string(stdout, csi_output()); |
| 415 |
VA_OUT(stdout, fmt, ap); |
| 416 |
|
| 417 |
FLUSH; |
| 418 |
|
| 419 |
if (LOG_ENABLED) { |
| 420 |
fputs(SEND_STR, log_fp); |
| 421 |
put_string(log_fp, csi_output()); |
| 422 |
VA_OUT(log_fp, fmt, ap); |
| 423 |
fputs("\n", log_fp); |
| 424 |
} |
| 425 |
putting_data = 0; |
| 426 |
} |
| 427 |
|
| 428 |
/* DCS xxx ST */ |
| 429 |
void |
| 430 |
do_dcs(const char *fmt, ...) |
| 431 |
{ |
| 432 |
va_list ap; |
| 433 |
|
| 434 |
putting_data = 1; |
| 435 |
|
| 436 |
put_string(stdout, dcs_output()); |
| 437 |
VA_OUT(stdout, fmt, ap); |
| 438 |
|
| 439 |
put_string(stdout, st_output()); |
| 440 |
FLUSH; |
| 441 |
|
| 442 |
if (LOG_ENABLED) { |
| 443 |
fputs(SEND_STR, log_fp); |
| 444 |
put_string(log_fp, dcs_output()); |
| 445 |
VA_OUT(log_fp, fmt, ap); |
| 446 |
put_string(log_fp, st_output()); |
| 447 |
fputs("\n", log_fp); |
| 448 |
} |
| 449 |
putting_data = 0; |
| 450 |
} |
| 451 |
|
| 452 |
/* DCS xxx ST */ |
| 453 |
void |
| 454 |
do_osc(const char *fmt, ...) |
| 455 |
{ |
| 456 |
va_list ap; |
| 457 |
|
| 458 |
putting_data = 1; |
| 459 |
|
| 460 |
put_string(stdout, osc_output()); |
| 461 |
VA_OUT(stdout, fmt, ap); |
| 462 |
|
| 463 |
put_string(stdout, st_output()); |
| 464 |
FLUSH; |
| 465 |
|
| 466 |
if (LOG_ENABLED) { |
| 467 |
fputs(SEND_STR, log_fp); |
| 468 |
put_string(log_fp, osc_output()); |
| 469 |
VA_OUT(log_fp, fmt, ap); |
| 470 |
put_string(log_fp, st_output()); |
| 471 |
fputs("\n", log_fp); |
| 472 |
} |
| 473 |
putting_data = 0; |
| 474 |
} |
| 475 |
|
| 476 |
int |
| 477 |
print_chr(int c) |
| 478 |
{ |
| 479 |
printf("%c", c); |
| 480 |
|
| 481 |
if (LOG_ENABLED) { |
| 482 |
fprintf(log_fp, SEND_STR); |
| 483 |
put_char(log_fp, c); |
| 484 |
fputs("\n", log_fp); |
| 485 |
} |
| 486 |
return 1; |
| 487 |
} |
| 488 |
|
| 489 |
int |
| 490 |
print_str(const char *s) |
| 491 |
{ |
| 492 |
int result = (int) strlen(s); |
| 493 |
printf("%s", s); |
| 494 |
|
| 495 |
if (LOG_ENABLED) { |
| 496 |
fprintf(log_fp, SEND_STR); |
| 497 |
while (*s) { |
| 498 |
put_char(log_fp, *s++); |
| 499 |
} |
| 500 |
fputs("\n", log_fp); |
| 501 |
} |
| 502 |
return result; |
| 503 |
} |
| 504 |
|
| 505 |
void |
| 506 |
esc(const char *s) |
| 507 |
{ |
| 508 |
putting_data = 1; |
| 509 |
|
| 510 |
put_char(stdout, ESC); |
| 511 |
put_string(stdout, s); |
| 512 |
|
| 513 |
if (LOG_ENABLED) { |
| 514 |
fprintf(log_fp, SEND_STR); |
| 515 |
put_char(log_fp, ESC); |
| 516 |
put_string(log_fp, s); |
| 517 |
fputs("\n", log_fp); |
| 518 |
} |
| 519 |
|
| 520 |
putting_data = 0; |
| 521 |
} |
| 522 |
|
| 523 |
/* |
| 524 |
* Maps positive sequence to [-1,0,1], where -1 denotes the absence of a |
| 525 |
* parameter, 0 and 1 are different ways to express the default parameter |
| 526 |
* when it is 1. |
| 527 |
*/ |
| 528 |
int |
| 529 |
default_1(int pn) |
| 530 |
{ |
| 531 |
return ((pn % 3) - 1); |
| 532 |
} |
| 533 |
|
| 534 |
/* |
| 535 |
* Special case for xterm's use of CSI T for mouse-tracking. |
| 536 |
*/ |
| 537 |
int |
| 538 |
default_1a(int pn) |
| 539 |
{ |
| 540 |
if ((pn = default_1(pn)) == 0) |
| 541 |
pn = 1; |
| 542 |
return pn; |
| 543 |
} |
| 544 |
|
| 545 |
void |
| 546 |
brc(int pn, int c) |
| 547 |
{ |
| 548 |
if (pn < 0) /* e.g., default_1() */ |
| 549 |
do_csi("%c", c); |
| 550 |
else |
| 551 |
do_csi("%d%c", pn, c); |
| 552 |
} |
| 553 |
|
| 554 |
void |
| 555 |
brc2(int pn1, int pn2, int c) |
| 556 |
{ |
| 557 |
do_csi("%d;%d%c", pn1, pn2, c); |
| 558 |
} |
| 559 |
|
| 560 |
void |
| 561 |
brc3(int pn1, int pn2, int pn3, int c) |
| 562 |
{ |
| 563 |
do_csi("%d;%d;%d%c", pn1, pn2, pn3, c); |
| 564 |
} |
| 565 |
|
| 566 |
/******************************************************************************/ |
| 567 |
|
| 568 |
void |
| 569 |
cbt(int pn) /* Cursor Back Tab */ |
| 570 |
{ |
| 571 |
brc(pn, 'Z'); |
| 572 |
} |
| 573 |
|
| 574 |
void |
| 575 |
cha(int pn) /* Cursor Character Absolute */ |
| 576 |
{ |
| 577 |
brc(pn, 'G'); |
| 578 |
} |
| 579 |
|
| 580 |
void |
| 581 |
cht(int pn) /* Cursor Forward Tabulation */ |
| 582 |
{ |
| 583 |
brc(pn, 'I'); |
| 584 |
} |
| 585 |
|
| 586 |
void |
| 587 |
cnl(int pn) /* Cursor Next Line */ |
| 588 |
{ |
| 589 |
brc(pn, 'E'); |
| 590 |
} |
| 591 |
|
| 592 |
void |
| 593 |
cpl(int pn) /* Cursor Previous Line */ |
| 594 |
{ |
| 595 |
brc(pn, 'F'); |
| 596 |
} |
| 597 |
|
| 598 |
void |
| 599 |
cub(int pn) /* Cursor Backward */ |
| 600 |
{ |
| 601 |
brc(pn, 'D'); |
| 602 |
padding(2); |
| 603 |
} |
| 604 |
|
| 605 |
void |
| 606 |
cud(int pn) /* Cursor Down */ |
| 607 |
{ |
| 608 |
brc(pn, 'B'); |
| 609 |
extra_padding(2); |
| 610 |
} |
| 611 |
|
| 612 |
void |
| 613 |
cuf(int pn) /* Cursor Forward */ |
| 614 |
{ |
| 615 |
brc(pn, 'C'); |
| 616 |
padding(2); |
| 617 |
} |
| 618 |
|
| 619 |
int |
| 620 |
cup(int pn1, int pn2) /* Cursor Position */ |
| 621 |
{ |
| 622 |
brc2(pn1, pn2, 'H'); |
| 623 |
padding(5); /* 10 for vt220 */ |
| 624 |
return 1; /* used for indenting */ |
| 625 |
} |
| 626 |
|
| 627 |
void |
| 628 |
cuu(int pn) /* Cursor Up */ |
| 629 |
{ |
| 630 |
brc(pn, 'A'); |
| 631 |
extra_padding(2); |
| 632 |
} |
| 633 |
|
| 634 |
void |
| 635 |
da(void) /* Device Attributes */ |
| 636 |
{ |
| 637 |
brc(0, 'c'); |
| 638 |
} |
| 639 |
|
| 640 |
void |
| 641 |
decac(int flag, int fg, int bg) /* DECAC - Assign Color EK-VT520-RM, p 5-16 */ |
| 642 |
{ |
| 643 |
if (use_decac) { |
| 644 |
decac_fg = fg; |
| 645 |
decac_bg = bg; |
| 646 |
} |
| 647 |
do_csi("%d;%d;%d,|", flag, fg, bg); |
| 648 |
} |
| 649 |
|
| 650 |
void |
| 651 |
decaln(void) /* Screen Alignment Display */ |
| 652 |
{ |
| 653 |
esc("#8"); |
| 654 |
} |
| 655 |
|
| 656 |
void |
| 657 |
decarm(int flag) /* DECARM autorepeat */ |
| 658 |
{ |
| 659 |
if (flag) |
| 660 |
sm("?8"); /* autorepeat */ |
| 661 |
else |
| 662 |
rm("?8"); /* no autorepeat */ |
| 663 |
} |
| 664 |
|
| 665 |
void |
| 666 |
decatc(int flag, int fg, int bg) /* DECATC - Alternate Text Color EK-VT520-RM, p 5-22 */ |
| 667 |
{ |
| 668 |
do_csi("%d;%d;%d,}", flag, fg, bg); |
| 669 |
} |
| 670 |
|
| 671 |
void |
| 672 |
decawm(int flag) /* DECAWM autowrap */ |
| 673 |
{ |
| 674 |
if (flag) |
| 675 |
sm("?7"); /* autowrap */ |
| 676 |
else |
| 677 |
rm("?7"); /* no autowrap */ |
| 678 |
} |
| 679 |
|
| 680 |
void |
| 681 |
decbi(void) /* VT400: Back Index */ |
| 682 |
{ |
| 683 |
esc("6"); |
| 684 |
padding(40); |
| 685 |
} |
| 686 |
|
| 687 |
void |
| 688 |
decbkm(int flag) /* VT400: Backarrow key */ |
| 689 |
{ |
| 690 |
if (flag) |
| 691 |
sm("?67"); /* backspace */ |
| 692 |
else |
| 693 |
rm("?67"); /* delete */ |
| 694 |
} |
| 695 |
|
| 696 |
void |
| 697 |
decncsm(int flag) /* VT500: DECNCSM no clear on DECCOLM */ |
| 698 |
{ |
| 699 |
if (flag) |
| 700 |
sm("?95"); /* no clear */ |
| 701 |
else |
| 702 |
rm("?95"); /* clear */ |
| 703 |
} |
| 704 |
|
| 705 |
void |
| 706 |
deccara(int top, int left, int bottom, int right, int attr) |
| 707 |
{ |
| 708 |
do_csi("%d;%d;%d;%d;%d$r", top, left, bottom, right, attr); |
| 709 |
} |
| 710 |
|
| 711 |
void |
| 712 |
decckm(int flag) /* DECCKM Cursor Keys */ |
| 713 |
{ |
| 714 |
if (flag) |
| 715 |
sm("?1"); /* application */ |
| 716 |
else |
| 717 |
rm("?1"); /* normal */ |
| 718 |
} |
| 719 |
|
| 720 |
void |
| 721 |
deccolm(int flag) /* DECCOLM 80/132 Columns */ |
| 722 |
{ |
| 723 |
if (flag) |
| 724 |
sm("?3"); /* 132 columns */ |
| 725 |
else |
| 726 |
rm("?3"); /* 80 columns */ |
| 727 |
} |
| 728 |
|
| 729 |
void |
| 730 |
deccra(int Pts, int Pl, int Pbs, int Prs, int Pps, int Ptd, int Pld, int Ppd) |
| 731 |
{ |
| 732 |
do_csi("%d;%d;%d;%d;%d;%d;%d;%d;$v", |
| 733 |
Pts, /* top-line border */ |
| 734 |
Pl, /* left-line border */ |
| 735 |
Pbs, /* bottom-line border */ |
| 736 |
Prs, /* right-line border */ |
| 737 |
Pps, /* source page number */ |
| 738 |
Ptd, /* destination top-line border */ |
| 739 |
Pld, /* destination left-line border */ |
| 740 |
Ppd); /* destination page number */ |
| 741 |
} |
| 742 |
|
| 743 |
int |
| 744 |
decdc(int pn) /* VT400 Delete Column */ |
| 745 |
{ |
| 746 |
do_csi("%d'~", pn); |
| 747 |
padding(10 * pn); |
| 748 |
return 1; |
| 749 |
} |
| 750 |
|
| 751 |
void |
| 752 |
decefr(int top, int left, int bottom, int right) /* DECterm Enable filter rectangle */ |
| 753 |
{ |
| 754 |
do_csi("%d;%d;%d;%d'w", top, left, bottom, right); |
| 755 |
} |
| 756 |
|
| 757 |
void |
| 758 |
decelr(int all_or_one, int pixels_or_cells) /* DECterm Enable Locator Reporting */ |
| 759 |
{ |
| 760 |
do_csi("%d;%d'z", all_or_one, pixels_or_cells); |
| 761 |
} |
| 762 |
|
| 763 |
void |
| 764 |
decera(int top, int left, int bottom, int right) /* VT400 Erase Rectangular area */ |
| 765 |
{ |
| 766 |
do_csi("%d;%d;%d;%d$z", top, left, bottom, right); |
| 767 |
} |
| 768 |
|
| 769 |
void |
| 770 |
decdhl(int lower) /* Double Height Line (also double width) */ |
| 771 |
{ |
| 772 |
if (lower) |
| 773 |
esc("#4"); |
| 774 |
else |
| 775 |
esc("#3"); |
| 776 |
} |
| 777 |
|
| 778 |
void |
| 779 |
decdwl(void) /* Double Wide Line */ |
| 780 |
{ |
| 781 |
esc("#6"); |
| 782 |
} |
| 783 |
|
| 784 |
void |
| 785 |
decfi(void) /* VT400: Forward Index */ |
| 786 |
{ |
| 787 |
esc("9"); |
| 788 |
padding(40); |
| 789 |
} |
| 790 |
|
| 791 |
void |
| 792 |
decfra(int c, int top, int left, int bottom, int right) /* VT400 Fill Rectangular area */ |
| 793 |
{ |
| 794 |
do_csi("%d;%d;%d;%d;%d$x", c, top, left, bottom, right); |
| 795 |
} |
| 796 |
|
| 797 |
void |
| 798 |
decid(void) /* required for VT52, not recommended above VT100 */ |
| 799 |
{ |
| 800 |
esc("Z"); /* Identify */ |
| 801 |
} |
| 802 |
|
| 803 |
int |
| 804 |
decic(int pn) /* VT400 Insert Column */ |
| 805 |
{ |
| 806 |
do_csi("%d'}", pn); |
| 807 |
padding(10 * pn); |
| 808 |
return 1; |
| 809 |
} |
| 810 |
|
| 811 |
void |
| 812 |
deckbum(int flag) /* VT400: Keyboard Usage */ |
| 813 |
{ |
| 814 |
if (flag) |
| 815 |
sm("?68"); /* data processing */ |
| 816 |
else |
| 817 |
rm("?68"); /* typewriter */ |
| 818 |
} |
| 819 |
|
| 820 |
void |
| 821 |
deckpam(void) /* Keypad Application Mode */ |
| 822 |
{ |
| 823 |
esc("="); |
| 824 |
} |
| 825 |
|
| 826 |
void |
| 827 |
deckpm(int flag) /* VT400: Keyboard Position */ |
| 828 |
{ |
| 829 |
if (flag) |
| 830 |
sm("?81"); /* position reports */ |
| 831 |
else |
| 832 |
rm("?81"); /* character codes */ |
| 833 |
} |
| 834 |
|
| 835 |
void |
| 836 |
deckpnm(void) /* Keypad Numeric Mode */ |
| 837 |
{ |
| 838 |
esc(">"); |
| 839 |
} |
| 840 |
|
| 841 |
void |
| 842 |
decll(const char *ps) /* Load LEDs */ |
| 843 |
{ |
| 844 |
do_csi("%sq", ps); |
| 845 |
} |
| 846 |
|
| 847 |
void |
| 848 |
decnkm(int flag) /* VT400: Numeric Keypad */ |
| 849 |
{ |
| 850 |
if (flag) |
| 851 |
sm("?66"); /* application */ |
| 852 |
else |
| 853 |
rm("?66"); /* numeric */ |
| 854 |
} |
| 855 |
|
| 856 |
void |
| 857 |
decom(int flag) /* DECOM Origin */ |
| 858 |
{ |
| 859 |
if (flag) |
| 860 |
sm("?6"); /* relative */ |
| 861 |
else |
| 862 |
rm("?6"); /* absolute */ |
| 863 |
} |
| 864 |
|
| 865 |
void |
| 866 |
decpex(int flag) /* VT220: printer extent mode */ |
| 867 |
{ |
| 868 |
if (flag) |
| 869 |
sm("?19"); /* full screen (page) */ |
| 870 |
else |
| 871 |
rm("?19"); /* scrolling region */ |
| 872 |
} |
| 873 |
|
| 874 |
void |
| 875 |
decpff(int flag) /* VT220: print form feed mode */ |
| 876 |
{ |
| 877 |
if (flag) |
| 878 |
sm("?18"); /* form feed */ |
| 879 |
else |
| 880 |
rm("?18"); /* no form feed */ |
| 881 |
} |
| 882 |
|
| 883 |
void |
| 884 |
decnrcm(int flag) /* VT220: National replacement character set */ |
| 885 |
{ |
| 886 |
if (flag) |
| 887 |
sm("?42"); /* national */ |
| 888 |
else |
| 889 |
rm("?42"); /* multinational */ |
| 890 |
} |
| 891 |
|
| 892 |
void |
| 893 |
decrara(int top, int left, int bottom, int right, int attr) |
| 894 |
{ |
| 895 |
do_csi("%d;%d;%d;%d;%d$t", top, left, bottom, right, attr); |
| 896 |
} |
| 897 |
|
| 898 |
void |
| 899 |
decrc(void) /* Restore Cursor */ |
| 900 |
{ |
| 901 |
esc("8"); |
| 902 |
} |
| 903 |
|
| 904 |
void |
| 905 |
decreqtparm(int pn) /* Request Terminal Parameters */ |
| 906 |
{ |
| 907 |
brc(pn, 'x'); |
| 908 |
} |
| 909 |
|
| 910 |
void |
| 911 |
decrqlp(int mode) /* DECterm Request Locator Position */ |
| 912 |
{ |
| 913 |
do_csi("%d'|", mode); |
| 914 |
} |
| 915 |
|
| 916 |
void |
| 917 |
decrqpsr(int mode) /* Request presentation report */ |
| 918 |
{ |
| 919 |
do_csi("%d$w", mode); |
| 920 |
} |
| 921 |
|
| 922 |
void |
| 923 |
decrqss(const char *pn) /* VT200 Request Status-String */ |
| 924 |
{ |
| 925 |
do_dcs("$q%s", pn); |
| 926 |
} |
| 927 |
|
| 928 |
void |
| 929 |
decsace(int flag) /* VT400 Select attribute change extent */ |
| 930 |
{ |
| 931 |
do_csi("%d*x", flag ? 2 : 0); |
| 932 |
} |
| 933 |
|
| 934 |
void |
| 935 |
decsasd(int pn) /* VT200 Select active status display */ |
| 936 |
{ |
| 937 |
do_csi("%d$}", pn); |
| 938 |
} |
| 939 |
|
| 940 |
void |
| 941 |
decsc(void) /* Save Cursor */ |
| 942 |
{ |
| 943 |
esc("7"); |
| 944 |
} |
| 945 |
|
| 946 |
void |
| 947 |
decsca(int pn1) /* VT200 select character attribute (protect) */ |
| 948 |
{ |
| 949 |
do_csi("%d\"q", pn1); |
| 950 |
} |
| 951 |
|
| 952 |
void |
| 953 |
decsclm(int flag) /* Scrolling mode (smooth/jump) */ |
| 954 |
{ |
| 955 |
if (flag) |
| 956 |
sm("?4"); /* smooth scrolling */ |
| 957 |
else |
| 958 |
rm("?4"); /* jump-scrolling scrolling */ |
| 959 |
soft_scroll = flag; |
| 960 |
} |
| 961 |
|
| 962 |
void |
| 963 |
decscnm(int flag) /* Screen mode (inverse-video) */ |
| 964 |
{ |
| 965 |
if (flag) |
| 966 |
sm("?5"); /* inverse video */ |
| 967 |
else |
| 968 |
rm("?5"); /* normal video */ |
| 969 |
padding(200); |
| 970 |
} |
| 971 |
|
| 972 |
void |
| 973 |
decsed(int pn1) /* VT200 selective erase in display */ |
| 974 |
{ |
| 975 |
do_csi("?%dJ", pn1); |
| 976 |
} |
| 977 |
|
| 978 |
void |
| 979 |
decsel(int pn1) /* VT200 selective erase in line */ |
| 980 |
{ |
| 981 |
do_csi("?%dK", pn1); |
| 982 |
} |
| 983 |
|
| 984 |
void |
| 985 |
decsera(int top, int left, int bottom, int right) /* VT400 Selective erase rectangular area */ |
| 986 |
{ |
| 987 |
do_csi("%d;%d;%d;%d${", top, left, bottom, right); |
| 988 |
} |
| 989 |
|
| 990 |
void |
| 991 |
decstglt(int mode) /* DECSTGLT Select Color Look-Up Table */ |
| 992 |
{ |
| 993 |
do_csi("%d){", mode); |
| 994 |
} |
| 995 |
|
| 996 |
void |
| 997 |
decsle(int mode) /* DECterm Select Locator Events */ |
| 998 |
{ |
| 999 |
do_csi("%d'{", mode); |
| 1000 |
} |
| 1001 |
|
| 1002 |
void /* VT300 Set columns per page */ |
| 1003 |
decscpp(int cols) |
| 1004 |
{ |
| 1005 |
if (cols >= 0) { |
| 1006 |
do_csi("%d$|", cols); |
| 1007 |
} else { |
| 1008 |
do_csi("$|"); |
| 1009 |
} |
| 1010 |
} |
| 1011 |
|
| 1012 |
void /* VT300 Set lines per page */ |
| 1013 |
decslpp(int rows) |
| 1014 |
{ |
| 1015 |
/* |
| 1016 |
* DEC defines 24, 25, 36, 48, 72 and 144. |
| 1017 |
* XTerm uses codes up to 24 for window operations, |
| 1018 |
* and 24 and up for this feature. |
| 1019 |
*/ |
| 1020 |
do_csi("%dt", rows); |
| 1021 |
} |
| 1022 |
|
| 1023 |
void |
| 1024 |
decsnls(int pn) /* VT400 Select number of lines per screen */ |
| 1025 |
{ |
| 1026 |
do_csi("%d*|", pn); |
| 1027 |
} |
| 1028 |
|
| 1029 |
void |
| 1030 |
decssdt(int pn) /* VT200 Select status line type */ |
| 1031 |
{ |
| 1032 |
do_csi("%d$~", pn); |
| 1033 |
} |
| 1034 |
|
| 1035 |
void |
| 1036 |
decstbm(int pn1, int pn2) /* Set Top and Bottom Margins */ |
| 1037 |
{ |
| 1038 |
if (pn1 || pn2) { |
| 1039 |
brc2(pn1, pn2, 'r'); |
| 1040 |
pending_decstbm = 1; |
| 1041 |
} else { |
| 1042 |
esc("[r"); |
| 1043 |
pending_decstbm = 0; |
| 1044 |
} |
| 1045 |
} |
| 1046 |
|
| 1047 |
void |
| 1048 |
np(void) /* NP - next page */ |
| 1049 |
{ |
| 1050 |
do_csi("U"); |
| 1051 |
} |
| 1052 |
|
| 1053 |
void |
| 1054 |
pp(void) /* PP - previous page */ |
| 1055 |
{ |
| 1056 |
do_csi("V"); |
| 1057 |
} |
| 1058 |
|
| 1059 |
void |
| 1060 |
ppa(int n) /* PPA - Page Position Absolute */ |
| 1061 |
{ |
| 1062 |
do_csi("%d P", n); |
| 1063 |
} |
| 1064 |
|
| 1065 |
void |
| 1066 |
ppb(int n) /* PPB - Page Position Backward */ |
| 1067 |
{ |
| 1068 |
do_csi("%d R", n); |
| 1069 |
} |
| 1070 |
|
| 1071 |
void |
| 1072 |
ppr(int n) /* PPR - Page Position Relative */ |
| 1073 |
{ |
| 1074 |
do_csi("%d Q", n); |
| 1075 |
} |
| 1076 |
|
| 1077 |
/* |
| 1078 |
* Reset top/bottom margins, but only if we set them to non-default. |
| 1079 |
*/ |
| 1080 |
void |
| 1081 |
reset_decstbm(void) |
| 1082 |
{ |
| 1083 |
if (pending_decstbm) { |
| 1084 |
decstbm(0, 0); |
| 1085 |
} |
| 1086 |
} |
| 1087 |
|
| 1088 |
void |
| 1089 |
decslrm(int pn1, int pn2) /* Set Left and Right Margins */ |
| 1090 |
{ |
| 1091 |
if (pn1 || pn2) { |
| 1092 |
brc2(pn1, pn2, 's'); |
| 1093 |
pending_decslrm = 1; |
| 1094 |
} else { |
| 1095 |
esc("[s"); |
| 1096 |
pending_decslrm = 0; |
| 1097 |
} |
| 1098 |
} |
| 1099 |
|
| 1100 |
/* |
| 1101 |
* Reset left/right margins, but only if we set them to non-default. |
| 1102 |
*/ |
| 1103 |
void |
| 1104 |
reset_decslrm(void) |
| 1105 |
{ |
| 1106 |
if (pending_decslrm) { |
| 1107 |
decslrm(0, 0); |
| 1108 |
} |
| 1109 |
} |
| 1110 |
|
| 1111 |
void |
| 1112 |
decstr(void) /* VT200 Soft terminal reset */ |
| 1113 |
{ |
| 1114 |
do_csi("!p"); |
| 1115 |
} |
| 1116 |
|
| 1117 |
void |
| 1118 |
decswl(void) /* Single Width Line */ |
| 1119 |
{ |
| 1120 |
esc("#5"); |
| 1121 |
} |
| 1122 |
|
| 1123 |
void |
| 1124 |
dectst(int pn) /* Invoke Confidence Test */ |
| 1125 |
{ |
| 1126 |
brc2(2, pn, 'y'); |
| 1127 |
#ifdef UNIX |
| 1128 |
fflush(stdout); |
| 1129 |
#endif |
| 1130 |
} |
| 1131 |
|
| 1132 |
void |
| 1133 |
dsr(int pn) /* Device Status Report */ |
| 1134 |
{ |
| 1135 |
brc(pn, 'n'); |
| 1136 |
} |
| 1137 |
|
| 1138 |
void |
| 1139 |
ed(int pn) /* Erase in Display */ |
| 1140 |
{ |
| 1141 |
brc(pn, 'J'); |
| 1142 |
padding(50); |
| 1143 |
} |
| 1144 |
|
| 1145 |
void |
| 1146 |
el(int pn) /* Erase in Line */ |
| 1147 |
{ |
| 1148 |
brc(pn, 'K'); |
| 1149 |
padding(3); /* 4 for vt400 */ |
| 1150 |
} |
| 1151 |
|
| 1152 |
void |
| 1153 |
ech(int pn) /* Erase character(s) */ |
| 1154 |
{ |
| 1155 |
brc(pn, 'X'); |
| 1156 |
} |
| 1157 |
|
| 1158 |
void |
| 1159 |
hpa(int pn) /* HPA - Horizontal Position Absolute */ |
| 1160 |
{ |
| 1161 |
brc(pn, '`'); |
| 1162 |
} |
| 1163 |
|
| 1164 |
void |
| 1165 |
hpr(int pn) /* HPR - Horizontal Position Relative */ |
| 1166 |
{ |
| 1167 |
brc(pn, 'a'); |
| 1168 |
} |
| 1169 |
|
| 1170 |
void |
| 1171 |
hts(void) /* Horizontal Tabulation Set */ |
| 1172 |
{ |
| 1173 |
esc("H"); |
| 1174 |
} |
| 1175 |
|
| 1176 |
void |
| 1177 |
hvp(int pn1, int pn2) /* Horizontal and Vertical Position */ |
| 1178 |
{ |
| 1179 |
brc2(pn1, pn2, 'f'); |
| 1180 |
} |
| 1181 |
|
| 1182 |
void |
| 1183 |
ind(void) /* Index */ |
| 1184 |
{ |
| 1185 |
esc("D"); |
| 1186 |
padding(20); /* vt220 */ |
| 1187 |
} |
| 1188 |
|
| 1189 |
/* The functions beginning "mc_" are variations of Media Copy (MC) */ |
| 1190 |
|
| 1191 |
void |
| 1192 |
mc_autoprint(int flag) /* VT220: auto print mode */ |
| 1193 |
{ |
| 1194 |
do_csi("?%di", flag ? 5 : 4); |
| 1195 |
} |
| 1196 |
|
| 1197 |
void |
| 1198 |
mc_printer_controller(int flag) /* VT220: printer controller mode */ |
| 1199 |
{ |
| 1200 |
do_csi("%di", flag ? 5 : 4); |
| 1201 |
} |
| 1202 |
|
| 1203 |
void |
| 1204 |
mc_print_page(void) /* VT220: print page */ |
| 1205 |
{ |
| 1206 |
do_csi("i"); |
| 1207 |
} |
| 1208 |
|
| 1209 |
void |
| 1210 |
mc_print_composed(void) /* VT300: print composed main display */ |
| 1211 |
{ |
| 1212 |
do_csi("?10i"); |
| 1213 |
} |
| 1214 |
|
| 1215 |
void |
| 1216 |
mc_print_all_pages(void) /* VT300: print composed all pages */ |
| 1217 |
{ |
| 1218 |
do_csi("?11i"); |
| 1219 |
} |
| 1220 |
|
| 1221 |
void |
| 1222 |
mc_print_cursor_line(void) /* VT220: print cursor line */ |
| 1223 |
{ |
| 1224 |
do_csi("?1i"); |
| 1225 |
} |
| 1226 |
|
| 1227 |
void |
| 1228 |
mc_printer_start(int flag) /* VT300: start/stop printer-to-host session */ |
| 1229 |
{ |
| 1230 |
do_csi("?%di", flag ? 9 : 8); |
| 1231 |
} |
| 1232 |
|
| 1233 |
void |
| 1234 |
mc_printer_assign(int flag) /* VT300: assign/release printer to active session */ |
| 1235 |
{ |
| 1236 |
do_csi("?%di", flag ? 18 : 19); |
| 1237 |
} |
| 1238 |
|
| 1239 |
void |
| 1240 |
nel(void) /* Next Line */ |
| 1241 |
{ |
| 1242 |
esc("E"); |
| 1243 |
} |
| 1244 |
|
| 1245 |
void |
| 1246 |
rep(int pn) /* Repeat */ |
| 1247 |
{ |
| 1248 |
if (pn < 0) |
| 1249 |
do_csi("b"); |
| 1250 |
else |
| 1251 |
do_csi("%db", pn); |
| 1252 |
} |
| 1253 |
|
| 1254 |
void |
| 1255 |
ri(void) /* Reverse Index */ |
| 1256 |
{ |
| 1257 |
esc("M"); |
| 1258 |
extra_padding(5); /* 14 on vt220 */ |
| 1259 |
} |
| 1260 |
|
| 1261 |
void |
| 1262 |
ris(void) /* Reset to Initial State */ |
| 1263 |
{ |
| 1264 |
esc("c"); |
| 1265 |
#ifdef UNIX |
| 1266 |
fflush(stdout); |
| 1267 |
#endif |
| 1268 |
} |
| 1269 |
|
| 1270 |
void |
| 1271 |
rm(const char *ps) /* Reset Mode */ |
| 1272 |
{ |
| 1273 |
do_csi("%sl", ps); |
| 1274 |
} |
| 1275 |
|
| 1276 |
void |
| 1277 |
s8c1t(int flag) /* Tell terminal to respond with 7-bit or 8-bit controls */ |
| 1278 |
{ |
| 1279 |
if ((input_8bits = flag) != FALSE) |
| 1280 |
esc(" G"); /* select 8-bit controls */ |
| 1281 |
else |
| 1282 |
esc(" F"); /* select 7-bit controls */ |
| 1283 |
fflush(stdout); |
| 1284 |
zleep(300); |
| 1285 |
} |
| 1286 |
|
| 1287 |
/* |
| 1288 |
* If g is zero, |
| 1289 |
* designate G0 as character set c |
| 1290 |
* designate G1 as character set B (ASCII) |
| 1291 |
* shift-in (select G0 into GL). |
| 1292 |
* If g is nonzero |
| 1293 |
* designate G0 as character set B (ASCII) |
| 1294 |
* designate G1 as character set c |
| 1295 |
* shift-out (select G1 into GL). |
| 1296 |
* See also scs_normal() and scs_graphics(). |
| 1297 |
*/ |
| 1298 |
void |
| 1299 |
scs(int g, int c) /* Select character Set */ |
| 1300 |
{ |
| 1301 |
char temp[10]; |
| 1302 |
|
| 1303 |
sprintf(temp, "%c%c", g ? ')' : '(', c); |
| 1304 |
esc(temp); |
| 1305 |
|
| 1306 |
sprintf(temp, "%c%c", g ? '(' : ')', 'B'); |
| 1307 |
esc(temp); |
| 1308 |
|
| 1309 |
print_chr(g ? SO : SI); |
| 1310 |
padding(4); |
| 1311 |
} |
| 1312 |
|
| 1313 |
void |
| 1314 |
sd(int pn) /* Scroll Down */ |
| 1315 |
{ |
| 1316 |
brc(pn, 'T'); |
| 1317 |
} |
| 1318 |
|
| 1319 |
void |
| 1320 |
sgr(const char *ps) /* Select Graphic Rendition */ |
| 1321 |
{ |
| 1322 |
do_csi("%sm", ps); |
| 1323 |
padding(2); |
| 1324 |
} |
| 1325 |
|
| 1326 |
void |
| 1327 |
sl(int pn) /* Scroll Left */ |
| 1328 |
{ |
| 1329 |
if (pn < 0) |
| 1330 |
do_csi(" @"); |
| 1331 |
else |
| 1332 |
do_csi("%d @", pn); |
| 1333 |
} |
| 1334 |
|
| 1335 |
void |
| 1336 |
sm(const char *ps) /* Set Mode */ |
| 1337 |
{ |
| 1338 |
do_csi("%sh", ps); |
| 1339 |
} |
| 1340 |
|
| 1341 |
void |
| 1342 |
sr(int pn) /* Scroll Right */ |
| 1343 |
{ |
| 1344 |
if (pn < 0) |
| 1345 |
do_csi(" A"); |
| 1346 |
else |
| 1347 |
do_csi("%d A", pn); |
| 1348 |
} |
| 1349 |
|
| 1350 |
void |
| 1351 |
srm(int flag) /* VT400: Send/Receive mode */ |
| 1352 |
{ |
| 1353 |
if (flag) |
| 1354 |
sm("12"); /* local echo off */ |
| 1355 |
else |
| 1356 |
rm("12"); /* local echo on */ |
| 1357 |
} |
| 1358 |
|
| 1359 |
void |
| 1360 |
su(int pn) /* Scroll Up */ |
| 1361 |
{ |
| 1362 |
brc(pn, 'S'); |
| 1363 |
extra_padding(5); |
| 1364 |
} |
| 1365 |
|
| 1366 |
void |
| 1367 |
tbc(int pn) /* Tabulation Clear */ |
| 1368 |
{ |
| 1369 |
brc(pn, 'g'); |
| 1370 |
} |
| 1371 |
|
| 1372 |
void |
| 1373 |
dch(int pn) /* Delete character */ |
| 1374 |
{ |
| 1375 |
brc(pn, 'P'); |
| 1376 |
} |
| 1377 |
|
| 1378 |
void |
| 1379 |
ich(int pn) /* Insert character -- not in VT102 */ |
| 1380 |
{ |
| 1381 |
brc(pn, '@'); |
| 1382 |
} |
| 1383 |
|
| 1384 |
void |
| 1385 |
dl(int pn) /* Delete line */ |
| 1386 |
{ |
| 1387 |
brc(pn, 'M'); |
| 1388 |
} |
| 1389 |
|
| 1390 |
void |
| 1391 |
il(int pn) /* Insert line */ |
| 1392 |
{ |
| 1393 |
brc(pn, 'L'); |
| 1394 |
} |
| 1395 |
|
| 1396 |
void |
| 1397 |
vpa(int pn) /* Vertical Position Absolute */ |
| 1398 |
{ |
| 1399 |
brc(pn, 'd'); |
| 1400 |
} |
| 1401 |
|
| 1402 |
void |
| 1403 |
vpr(int pn) /* Vertical Position Relative */ |
| 1404 |
{ |
| 1405 |
brc(pn, 'e'); |
| 1406 |
} |
| 1407 |
|
| 1408 |
void |
| 1409 |
vt52cub1(void) /* cursor left */ |
| 1410 |
{ |
| 1411 |
esc("D"); |
| 1412 |
padding(5); |
| 1413 |
} |
| 1414 |
|
| 1415 |
void |
| 1416 |
vt52cud1(void) /* cursor down */ |
| 1417 |
{ |
| 1418 |
esc("B"); |
| 1419 |
padding(5); |
| 1420 |
} |
| 1421 |
|
| 1422 |
void |
| 1423 |
vt52cuf1(void) /* cursor right */ |
| 1424 |
{ |
| 1425 |
esc("C"); |
| 1426 |
padding(5); |
| 1427 |
} |
| 1428 |
|
| 1429 |
void |
| 1430 |
vt52cup(int l, int c) /* direct cursor address */ |
| 1431 |
{ |
| 1432 |
char temp[10]; |
| 1433 |
sprintf(temp, "Y%c%c", l + 31, c + 31); |
| 1434 |
esc(temp); |
| 1435 |
padding(5); |
| 1436 |
} |
| 1437 |
|
| 1438 |
void |
| 1439 |
vt52cuu1(void) /* cursor up */ |
| 1440 |
{ |
| 1441 |
esc("A"); |
| 1442 |
padding(5); |
| 1443 |
} |
| 1444 |
|
| 1445 |
void |
| 1446 |
vt52ed(void) /* erase to end of screen */ |
| 1447 |
{ |
| 1448 |
esc("J"); |
| 1449 |
padding(5); |
| 1450 |
} |
| 1451 |
|
| 1452 |
void |
| 1453 |
vt52el(void) /* erase to end of line */ |
| 1454 |
{ |
| 1455 |
esc("K"); |
| 1456 |
padding(5); |
| 1457 |
} |
| 1458 |
|
| 1459 |
void |
| 1460 |
vt52home(void) /* cursor to home */ |
| 1461 |
{ |
| 1462 |
esc("H"); |
| 1463 |
padding(5); |
| 1464 |
} |
| 1465 |
|
| 1466 |
void |
| 1467 |
vt52ri(void) /* reverse line feed */ |
| 1468 |
{ |
| 1469 |
esc("I"); |
| 1470 |
padding(5); |
| 1471 |
} |