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_out.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_out.c')
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_out.c | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/sys/i386/isa/pcvt/pcvt_out.c b/sys/i386/isa/pcvt/pcvt_out.c index e7ce9e2..2c6d008 100644 --- a/sys/i386/isa/pcvt/pcvt_out.c +++ b/sys/i386/isa/pcvt/pcvt_out.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. @@ -33,29 +35,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_out.c, 3.20, Last Edit-Date: [Mon Apr 19 17:18:58 1999] - * */ /*---------------------------------------------------------------------------* * * pcvt_out.c VT220 Terminal Emulator * --------------------------------------- - * -hm ------------ Release 3.00 -------------- - * -hm integrating NetBSD-current patches - * -hm integrating patch from Thomas Gellekum - * -hm bugfix: clear last line when hpmode 28lines and force 24 - * -hm right fkey labels after soft/hard reset - * -hm patch from Joerg for comconsole operation - * -hm patch from Lon Willet to preserve the initial cursor shape - * -hm if FAT_CURSOR is defined, you get the old cursor type back .. - * -hm patch from Lon Willett regarding winsize settings - * -hm applying patch from Joerg fixing Crtat bug, non VGA startup bug - * -hm setting variable color for CGA and MDA/HGC in coldinit - * -hm fixing bug initializing cursor position on startup - * -hm fixing support for EGA boards in vt_coldinit() + * + * Last Edit-Date: [Mon Dec 27 14:07:39 1999] + * + * $FreeBSD$ * *---------------------------------------------------------------------------*/ @@ -79,6 +68,7 @@ static void vt_coldinit ( void ); static void wrfkl ( int num, u_char *string, struct video_state *svsp ); static void writefkl ( int num, u_char *string, struct video_state *svsp ); +static int check_scrollback ( struct video_state *svsp ); /*---------------------------------------------------------------------------* * do character set transformation and write to display memory (inline) @@ -148,7 +138,8 @@ sput (u_char *s, U_char kernel, int len, int page) register struct video_state *svsp; u_short attrib; u_short ch; - + u_short extra; + if(page >= PCVT_NSCREENS) /* failsafe */ page = 0; @@ -263,6 +254,18 @@ sput (u_char *s, U_char kernel, int len, int page) case 0x0a: /* LF */ case 0x0b: /* VT */ case 0x0c: /* FF */ + if (check_scrollback(svsp)) + { + extra = (svsp->cur_offset % + svsp->maxcol) ? + svsp->col : 0; + bcopy(svsp->Crtat + + svsp->cur_offset - extra, + svsp->Scrollback + + (svsp->scr_offset * + svsp->maxcol), + svsp->maxcol * CHR); + } if(svsp->lnm) { svsp->cur_offset -= svsp->col; @@ -343,6 +346,17 @@ sput (u_char *s, U_char kernel, int len, int page) svsp->cur_offset++; svsp->col = 0; svsp->lastchar = 0; + + if (check_scrollback(svsp)) + { + bcopy(svsp->Crtat + + svsp->cur_offset - + svsp->maxcol, + svsp->Scrollback + + (svsp->scr_offset * + svsp->maxcol), + svsp->maxcol * CHR); + } check_scroll(svsp); } @@ -735,6 +749,9 @@ sput (u_char *s, U_char kernel, int len, int page) case 'K': /* erase line */ vt_clreol(svsp); svsp->state = STATE_INIT; + if (svsp->scr_offset > 0 && + svsp == vsp) + svsp->scr_offset--; break; case 'L': /* insert line */ @@ -1009,6 +1026,9 @@ vt_coldinit(void) { svsp->Crtat = Crtat; /* all same until malloc'ed */ svsp->Memory = Crtat; /* until malloc'ed */ + svsp->Scrollback = 0; /* until malloc'ed */ + svsp->scr_offset = 0; /* scrollback offset (lines) */ + svsp->scrolling = 0; /* current scrollback page */ svsp->cur_offset = 0; /* cursor offset */ svsp->c_attr = user_attr; /* non-kernel attributes */ svsp->bell_on = 1; /* enable bell */ @@ -1042,6 +1062,7 @@ vt_coldinit(void) #endif /* PCVT_24LINESDEF */ svsp->screen_rowsize = 25; /* default 25 rows on screen */ + svsp->max_off = svsp->screen_rowsize * SCROLLBACK_PAGES - 1; svsp->scrr_beg = 0; /* scrolling region begin row*/ svsp->scrr_len = svsp->screen_rows; /* scrolling region length*/ svsp->scrr_end = svsp->scrr_len - 1;/* scrolling region end */ @@ -1287,15 +1308,15 @@ vt_coldmalloc(void) for(nscr = 0; nscr < PCVT_NSCREENS; nscr++) { - if((vs[nscr].Memory = - (u_short *)malloc(screen_max_size * 2, M_DEVBUF, M_WAITOK)) - == NULL) + if((vs[nscr].Memory = (u_short *)malloc(screen_max_size * 2, + M_DEVBUF, M_WAITOK)) == NULL) { printf("pcvt: screen memory malloc failed, " "NSCREEN=%d, nscr=%d\n", PCVT_NSCREENS, nscr); break; } + if(nscr != 0) { vs[nscr].Crtat = vs[nscr].Memory; @@ -1304,6 +1325,10 @@ vt_coldmalloc(void) vs[nscr].maxcol * vs[nscr].screen_rowsize); totalscreens++; } + + vs[nscr].scrollback_pages = SCROLLBACK_PAGES; + + reallocate_scrollbuffer(&(vs[nscr]), vs[nscr].scrollback_pages); } } @@ -1347,6 +1372,27 @@ check_scroll(struct video_state *svsp) } } +static int +check_scrollback(struct video_state *svsp) +{ + /* still waiting for scrollback memory or not on current page */ + if (!svsp->Scrollback || svsp != vsp) + return 0; + + /* remove first line of scrollback buffer to make room for new line */ + if (svsp->scr_offset == svsp->max_off) + { + bcopy(svsp->Scrollback + svsp->maxcol, svsp->Scrollback, + svsp->maxcol * svsp->max_off * CHR); + } + else + { + /* still room left, increase scroll offset (lines) */ + svsp->scr_offset++; + } + return 1; +} + /*---------------------------------------------------------------------------* * write to one user function key label *---------------------------------------------------------------------------*/ @@ -1831,6 +1877,7 @@ vt_col(struct video_state *svsp, int cols) #endif /* PCVT_SIGWINCH */ } + reallocate_scrollbuffer(svsp, svsp->scrollback_pages); return(1); } |