Пример #1
0
/* go to the top of the history buffer */
void
sc_hist_end(scr_stat *scp)
{
	scp->history_pos = sc_vtb_pos(scp->history, sc_vtb_tail(scp->history),
				      scp->xsize*scp->ysize);
	history_to_screen(scp);
}
Пример #2
0
/* restore the screen by copying from the history buffer */
int
sc_hist_restore(scr_stat *scp)
{
	int ret;

	if (scp->history_pos != sc_vtb_tail(scp->history)) {
		scp->history_pos = sc_vtb_tail(scp->history);
		history_to_screen(scp);
		ret =  0;
	} else {
		ret = 1;
	}
	sc_vtb_seek(scp->history, sc_vtb_pos(scp->history, 
					     sc_vtb_tail(scp->history),
					     -scp->xsize*scp->ysize));
	return ret;
}
Пример #3
0
/* move one line down */
int
sc_hist_down_line(scr_stat *scp)
{
	if (scp->history_pos == sc_vtb_tail(scp->history))
		return -1;
	scp->history_pos = sc_vtb_pos(scp->history, scp->history_pos,
				      scp->xsize);
	history_to_screen(scp);
	return 0;
}
Пример #4
0
static void
copy_history(sc_vtb_t *from, sc_vtb_t *to)
{
	int lines;
	int cols;
	int cols1;
	int cols2;
	int pos;
	int i;

	lines = sc_vtb_rows(from);
	cols1 = sc_vtb_cols(from);
	cols2 = sc_vtb_cols(to);
	cols = imin(cols1, cols2);
	pos = sc_vtb_tail(from);
	for (i = 0; i < lines; ++i) {
		sc_vtb_append(from, pos, to, cols);
		if (cols < cols2)
			sc_vtb_seek(to, sc_vtb_pos(to, 
						   sc_vtb_tail(to), 
						   cols2 - cols));
		pos = sc_vtb_pos(from, pos, cols1);
	}
}
Пример #5
0
/* allocate a history buffer */
int
sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait)
{
	/*
	 * syscons unconditionally allocates buffers up to 
	 * SC_HISTORY_SIZE lines or scp->ysize lines, whichever 
	 * is larger. A value greater than that is allowed, 
	 * subject to extra_history_size.
	 */
	sc_vtb_t *history;
	sc_vtb_t *prev_history;
	int cur_lines;				/* current buffer size */
	int min_lines;				/* guaranteed buffer size */
	int delta;				/* lines to put back */

	if (lines <= 0)
		lines = SC_HISTORY_SIZE;	/* use the default value */

	/* make it at least as large as the screen size */
	lines = imax(lines, scp->ysize);

	/* remove the history buffer while we update it */
	history = prev_history = scp->history;
	scp->history = NULL;

	/* calculate the amount of lines to put back to extra_history_size */
	delta = 0;
	if (prev_history) {
		cur_lines = sc_vtb_rows(history);
		min_lines = imax(SC_HISTORY_SIZE, prev_ysize);
		if (cur_lines > min_lines)
			delta = cur_lines - min_lines;
	}

	/* lines up to min_lines are always allowed. */
	min_lines = imax(SC_HISTORY_SIZE, scp->ysize);
	if (lines > min_lines) {
		if (lines - min_lines > extra_history_size + delta) {
			/* too many lines are requested */
			scp->history = prev_history;
			return EINVAL;
		}
	}

	/* allocate a new buffer */
	history = (sc_vtb_t *)malloc(sizeof(*history),
				     M_DEVBUF,
				     (wait) ? M_WAITOK : M_NOWAIT);
	if (history != NULL) {
		if (lines > min_lines)
			extra_history_size -= lines - min_lines;
		/* XXX error check? */
		sc_vtb_init(history, VTB_RINGBUFFER, scp->xsize, lines,
			    NULL, wait);
		/* FIXME: XXX no good? */
		sc_vtb_clear(history, scp->sc->scr_map[0x20],
			     SC_NORM_ATTR << 8);
		if (prev_history != NULL)
			copy_history(prev_history, history);
		scp->history_pos = sc_vtb_tail(history);
	} else {
		scp->history_pos = 0;
	}

	/* destroy the previous buffer */
	if (prev_history != NULL) {
		extra_history_size += delta;
		sc_vtb_destroy(prev_history);
		free(prev_history, M_DEVBUF);
	}

	scp->history = history;

	return 0;
}
Пример #6
0
/* go to the tail of the history buffer */
void
sc_hist_home(scr_stat *scp)
{
	scp->history_pos = sc_vtb_tail(scp->history);
	history_to_screen(scp);
}
Пример #7
0
/* copy entire screen into the top of the history buffer */
void
sc_hist_save(scr_stat *scp)
{
	sc_vtb_append(&scp->vtb, 0, scp->history, scp->xsize*scp->ysize);
	scp->history_pos = sc_vtb_tail(scp->history);
}
Пример #8
0
/* Restore old_ysize lines from the tail of the history buffer */
void
sc_hist_getback(scr_stat *scp, int old_ysize)
{
	scp->history_pos = sc_vtb_tail(scp->history);
	history_to_screen_lines(scp, old_ysize);
}