1 /*
2 * Copyright (c) 1999, 2000 Hellmuth Michaelis
3 *
4 * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
5 *
6 * Copyright (c) 1992, 1993 Brian Dunford-Shore and Holger Veit.
7 *
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * William Jolitz and Don Ahn.
12 *
13 * This code is derived from software contributed to 386BSD by
14 * Holger Veit.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Hellmuth Michaelis,
27 * Brian Dunford-Shore and Joerg Wunsch.
28 * 4. The name authors may not be used to endorse or promote products
29 * derived from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
32 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42
43 /*---------------------------------------------------------------------------*
44 *
45 * pcvt_kbd.c VT220 Driver Keyboard Interface Code
46 * ----------------------------------------------------
47 *
48 * Last Edit-Date: [Wed Apr 5 18:16:52 2000]
49 *
50 * $FreeBSD: releng/5.0/sys/i386/isa/pcvt/pcvt_kbd.c 65691 2000-09-10 14:31:40Z markm $
51 *
52 *---------------------------------------------------------------------------*/
53
54 #include "opt_ddb.h"
55
56 #include <i386/isa/pcvt/pcvt_hdr.h> /* global include */
57
58 #define LEDSTATE_UPDATE_PENDING (1 << 3)
59
60 static void fkey1(void), fkey2(void), fkey3(void), fkey4(void);
61 static void fkey5(void), fkey6(void), fkey7(void), fkey8(void);
62 static void fkey9(void), fkey10(void), fkey11(void), fkey12(void);
63
64 static void sfkey1(void), sfkey2(void), sfkey3(void), sfkey4(void);
65 static void sfkey5(void), sfkey6(void), sfkey7(void), sfkey8(void);
66 static void sfkey9(void), sfkey10(void), sfkey11(void), sfkey12(void);
67
68 static void cfkey1(void), cfkey2(void), cfkey3(void), cfkey4(void);
69 static void cfkey5(void), cfkey6(void), cfkey7(void), cfkey8(void);
70 static void cfkey9(void), cfkey10(void), cfkey11(void), cfkey12(void);
71
72 #include <i386/isa/pcvt/pcvt_kbd.h> /* tables etc */
73
74 static void doreset ( void );
75 static void ovlinit ( int force );
76 static void settpmrate ( int rate );
77 static void setlockkeys ( int snc );
78 static int getokeydef ( unsigned key, struct kbd_ovlkey *thisdef );
79 static int getckeydef ( unsigned key, struct kbd_ovlkey *thisdef );
80 static int rmkeydef ( int key );
81 static void scrollback_save_screen ( void );
82 static void scrollback_restore_screen ( void );
83 static int setkeydef ( struct kbd_ovlkey *data );
84 static u_char *xlatkey2ascii( int key );
85
86 static int ledstate = LEDSTATE_UPDATE_PENDING; /* keyboard led's */
87 static int tpmrate = KBD_TPD500|KBD_TPM100;
88 static u_char altkpflag = 0;
89 static u_short altkpval = 0;
90 static u_short *scrollback_savedscreen = (u_short *)0;
91 static size_t scrnsv_size = (size_t)-1;
92 static int lost_intr_timeout_queued = 0;
93 static struct callout_handle lost_intr_ch =
94 CALLOUT_HANDLE_INITIALIZER(&lost_intr_ch);
95
96 #if PCVT_SHOWKEYS
97 u_char rawkeybuf[80];
98 #endif
99
100 #if PCVT_USEKBDSEC /* security enabled */
101
102 # if PCVT_SCANSET == 2
103 # define KBDINITCMD 0
104 # else /* PCVT_SCANSET != 2 */
105 # define KBDINITCMD KBD_TRANSLATION
106 # endif /* PCVT_SCANSET == 2 */
107
108 #else /* ! PCVT_USEKBDSEC */ /* security disabled */
109
110 # if PCVT_SCANSET == 2
111 # define KBDINITCMD KBD_OVERRIDE_KBD_LOCK
112 # else /* PCVT_SCANSET != 2 */
113 # define KBDINITCMD KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK
114 # endif /* PCVT_SCANSET == 2 */
115
116 #endif /* PCVT_USEKBDSEC */
117
118 #if PCVT_SHOWKEYS
119 /*---------------------------------------------------------------------------*
120 * keyboard debugging: put kbd communication char into some buffer
121 *---------------------------------------------------------------------------*/
122 static void showkey (char delim, u_char val)
123 {
124 int rki;
125
126 for(rki = 3; rki < 80; rki++) /* shift left buffer */
127 rawkeybuf[rki-3] = rawkeybuf[rki];
128
129 rawkeybuf[77] = delim; /* delimiter */
130
131 rki = (val & 0xf0) >> 4; /* ms nibble */
132
133 if(rki <= 9)
134 rki = rki + '';
135 else
136 rki = rki - 10 + 'A';
137
138 rawkeybuf[78] = rki;
139
140 rki = val & 0x0f; /* ls nibble */
141
142 if(rki <= 9)
143 rki = rki + '';
144 else
145 rki = rki - 10 + 'A';
146
147 rawkeybuf[79] = rki;
148 }
149 #endif /* PCVT_SHOWKEYS */
150
151 /*---------------------------------------------------------------------------*
152 * function to switch to another virtual screen
153 *---------------------------------------------------------------------------*/
154 static void
155 do_vgapage(int page)
156 {
157 if(critical_scroll) /* executing critical region ? */
158 switch_page = page; /* yes, auto switch later */
159 else
160 vgapage(page); /* no, switch now */
161 }
162
163 /*---------------------------------------------------------------------------*
164 * check for lost keyboard interrupts
165 *---------------------------------------------------------------------------*/
166 static void
167 check_for_lost_intr(void *arg)
168 {
169 int opri;
170
171 lost_intr_timeout_queued = 0;
172
173 if (kbd && (*kbdsw[kbd->kb_index]->lock)(kbd, TRUE))
174 {
175 opri = spltty ();
176 (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
177 if ((*kbdsw[kbd->kb_index]->check)(kbd))
178 pcvt_rint(0);
179 splx (opri);
180 }
181
182 lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz);
183 lost_intr_timeout_queued = 1;
184 }
185
186 /*---------------------------------------------------------------------------*
187 * update keyboard led's
188 *---------------------------------------------------------------------------*/
189 void
190 update_led(void)
191 {
192 #if !PCVT_NO_LED_UPDATE
193
194 /* Don't update LED's unless necessary. */
195
196 int opri, new_ledstate;
197
198 opri = spltty();
199
200 new_ledstate = ((vsp->scroll_lock) ? LED_SCR : 0) |
201 ((vsp->num_lock) ? LED_NUM : 0) |
202 ((vsp->caps_lock) ? LED_CAP : 0);
203
204 if (new_ledstate != ledstate)
205 {
206 if (kbd == NULL)
207 {
208 ledstate = new_ledstate;
209 splx(opri);
210 }
211 else
212 {
213 ledstate = LEDSTATE_UPDATE_PENDING;
214 splx(opri);
215 if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED,
216 (caddr_t)&new_ledstate) == 0)
217 ledstate = new_ledstate;
218 }
219 }
220 #endif /* !PCVT_NO_LED_UPDATE */
221 }
222
223 /*---------------------------------------------------------------------------*
224 * set typematic rate
225 *---------------------------------------------------------------------------*/
226 static void
227 settpmrate(int rate)
228 {
229 if (kbd == NULL)
230 return;
231 tpmrate = rate & 0x7f;
232 if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETRAD, (caddr_t)&tpmrate))
233 printf("pcvt: failed to set keyboard TYPEMATIC.\n");
234 }
235
236 #if PCVT_SCANSET > 1
237 /*---------------------------------------------------------------------------*
238 * switch PC scan code emulation mode
239 *---------------------------------------------------------------------------*/
240 void
241 kbd_emulate_pc(int do_emulation)
242 {
243 set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION,
244 (do_emulation) ? KBD_TRANSLATION : 0);
245 }
246 #endif /* PCVT_SCANSET > 1 */
247
248 /*---------------------------------------------------------------------------*
249 * try to force keyboard into a known state ..
250 *---------------------------------------------------------------------------*/
251 static
252 void doreset(void)
253 {
254 int type;
255
256 if (!reset_keyboard) /* no, we are not ready to reset */
257 return;
258
259 if (lost_intr_timeout_queued)
260 {
261 untimeout(check_for_lost_intr, (void *)NULL, lost_intr_ch);
262 lost_intr_timeout_queued = 0;
263 }
264
265 if (kbd == NULL)
266 return; /* shouldn't happen */
267
268 kbd_configure(0);
269
270 ledstate = LEDSTATE_UPDATE_PENDING;
271
272 set_controller_command_byte(*(KBDC *)kbd->kb_data,
273 KBD_OVERRIDE_KBD_LOCK | KBD_TRANSLATION, KBDINITCMD);
274
275 type = KB_101;
276
277 (*kbdsw[kbd->kb_index]->ioctl)(kbd, KDGKBTYPE, (caddr_t)&type);
278
279 switch (type)
280 {
281 case KB_84:
282 keyboard_type = KB_AT;
283 break;
284 case KB_101:
285 keyboard_type = KB_MFII;
286 break;
287 default:
288 keyboard_type = KB_UNKNOWN;
289 break;
290 }
291
292 update_led();
293
294 lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz);
295 lost_intr_timeout_queued = 1;
296 }
297
298 /*---------------------------------------------------------------------------*
299 * init keyboard code
300 *---------------------------------------------------------------------------*/
301 void
302 kbd_code_init(void)
303 {
304 doreset();
305 ovlinit(0);
306 keyboard_is_initialized = 1;
307 }
308
309 /*---------------------------------------------------------------------------*
310 * init keyboard code, this initializes the keyboard subsystem
311 * just "a bit" so the very very first ddb session is able to
312 * get proper keystrokes - in other words, it's a hack ....
313 *---------------------------------------------------------------------------*/
314 void
315 kbd_code_init1(void)
316 {
317 doreset();
318 keyboard_is_initialized = 1;
319 }
320
321 /*---------------------------------------------------------------------------*
322 * init keyboard overlay table
323 *---------------------------------------------------------------------------*/
324 static
325 void ovlinit(int force)
326 {
327 register int i;
328
329 if(force || ovlinitflag==0)
330 {
331 if(ovlinitflag == 0 &&
332 (ovltbl = (Ovl_tbl *)malloc(sizeof(Ovl_tbl) * OVLTBL_SIZE,
333 M_DEVBUF, M_WAITOK)) == NULL)
334 panic("pcvt_kbd: malloc of Ovl_tbl failed");
335
336 for(i=0; i<OVLTBL_SIZE; i++)
337 {
338 ovltbl[i].keynum =
339 ovltbl[i].type = 0;
340 ovltbl[i].unshift[0] =
341 ovltbl[i].shift[0] =
342 ovltbl[i].ctrl[0] =
343 ovltbl[i].altgr[0] = 0;
344 ovltbl[i].subu =
345 ovltbl[i].subs =
346 ovltbl[i].subc =
347 ovltbl[i].suba = KBD_SUBT_STR; /* just strings .. */
348 }
349 for(i=0; i<=MAXKEYNUM; i++)
350 key2ascii[i].type &= KBD_MASK;
351 ovlinitflag = 1;
352 }
353 }
354
355 /*---------------------------------------------------------------------------*
356 * get original key definition
357 *---------------------------------------------------------------------------*/
358 static int
359 getokeydef(unsigned key, Ovl_tbl *thisdef)
360 {
361 if(key == 0 || key > MAXKEYNUM)
362 return EINVAL;
363
364 thisdef->keynum = key;
365 thisdef->type = key2ascii[key].type;
366
367 if(key2ascii[key].unshift.subtype == STR)
368 {
369 bcopy((u_char *)(key2ascii[key].unshift.what.string),
370 thisdef->unshift, CODE_SIZE);
371 thisdef->subu = KBD_SUBT_STR;
372 }
373 else
374 {
375 bcopy("", thisdef->unshift, CODE_SIZE);
376 thisdef->subu = KBD_SUBT_FNC;
377 }
378
379 if(key2ascii[key].shift.subtype == STR)
380 {
381 bcopy((u_char *)(key2ascii[key].shift.what.string),
382 thisdef->shift, CODE_SIZE);
383 thisdef->subs = KBD_SUBT_STR;
384 }
385 else
386 {
387 bcopy("",thisdef->shift,CODE_SIZE);
388 thisdef->subs = KBD_SUBT_FNC;
389 }
390
391 if(key2ascii[key].ctrl.subtype == STR)
392 {
393 bcopy((u_char *)(key2ascii[key].ctrl.what.string),
394 thisdef->ctrl, CODE_SIZE);
395 thisdef->subc = KBD_SUBT_STR;
396 }
397 else
398 {
399 bcopy("",thisdef->ctrl,CODE_SIZE);
400 thisdef->subc = KBD_SUBT_FNC;
401 }
402
403 /* deliver at least anything for ALTGR settings ... */
404
405 if(key2ascii[key].unshift.subtype == STR)
406 {
407 bcopy((u_char *)(key2ascii[key].unshift.what.string),
408 thisdef->altgr, CODE_SIZE);
409 thisdef->suba = KBD_SUBT_STR;
410 }
411 else
412 {
413 bcopy("",thisdef->altgr, CODE_SIZE);
414 thisdef->suba = KBD_SUBT_FNC;
415 }
416 return 0;
417 }
418
419 /*---------------------------------------------------------------------------*
420 * get current key definition
421 *---------------------------------------------------------------------------*/
422 static int
423 getckeydef(unsigned key, Ovl_tbl *thisdef)
424 {
425 u_short type = key2ascii[key].type;
426
427 if(key>MAXKEYNUM)
428 return EINVAL;
429
430 if(type & KBD_OVERLOAD)
431 *thisdef = ovltbl[key2ascii[key].ovlindex];
432 else
433 getokeydef(key,thisdef);
434
435 return 0;
436 }
437
438 /*---------------------------------------------------------------------------*
439 * translate keynumber and returns ptr to associated ascii string
440 * if key is bound to a function, executes it, and ret empty ptr
441 *---------------------------------------------------------------------------*/
442 static u_char *
443 xlatkey2ascii(int key)
444 {
445 static u_char capchar[2] = {0, 0};
446 #if PCVT_META_ESC
447 static u_char metachar[3] = {0x1b, 0, 0};
448 #else
449 static u_char metachar[2] = {0, 0};
450 #endif
451 static Ovl_tbl thisdef;
452 int n;
453 void (*fnc)(void);
454
455 if(key==0) /* ignore the NON-KEY */
456 return 0;
457
458 getckeydef(key&0x7F, &thisdef); /* get the current ASCII value */
459
460 thisdef.type &= KBD_MASK;
461
462 if(key&0x80) /* special handling of ALT-KEYPAD */
463 {
464 /* is the ALT Key released? */
465 if(thisdef.type==KBD_META || thisdef.type==KBD_ALTGR)
466 {
467 if(altkpflag) /* have we been in altkp mode? */
468 {
469 capchar[0] = altkpval;
470 altkpflag = 0;
471 altkpval = 0;
472 return capchar;
473 }
474 }
475 return 0;
476 }
477
478 switch(thisdef.type) /* convert the keys */
479 {
480 case KBD_BREAK:
481 case KBD_ASCII:
482 case KBD_FUNC:
483 fnc = NULL;
484 more_chars = NULL;
485
486 if(altgr_down)
487 {
488 more_chars = (u_char *)thisdef.altgr;
489 }
490 else if(!ctrl_down && (shift_down || vsp->shift_lock))
491 {
492 if(key2ascii[key].shift.subtype == STR)
493 more_chars = (u_char *)thisdef.shift;
494 else
495 fnc = key2ascii[key].shift.what.func;
496 }
497
498 else if(ctrl_down)
499 {
500 if(key2ascii[key].ctrl.subtype == STR)
501 more_chars = (u_char *)thisdef.ctrl;
502 else
503 fnc = key2ascii[key].ctrl.what.func;
504 }
505
506 else
507 {
508 if(key2ascii[key].unshift.subtype == STR)
509 more_chars = (u_char *)thisdef.unshift;
510 else
511 fnc = key2ascii[key].unshift.what.func;
512 }
513
514 if(fnc)
515 (*fnc)(); /* execute function */
516
517 if((more_chars != NULL) && (more_chars[1] == 0))
518 {
519 if(vsp->caps_lock && more_chars[0] >= 'a'
520 && more_chars[0] <= 'z')
521 {
522 capchar[0] = *more_chars - ('a'-'A');
523 more_chars = capchar;
524 }
525 if(meta_down)
526 {
527 #if PCVT_META_ESC
528 metachar[1] = *more_chars;
529 #else
530 metachar[0] = *more_chars | 0x80;
531 #endif
532 more_chars = metachar;
533 }
534 }
535 return(more_chars);
536
537 case KBD_KP:
538 fnc = NULL;
539 more_chars = NULL;
540
541 if(meta_down)
542 {
543 switch(key)
544 {
545 case 95: /* / */
546 altkpflag = 0;
547 more_chars =
548 (u_char *)"\033OQ";
549 return(more_chars);
550
551 case 100: /* * */
552 altkpflag = 0;
553 more_chars =
554 (u_char *)"\033OR";
555 return(more_chars);
556
557 case 105: /* - */
558 altkpflag = 0;
559 more_chars =
560 (u_char *)"\033OS";
561 return(more_chars);
562 }
563 }
564
565 if(meta_down || altgr_down)
566 {
567 if((n = keypad2num[key-91]) >= 0)
568 {
569 if(!altkpflag)
570 {
571 /* start ALT-KP mode */
572 altkpflag = 1;
573 altkpval = 0;
574 }
575 altkpval *= 10;
576 altkpval += n;
577 }
578 else
579 altkpflag = 0;
580 return 0;
581 }
582
583 if(!(vsp->num_lock))
584 {
585 if(key2ascii[key].shift.subtype == STR)
586 more_chars = (u_char *)thisdef.shift;
587 else
588 fnc = key2ascii[key].shift.what.func;
589 }
590 else
591 {
592 if(key2ascii[key].unshift.subtype == STR)
593 more_chars = (u_char *)thisdef.unshift;
594 else
595 fnc = key2ascii[key].unshift.what.func;
596 }
597
598 if(fnc)
599 (*fnc)(); /* execute function */
600 return(more_chars);
601
602 case KBD_CURSOR:
603 fnc = NULL;
604 more_chars = NULL;
605
606 if(vsp->ckm)
607 {
608 if(key2ascii[key].shift.subtype == STR)
609 more_chars = (u_char *)thisdef.shift;
610 else
611 fnc = key2ascii[key].shift.what.func;
612 }
613 else
614 {
615 if(key2ascii[key].unshift.subtype == STR)
616 more_chars = (u_char *)thisdef.unshift;
617 else
618 fnc = key2ascii[key].unshift.what.func;
619 }
620
621 if(fnc)
622 (*fnc)(); /* execute function */
623 return(more_chars);
624
625 case KBD_NUM: /* special kp-num handling */
626 more_chars = NULL;
627
628 if(meta_down)
629 {
630 more_chars = (u_char *)"\033OP"; /* PF1 */
631 }
632 else
633 {
634 vsp->num_lock ^= 1;
635 update_led();
636 }
637 return(more_chars);
638
639 case KBD_RETURN:
640 more_chars = NULL;
641
642 if(!(vsp->num_lock))
643 {
644 more_chars = (u_char *)thisdef.shift;
645 }
646 else
647 {
648 more_chars = (u_char *)thisdef.unshift;
649 }
650 if(vsp->lnm && (*more_chars == '\r'))
651 {
652 more_chars = (u_char *)"\r\n"; /* CR LF */
653 }
654 if(meta_down)
655 {
656 #if PCVT_META_ESC
657 metachar[1] = *more_chars;
658 #else
659 metachar[0] = *more_chars | 0x80;
660 #endif
661 more_chars = metachar;
662 }
663 return(more_chars);
664
665 case KBD_META: /* these keys are */
666 case KBD_ALTGR: /* handled directly */
667 case KBD_SCROLL: /* by the keyboard */
668 case KBD_CAPS: /* handler - they are */
669 case KBD_SHFTLOCK: /* ignored here */
670 case KBD_CTL:
671 case KBD_NONE:
672 default:
673 return 0;
674 }
675 }
676
677 /*---------------------------------------------------------------------------*
678 * get keystrokes from the keyboard.
679 * if noblock = 0, wait until a key is pressed.
680 * else return NULL if no characters present.
681 *---------------------------------------------------------------------------*/
682 u_char *
683 sgetc(int noblock)
684 {
685 u_char *cp;
686 u_char dt = 0;
687 u_char key = 0;
688 u_short type;
689 int c;
690
691 #if PCVT_SLOW_INTERRUPT
692 int s;
693 #endif
694
695 #ifdef XSERVER
696 static char keybuf[2] = {0}; /* the second 0 is a delimiter! */
697 #endif /* XSERVER */
698
699 static u_char kbd_lastkey = 0; /* last keystroke */
700
701 static struct
702 {
703 u_char extended: 1; /* extended prefix seen */
704 u_char ext1: 1; /* extended prefix 1 seen */
705 u_char breakseen: 1; /* break code seen */
706 u_char vshift: 1; /* virtual shift pending */
707 u_char vcontrol: 1; /* virtual control pending */
708 u_char sysrq: 1; /* sysrq pressed */
709 } kbd_status = {0};
710
711 loop:
712
713 if(noblock == SCROLLBACK_COOKIE)
714 {
715 vsp->scrolling = 1;
716 goto scroll_reset;
717 }
718
719 #ifdef XSERVER
720
721 if (pcvt_kbd_count)
722 {
723 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++];
724 PCVT_DISABLE_INTR();
725 pcvt_kbd_count--;
726 PCVT_ENABLE_INTR();
727 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
728 pcvt_kbd_rptr = 0;
729 }
730 else if (!noblock)
731 {
732 while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1)
733 ;
734 dt = c;
735 }
736 else
737 {
738 if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1)
739 return NULL;
740 dt = c;
741 }
742
743 /*
744 * If x mode is active, only care for locking keys, then
745 * return the scan code instead of any key translation.
746 * Additionally, this prevents us from any attempts to
747 * execute pcvt internal functions caused by keys (such
748 * as screen flipping).
749 */
750 if (pcvt_kbd_raw)
751 {
752 keybuf[0] = dt;
753
754 random_harvest(keybuf, sizeof(keybuf), 1, 0, RANDOM_KEYBOARD);
755
756 return ((u_char *)keybuf);
757 }
758
759 #else /* !XSERVER */
760
761 if (pcvt_kbd_count)
762 {
763 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++];
764 PCVT_DISABLE_INTR();
765 pcvt_kbd_count--;
766 PCVT_ENABLE_INTR();
767 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
768 pcvt_kbd_rptr = 0;
769 }
770 else if (!noblock)
771 {
772 while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1)
773 ;
774 dt = c;
775 }
776 else
777 {
778 if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1)
779 return NULL;
780 dt = c;
781 }
782 #endif /* !XSERVER */
783
784 #if PCVT_SHOWKEYS
785 showkey (' ', dt);
786 #endif /* PCVT_SHOWKEYS */
787
788 /* lets look what we got */
789 switch(dt)
790 {
791 case KEYB_R_OVERRUN0: /* keyboard buffer overflow */
792
793 #if PCVT_SCANSET == 2
794 case KEYB_R_SELFOK: /* keyboard selftest ok */
795 #endif /* PCVT_SCANSET == 2 */
796
797 case KEYB_R_ECHO: /* keyboard response to KEYB_C_ECHO */
798 case KEYB_R_ACK: /* acknowledge after command has rx'd*/
799 case KEYB_R_SELFBAD: /* keyboard selftest FAILED */
800 case KEYB_R_DIAGBAD: /* keyboard self diagnostic failure */
801 case KEYB_R_RESEND: /* keyboard wants us to resend cmnd */
802 case KEYB_R_OVERRUN1: /* keyboard buffer overflow */
803 break;
804
805 case KEYB_R_EXT1: /* keyboard extended scancode pfx 2 */
806 kbd_status.ext1 = 1;
807 /* FALLTHROUGH */
808 case KEYB_R_EXT0: /* keyboard extended scancode pfx 1 */
809 kbd_status.extended = 1;
810 break;
811
812 #if PCVT_SCANSET == 2
813 case KEYB_R_BREAKPFX: /* break code prefix for set 2 and 3 */
814 kbd_status.breakseen = 1;
815 break;
816 #endif /* PCVT_SCANSET == 2 */
817
818 default:
819 goto regular; /* regular key */
820 }
821
822 if(noblock)
823 return NULL;
824 else
825 goto loop;
826
827 /* got a normal scan key */
828 regular:
829
830 random_harvest(&dt, sizeof(dt), 1, 0, RANDOM_KEYBOARD);
831
832 #if PCVT_SCANSET == 1
833 kbd_status.breakseen = dt & 0x80 ? 1 : 0;
834 dt &= 0x7f;
835 #endif /* PCVT_SCANSET == 1 */
836
837 /* make a keycode from scan code */
838 if(dt >= sizeof scantokey / sizeof(u_char))
839 key = 0;
840 else
841 key = kbd_status.extended ? extscantokey[dt] : scantokey[dt];
842
843 if(kbd_status.ext1 && key == 64)
844 /* virtual control key */
845 key = 129;
846
847 kbd_status.extended = kbd_status.ext1 = 0;
848
849 if ((key == 85) && shift_down && kbd_lastkey != 85)
850 {
851 if (vsp->scr_offset > (vsp->screen_rows - 1))
852 {
853 if (!vsp->scrolling)
854 {
855 vsp->scrolling += vsp->screen_rows - 2;
856 if (vsp->Scrollback)
857 {
858 scrollback_save_screen();
859 if (vsp->scr_offset == vsp->max_off)
860 {
861 bcopy(vsp->Scrollback +
862 vsp->maxcol,
863 vsp->Scrollback,
864 vsp->maxcol *
865 vsp->max_off * CHR);
866 vsp->scr_offset--;
867 }
868 bcopy(vsp->Crtat + vsp->cur_offset -
869 vsp->col, vsp->Scrollback +
870 ((vsp->scr_offset + 1) *
871 vsp->maxcol), vsp->maxcol * CHR);
872 }
873
874 if (vsp->cursor_on)
875 sw_cursor(0);
876 }
877
878 vsp->scrolling += vsp->screen_rows - 1;
879
880 if (vsp->scrolling > vsp->scr_offset)
881 vsp->scrolling = vsp->scr_offset;
882
883 bcopy(vsp->Scrollback + ((vsp->scr_offset -
884 vsp->scrolling) * vsp->maxcol), vsp->Crtat,
885 vsp->screen_rows * vsp->maxcol * CHR);
886 }
887
888 kbd_lastkey = 85;
889 goto loop;
890 }
891 else if ((key == 86) && shift_down && kbd_lastkey != 86)
892 {
893
894 scroll_reset:
895 if (vsp->scrolling > 0)
896 {
897 vsp->scrolling -= vsp->screen_rows - 1;
898 if (vsp->scrolling < 0)
899 vsp->scrolling = 0;
900
901 if (vsp->scrolling <= vsp->screen_rows)
902 {
903 vsp->scrolling = 0;
904 scrollback_restore_screen();
905 }
906 else
907 {
908 bcopy(vsp->Scrollback + ((vsp->scr_offset -
909 vsp->scrolling) * vsp->maxcol),
910 vsp->Crtat, vsp->screen_rows *
911 vsp->maxcol * CHR);
912 }
913 }
914
915 if (vsp->scrolling == 0)
916 {
917 if (vsp->cursor_on)
918 {
919 sw_cursor(1);
920 }
921 }
922
923 if (noblock == SCROLLBACK_COOKIE)
924 return NULL;
925
926 if (key != 86)
927 {
928 goto regular;
929 }
930 else
931 {
932 kbd_lastkey = 86;
933 goto loop;
934 }
935 }
936 else if (vsp->scrolling && key != 128 && key != 44 && key != 85 &&
937 key != 86)
938 {
939 vsp->scrolling = 1;
940 goto scroll_reset;
941 }
942
943 #if PCVT_CTRL_ALT_DEL /* Check for cntl-alt-del */
944 if((key == 76) && ctrl_down && (meta_down||altgr_down))
945 shutdown_nice(0);
946 #endif /* PCVT_CTRL_ALT_DEL */
947
948 #if defined(DDB) /* Check for cntl-alt-esc */
949
950 if((key == 110) && ctrl_down && (meta_down || altgr_down))
951 {
952 static u_char in_Debugger;
953
954 if(!in_Debugger)
955 {
956 in_Debugger = 1;
957
958 /* the string is actually not used... */
959 Debugger("kbd");
960
961 in_Debugger = 0;
962 if(noblock)
963 return NULL;
964 else
965 goto loop;
966 }
967 }
968 #endif /* defined(DDB) */
969
970 /* look for keys with special handling */
971 if(key == 128)
972 {
973 /*
974 * virtual shift; sent around PrtScr, and around the arrow
975 * keys if the NumLck LED is on
976 */
977 kbd_status.vshift = !kbd_status.breakseen;
978 key = 0; /* no key */
979 }
980 else if(key == 129)
981 {
982 /*
983 * virtual control - the most ugly thingie at all
984 * the Pause key sends:
985 * <virtual control make> <numlock make> <virtual control
986 * break> <numlock break>
987 */
988 if(!kbd_status.breakseen)
989 kbd_status.vcontrol = 1;
990 /* else: let the numlock hook clear this */
991 key = 0; /* no key */
992 }
993 else if(key == 90)
994 {
995 /* NumLock, look whether this is rather a Pause */
996 if(kbd_status.vcontrol)
997 key = 126;
998 /*
999 * if this is the final break code of a Pause key,
1000 * clear the virtual control status, too
1001 */
1002 if(kbd_status.vcontrol && kbd_status.breakseen)
1003 kbd_status.vcontrol = 0;
1004 }
1005 else if(key == 127)
1006 {
1007 /*
1008 * a SysRq; some keyboards are brain-dead enough to
1009 * repeat the SysRq key make code by sending PrtScr
1010 * make codes; other keyboards do not repeat SysRq
1011 * at all. We keep track of the SysRq state here.
1012 */
1013 kbd_status.sysrq = !kbd_status.breakseen;
1014 }
1015 else if(key == 124)
1016 {
1017 /*
1018 * PrtScr; look whether this is really PrtScr or rather
1019 * a silly repeat of a SysRq key
1020 */
1021 if(kbd_status.sysrq)
1022 /* ignore the garbage */
1023 key = 0;
1024 }
1025
1026 /* in NOREPEAT MODE ignore the key if it was the same as before */
1027
1028 if(!kbrepflag && key == kbd_lastkey && !kbd_status.breakseen)
1029 {
1030 if(noblock)
1031 return NULL;
1032 else
1033 goto loop;
1034 }
1035
1036 type = key2ascii[key].type;
1037
1038 if(type & KBD_OVERLOAD)
1039 type = ovltbl[key2ascii[key].ovlindex].type;
1040
1041 type &= KBD_MASK;
1042
1043 switch(type)
1044 {
1045 case KBD_SHFTLOCK:
1046 if(!kbd_status.breakseen && key != kbd_lastkey)
1047 {
1048 vsp->shift_lock ^= 1;
1049 }
1050 break;
1051
1052 case KBD_CAPS:
1053 if(!kbd_status.breakseen && key != kbd_lastkey)
1054 {
1055 vsp->caps_lock ^= 1;
1056 update_led();
1057 }
1058 break;
1059
1060 case KBD_SCROLL:
1061 if(!kbd_status.breakseen && key != kbd_lastkey)
1062 {
1063 vsp->scroll_lock ^= 1;
1064 update_led();
1065
1066 if(!(vsp->scroll_lock))
1067 {
1068 /* someone may be sleeping */
1069 wakeup((caddr_t)&(vsp->scroll_lock));
1070 }
1071 }
1072 break;
1073
1074 case KBD_SHIFT:
1075 shift_down = kbd_status.breakseen ? 0 : 1;
1076 break;
1077
1078 case KBD_META:
1079 meta_down = kbd_status.breakseen ? 0 : 0x80;
1080 break;
1081
1082 case KBD_ALTGR:
1083 altgr_down = kbd_status.breakseen ? 0 : 1;
1084 break;
1085
1086 case KBD_CTL:
1087 ctrl_down = kbd_status.breakseen ? 0 : 1;
1088 break;
1089
1090 case KBD_NONE:
1091 default:
1092 break; /* deliver a key */
1093 }
1094
1095 if(kbd_status.breakseen)
1096 {
1097 key |= 0x80;
1098 kbd_status.breakseen = 0;
1099 kbd_lastkey = 0; /* -hv- I know this is a bug with */
1100 } /* N-Key-Rollover, but I ignore that */
1101 else /* because avoidance is too complicated */
1102 kbd_lastkey = key;
1103
1104 cp = xlatkey2ascii(key); /* have a key */
1105
1106 if(cp == NULL && !noblock)
1107 goto loop;
1108
1109 return cp;
1110 }
1111
1112 /*---------------------------------------------------------------------------*
1113 * reflect status of locking keys & set led's
1114 *---------------------------------------------------------------------------*/
1115 static void
1116 setlockkeys(int snc)
1117 {
1118 vsp->scroll_lock = snc & 1;
1119 vsp->num_lock = (snc & 2) ? 1 : 0;
1120 vsp->caps_lock = (snc & 4) ? 1 : 0;
1121 update_led();
1122 }
1123
1124 /*---------------------------------------------------------------------------*
1125 * remove a key definition
1126 *---------------------------------------------------------------------------*/
1127 static int
1128 rmkeydef(int key)
1129 {
1130 register Ovl_tbl *ref;
1131
1132 if(key==0 || key > MAXKEYNUM)
1133 return EINVAL;
1134
1135 if(key2ascii[key].type & KBD_OVERLOAD)
1136 {
1137 ref = &ovltbl[key2ascii[key].ovlindex];
1138 ref->keynum = 0;
1139 ref->type = 0;
1140 ref->unshift[0] =
1141 ref->shift[0] =
1142 ref->ctrl[0] =
1143 ref->altgr[0] = 0;
1144 key2ascii[key].type &= KBD_MASK;
1145 }
1146 return 0;
1147 }
1148
1149 /*---------------------------------------------------------------------------*
1150 * overlay a key
1151 *---------------------------------------------------------------------------*/
1152 static int
1153 setkeydef(Ovl_tbl *data)
1154 {
1155 register int i;
1156
1157 if( data->keynum > MAXKEYNUM ||
1158 (data->type & KBD_MASK) == KBD_BREAK ||
1159 (data->type & KBD_MASK) > KBD_SHFTLOCK)
1160 return EINVAL;
1161
1162 data->unshift[KBDMAXOVLKEYSIZE] =
1163 data->shift[KBDMAXOVLKEYSIZE] =
1164 data->ctrl[KBDMAXOVLKEYSIZE] =
1165 data->altgr[KBDMAXOVLKEYSIZE] = 0;
1166
1167 data->subu =
1168 data->subs =
1169 data->subc =
1170 data->suba = KBD_SUBT_STR; /* just strings .. */
1171
1172 data->type |= KBD_OVERLOAD; /* mark overloaded */
1173
1174 /* if key already overloaded, use that slot else find free slot */
1175
1176 if(key2ascii[data->keynum].type & KBD_OVERLOAD)
1177 {
1178 i = key2ascii[data->keynum].ovlindex;
1179 }
1180 else
1181 {
1182 for(i=0; i<OVLTBL_SIZE; i++)
1183 if(ovltbl[i].keynum==0)
1184 break;
1185
1186 if(i==OVLTBL_SIZE)
1187 return ENOSPC; /* no space, abuse of ENOSPC(!) */
1188 }
1189
1190 ovltbl[i] = *data; /* copy new data string */
1191
1192 key2ascii[data->keynum].type |= KBD_OVERLOAD; /* mark key */
1193 key2ascii[data->keynum].ovlindex = i;
1194
1195 return 0;
1196 }
1197
1198 /*---------------------------------------------------------------------------*
1199 * keyboard ioctl's entry
1200 *---------------------------------------------------------------------------*/
1201 int
1202 kbdioctl(dev_t dev, int cmd, caddr_t data, int flag)
1203 {
1204 int key;
1205
1206 switch(cmd)
1207 {
1208 case KBDRESET:
1209 doreset();
1210 ovlinit(1);
1211 settpmrate(KBD_TPD500|KBD_TPM100);
1212 setlockkeys(0);
1213 break;
1214
1215 case KBDGTPMAT:
1216 *(int *)data = tpmrate;
1217 break;
1218
1219 case KBDSTPMAT:
1220 settpmrate(*(int *)data);
1221 break;
1222
1223 case KBDGREPSW:
1224 *(int *)data = kbrepflag;
1225 break;
1226
1227 case KBDSREPSW:
1228 kbrepflag = (*(int *)data) & 1;
1229 break;
1230
1231 case KBDGLEDS:
1232 *(int *)data = ledstate;
1233 break;
1234
1235 case KBDSLEDS:
1236 update_led(); /* ? */
1237 break;
1238
1239 case KBDGLOCK:
1240 *(int *)data = ( (vsp->scroll_lock) |
1241 (vsp->num_lock * 2) |
1242 (vsp->caps_lock * 4));
1243 break;
1244
1245 case KBDSLOCK:
1246 setlockkeys(*(int *)data);
1247 break;
1248
1249 case KBDGCKEY:
1250 key = ((Ovl_tbl *)data)->keynum;
1251 return getckeydef(key,(Ovl_tbl *)data);
1252
1253 case KBDSCKEY:
1254 key = ((Ovl_tbl *)data)->keynum;
1255 return setkeydef((Ovl_tbl *)data);
1256
1257 case KBDGOKEY:
1258 key = ((Ovl_tbl *)data)->keynum;
1259 return getokeydef(key,(Ovl_tbl *)data);
1260
1261 case KBDRMKEY:
1262 key = *(int *)data;
1263 return rmkeydef(key);
1264
1265 case KBDDEFAULT:
1266 ovlinit(1);
1267 break;
1268
1269 default:
1270 /* proceed with vga ioctls */
1271 return -1;
1272 }
1273 return 0;
1274 }
1275
1276 #ifdef XSERVER
1277 /*---------------------------------------------------------------------------*
1278 * convert ISO-8859 style keycode into IBM 437
1279 *---------------------------------------------------------------------------*/
1280 static __inline u_char
1281 iso2ibm(u_char c)
1282 {
1283 if(c < 0x80)
1284 return c;
1285 return iso2ibm437[c - 0x80];
1286 }
1287
1288 /*---------------------------------------------------------------------------*
1289 * build up a USL style keyboard map
1290 *---------------------------------------------------------------------------*/
1291 void
1292 get_usl_keymap(keymap_t *map)
1293 {
1294 int i;
1295
1296 bzero((caddr_t)map, sizeof(keymap_t));
1297
1298 map->n_keys = 0x59; /* that many keys we know about */
1299
1300 for(i = 1; i < N_KEYNUMS; i++)
1301 {
1302 Ovl_tbl kdef;
1303 u_char c;
1304 int j;
1305 int idx = key2scan1[i];
1306
1307 if(idx == 0 || idx >= map->n_keys)
1308 continue;
1309
1310 getckeydef(i, &kdef);
1311 kdef.type &= KBD_MASK;
1312 switch(kdef.type)
1313 {
1314 case KBD_ASCII:
1315 case KBD_RETURN:
1316 map->key[idx].map[0] = iso2ibm(kdef.unshift[0]);
1317 map->key[idx].map[1] = iso2ibm(kdef.shift[0]);
1318 map->key[idx].map[2] = map->key[idx].map[3] =
1319 iso2ibm(kdef.ctrl[0]);
1320 map->key[idx].map[4] = map->key[idx].map[5] =
1321 iso2ibm(c = kdef.altgr[0]);
1322 /*
1323 * XXX this is a hack
1324 * since we currently do not map strings to AltGr +
1325 * shift, we attempt to use the unshifted AltGr
1326 * definition here and try to toggle the case
1327 * this should at least work for ISO8859 letters,
1328 * but also for (e.g.) russian KOI-8 style
1329 */
1330 if((c & 0x7f) >= 0x40)
1331 map->key[idx].map[5] = iso2ibm(c ^ 0x20);
1332 break;
1333
1334 case KBD_FUNC:
1335 /* we are only interested in F1 thru F12 here */
1336 if(i >= 112 && i <= 123) {
1337 map->key[idx].map[0] = i - 112 + 27;
1338 map->key[idx].spcl = 0x80;
1339 }
1340 break;
1341
1342 case KBD_SHIFT:
1343 c = i == 44? 2 /* lSh */: 3 /* rSh */; goto special;
1344
1345 case KBD_CAPS:
1346 c = 4; goto special;
1347
1348 case KBD_NUM:
1349 c = 5; goto special;
1350
1351 case KBD_SCROLL:
1352 c = 6; goto special;
1353
1354 case KBD_META:
1355 c = 7; goto special;
1356
1357 case KBD_CTL:
1358 c = 9; goto special;
1359 special:
1360 for(j = 0; j < NUM_STATES; j++)
1361 map->key[idx].map[j] = c;
1362 map->key[idx].spcl = 0xff;
1363 break;
1364
1365 default:
1366 break;
1367 }
1368 }
1369 }
1370 #endif /* XSERVER */
1371
1372 /*---------------------------------------------------------------------------*
1373 * switch keypad to numeric mode
1374 *---------------------------------------------------------------------------*/
1375 void
1376 vt_keynum(struct video_state *svsp)
1377 {
1378 svsp->num_lock = 1;
1379 update_led();
1380 }
1381
1382 /*---------------------------------------------------------------------------*
1383 * switch keypad to application mode
1384 *---------------------------------------------------------------------------*/
1385 void
1386 vt_keyappl(struct video_state *svsp)
1387 {
1388 svsp->num_lock = 0;
1389 update_led();
1390 }
1391
1392 #if !PCVT_VT220KEYB /* !PCVT_VT220KEYB, HP-like Keyboard layout */
1393
1394 /*---------------------------------------------------------------------------*
1395 * function bound to function key 1
1396 *---------------------------------------------------------------------------*/
1397 static void
1398 fkey1(void)
1399 {
1400 if(!meta_down)
1401 {
1402 if((vsp->vt_pure_mode == M_HPVT)
1403 && (vsp->which_fkl == SYS_FKL))
1404 toggl_columns(vsp);
1405 else
1406 more_chars = (u_char *)"\033[17~"; /* F6 */
1407 }
1408 else
1409 {
1410 if(vsp->vt_pure_mode == M_PUREVT
1411 || (vsp->which_fkl == USR_FKL))
1412 more_chars = (u_char *)"\033[26~"; /* F14 */
1413 }
1414 }
1415
1416 /*---------------------------------------------------------------------------*
1417 * function bound to function key 2
1418 *---------------------------------------------------------------------------*/
1419 static void
1420 fkey2(void)
1421 {
1422 if(!meta_down)
1423 {
1424 if((vsp->vt_pure_mode == M_HPVT)
1425 && (vsp->which_fkl == SYS_FKL))
1426 vt_ris(vsp);
1427 else
1428 more_chars = (u_char *)"\033[18~"; /* F7 */
1429 }
1430 else
1431 {
1432 if(vsp->vt_pure_mode == M_PUREVT
1433 || (vsp->which_fkl == USR_FKL))
1434 more_chars = (u_char *)"\033[28~"; /* HELP */
1435 }
1436 }
1437
1438 /*---------------------------------------------------------------------------*
1439 * function bound to function key 3
1440 *---------------------------------------------------------------------------*/
1441 static void
1442 fkey3(void)
1443 {
1444 if(!meta_down)
1445 {
1446 if((vsp->vt_pure_mode == M_HPVT)
1447 && (vsp->which_fkl == SYS_FKL))
1448 toggl_24l(vsp);
1449 else
1450 more_chars = (u_char *)"\033[19~"; /* F8 */
1451 }
1452 else
1453 {
1454 if(vsp->vt_pure_mode == M_PUREVT
1455 || (vsp->which_fkl == USR_FKL))
1456 more_chars = (u_char *)"\033[29~"; /* DO */
1457 }
1458 }
1459
1460 /*---------------------------------------------------------------------------*
1461 * function bound to function key 4
1462 *---------------------------------------------------------------------------*/
1463 static void
1464 fkey4(void)
1465 {
1466 if(!meta_down)
1467 {
1468
1469 #if PCVT_SHOWKEYS
1470 if((vsp->vt_pure_mode == M_HPVT)
1471 && (vsp->which_fkl == SYS_FKL))
1472 toggl_kbddbg(vsp);
1473 else
1474 more_chars = (u_char *)"\033[20~"; /* F9 */
1475 #else
1476 if(vsp->vt_pure_mode == M_PUREVT
1477 || (vsp->which_fkl == USR_FKL))
1478 more_chars = (u_char *)"\033[20~"; /* F9 */
1479 #endif /* PCVT_SHOWKEYS */
1480
1481 }
1482 else
1483 {
1484 if(vsp->vt_pure_mode == M_PUREVT
1485 || (vsp->which_fkl == USR_FKL))
1486 more_chars = (u_char *)"\033[31~"; /* F17 */
1487 }
1488 }
1489
1490 /*---------------------------------------------------------------------------*
1491 * function bound to function key 5
1492 *---------------------------------------------------------------------------*/
1493 static void
1494 fkey5(void)
1495 {
1496 if(!meta_down)
1497 {
1498 if((vsp->vt_pure_mode == M_HPVT)
1499 && (vsp->which_fkl == SYS_FKL))
1500 toggl_bell(vsp);
1501 else
1502 more_chars = (u_char *)"\033[21~"; /* F10 */
1503 }
1504 else
1505 {
1506 if(vsp->vt_pure_mode == M_PUREVT
1507 || (vsp->which_fkl == USR_FKL))
1508 more_chars = (u_char *)"\033[32~"; /* F18 */
1509 }
1510 }
1511
1512 /*---------------------------------------------------------------------------*
1513 * function bound to function key 6
1514 *---------------------------------------------------------------------------*/
1515 static void
1516 fkey6(void)
1517 {
1518 if(!meta_down)
1519 {
1520 if((vsp->vt_pure_mode == M_HPVT)
1521 && (vsp->which_fkl == SYS_FKL))
1522 toggl_sevenbit(vsp);
1523 else
1524 more_chars = (u_char *)"\033[23~"; /* F11 */
1525 }
1526 else
1527 {
1528 if(vsp->vt_pure_mode == M_PUREVT
1529 || (vsp->which_fkl == USR_FKL))
1530 more_chars = (u_char *)"\033[33~"; /* F19 */
1531 }
1532 }
1533
1534 /*---------------------------------------------------------------------------*
1535 * function bound to function key 7
1536 *---------------------------------------------------------------------------*/
1537 static void
1538 fkey7(void)
1539 {
1540 if(!meta_down)
1541 {
1542 if((vsp->vt_pure_mode == M_HPVT)
1543 && (vsp->which_fkl == SYS_FKL))
1544 toggl_dspf(vsp);
1545 else
1546 more_chars = (u_char *)"\033[24~"; /* F12 */
1547 }
1548 else
1549 {
1550 if(vsp->vt_pure_mode == M_PUREVT
1551 || (vsp->which_fkl == USR_FKL))
1552 more_chars = (u_char *)"\033[34~"; /* F20 */
1553 }
1554 }
1555
1556 /*---------------------------------------------------------------------------*
1557 * function bound to function key 8
1558 *---------------------------------------------------------------------------*/
1559 static void
1560 fkey8(void)
1561 {
1562 if(!meta_down)
1563 {
1564 if((vsp->vt_pure_mode == M_HPVT)
1565 && (vsp->which_fkl == SYS_FKL))
1566 toggl_awm(vsp);
1567 else
1568 more_chars = (u_char *)"\033[25~"; /* F13 */
1569 }
1570 else
1571 {
1572 if(vsp->vt_pure_mode == M_PUREVT
1573 || (vsp->which_fkl == USR_FKL))
1574 more_chars = (u_char *)"\033[35~"; /* F21 ? !! */
1575 }
1576 }
1577
1578 /*---------------------------------------------------------------------------*
1579 * function bound to function key 9
1580 *---------------------------------------------------------------------------*/
1581 static void
1582 fkey9(void)
1583 {
1584 if(meta_down)
1585 {
1586 if(vsp->vt_pure_mode == M_PUREVT)
1587 return;
1588
1589 if(vsp->labels_on) /* toggle label display on/off */
1590 fkl_off(vsp);
1591 else
1592 fkl_on(vsp);
1593 }
1594 else
1595 {
1596 do_vgapage(0);
1597 }
1598 }
1599
1600 /*---------------------------------------------------------------------------*
1601 * function bound to function key 10
1602 *---------------------------------------------------------------------------*/
1603 static void
1604 fkey10(void)
1605 {
1606 if(meta_down)
1607 {
1608 if(vsp->vt_pure_mode != M_PUREVT && vsp->labels_on)
1609 {
1610 if(vsp->which_fkl == USR_FKL)
1611 sw_sfkl(vsp);
1612 else if(vsp->which_fkl == SYS_FKL)
1613 sw_ufkl(vsp);
1614 }
1615 }
1616 else
1617 {
1618 do_vgapage(1);
1619 }
1620 }
1621
1622 /*---------------------------------------------------------------------------*
1623 * function bound to function key 11
1624 *---------------------------------------------------------------------------*/
1625 static void
1626 fkey11(void)
1627 {
1628 if(meta_down)
1629 {
1630 if(vsp->vt_pure_mode == M_PUREVT)
1631 set_emulation_mode(vsp, M_HPVT);
1632 else if(vsp->vt_pure_mode == M_HPVT)
1633 set_emulation_mode(vsp, M_PUREVT);
1634 }
1635 else
1636 {
1637 do_vgapage(2);
1638 }
1639 }
1640
1641 /*---------------------------------------------------------------------------*
1642 * function bound to function key 12
1643 *---------------------------------------------------------------------------*/
1644 static void
1645 fkey12(void)
1646 {
1647 if(meta_down)
1648 {
1649 if(current_video_screen + 1 > totalscreens-1)
1650 do_vgapage(0);
1651 else
1652 do_vgapage(current_video_screen + 1);
1653 }
1654 else
1655 {
1656 do_vgapage(3);
1657 }
1658 }
1659
1660 /*---------------------------------------------------------------------------*
1661 * function bound to SHIFTED function key 1
1662 *---------------------------------------------------------------------------*/
1663 static void
1664 sfkey1(void)
1665 {
1666 if(!meta_down)
1667 {
1668 if(vsp->ukt.length[0]) /* entry available ? */
1669 more_chars = (u_char *)
1670 &(vsp->udkbuf[vsp->ukt.first[0]]);
1671 }
1672 else
1673 {
1674 if(vsp->ukt.length[9]) /* entry available ? */
1675 more_chars = (u_char *)
1676 &(vsp->udkbuf[vsp->ukt.first[9]]);
1677 }
1678 }
1679
1680 /*---------------------------------------------------------------------------*
1681 * function bound to SHIFTED function key 2
1682 *---------------------------------------------------------------------------*/
1683 static void
1684 sfkey2(void)
1685 {
1686 if(!meta_down)
1687 {
1688 if(vsp->ukt.length[1]) /* entry available ? */
1689 more_chars = (u_char *)
1690 &(vsp->udkbuf[vsp->ukt.first[1]]);
1691 }
1692 else
1693 {
1694 if(vsp->ukt.length[11]) /* entry available ? */
1695 more_chars = (u_char *)
1696 &(vsp->udkbuf[vsp->ukt.first[11]]);
1697 }
1698 }
1699
1700 /*---------------------------------------------------------------------------*
1701 * function bound to SHIFTED function key 3
1702 *---------------------------------------------------------------------------*/
1703 static void
1704 sfkey3(void)
1705 {
1706 if(!meta_down)
1707 {
1708 if(vsp->ukt.length[2]) /* entry available ? */
1709 more_chars = (u_char *)
1710 &(vsp->udkbuf[vsp->ukt.first[2]]);
1711 }
1712 else
1713 {
1714 if(vsp->ukt.length[12]) /* entry available ? */
1715 more_chars = (u_char *)
1716 &(vsp->udkbuf[vsp->ukt.first[12]]);
1717 }
1718 }
1719
1720 /*---------------------------------------------------------------------------*
1721 * function bound to SHIFTED function key 4
1722 *---------------------------------------------------------------------------*/
1723 static void
1724 sfkey4(void)
1725 {
1726 if(!meta_down)
1727 {
1728 if(vsp->ukt.length[3]) /* entry available ? */
1729 more_chars = (u_char *)
1730 &(vsp->udkbuf[vsp->ukt.first[3]]);
1731 }
1732 else
1733 {
1734 if(vsp->ukt.length[13]) /* entry available ? */
1735 more_chars = (u_char *)
1736 &(vsp->udkbuf[vsp->ukt.first[13]]);
1737 }
1738 }
1739
1740 /*---------------------------------------------------------------------------*
1741 * function bound to SHIFTED function key 5
1742 *---------------------------------------------------------------------------*/
1743 static void
1744 sfkey5(void)
1745 {
1746 if(!meta_down)
1747 {
1748 if(vsp->ukt.length[4]) /* entry available ? */
1749 more_chars = (u_char *)
1750 &(vsp->udkbuf[vsp->ukt.first[4]]);
1751 }
1752 else
1753 {
1754 if(vsp->ukt.length[14]) /* entry available ? */
1755 more_chars = (u_char *)
1756 &(vsp->udkbuf[vsp->ukt.first[14]]);
1757 }
1758 }
1759
1760 /*---------------------------------------------------------------------------*
1761 * function bound to SHIFTED function key 6
1762 *---------------------------------------------------------------------------*/
1763 static void
1764 sfkey6(void)
1765 {
1766 if(!meta_down)
1767 {
1768 if(vsp->ukt.length[6]) /* entry available ? */
1769 more_chars = (u_char *)
1770 &(vsp->udkbuf[vsp->ukt.first[6]]);
1771 }
1772 else
1773 {
1774 if(vsp->ukt.length[15]) /* entry available ? */
1775 more_chars = (u_char *)
1776 &(vsp->udkbuf[vsp->ukt.first[15]]);
1777 }
1778 }
1779
1780 /*---------------------------------------------------------------------------*
1781 * function bound to SHIFTED function key 7
1782 *---------------------------------------------------------------------------*/
1783 static void
1784 sfkey7(void)
1785 {
1786 if(!meta_down)
1787 {
1788 if(vsp->ukt.length[7]) /* entry available ? */
1789 more_chars = (u_char *)
1790 &(vsp->udkbuf[vsp->ukt.first[7]]);
1791 }
1792 else
1793 {
1794 if(vsp->ukt.length[16]) /* entry available ? */
1795 more_chars = (u_char *)
1796 &(vsp->udkbuf[vsp->ukt.first[16]]);
1797 }
1798 }
1799
1800 /*---------------------------------------------------------------------------*
1801 * function bound to SHIFTED function key 8
1802 *---------------------------------------------------------------------------*/
1803 static void
1804 sfkey8(void)
1805 {
1806 if(!meta_down)
1807 {
1808 if(vsp->ukt.length[8]) /* entry available ? */
1809 more_chars = (u_char *)
1810 &(vsp->udkbuf[vsp->ukt.first[8]]);
1811 }
1812 else
1813 {
1814 if(vsp->ukt.length[17]) /* entry available ? */
1815 more_chars = (u_char *)
1816 &(vsp->udkbuf[vsp->ukt.first[17]]);
1817 }
1818 }
1819 /*---------------------------------------------------------------------------*
1820 * function bound to SHIFTED function key 9
1821 *---------------------------------------------------------------------------*/
1822 static void
1823 sfkey9(void)
1824 {
1825 }
1826
1827 /*---------------------------------------------------------------------------*
1828 * function bound to SHIFTED function key 10
1829 *---------------------------------------------------------------------------*/
1830 static void
1831 sfkey10(void)
1832 {
1833 }
1834
1835 /*---------------------------------------------------------------------------*
1836 * function bound to SHIFTED function key 11
1837 *---------------------------------------------------------------------------*/
1838 static void
1839 sfkey11(void)
1840 {
1841 }
1842
1843 /*---------------------------------------------------------------------------*
1844 * function bound to SHIFTED function key 12
1845 *---------------------------------------------------------------------------*/
1846 static void
1847 sfkey12(void)
1848 {
1849 }
1850
1851 /*---------------------------------------------------------------------------*
1852 * function bound to control function key 1
1853 *---------------------------------------------------------------------------*/
1854 static void
1855 cfkey1(void)
1856 {
1857 if(meta_down)
1858 do_vgapage(0);
1859 }
1860
1861 /*---------------------------------------------------------------------------*
1862 * function bound to control function key 2
1863 *---------------------------------------------------------------------------*/
1864 static void
1865 cfkey2(void)
1866 {
1867 if(meta_down)
1868 do_vgapage(1);
1869 }
1870
1871 /*---------------------------------------------------------------------------*
1872 * function bound to control function key 3
1873 *---------------------------------------------------------------------------*/
1874 static void
1875 cfkey3(void)
1876 {
1877 if(meta_down)
1878 do_vgapage(2);
1879 }
1880
1881 /*---------------------------------------------------------------------------*
1882 * function bound to control function key 4
1883 *---------------------------------------------------------------------------*/
1884 static void
1885 cfkey4(void)
1886 {
1887 if(meta_down)
1888 do_vgapage(3);
1889 }
1890
1891 /*---------------------------------------------------------------------------*
1892 * function bound to control function key 5
1893 *---------------------------------------------------------------------------*/
1894 static void
1895 cfkey5(void)
1896 {
1897 if(meta_down)
1898 do_vgapage(4);
1899 }
1900
1901 /*---------------------------------------------------------------------------*
1902 * function bound to control function key 6
1903 *---------------------------------------------------------------------------*/
1904 static void
1905 cfkey6(void)
1906 {
1907 if(meta_down)
1908 do_vgapage(5);
1909 }
1910
1911 /*---------------------------------------------------------------------------*
1912 * function bound to control function key 7
1913 *---------------------------------------------------------------------------*/
1914 static void
1915 cfkey7(void)
1916 {
1917 if(meta_down)
1918 do_vgapage(6);
1919 }
1920
1921 /*---------------------------------------------------------------------------*
1922 * function bound to control function key 8
1923 *---------------------------------------------------------------------------*/
1924 static void
1925 cfkey8(void)
1926 {
1927 if(meta_down)
1928 do_vgapage(7);
1929 }
1930
1931 /*---------------------------------------------------------------------------*
1932 * function bound to control function key 9
1933 *---------------------------------------------------------------------------*/
1934 static void
1935 cfkey9(void)
1936 {
1937 if(meta_down)
1938 do_vgapage(8);
1939 }
1940
1941 /*---------------------------------------------------------------------------*
1942 * function bound to control function key 10
1943 *---------------------------------------------------------------------------*/
1944 static void
1945 cfkey10(void)
1946 {
1947 if(meta_down)
1948 do_vgapage(9);
1949 }
1950
1951 /*---------------------------------------------------------------------------*
1952 * function bound to control function key 11
1953 *---------------------------------------------------------------------------*/
1954 static void
1955 cfkey11(void)
1956 {
1957 if(meta_down)
1958 do_vgapage(10);
1959 }
1960
1961 /*---------------------------------------------------------------------------*
1962 * function bound to control function key 12
1963 *---------------------------------------------------------------------------*/
1964 static void
1965 cfkey12(void)
1966 {
1967 if(meta_down)
1968 do_vgapage(11);
1969 }
1970
1971 #else /* PCVT_VT220 - VT220-like Keyboard layout */
1972
1973 /*---------------------------------------------------------------------------*
1974 * function bound to function key 1
1975 *---------------------------------------------------------------------------*/
1976 static void
1977 fkey1(void)
1978 {
1979 if(meta_down)
1980 more_chars = (u_char *)"\033[23~"; /* F11 */
1981 else
1982 do_vgapage(0);
1983 }
1984
1985 /*---------------------------------------------------------------------------*
1986 * function bound to function key 2
1987 *---------------------------------------------------------------------------*/
1988 static void
1989 fkey2(void)
1990 {
1991 if(meta_down)
1992 more_chars = (u_char *)"\033[24~"; /* F12 */
1993 else
1994 do_vgapage(1);
1995 }
1996
1997 /*---------------------------------------------------------------------------*
1998 * function bound to function key 3
1999 *---------------------------------------------------------------------------*/
2000 static void
2001 fkey3(void)
2002 {
2003 if(meta_down)
2004 more_chars = (u_char *)"\033[25~"; /* F13 */
2005 else
2006 do_vgapage(2);
2007 }
2008
2009 /*---------------------------------------------------------------------------*
2010 * function bound to function key 4
2011 *---------------------------------------------------------------------------*/
2012 static void
2013 fkey4(void)
2014 {
2015 if(meta_down)
2016 more_chars = (u_char *)"\033[26~"; /* F14 */
2017 else
2018 do_vgapage(3);
2019 }
2020
2021 /*---------------------------------------------------------------------------*
2022 * function bound to function key 5
2023 *---------------------------------------------------------------------------*/
2024 static void
2025 fkey5(void)
2026 {
2027 if(meta_down)
2028 more_chars = (u_char *)"\033[28~"; /* Help */
2029 else
2030 {
2031 if((current_video_screen + 1) > totalscreens-1)
2032 do_vgapage(0);
2033 else
2034 do_vgapage(current_video_screen + 1);
2035 }
2036 }
2037
2038 /*---------------------------------------------------------------------------*
2039 * function bound to function key 6
2040 *---------------------------------------------------------------------------*/
2041 static void
2042 fkey6(void)
2043 {
2044 if(meta_down)
2045 more_chars = (u_char *)"\033[29~"; /* DO */
2046 else
2047 more_chars = (u_char *)"\033[17~"; /* F6 */
2048 }
2049
2050 /*---------------------------------------------------------------------------*
2051 * function bound to function key 7
2052 *---------------------------------------------------------------------------*/
2053 static void
2054 fkey7(void)
2055 {
2056 if(meta_down)
2057 more_chars = (u_char *)"\033[31~"; /* F17 */
2058 else
2059 more_chars = (u_char *)"\033[18~"; /* F7 */
2060 }
2061
2062 /*---------------------------------------------------------------------------*
2063 * function bound to function key 8
2064 *---------------------------------------------------------------------------*/
2065 static void
2066 fkey8(void)
2067 {
2068 if(meta_down)
2069 more_chars = (u_char *)"\033[32~"; /* F18 */
2070 else
2071 more_chars = (u_char *)"\033[19~"; /* F8 */
2072 }
2073
2074 /*---------------------------------------------------------------------------*
2075 * function bound to function key 9
2076 *---------------------------------------------------------------------------*/
2077 static void
2078 fkey9(void)
2079 {
2080 if(meta_down)
2081 more_chars = (u_char *)"\033[33~"; /* F19 */
2082 else
2083 more_chars = (u_char *)"\033[20~"; /* F9 */
2084 }
2085
2086 /*---------------------------------------------------------------------------*
2087 * function bound to function key 10
2088 *---------------------------------------------------------------------------*/
2089 static void
2090 fkey10(void)
2091 {
2092 if(meta_down)
2093 more_chars = (u_char *)"\033[34~"; /* F20 */
2094 else
2095 more_chars = (u_char *)"\033[21~"; /* F10 */
2096 }
2097
2098 /*---------------------------------------------------------------------------*
2099 * function bound to function key 11
2100 *---------------------------------------------------------------------------*/
2101 static void
2102 fkey11(void)
2103 {
2104 if(meta_down)
2105 more_chars = (u_char *)"\0x8FP"; /* PF1 */
2106 else
2107 more_chars = (u_char *)"\033[23~"; /* F11 */
2108 }
2109
2110 /*---------------------------------------------------------------------------*
2111 * function bound to function key 12
2112 *---------------------------------------------------------------------------*/
2113 static void
2114 fkey12(void)
2115 {
2116 if(meta_down)
2117 more_chars = (u_char *)"\0x8FQ"; /* PF2 */
2118 else
2119 more_chars = (u_char *)"\033[24~"; /* F12 */
2120 }
2121
2122 /*---------------------------------------------------------------------------*
2123 * function bound to SHIFTED function key 1
2124 *---------------------------------------------------------------------------*/
2125 static void
2126 sfkey1(void)
2127 {
2128 if(meta_down)
2129 {
2130 if(vsp->ukt.length[6]) /* entry available ? */
2131 more_chars = (u_char *)
2132 &(vsp->udkbuf[vsp->ukt.first[6]]);
2133 else
2134 more_chars = (u_char *)"\033[23~"; /* F11 */
2135 }
2136 else
2137 {
2138 do_vgapage(4);
2139 }
2140 }
2141
2142 /*---------------------------------------------------------------------------*
2143 * function bound to SHIFTED function key 2
2144 *---------------------------------------------------------------------------*/
2145 static void
2146 sfkey2(void)
2147 {
2148 if(meta_down)
2149 {
2150 if(vsp->ukt.length[7]) /* entry available ? */
2151 more_chars = (u_char *)
2152 &(vsp->udkbuf[vsp->ukt.first[7]]);
2153 else
2154 more_chars = (u_char *)"\033[24~"; /* F12 */
2155 }
2156 else
2157 {
2158 do_vgapage(5);
2159 }
2160 }
2161
2162 /*---------------------------------------------------------------------------*
2163 * function bound to SHIFTED function key 3
2164 *---------------------------------------------------------------------------*/
2165 static void
2166 sfkey3(void)
2167 {
2168 if(meta_down)
2169 {
2170 if(vsp->ukt.length[8]) /* entry available ? */
2171 more_chars = (u_char *)
2172 &(vsp->udkbuf[vsp->ukt.first[8]]);
2173 else
2174 more_chars = (u_char *)"\033[25~"; /* F13 */
2175 }
2176 else
2177 {
2178 do_vgapage(6);
2179 }
2180 }
2181
2182 /*---------------------------------------------------------------------------*
2183 * function bound to SHIFTED function key 4
2184 *---------------------------------------------------------------------------*/
2185 static void
2186 sfkey4(void)
2187 {
2188 if(meta_down)
2189 {
2190 if(vsp->ukt.length[9]) /* entry available ? */
2191 more_chars = (u_char *)
2192 &(vsp->udkbuf[vsp->ukt.first[9]]);
2193 else
2194 more_chars = (u_char *)"\033[26~"; /* F14 */
2195 }
2196 else
2197 {
2198 do_vgapage(7);
2199 }
2200 }
2201
2202 /*---------------------------------------------------------------------------*
2203 * function bound to SHIFTED function key 5
2204 *---------------------------------------------------------------------------*/
2205 static void
2206 sfkey5(void)
2207 {
2208 if(meta_down)
2209 {
2210 if(vsp->ukt.length[11]) /* entry available ? */
2211 more_chars = (u_char *)
2212 &(vsp->udkbuf[vsp->ukt.first[11]]);
2213 else
2214 more_chars = (u_char *)"\033[28~"; /* Help */
2215 }
2216 else
2217 {
2218 if(current_video_screen <= 0)
2219 do_vgapage(totalscreens-1);
2220 else
2221 do_vgapage(current_video_screen - 1);
2222 }
2223 }
2224
2225 /*---------------------------------------------------------------------------*
2226 * function bound to SHIFTED function key 6
2227 *---------------------------------------------------------------------------*/
2228 static void
2229 sfkey6(void)
2230 {
2231 if(!meta_down)
2232 {
2233 if(vsp->ukt.length[0]) /* entry available ? */
2234 more_chars = (u_char *)
2235 &(vsp->udkbuf[vsp->ukt.first[0]]);
2236 else
2237 more_chars = (u_char *)"\033[17~"; /* F6 */
2238 }
2239 else if(vsp->ukt.length[12]) /* entry available ? */
2240 more_chars = (u_char *)
2241 &(vsp->udkbuf[vsp->ukt.first[12]]);
2242 else
2243 more_chars = (u_char *)"\033[29~"; /* DO */
2244 }
2245
2246 /*---------------------------------------------------------------------------*
2247 * function bound to SHIFTED function key 7
2248 *---------------------------------------------------------------------------*/
2249 static void
2250 sfkey7(void)
2251 {
2252 if(!meta_down)
2253 {
2254 if(vsp->ukt.length[1]) /* entry available ? */
2255 more_chars = (u_char *)
2256 &(vsp->udkbuf[vsp->ukt.first[1]]);
2257 else
2258 more_chars = (u_char *)"\033[18~"; /* F7 */
2259 }
2260 else if(vsp->ukt.length[14]) /* entry available ? */
2261 more_chars = (u_char *)
2262 &(vsp->udkbuf[vsp->ukt.first[14]]);
2263 else
2264 more_chars = (u_char *)"\033[31~"; /* F17 */
2265 }
2266
2267 /*---------------------------------------------------------------------------*
2268 * function bound to SHIFTED function key 8
2269 *---------------------------------------------------------------------------*/
2270 static void
2271 sfkey8(void)
2272 {
2273 if(!meta_down)
2274 {
2275 if(vsp->ukt.length[2]) /* entry available ? */
2276 more_chars = (u_char *)
2277 &(vsp->udkbuf[vsp->ukt.first[2]]);
2278 else
2279 more_chars = (u_char *)"\033[19~"; /* F8 */
2280 }
2281 else if(vsp->ukt.length[14]) /* entry available ? */
2282 more_chars = (u_char *)
2283 &(vsp->udkbuf[vsp->ukt.first[15]]);
2284 else
2285 more_chars = (u_char *)"\033[32~"; /* F18 */
2286 }
2287
2288 /*---------------------------------------------------------------------------*
2289 * function bound to SHIFTED function key 9
2290 *---------------------------------------------------------------------------*/
2291 static void
2292 sfkey9(void)
2293 {
2294 if(!meta_down)
2295 {
2296 if(vsp->ukt.length[3]) /* entry available ? */
2297 more_chars = (u_char *)
2298 &(vsp->udkbuf[vsp->ukt.first[3]]);
2299 else
2300 more_chars = (u_char *)"\033[20~"; /* F9 */
2301 }
2302 else if(vsp->ukt.length[16]) /* entry available ? */
2303 more_chars = (u_char *)
2304 &(vsp->udkbuf[vsp->ukt.first[16]]);
2305 else
2306 more_chars = (u_char *)"\033[33~"; /* F19 */
2307 }
2308
2309 /*---------------------------------------------------------------------------*
2310 * function bound to SHIFTED function key 10
2311 *---------------------------------------------------------------------------*/
2312 static void
2313 sfkey10(void)
2314 {
2315 if(!meta_down)
2316 {
2317 if(vsp->ukt.length[4]) /* entry available ? */
2318 more_chars = (u_char *)
2319 &(vsp->udkbuf[vsp->ukt.first[4]]);
2320 else
2321 more_chars = (u_char *)"\033[21~"; /* F10 */
2322 }
2323 else if(vsp->ukt.length[17]) /* entry available ? */
2324 more_chars = (u_char *)
2325 &(vsp->udkbuf[vsp->ukt.first[17]]);
2326 else
2327 more_chars = (u_char *)"\033[34~"; /* F20 */
2328 }
2329
2330 /*---------------------------------------------------------------------------*
2331 * function bound to SHIFTED function key 11
2332 *---------------------------------------------------------------------------*/
2333 static void
2334 sfkey11(void)
2335 {
2336 if(!meta_down)
2337 {
2338 if(vsp->ukt.length[6]) /* entry available ? */
2339 more_chars = (u_char *)
2340 &(vsp->udkbuf[vsp->ukt.first[6]]);
2341 else
2342 more_chars = (u_char *)"\033[23~"; /* F11 */
2343 }
2344 }
2345
2346 /*---------------------------------------------------------------------------*
2347 * function bound to SHIFTED function key 12
2348 *---------------------------------------------------------------------------*/
2349 static void
2350 sfkey12(void)
2351 {
2352 if(!meta_down)
2353 {
2354 if(vsp->ukt.length[7]) /* entry available ? */
2355 more_chars = (u_char *)
2356 &(vsp->udkbuf[vsp->ukt.first[7]]);
2357 else
2358 more_chars = (u_char *)"\033[24~"; /* F12 */
2359 }
2360 }
2361
2362 /*---------------------------------------------------------------------------*
2363 * function bound to control function key 1
2364 *---------------------------------------------------------------------------*/
2365 static void
2366 cfkey1(void)
2367 {
2368 if(vsp->which_fkl == SYS_FKL)
2369 toggl_columns(vsp);
2370 }
2371
2372 /*---------------------------------------------------------------------------*
2373 * function bound to control function key 2
2374 *---------------------------------------------------------------------------*/
2375 static void
2376 cfkey2(void)
2377 {
2378 if(vsp->which_fkl == SYS_FKL)
2379 vt_ris(vsp);
2380 }
2381
2382 /*---------------------------------------------------------------------------*
2383 * function bound to control function key 3
2384 *---------------------------------------------------------------------------*/
2385 static void
2386 cfkey3(void)
2387 {
2388 if(vsp->which_fkl == SYS_FKL)
2389 toggl_24l(vsp);
2390 }
2391
2392 /*---------------------------------------------------------------------------*
2393 * function bound to control function key 4
2394 *---------------------------------------------------------------------------*/
2395 static void
2396 cfkey4(void)
2397 {
2398
2399 #if PCVT_SHOWKEYS
2400 if(vsp->which_fkl == SYS_FKL)
2401 toggl_kbddbg(vsp);
2402 #endif /* PCVT_SHOWKEYS */
2403
2404 }
2405
2406 /*---------------------------------------------------------------------------*
2407 * function bound to control function key 5
2408 *---------------------------------------------------------------------------*/
2409 static void
2410 cfkey5(void)
2411 {
2412 if(vsp->which_fkl == SYS_FKL)
2413 toggl_bell(vsp);
2414 }
2415
2416 /*---------------------------------------------------------------------------*
2417 * function bound to control function key 6
2418 *---------------------------------------------------------------------------*/
2419 static void
2420 cfkey6(void)
2421 {
2422 if(vsp->which_fkl == SYS_FKL)
2423 toggl_sevenbit(vsp);
2424 }
2425
2426 /*---------------------------------------------------------------------------*
2427 * function bound to control function key 7
2428 *---------------------------------------------------------------------------*/
2429 static void
2430 cfkey7(void)
2431 {
2432 if(vsp->which_fkl == SYS_FKL)
2433 toggl_dspf(vsp);
2434 }
2435
2436 /*---------------------------------------------------------------------------*
2437 * function bound to control function key 8
2438 *---------------------------------------------------------------------------*/
2439 static void
2440 cfkey8(void)
2441 {
2442 if(vsp->which_fkl == SYS_FKL)
2443 toggl_awm(vsp);
2444 }
2445
2446 /*---------------------------------------------------------------------------*
2447 * function bound to control function key 9
2448 *---------------------------------------------------------------------------*/
2449 static void
2450 cfkey9(void)
2451 {
2452 if(vsp->labels_on) /* toggle label display on/off */
2453 fkl_off(vsp);
2454 else
2455 fkl_on(vsp);
2456 }
2457
2458 /*---------------------------------------------------------------------------*
2459 * function bound to control function key 10
2460 *---------------------------------------------------------------------------*/
2461 static void
2462 cfkey10(void)
2463 {
2464 if(vsp->labels_on) /* toggle user/system fkey labels */
2465 {
2466 if(vsp->which_fkl == USR_FKL)
2467 sw_sfkl(vsp);
2468 else if(vsp->which_fkl == SYS_FKL)
2469 sw_ufkl(vsp);
2470 }
2471 }
2472
2473 /*---------------------------------------------------------------------------*
2474 * function bound to control function key 11
2475 *---------------------------------------------------------------------------*/
2476 static void
2477 cfkey11(void)
2478 {
2479 if(vsp->vt_pure_mode == M_PUREVT)
2480 set_emulation_mode(vsp, M_HPVT);
2481 else if(vsp->vt_pure_mode == M_HPVT)
2482 set_emulation_mode(vsp, M_PUREVT);
2483 }
2484
2485 /*---------------------------------------------------------------------------*
2486 * function bound to control function key 12
2487 *---------------------------------------------------------------------------*/
2488 static void
2489 cfkey12(void)
2490 {
2491 }
2492
2493 #endif /* PCVT_VT220KEYB */
2494
2495 /*---------------------------------------------------------------------------*
2496 *
2497 *---------------------------------------------------------------------------*/
2498 static void
2499 scrollback_save_screen(void)
2500 {
2501 int x = spltty();
2502 register size_t s;
2503
2504 s = sizeof(u_short) * vsp->screen_rowsize * vsp->maxcol;
2505
2506 if (scrollback_savedscreen)
2507 free(scrollback_savedscreen, M_TEMP);
2508
2509 scrnsv_size = s;
2510
2511 if (!(scrollback_savedscreen = (u_short *)malloc(s, M_TEMP, M_NOWAIT)))
2512 {
2513 splx(x);
2514 return;
2515 }
2516 bcopy(vsp->Crtat, scrollback_savedscreen, scrnsv_size);
2517 splx(x);
2518 }
2519
2520 /*---------------------------------------------------------------------------*
2521 *
2522 *---------------------------------------------------------------------------*/
2523 static void
2524 scrollback_restore_screen(void)
2525 {
2526 if (scrollback_savedscreen)
2527 bcopy(scrollback_savedscreen, vsp->Crtat, scrnsv_size);
2528 }
2529
2530 /* ------------------------------- EOF -------------------------------------*/
Cache object: d890c0906042332e821fa9c9804b377c
|