+ p->in_scs=0;
+}
+
+
+void
+vt102_send (VT102 * v, uint8_t key)
+{
+ uint8_t c;
+#if 0
+ fprintf (stderr, "vts: %d(%c)\n", key, (key > 31) ? key : ' ');
+#endif
+ if ((key > 31) && (key < 127))
+ {
+ tty_write (v->tty, &key, 1);
+ return;
+ }
+
+ switch (key)
+ {
+ /*NUL*/ case 0:
+ /*SOH*/ case 1:
+ /*STX*/ case 2:
+ /*ETX*/ case 3:
+ /*EOT*/ case 4:
+ /*ENQ*/ case 5:
+ /*ACK*/ case 6:
+ /*BEL*/ case 7:
+ /*BS*/ case 8:
+ /*HT*/ case 9:
+ /*LF*/ case 10:
+ /*VT*/ case 11:
+ /*FF*/ case 12:
+ tty_write (v->tty, &key, 1);
+ break;
+ /*CR*/ case 13:
+ tty_write (v->tty, &key, 1);
+ if (v->modes[VT102_MODE_NEWLINE_MODE])
+ {
+ c = 10;
+ tty_write (v->tty, &c, 1);
+ }
+ break;
+ /*SO*/ case 14:
+ /*SI*/ case 15:
+ /*DLE*/ case 16:
+ /*DC1 */ case 17:
+ /*DC2 */ case 18:
+ /*DC3 */ case 19:
+ /*DC4 */ case 20:
+ /*NAK*/ case 21:
+ /*SYN*/ case 22:
+ /*ETB*/ case 23:
+ /*CAN*/ case 24:
+ /*EM*/ case 25:
+ /*SUB*/ case 26:
+ tty_write (v->tty, &key, 1);
+ break;
+ /*ESC*/ case 27:
+ /*FS*/ case 28:
+ /*GS*/ case 29:
+ /*RS*/ case 30:
+ /*US*/ case 31:
+ /*DEL*/ case 127:
+ tty_write (v->tty, &key, 1);
+ break;
+
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_RIGHT:
+ case KEY_LEFT:
+ case KEY_HOME:
+ case KEY_MIDDLE:
+ case KEY_END:
+
+ if (v->private_modes[VT102_PRIVATE_MODE_CURSOR_MODE])
+ {
+ uint8_t buf[] = { 033, 'O', 'A' + (key - KEY_UP) };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ else
+ {
+ uint8_t buf[] = { 033, '[', 'A' + (key - KEY_UP) };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ break;
+ case KEY_STAR:
+ case KEY_PLUS:
+ case KEY_COMMA:
+ case KEY_PERIOD:
+ case KEY_DIVIDE:
+ case KEY_0:
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (v->application_keypad_mode)
+ {
+ uint8_t buf[] = { 033, 'O', 'a' + (key - KEY_154) };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ else
+ {
+ static char kpoff[KEY_NUM] = {
+ [KEY_STAR] = '*',
+ [KEY_PLUS] = '+',
+ [KEY_COMMA] = ',',
+ [KEY_MINUS] = '-',
+ [KEY_PERIOD] = '.',
+ [KEY_DIVIDE] = '/',
+ [KEY_0] = '0',
+ [KEY_1] = '1',
+ [KEY_2] = '2',
+ [KEY_3] = '3',
+ [KEY_4] = '4',
+ [KEY_5] = '5',
+ [KEY_6] = '6',
+ [KEY_7] = '7',
+ [KEY_8] = '8',
+ [KEY_9] = '9'
+ };
+
+ tty_write (v->tty, &kpoff[key], 1);
+ }
+ break;
+ case KEY_ENTER:
+ if (v->application_keypad_mode)
+ {
+ uint8_t buf[] = { 033, 'O', 'M' };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ else
+ {
+ c = 13;
+ tty_write (v->tty, &c, 1);
+ if (v->modes[VT102_MODE_NEWLINE_MODE])
+ {
+ c = 10;
+ tty_write (v->tty, &c, 1);
+ }
+ }
+ break;
+ case KEY_PF1:
+ case KEY_PF2:
+ case KEY_PF3:
+ case KEY_PF4:
+ {
+ uint8_t buf[] = { 033, 'O', 'P' + (key - KEY_PF1) };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ break;
+ case KEY_INSERT:
+ case KEY_DELETE:
+ case KEY_PGUP:
+ case KEY_PGDN:
+ {
+ uint8_t buf[] = { 033, '[', '0' + (key - KEY_180), '~' };
+ tty_write (v->tty, &buf, sizeof (buf));
+ }
+ break;
+ }
+