summaryrefslogtreecommitdiff
path: root/sys/arch/i386/isa/pcvt/pcvt_out.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/i386/isa/pcvt/pcvt_out.c')
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_out.c86
1 files changed, 83 insertions, 3 deletions
diff --git a/sys/arch/i386/isa/pcvt/pcvt_out.c b/sys/arch/i386/isa/pcvt/pcvt_out.c
index e6e9d232d20..734e19f2426 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_out.c
+++ b/sys/arch/i386/isa/pcvt/pcvt_out.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_out.c,v 1.7 1999/01/13 07:26:02 niklas Exp $ */
+/* $OpenBSD: pcvt_out.c,v 1.8 1999/09/06 00:12:40 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
@@ -80,6 +80,9 @@ 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 __inline void write_char (struct video_state *, u_short, u_short ch);
+#ifdef PCVT_SCROLLBACK
+static int check_scrollback ( struct video_state *svsp );
+#endif
/*---------------------------------------------------------------------------*
* do character set transformation and write to display memory (inline)
@@ -147,6 +150,9 @@ void
sput (u_char *s, U_char kernel, int len, int page)
{
register struct video_state *svsp;
+#ifdef PCVT_SCROLLBACK
+ int extra;
+#endif
u_short attrib;
u_short ch;
@@ -269,6 +275,20 @@ sput (u_char *s, U_char kernel, int len, int page)
case 0x0a: /* LF */
case 0x0b: /* VT */
case 0x0c: /* FF */
+#ifdef PCVT_SCROLLBACK
+ 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);
+ }
+#endif
if(svsp->lnm)
{
svsp->cur_offset -= svsp->col;
@@ -421,6 +441,18 @@ sput (u_char *s, U_char kernel, int len, int page)
svsp->cur_offset++;
svsp->col = 0;
svsp->lastchar = 0;
+#ifdef PCVT_SCROLLBACK
+ if (check_scrollback(svsp))
+ {
+ bcopy(svsp->Crtat +
+ svsp->cur_offset -
+ svsp->maxcol,
+ svsp->Scrollback +
+ (svsp->scr_offset *
+ svsp->maxcol),
+ svsp->maxcol * CHR);
+ }
+#endif
check_scroll(svsp);
}
@@ -813,6 +845,11 @@ sput (u_char *s, U_char kernel, int len, int page)
case 'K': /* erase line */
vt_clreol(svsp);
svsp->state = STATE_INIT;
+#ifdef PCVT_SCROLLBACK
+ if (svsp->scr_offset > 0 &&
+ svsp == vsp)
+ svsp->scr_offset--;
+#endif
break;
case 'L': /* insert line */
@@ -1094,6 +1131,11 @@ vt_coldinit(void)
{
svsp->Crtat = Crtat; /* all same until malloc'ed */
svsp->Memory = Crtat; /* until malloc'ed */
+#ifdef PCVT_SCROLLBACK
+ svsp->Scrollback = 0; /* until malloc'ed */
+ svsp->scr_offset = 0; /* scrollback offset (lines) */
+ svsp->scrolling = 0; /* current scrollback page */
+#endif
svsp->cur_offset = 0; /* cursor offset */
svsp->c_attr = user_attr; /* non-kernel attributes */
svsp->bell_on = 1; /* enable bell */
@@ -1128,6 +1170,9 @@ vt_coldinit(void)
#endif /* PCVT_24LINESDEF */
svsp->screen_rowsize = 25; /* default 25 rows on screen */
+#ifdef PCVT_SCROLLBACK
+ svsp->max_off = svsp->screen_rowsize * SCROLLBACK_PAGES - 1;
+#endif
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 */
@@ -1361,6 +1406,15 @@ vt_coldmalloc(void)
MAXROW_VGA * MAXCOL_VGA * CHR;
}
+#ifdef PCVT_SCROLLBACK
+ if ((Scrollbuffer = (u_short *)malloc(vs[0].maxcol *
+ vs[0].screen_rowsize * SCROLLBACK_PAGES * CHR * 2, M_DEVBUF,
+ M_WAITOK)) == NULL)
+ {
+ printf("pcvt: scrollback memory malloc failed\n");
+ }
+#endif
+
for(nscr = 0; nscr < PCVT_NSCREENS; nscr++)
{
if((vs[nscr].Memory =
@@ -1372,6 +1426,9 @@ vt_coldmalloc(void)
PCVT_NSCREENS, nscr);
break;
}
+#ifdef PCVT_SCROLLBACK
+ vs[nscr].Scrollback = Scrollbuffer;
+#endif
if(nscr != 0)
{
vs[nscr].Crtat = vs[nscr].Memory;
@@ -1423,6 +1480,29 @@ check_scroll(struct video_state *svsp)
}
}
+#ifdef PCVT_SCROLLBACK
+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;
+}
+#endif
+
/*---------------------------------------------------------------------------*
* write to one user function key label
*---------------------------------------------------------------------------*/
@@ -1877,8 +1957,8 @@ vt_col(struct video_state *svsp, int cols)
clr_parms(svsp); /* escape parameter init */
svsp->state = STATE_INIT; /* initial state */
- svsp->col = 0; /* init row */
- svsp->row = 0; /* init col */
+ svsp->col = 0; /* init col */
+ svsp->row = 0; /* init row */
svsp->cur_offset = 0; /* cursor offset init */
svsp->sc_flag = 0; /* invalidate saved cursor position */
svsp->scrr_beg = 0; /* reset scrolling region */