diff options
author | hm <hm@FreeBSD.org> | 1999-12-30 16:17:11 +0000 |
---|---|---|
committer | hm <hm@FreeBSD.org> | 1999-12-30 16:17:11 +0000 |
commit | 2b8b744edff9d6e0a54db72774d07cbea9a1ce17 (patch) | |
tree | a19b15c5936e3ad6c77250ecde910e741e9cfd5e /sys/i386/isa/pcvt/pcvt_kbd.c | |
parent | d229c8a13c2216189320fb983ddf4e7b04f026f0 (diff) | |
download | FreeBSD-src-2b8b744edff9d6e0a54db72774d07cbea9a1ce17.zip FreeBSD-src-2b8b744edff9d6e0a54db72774d07cbea9a1ce17.tar.gz |
Implement scrollback for pcvt based on code submitted by
Aaron Campbell <aaron@cs.dal.ca>.
Use SHIFT-PgUp and SHIFT-PgDn to scroll back and forward.
Aarons original code was enhanced to have a separate scrollbuffer
for every virtual terminal and to preserve the screen contents
when switching screen sizes.
The scrollbuffer size is currently fixed at 8 pages but this
will be made configurable through the use of scon(1) in the
near future.
For pcvt_kbd.h, a longstanding compiler warning was fixed by
using excessive backetizing of the key2ascii[] table.
Diffstat (limited to 'sys/i386/isa/pcvt/pcvt_kbd.c')
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_kbd.c | 172 |
1 files changed, 149 insertions, 23 deletions
diff --git a/sys/i386/isa/pcvt/pcvt_kbd.c b/sys/i386/isa/pcvt/pcvt_kbd.c index a394187..6155a11 100644 --- a/sys/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/i386/isa/pcvt/pcvt_kbd.c @@ -1,4 +1,6 @@ /* + * Copyright (c) 1999 Hellmuth Michaelis + * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * * Copyright (c) 1992, 1993 Brian Dunford-Shore and Holger Veit. @@ -36,33 +38,16 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @(#)pcvt_kbd.c, 3.20, Last Edit-Date: [Mon Apr 19 17:16:47 1999] - * */ /*---------------------------------------------------------------------------* * * pcvt_kbd.c VT220 Driver Keyboard Interface Code * ---------------------------------------------------- - * -hm ------------ Release 3.00 -------------- - * -hm integrating NetBSD-current patches - * -jw introduced kbd_emulate_pc() if scanset > 1 - * -hm patch from joerg for timeout in kbd_emulate_pc() - * -hm starting to implement alt-shift/ctrl key mappings - * -hm Gateway 2000 Keyboard fix from Brian Moore - * -hm some #if adjusting for NetBSD 0.9 - * -hm split off pcvt_kbd.h - * -hm applying Joerg's patches for FreeBSD 2.0 - * -hm patch from Martin, PCVT_NO_LED_UPDATE - * -hm PCVT_VT220KEYB patches from Lon Willet - * -hm PR #399, patch from Bill Sommerfeld: Return with PCVT_META_ESC - * -hm allow keyboard-less kernel boot for serial consoles and such .. - * -hm patch from Lon Willett for led-update and showkey() - * -hm patch from Lon Willett to fix mapping of Control-R scancode - * -hm delay patch from Martin Husemann after port-i386 ml-discussion - * -hm added PCVT_NONRESP_KEYB_TRY definition to doreset() + * + * Last Edit-Date: [Mon Dec 27 14:01:50 1999] + * + * $FreeBSD$ * *---------------------------------------------------------------------------*/ @@ -105,6 +90,11 @@ static int tpmrate = KBD_TPD500|KBD_TPM100; static u_char altkpflag = 0; static u_short altkpval = 0; +static u_short *scrollback_savedscreen = (u_short *)0; +static size_t scrnsv_size = (size_t)-1; +static void scrollback_save_screen ( void ); +static void scrollback_restore_screen ( void ); + #if PCVT_SHOWKEYS u_char rawkeybuf[80]; #endif @@ -1081,8 +1071,8 @@ u_char * sgetc(int noblock) { u_char *cp; - u_char dt; - u_char key; + u_char dt = 0; + u_char key = 0; u_short type; #if PCVT_KBD_FIFO && PCVT_SLOW_INTERRUPT @@ -1111,6 +1101,12 @@ sgetc(int noblock) loop: + if(noblock == 31337) + { + vsp->scrolling = 1; + goto scroll_reset; + } + #ifdef XSERVER #ifndef _DEV_KBD_KBDREG_H_ @@ -1590,6 +1586,100 @@ regular: kbd_status.extended = kbd_status.ext1 = 0; + if ((key == 85) && shift_down && kbd_lastkey != 85) + { + if (vsp->scr_offset > (vsp->screen_rows - 1)) + { + if (!vsp->scrolling) + { + vsp->scrolling += vsp->screen_rows - 2; + if (vsp->Scrollback) + { + scrollback_save_screen(); + if (vsp->scr_offset == vsp->max_off) + { + bcopy(vsp->Scrollback + + vsp->maxcol, + vsp->Scrollback, + vsp->maxcol * + vsp->max_off * CHR); + vsp->scr_offset--; + } + bcopy(vsp->Crtat + vsp->cur_offset - + vsp->col, vsp->Scrollback + + ((vsp->scr_offset + 1) * + vsp->maxcol), vsp->maxcol * CHR); + } + + if (vsp->cursor_on) + sw_cursor(0); + } + + vsp->scrolling += vsp->screen_rows - 1; + + if (vsp->scrolling > vsp->scr_offset) + vsp->scrolling = vsp->scr_offset; + + bcopy(vsp->Scrollback + ((vsp->scr_offset - + vsp->scrolling) * vsp->maxcol), vsp->Crtat, + vsp->screen_rows * vsp->maxcol * CHR); + } + + kbd_lastkey = 85; + goto loop; + } + else if ((key == 86) && shift_down && kbd_lastkey != 86) + { + +scroll_reset: + if (vsp->scrolling > 0) + { + vsp->scrolling -= vsp->screen_rows - 1; + if (vsp->scrolling < 0) + vsp->scrolling = 0; + + if (vsp->scrolling <= vsp->screen_rows) + { + vsp->scrolling = 0; + scrollback_restore_screen(); + } + else + { + bcopy(vsp->Scrollback + ((vsp->scr_offset - + vsp->scrolling) * vsp->maxcol), + vsp->Crtat, vsp->screen_rows * + vsp->maxcol * CHR); + } + } + + if (vsp->scrolling == 0) + { + if (vsp->cursor_on) + { + sw_cursor(1); + } + } + + if (noblock == 31337) + return NULL; + + if (key != 86) + { + goto regular; + } + else + { + kbd_lastkey = 86; + goto loop; + } + } + else if (vsp->scrolling && key != 128 && key != 44 && key != 85 && + key != 86) + { + vsp->scrolling = 1; + goto scroll_reset; + } + #if PCVT_CTRL_ALT_DEL /* Check for cntl-alt-del */ if((key == 76) && ctrl_down && (meta_down||altgr_down)) shutdown_nice(); @@ -3175,6 +3265,42 @@ cfkey12(void) #endif /* PCVT_VT220KEYB */ +/*---------------------------------------------------------------------------* + * + *---------------------------------------------------------------------------*/ +static void +scrollback_save_screen(void) +{ + int x = spltty(); + register size_t s; + + s = sizeof(u_short) * vsp->screen_rowsize * vsp->maxcol; + + if (scrollback_savedscreen) + free(scrollback_savedscreen, M_TEMP); + + scrnsv_size = s; + + if (!(scrollback_savedscreen = (u_short *)malloc(s, M_TEMP, M_NOWAIT))) + { + splx(x); + return; + } + bcopy(vsp->Crtat, scrollback_savedscreen, scrnsv_size); + splx(x); +} + +/*---------------------------------------------------------------------------* + * + *---------------------------------------------------------------------------*/ +static void +scrollback_restore_screen(void) +{ + if (scrollback_savedscreen) + bcopy(scrollback_savedscreen, vsp->Crtat, scrnsv_size); +} + + #endif /* NVT > 0 */ /* ------------------------------- EOF -------------------------------------*/ |