2011-03-22 21:31:31 +00:00
|
|
|
/*-
|
2013-11-02 14:20:29 +00:00
|
|
|
* Copyright (c) 2009, 2013 The FreeBSD Foundation
|
2011-03-22 21:31:31 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by Ed Schouten under sponsorship from the
|
|
|
|
* FreeBSD Foundation.
|
|
|
|
*
|
2013-11-02 14:20:29 +00:00
|
|
|
* Portions of this software were developed by Oleksandr Rybalko
|
|
|
|
* under sponsorship from the FreeBSD Foundation.
|
|
|
|
*
|
2011-03-22 21:31:31 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mutex.h>
|
2014-06-27 19:57:57 +00:00
|
|
|
#include <sys/reboot.h>
|
2011-03-22 21:31:31 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <dev/vt/vt.h>
|
|
|
|
|
|
|
|
static MALLOC_DEFINE(M_VTBUF, "vtbuf", "vt buffer");
|
|
|
|
|
|
|
|
#define VTBUF_LOCK(vb) mtx_lock_spin(&(vb)->vb_lock)
|
|
|
|
#define VTBUF_UNLOCK(vb) mtx_unlock_spin(&(vb)->vb_lock)
|
2013-11-11 11:50:17 +00:00
|
|
|
|
2013-11-13 12:32:41 +00:00
|
|
|
#define POS_INDEX(c, r) (((r) << 12) + (c))
|
|
|
|
#define POS_COPY(d, s) do { \
|
|
|
|
(d).tp_col = (s).tp_col; \
|
|
|
|
(d).tp_row = (s).tp_row; \
|
|
|
|
} while (0)
|
|
|
|
|
2013-11-11 11:50:17 +00:00
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
/*
|
|
|
|
* line4
|
|
|
|
* line5 <--- curroffset (terminal output to that line)
|
|
|
|
* line0
|
|
|
|
* line1 <--- roffset (history display from that point)
|
|
|
|
* line2
|
|
|
|
* line3
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vthistory_seek(struct vt_buf *vb, int offset, int whence)
|
|
|
|
{
|
2013-10-24 21:43:46 +00:00
|
|
|
int diff, top, bottom, roffset;
|
2013-10-08 12:40:04 +00:00
|
|
|
|
|
|
|
/* No scrolling if not enabled. */
|
|
|
|
if ((vb->vb_flags & VBF_SCROLL) == 0) {
|
|
|
|
if (vb->vb_roffset != vb->vb_curroffset) {
|
|
|
|
vb->vb_roffset = vb->vb_curroffset;
|
2013-10-24 21:43:46 +00:00
|
|
|
return (0xffff);
|
2013-10-08 12:40:04 +00:00
|
|
|
}
|
|
|
|
return (0); /* No changes */
|
|
|
|
}
|
2013-10-23 14:15:46 +00:00
|
|
|
top = (vb->vb_flags & VBF_HISTORY_FULL)?
|
|
|
|
(vb->vb_curroffset + vb->vb_scr_size.tp_row):vb->vb_history_size;
|
|
|
|
bottom = vb->vb_curroffset + vb->vb_history_size;
|
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
/*
|
|
|
|
* Operate on copy of offset value, since it temporary can be bigger
|
|
|
|
* than amount of rows in buffer.
|
|
|
|
*/
|
2013-10-23 14:15:46 +00:00
|
|
|
roffset = vb->vb_roffset + vb->vb_history_size;
|
2013-10-08 12:40:04 +00:00
|
|
|
switch (whence) {
|
|
|
|
case VHS_SET:
|
2013-10-24 21:43:46 +00:00
|
|
|
roffset = offset + vb->vb_history_size;
|
2013-10-08 12:40:04 +00:00
|
|
|
break;
|
|
|
|
case VHS_CUR:
|
|
|
|
roffset += offset;
|
|
|
|
break;
|
|
|
|
case VHS_END:
|
|
|
|
/* Go to current offset. */
|
2013-10-24 21:43:46 +00:00
|
|
|
roffset = vb->vb_curroffset + vb->vb_history_size;
|
2013-10-08 12:40:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-23 14:15:46 +00:00
|
|
|
roffset = (roffset < top)?top:roffset;
|
|
|
|
roffset = (roffset > bottom)?bottom:roffset;
|
|
|
|
|
|
|
|
roffset %= vb->vb_history_size;
|
2013-10-08 12:40:04 +00:00
|
|
|
|
|
|
|
if (vb->vb_roffset != roffset) {
|
2013-10-24 21:43:46 +00:00
|
|
|
diff = vb->vb_roffset - roffset;
|
2013-10-08 12:40:04 +00:00
|
|
|
vb->vb_roffset = roffset;
|
2013-10-24 21:43:46 +00:00
|
|
|
/*
|
|
|
|
* Offset changed, please update Nth lines on sceen.
|
|
|
|
* +N - Nth lines at top;
|
|
|
|
* -N - Nth lines at bottom.
|
|
|
|
*/
|
|
|
|
return (diff);
|
2013-10-08 12:40:04 +00:00
|
|
|
}
|
|
|
|
return (0); /* No changes */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vthistory_addlines(struct vt_buf *vb, int offset)
|
|
|
|
{
|
|
|
|
|
|
|
|
vb->vb_curroffset += offset;
|
|
|
|
if (vb->vb_curroffset < 0)
|
|
|
|
vb->vb_curroffset = 0;
|
|
|
|
vb->vb_curroffset %= vb->vb_history_size;
|
|
|
|
if ((vb->vb_flags & VBF_SCROLL) == 0) {
|
|
|
|
vb->vb_roffset = vb->vb_curroffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vthistory_getpos(const struct vt_buf *vb, unsigned int *offset)
|
|
|
|
{
|
|
|
|
|
|
|
|
*offset = vb->vb_roffset;
|
|
|
|
}
|
2011-03-22 21:31:31 +00:00
|
|
|
|
2013-12-09 15:01:34 +00:00
|
|
|
#ifndef SC_NO_CUTPASTE /* Only mouse support use it now. */
|
2013-11-13 12:32:41 +00:00
|
|
|
/* Translate current view row number to history row. */
|
|
|
|
static int
|
|
|
|
vtbuf_wth(struct vt_buf *vb, int row)
|
|
|
|
{
|
|
|
|
|
|
|
|
return ((vb->vb_roffset + row) % vb->vb_history_size);
|
|
|
|
}
|
2013-12-09 15:01:34 +00:00
|
|
|
#endif
|
2013-11-13 12:32:41 +00:00
|
|
|
|
|
|
|
/* Translate history row to current view row number. */
|
|
|
|
static int
|
2014-08-21 18:26:32 +00:00
|
|
|
vtbuf_htw(const struct vt_buf *vb, int row)
|
2013-11-13 12:32:41 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* total 1000 rows.
|
|
|
|
* History offset roffset winrow
|
|
|
|
* 205 200 ((205 - 200 + 1000) % 1000) = 5
|
|
|
|
* 90 990 ((90 - 990 + 1000) % 1000) = 100
|
|
|
|
*/
|
|
|
|
return ((row - vb->vb_roffset + vb->vb_history_size) %
|
|
|
|
vb->vb_history_size);
|
|
|
|
}
|
|
|
|
|
2013-11-11 11:50:17 +00:00
|
|
|
int
|
2014-08-21 18:26:32 +00:00
|
|
|
vtbuf_iscursor(const struct vt_buf *vb, int row, int col)
|
2013-11-11 11:50:17 +00:00
|
|
|
{
|
2013-11-13 12:32:41 +00:00
|
|
|
int sc, sr, ec, er, tmp;
|
|
|
|
|
|
|
|
if ((vb->vb_flags & (VBF_CURSOR|VBF_SCROLL)) == VBF_CURSOR &&
|
|
|
|
(vb->vb_cursor.tp_row == row) && (vb->vb_cursor.tp_col == col))
|
2013-11-11 11:50:17 +00:00
|
|
|
return (1);
|
|
|
|
|
2013-11-13 12:32:41 +00:00
|
|
|
/* Mark cut/paste region. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Luckily screen view is not like circular buffer, so we will
|
|
|
|
* calculate in screen coordinates. Translate first.
|
|
|
|
*/
|
|
|
|
sc = vb->vb_mark_start.tp_col;
|
|
|
|
sr = vtbuf_htw(vb, vb->vb_mark_start.tp_row);
|
|
|
|
ec = vb->vb_mark_end.tp_col;
|
|
|
|
er = vtbuf_htw(vb, vb->vb_mark_end.tp_row);
|
|
|
|
|
|
|
|
|
|
|
|
/* Swap start and end if start > end. */
|
|
|
|
if (POS_INDEX(sc, sr) > POS_INDEX(ec, er)) {
|
|
|
|
tmp = sc; sc = ec; ec = tmp;
|
|
|
|
tmp = sr; sr = er; er = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((POS_INDEX(sc, sr) <= POS_INDEX(col, row)) &&
|
|
|
|
(POS_INDEX(col, row) < POS_INDEX(ec, er)))
|
2013-11-11 11:50:17 +00:00
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-03-22 21:31:31 +00:00
|
|
|
static inline uint64_t
|
|
|
|
vtbuf_dirty_axis(unsigned int begin, unsigned int end)
|
|
|
|
{
|
|
|
|
uint64_t left, right, mask;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark all bits between begin % 64 and end % 64 dirty.
|
|
|
|
* This code is functionally equivalent to:
|
|
|
|
*
|
|
|
|
* for (i = begin; i < end; i++)
|
|
|
|
* mask |= (uint64_t)1 << (i % 64);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Obvious case. Mark everything dirty. */
|
|
|
|
if (end - begin >= 64)
|
|
|
|
return (VBM_DIRTY);
|
|
|
|
|
|
|
|
/* 1....0; used bits on the left. */
|
|
|
|
left = VBM_DIRTY << begin % 64;
|
|
|
|
/* 0....1; used bits on the right. */
|
|
|
|
right = VBM_DIRTY >> -end % 64;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only take the intersection. If the result of that is 0, it
|
|
|
|
* means that the selection crossed a 64 bit boundary along the
|
|
|
|
* way, which means we have to take the complement.
|
|
|
|
*/
|
|
|
|
mask = left & right;
|
|
|
|
if (mask == 0)
|
|
|
|
mask = left | right;
|
|
|
|
return (mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area)
|
2011-03-22 21:31:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (vb->vb_dirtyrect.tr_begin.tp_row > area->tr_begin.tp_row)
|
|
|
|
vb->vb_dirtyrect.tr_begin.tp_row = area->tr_begin.tp_row;
|
|
|
|
if (vb->vb_dirtyrect.tr_begin.tp_col > area->tr_begin.tp_col)
|
|
|
|
vb->vb_dirtyrect.tr_begin.tp_col = area->tr_begin.tp_col;
|
|
|
|
if (vb->vb_dirtyrect.tr_end.tp_row < area->tr_end.tp_row)
|
|
|
|
vb->vb_dirtyrect.tr_end.tp_row = area->tr_end.tp_row;
|
|
|
|
if (vb->vb_dirtyrect.tr_end.tp_col < area->tr_end.tp_col)
|
|
|
|
vb->vb_dirtyrect.tr_end.tp_col = area->tr_end.tp_col;
|
|
|
|
vb->vb_dirtymask.vbm_row |=
|
|
|
|
vtbuf_dirty_axis(area->tr_begin.tp_row, area->tr_end.tp_row);
|
|
|
|
vb->vb_dirtymask.vbm_col |=
|
|
|
|
vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col);
|
2014-08-10 15:02:51 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 17:09:31 +00:00
|
|
|
void
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area)
|
|
|
|
{
|
|
|
|
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
vtbuf_dirty_locked(vb, area);
|
2011-03-22 21:31:31 +00:00
|
|
|
VTBUF_UNLOCK(vb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_cell_locked(struct vt_buf *vb, const term_pos_t *p)
|
2011-03-22 21:31:31 +00:00
|
|
|
{
|
|
|
|
term_rect_t area;
|
|
|
|
|
|
|
|
area.tr_begin = *p;
|
|
|
|
area.tr_end.tp_row = p->tp_row + 1;
|
|
|
|
area.tr_end.tp_col = p->tp_col + 1;
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_locked(vb, &area);
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vtbuf_make_undirty(struct vt_buf *vb)
|
|
|
|
{
|
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
vb->vb_dirtyrect.tr_begin = vb->vb_scr_size;
|
2011-03-22 21:31:31 +00:00
|
|
|
vb->vb_dirtyrect.tr_end.tp_row = vb->vb_dirtyrect.tr_end.tp_col = 0;
|
|
|
|
vb->vb_dirtymask.vbm_row = vb->vb_dirtymask.vbm_col = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_undirty(struct vt_buf *vb, term_rect_t *r, struct vt_bufmask *m)
|
|
|
|
{
|
|
|
|
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
*r = vb->vb_dirtyrect;
|
|
|
|
*m = vb->vb_dirtymask;
|
|
|
|
vtbuf_make_undirty(vb);
|
|
|
|
VTBUF_UNLOCK(vb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_copy(struct vt_buf *vb, const term_rect_t *r, const term_pos_t *p2)
|
|
|
|
{
|
|
|
|
const term_pos_t *p1 = &r->tr_begin;
|
|
|
|
term_rect_t area;
|
|
|
|
unsigned int rows, cols;
|
2013-10-08 12:40:04 +00:00
|
|
|
int pr, rdiff;
|
|
|
|
|
|
|
|
KASSERT(r->tr_begin.tp_row < vb->vb_scr_size.tp_row,
|
|
|
|
("vtbuf_copy begin.tp_row %d must be less than screen width %d",
|
|
|
|
r->tr_begin.tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(r->tr_begin.tp_col < vb->vb_scr_size.tp_col,
|
|
|
|
("vtbuf_copy begin.tp_col %d must be less than screen height %d",
|
|
|
|
r->tr_begin.tp_col, vb->vb_scr_size.tp_col));
|
|
|
|
|
|
|
|
KASSERT(r->tr_end.tp_row <= vb->vb_scr_size.tp_row,
|
|
|
|
("vtbuf_copy end.tp_row %d must be less than screen width %d",
|
|
|
|
r->tr_end.tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(r->tr_end.tp_col <= vb->vb_scr_size.tp_col,
|
|
|
|
("vtbuf_copy end.tp_col %d must be less than screen height %d",
|
|
|
|
r->tr_end.tp_col, vb->vb_scr_size.tp_col));
|
|
|
|
|
|
|
|
KASSERT(p2->tp_row < vb->vb_scr_size.tp_row,
|
|
|
|
("vtbuf_copy tp_row %d must be less than screen width %d",
|
|
|
|
p2->tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(p2->tp_col < vb->vb_scr_size.tp_col,
|
|
|
|
("vtbuf_copy tp_col %d must be less than screen height %d",
|
|
|
|
p2->tp_col, vb->vb_scr_size.tp_col));
|
2011-03-22 21:31:31 +00:00
|
|
|
|
|
|
|
rows = r->tr_end.tp_row - r->tr_begin.tp_row;
|
2013-10-08 12:40:04 +00:00
|
|
|
rdiff = r->tr_begin.tp_row - p2->tp_row;
|
2011-03-22 21:31:31 +00:00
|
|
|
cols = r->tr_end.tp_col - r->tr_begin.tp_col;
|
2013-10-08 12:40:04 +00:00
|
|
|
if (r->tr_begin.tp_row > p2->tp_row && r->tr_begin.tp_col == 0 &&
|
|
|
|
r->tr_end.tp_col == vb->vb_scr_size.tp_col && /* Full row. */
|
|
|
|
(rows + rdiff) == vb->vb_scr_size.tp_row && /* Whole screen. */
|
|
|
|
rdiff > 0) { /* Only forward dirrection. Do not eat history. */
|
|
|
|
vthistory_addlines(vb, rdiff);
|
|
|
|
} else if (p2->tp_row < p1->tp_row) {
|
|
|
|
/* Handle overlapping copies of line segments. */
|
2011-03-22 21:31:31 +00:00
|
|
|
/* Move data up. */
|
|
|
|
for (pr = 0; pr < rows; pr++)
|
|
|
|
memmove(
|
|
|
|
&VTBUF_FIELD(vb, p2->tp_row + pr, p2->tp_col),
|
|
|
|
&VTBUF_FIELD(vb, p1->tp_row + pr, p1->tp_col),
|
|
|
|
cols * sizeof(term_char_t));
|
|
|
|
} else {
|
|
|
|
/* Move data down. */
|
|
|
|
for (pr = rows - 1; pr >= 0; pr--)
|
|
|
|
memmove(
|
|
|
|
&VTBUF_FIELD(vb, p2->tp_row + pr, p2->tp_col),
|
|
|
|
&VTBUF_FIELD(vb, p1->tp_row + pr, p1->tp_col),
|
|
|
|
cols * sizeof(term_char_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
area.tr_begin = *p2;
|
2013-10-08 12:40:04 +00:00
|
|
|
area.tr_end.tp_row = MIN(p2->tp_row + rows, vb->vb_scr_size.tp_row);
|
|
|
|
area.tr_end.tp_col = MIN(p2->tp_col + cols, vb->vb_scr_size.tp_col);
|
2011-03-22 21:31:31 +00:00
|
|
|
vtbuf_dirty(vb, &area);
|
|
|
|
}
|
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
static void
|
2011-03-22 21:31:31 +00:00
|
|
|
vtbuf_fill(struct vt_buf *vb, const term_rect_t *r, term_char_t c)
|
|
|
|
{
|
|
|
|
unsigned int pr, pc;
|
2013-10-08 12:40:04 +00:00
|
|
|
term_char_t *row;
|
|
|
|
|
|
|
|
for (pr = r->tr_begin.tp_row; pr < r->tr_end.tp_row; pr++) {
|
|
|
|
row = vb->vb_rows[(vb->vb_curroffset + pr) %
|
|
|
|
VTBUF_MAX_HEIGHT(vb)];
|
|
|
|
for (pc = r->tr_begin.tp_col; pc < r->tr_end.tp_col; pc++) {
|
|
|
|
row[pc] = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_fill_locked(struct vt_buf *vb, const term_rect_t *r, term_char_t c)
|
|
|
|
{
|
|
|
|
KASSERT(r->tr_begin.tp_row < vb->vb_scr_size.tp_row,
|
2014-05-29 20:26:01 +00:00
|
|
|
("vtbuf_fill_locked begin.tp_row %d must be < screen height %d",
|
2013-10-08 12:40:04 +00:00
|
|
|
r->tr_begin.tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(r->tr_begin.tp_col < vb->vb_scr_size.tp_col,
|
2014-05-29 20:26:01 +00:00
|
|
|
("vtbuf_fill_locked begin.tp_col %d must be < screen width %d",
|
2013-10-08 12:40:04 +00:00
|
|
|
r->tr_begin.tp_col, vb->vb_scr_size.tp_col));
|
|
|
|
|
|
|
|
KASSERT(r->tr_end.tp_row <= vb->vb_scr_size.tp_row,
|
2014-05-29 20:26:01 +00:00
|
|
|
("vtbuf_fill_locked end.tp_row %d must be <= screen height %d",
|
2013-10-08 12:40:04 +00:00
|
|
|
r->tr_end.tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(r->tr_end.tp_col <= vb->vb_scr_size.tp_col,
|
2014-05-29 20:26:01 +00:00
|
|
|
("vtbuf_fill_locked end.tp_col %d must be <= screen width %d",
|
2013-10-08 12:40:04 +00:00
|
|
|
r->tr_end.tp_col, vb->vb_scr_size.tp_col));
|
2011-03-22 21:31:31 +00:00
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
vtbuf_fill(vb, r, c);
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_locked(vb, r);
|
2013-10-08 12:40:04 +00:00
|
|
|
VTBUF_UNLOCK(vb);
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
static void
|
|
|
|
vtbuf_init_rows(struct vt_buf *vb)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
vb->vb_history_size = MAX(vb->vb_history_size, vb->vb_scr_size.tp_row);
|
|
|
|
|
|
|
|
for (r = 0; r < vb->vb_history_size; r++)
|
2014-06-27 19:57:57 +00:00
|
|
|
vb->vb_rows[r] = &vb->vb_buffer[r * vb->vb_scr_size.tp_col];
|
2013-10-08 12:40:04 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 21:31:31 +00:00
|
|
|
void
|
|
|
|
vtbuf_init_early(struct vt_buf *vb)
|
|
|
|
{
|
2014-06-27 19:57:57 +00:00
|
|
|
term_rect_t rect;
|
2011-03-22 21:31:31 +00:00
|
|
|
|
|
|
|
vb->vb_flags |= VBF_CURSOR;
|
2013-10-08 12:40:04 +00:00
|
|
|
vb->vb_roffset = 0;
|
|
|
|
vb->vb_curroffset = 0;
|
2013-11-13 12:32:41 +00:00
|
|
|
vb->vb_mark_start.tp_row = 0;
|
|
|
|
vb->vb_mark_start.tp_col = 0;
|
|
|
|
vb->vb_mark_end.tp_row = 0;
|
|
|
|
vb->vb_mark_end.tp_col = 0;
|
2013-10-08 12:40:04 +00:00
|
|
|
|
|
|
|
vtbuf_init_rows(vb);
|
2014-06-27 19:57:57 +00:00
|
|
|
rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0;
|
vt(4): When creating a window buffer, fill it entirely
... not just the visible part.
This fixes a bug where, when switching from eg. vt_vga to vt_fb (ie. the
resolution goes up), the originally hidden, uninitialized area of the
buffer is displayed on the screen. This leads to a missing text cursor
when it's over an unitialized area.
This was also visible when selecting text: the uninitialized area was
not highlighted.
Internally, this area was zeroed: characters were all 0x00000000,
meaning the foreground and background color was black. Now, everything
is filled with a space with a gray foreground color, like the visible
area.
While here, remove the check for the mute flag and always use
TERMINAL_NORM_ATTR as the character attribute (ie. gray foreground,
black background).
MFC after: 1 week
2014-08-26 17:48:05 +00:00
|
|
|
rect.tr_end.tp_col = vb->vb_scr_size.tp_col;
|
|
|
|
rect.tr_end.tp_row = vb->vb_history_size;
|
|
|
|
vtbuf_fill(vb, &rect, VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR));
|
2011-03-22 21:31:31 +00:00
|
|
|
vtbuf_make_undirty(vb);
|
2013-10-08 12:40:04 +00:00
|
|
|
if ((vb->vb_flags & VBF_MTX_INIT) == 0) {
|
|
|
|
mtx_init(&vb->vb_lock, "vtbuf", NULL, MTX_SPIN);
|
|
|
|
vb->vb_flags |= VBF_MTX_INIT;
|
|
|
|
}
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_init(struct vt_buf *vb, const term_pos_t *p)
|
|
|
|
{
|
2013-10-08 12:40:04 +00:00
|
|
|
int sz;
|
|
|
|
|
|
|
|
vb->vb_scr_size = *p;
|
|
|
|
vb->vb_history_size = VBF_DEFAULT_HISTORY_SIZE;
|
|
|
|
|
|
|
|
if ((vb->vb_flags & VBF_STATIC) == 0) {
|
|
|
|
sz = vb->vb_history_size * p->tp_col * sizeof(term_char_t);
|
2013-10-22 13:53:58 +00:00
|
|
|
vb->vb_buffer = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO);
|
2013-10-08 12:40:04 +00:00
|
|
|
|
|
|
|
sz = vb->vb_history_size * sizeof(term_char_t *);
|
2013-10-22 13:53:58 +00:00
|
|
|
vb->vb_rows = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO);
|
2013-10-08 12:40:04 +00:00
|
|
|
}
|
2011-03-22 21:31:31 +00:00
|
|
|
|
|
|
|
vtbuf_init_early(vb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-08 12:40:04 +00:00
|
|
|
vtbuf_sethistory_size(struct vt_buf *vb, int size)
|
|
|
|
{
|
|
|
|
term_pos_t p;
|
|
|
|
|
|
|
|
/* With same size */
|
|
|
|
p.tp_row = vb->vb_scr_size.tp_row;
|
|
|
|
p.tp_col = vb->vb_scr_size.tp_col;
|
|
|
|
vtbuf_grow(vb, &p, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-08-29 08:16:31 +00:00
|
|
|
vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size)
|
2011-03-22 21:31:31 +00:00
|
|
|
{
|
2013-10-08 12:40:04 +00:00
|
|
|
term_char_t *old, *new, **rows, **oldrows, **copyrows, *row;
|
|
|
|
int bufsize, rowssize, w, h, c, r;
|
|
|
|
term_rect_t rect;
|
2011-03-22 21:31:31 +00:00
|
|
|
|
2013-10-08 12:40:04 +00:00
|
|
|
history_size = MAX(history_size, p->tp_row);
|
|
|
|
|
2014-05-08 13:46:36 +00:00
|
|
|
/* If new screen/history size bigger or buffer is VBF_STATIC. */
|
|
|
|
if ((history_size > vb->vb_history_size) || (p->tp_col >
|
|
|
|
vb->vb_scr_size.tp_col) || (vb->vb_flags & VBF_STATIC)) {
|
2011-03-22 21:31:31 +00:00
|
|
|
/* Allocate new buffer. */
|
2013-10-08 12:40:04 +00:00
|
|
|
bufsize = history_size * p->tp_col * sizeof(term_char_t);
|
2013-10-22 13:53:58 +00:00
|
|
|
new = malloc(bufsize, M_VTBUF, M_WAITOK | M_ZERO);
|
2013-10-08 12:40:04 +00:00
|
|
|
rowssize = history_size * sizeof(term_pos_t *);
|
2013-10-22 13:53:58 +00:00
|
|
|
rows = malloc(rowssize, M_VTBUF, M_WAITOK | M_ZERO);
|
2011-03-22 21:31:31 +00:00
|
|
|
|
|
|
|
/* Toggle it. */
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
old = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_buffer;
|
2013-10-08 12:40:04 +00:00
|
|
|
oldrows = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_rows;
|
|
|
|
copyrows = vb->vb_rows;
|
|
|
|
w = vb->vb_scr_size.tp_col;
|
|
|
|
h = vb->vb_history_size;
|
|
|
|
|
|
|
|
vb->vb_history_size = history_size;
|
2011-03-22 21:31:31 +00:00
|
|
|
vb->vb_buffer = new;
|
2013-10-08 12:40:04 +00:00
|
|
|
vb->vb_rows = rows;
|
2011-03-22 21:31:31 +00:00
|
|
|
vb->vb_flags &= ~VBF_STATIC;
|
2013-10-08 12:40:04 +00:00
|
|
|
vb->vb_scr_size = *p;
|
|
|
|
vtbuf_init_rows(vb);
|
|
|
|
|
|
|
|
/* Copy history and fill extra space. */
|
|
|
|
for (r = 0; r < history_size; r ++) {
|
2014-06-27 19:57:57 +00:00
|
|
|
/*
|
|
|
|
* XXX VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR) will
|
|
|
|
* extended lines of kernel text using the wrong
|
|
|
|
* background color.
|
|
|
|
*/
|
2013-10-08 12:40:04 +00:00
|
|
|
row = rows[r];
|
|
|
|
if (r < h) { /* Copy. */
|
|
|
|
memmove(rows[r], copyrows[r],
|
|
|
|
MIN(p->tp_col, w) * sizeof(term_char_t));
|
|
|
|
for (c = MIN(p->tp_col, w); c < p->tp_col;
|
|
|
|
c++) {
|
2014-06-27 19:57:57 +00:00
|
|
|
row[c] = VTBUF_SPACE_CHAR(
|
|
|
|
TERMINAL_NORM_ATTR);
|
2013-10-08 12:40:04 +00:00
|
|
|
}
|
|
|
|
} else { /* Just fill. */
|
|
|
|
rect.tr_begin.tp_col = 0;
|
|
|
|
rect.tr_begin.tp_row = r;
|
|
|
|
rect.tr_end.tp_col = p->tp_col;
|
|
|
|
rect.tr_end.tp_row = p->tp_row;
|
2014-06-27 19:57:57 +00:00
|
|
|
vtbuf_fill(vb, &rect,
|
|
|
|
VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR));
|
2013-10-08 12:40:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-03-22 21:31:31 +00:00
|
|
|
vtbuf_make_undirty(vb);
|
|
|
|
VTBUF_UNLOCK(vb);
|
|
|
|
/* Deallocate old buffer. */
|
2013-10-08 12:40:04 +00:00
|
|
|
free(old, M_VTBUF);
|
|
|
|
free(oldrows, M_VTBUF);
|
2014-05-29 21:10:33 +00:00
|
|
|
} else {
|
|
|
|
/* Just update the size. */
|
|
|
|
vb->vb_scr_size = *p;
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_putchar(struct vt_buf *vb, const term_pos_t *p, term_char_t c)
|
|
|
|
{
|
2013-10-08 12:40:04 +00:00
|
|
|
term_char_t *row;
|
|
|
|
|
|
|
|
KASSERT(p->tp_row < vb->vb_scr_size.tp_row,
|
|
|
|
("vtbuf_putchar tp_row %d must be less than screen width %d",
|
|
|
|
p->tp_row, vb->vb_scr_size.tp_row));
|
|
|
|
KASSERT(p->tp_col < vb->vb_scr_size.tp_col,
|
|
|
|
("vtbuf_putchar tp_col %d must be less than screen height %d",
|
|
|
|
p->tp_col, vb->vb_scr_size.tp_col));
|
|
|
|
|
|
|
|
row = vb->vb_rows[(vb->vb_curroffset + p->tp_row) %
|
|
|
|
VTBUF_MAX_HEIGHT(vb)];
|
|
|
|
if (row[p->tp_col] != c) {
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
row[p->tp_col] = c;
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_cell_locked(vb, p);
|
2013-10-08 12:40:04 +00:00
|
|
|
VTBUF_UNLOCK(vb);
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_cursor_position(struct vt_buf *vb, const term_pos_t *p)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (vb->vb_flags & VBF_CURSOR) {
|
2014-08-10 15:02:51 +00:00
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
|
2011-03-22 21:31:31 +00:00
|
|
|
vb->vb_cursor = *p;
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
|
|
|
|
VTBUF_UNLOCK(vb);
|
2011-03-22 21:31:31 +00:00
|
|
|
} else {
|
|
|
|
vb->vb_cursor = *p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 15:01:34 +00:00
|
|
|
#ifndef SC_NO_CUTPASTE
|
2013-11-13 12:32:41 +00:00
|
|
|
static void
|
|
|
|
vtbuf_flush_mark(struct vt_buf *vb)
|
|
|
|
{
|
|
|
|
term_rect_t area;
|
|
|
|
int s, e;
|
|
|
|
|
|
|
|
/* Notify renderer to update marked region. */
|
|
|
|
if (vb->vb_mark_start.tp_col || vb->vb_mark_end.tp_col ||
|
|
|
|
vb->vb_mark_start.tp_row || vb->vb_mark_end.tp_row) {
|
|
|
|
|
|
|
|
s = vtbuf_htw(vb, vb->vb_mark_start.tp_row);
|
|
|
|
e = vtbuf_htw(vb, vb->vb_mark_end.tp_row);
|
|
|
|
|
|
|
|
area.tr_begin.tp_col = 0;
|
|
|
|
area.tr_begin.tp_row = MIN(s, e);
|
|
|
|
|
|
|
|
area.tr_end.tp_col = vb->vb_scr_size.tp_col;
|
|
|
|
area.tr_end.tp_row = MAX(s, e) + 1;
|
|
|
|
|
|
|
|
vtbuf_dirty(vb, &area);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
vtbuf_get_marked_len(struct vt_buf *vb)
|
|
|
|
{
|
|
|
|
int ei, si, sz;
|
|
|
|
term_pos_t s, e;
|
|
|
|
|
|
|
|
/* Swap according to window coordinates. */
|
2013-11-14 15:14:27 +00:00
|
|
|
if (POS_INDEX(vtbuf_htw(vb, vb->vb_mark_start.tp_row),
|
|
|
|
vb->vb_mark_start.tp_col) >
|
|
|
|
POS_INDEX(vtbuf_htw(vb, vb->vb_mark_end.tp_row),
|
|
|
|
vb->vb_mark_end.tp_col)) {
|
2013-11-13 12:32:41 +00:00
|
|
|
POS_COPY(e, vb->vb_mark_start);
|
|
|
|
POS_COPY(s, vb->vb_mark_end);
|
|
|
|
} else {
|
|
|
|
POS_COPY(s, vb->vb_mark_start);
|
|
|
|
POS_COPY(e, vb->vb_mark_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
si = s.tp_row * vb->vb_scr_size.tp_col + s.tp_col;
|
|
|
|
ei = e.tp_row * vb->vb_scr_size.tp_col + e.tp_col;
|
|
|
|
|
|
|
|
/* Number symbols and number of rows to inject \n */
|
|
|
|
sz = ei - si + ((e.tp_row - s.tp_row) * 2) + 1;
|
|
|
|
|
|
|
|
return (sz * sizeof(term_char_t));
|
|
|
|
}
|
|
|
|
|
2013-11-11 11:50:17 +00:00
|
|
|
void
|
2013-11-13 12:32:41 +00:00
|
|
|
vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz)
|
|
|
|
{
|
|
|
|
int i, r, c, cs, ce;
|
|
|
|
term_pos_t s, e;
|
|
|
|
|
|
|
|
/* Swap according to window coordinates. */
|
2013-11-14 15:14:27 +00:00
|
|
|
if (POS_INDEX(vtbuf_htw(vb, vb->vb_mark_start.tp_row),
|
|
|
|
vb->vb_mark_start.tp_col) >
|
|
|
|
POS_INDEX(vtbuf_htw(vb, vb->vb_mark_end.tp_row),
|
|
|
|
vb->vb_mark_end.tp_col)) {
|
2013-11-13 12:32:41 +00:00
|
|
|
POS_COPY(e, vb->vb_mark_start);
|
|
|
|
POS_COPY(s, vb->vb_mark_end);
|
|
|
|
} else {
|
|
|
|
POS_COPY(s, vb->vb_mark_start);
|
|
|
|
POS_COPY(e, vb->vb_mark_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
for (r = s.tp_row; r <= e.tp_row; r ++) {
|
|
|
|
cs = (r == s.tp_row)?s.tp_col:0;
|
|
|
|
ce = (r == e.tp_row)?e.tp_col:vb->vb_scr_size.tp_col;
|
|
|
|
for (c = cs; c < ce; c ++) {
|
|
|
|
buf[i++] = vb->vb_rows[r][c];
|
|
|
|
}
|
2013-11-13 14:35:00 +00:00
|
|
|
/* Add new line for all rows, but not for last one. */
|
|
|
|
if (r != e.tp_row) {
|
|
|
|
buf[i++] = '\r';
|
|
|
|
buf[i++] = '\n';
|
|
|
|
}
|
2013-11-13 12:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-11-11 11:50:17 +00:00
|
|
|
vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row)
|
|
|
|
{
|
2013-11-14 15:44:22 +00:00
|
|
|
term_char_t *r;
|
|
|
|
int i;
|
2013-11-11 11:50:17 +00:00
|
|
|
|
|
|
|
switch (type) {
|
2013-11-14 13:25:47 +00:00
|
|
|
case VTB_MARK_END: /* B1 UP */
|
|
|
|
if (vb->vb_mark_last != VTB_MARK_MOVE)
|
|
|
|
return (0);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case VTB_MARK_MOVE:
|
2013-11-11 11:50:17 +00:00
|
|
|
case VTB_MARK_EXTEND:
|
2013-11-13 12:32:41 +00:00
|
|
|
vtbuf_flush_mark(vb); /* Clean old mark. */
|
2013-11-11 11:50:17 +00:00
|
|
|
vb->vb_mark_end.tp_col = col;
|
2013-11-13 12:32:41 +00:00
|
|
|
vb->vb_mark_end.tp_row = vtbuf_wth(vb, row);
|
2013-11-11 11:50:17 +00:00
|
|
|
break;
|
|
|
|
case VTB_MARK_START:
|
2013-11-13 12:32:41 +00:00
|
|
|
vtbuf_flush_mark(vb); /* Clean old mark. */
|
2013-11-11 11:50:17 +00:00
|
|
|
vb->vb_mark_start.tp_col = col;
|
2013-11-13 12:32:41 +00:00
|
|
|
vb->vb_mark_start.tp_row = vtbuf_wth(vb, row);
|
2013-11-11 11:50:17 +00:00
|
|
|
/* Start again, so clear end point. */
|
2013-11-13 12:32:41 +00:00
|
|
|
vb->vb_mark_end.tp_col = col;
|
|
|
|
vb->vb_mark_end.tp_row = vtbuf_wth(vb, row);
|
2013-11-11 11:50:17 +00:00
|
|
|
break;
|
|
|
|
case VTB_MARK_WORD:
|
2013-11-13 12:32:41 +00:00
|
|
|
vtbuf_flush_mark(vb); /* Clean old mark. */
|
|
|
|
vb->vb_mark_start.tp_row = vb->vb_mark_end.tp_row =
|
|
|
|
vtbuf_wth(vb, row);
|
2013-11-14 15:44:22 +00:00
|
|
|
r = vb->vb_rows[vb->vb_mark_start.tp_row];
|
|
|
|
for (i = col; i >= 0; i --) {
|
|
|
|
if (TCHAR_CHARACTER(r[i]) == ' ') {
|
|
|
|
vb->vb_mark_start.tp_col = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = col; i < vb->vb_scr_size.tp_col; i ++) {
|
|
|
|
if (TCHAR_CHARACTER(r[i]) == ' ') {
|
|
|
|
vb->vb_mark_end.tp_col = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (vb->vb_mark_start.tp_col > vb->vb_mark_end.tp_col)
|
|
|
|
vb->vb_mark_start.tp_col = vb->vb_mark_end.tp_col;
|
2013-11-11 11:50:17 +00:00
|
|
|
break;
|
|
|
|
case VTB_MARK_ROW:
|
2013-11-13 12:32:41 +00:00
|
|
|
vtbuf_flush_mark(vb); /* Clean old mark. */
|
2013-11-11 11:50:17 +00:00
|
|
|
vb->vb_mark_start.tp_col = 0;
|
|
|
|
vb->vb_mark_end.tp_col = vb->vb_scr_size.tp_col;
|
2013-11-13 12:32:41 +00:00
|
|
|
vb->vb_mark_start.tp_row = vb->vb_mark_end.tp_row =
|
|
|
|
vtbuf_wth(vb, row);
|
2013-11-11 11:50:17 +00:00
|
|
|
break;
|
2013-11-13 12:32:41 +00:00
|
|
|
case VTB_MARK_NONE:
|
2013-11-14 13:25:47 +00:00
|
|
|
vb->vb_mark_last = type;
|
|
|
|
/* FALLTHROUGH */
|
2013-11-13 12:32:41 +00:00
|
|
|
default:
|
|
|
|
/* panic? */
|
|
|
|
return (0);
|
2013-11-11 11:50:17 +00:00
|
|
|
}
|
2013-11-14 00:00:55 +00:00
|
|
|
|
2013-11-14 13:25:47 +00:00
|
|
|
vb->vb_mark_last = type;
|
2013-11-14 00:00:55 +00:00
|
|
|
/* Draw new marked region. */
|
|
|
|
vtbuf_flush_mark(vb);
|
|
|
|
return (1);
|
2013-11-11 11:50:17 +00:00
|
|
|
}
|
2013-12-09 15:01:34 +00:00
|
|
|
#endif
|
2013-11-11 11:50:17 +00:00
|
|
|
|
2011-03-22 21:31:31 +00:00
|
|
|
void
|
|
|
|
vtbuf_cursor_visibility(struct vt_buf *vb, int yes)
|
|
|
|
{
|
|
|
|
int oflags, nflags;
|
|
|
|
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
oflags = vb->vb_flags;
|
|
|
|
if (yes)
|
|
|
|
vb->vb_flags |= VBF_CURSOR;
|
|
|
|
else
|
|
|
|
vb->vb_flags &= ~VBF_CURSOR;
|
|
|
|
nflags = vb->vb_flags;
|
|
|
|
|
|
|
|
if (oflags != nflags)
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
|
|
|
|
VTBUF_UNLOCK(vb);
|
2011-03-22 21:31:31 +00:00
|
|
|
}
|
2013-11-13 12:32:41 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vtbuf_scroll_mode(struct vt_buf *vb, int yes)
|
|
|
|
{
|
|
|
|
int oflags, nflags;
|
|
|
|
|
|
|
|
VTBUF_LOCK(vb);
|
|
|
|
oflags = vb->vb_flags;
|
|
|
|
if (yes)
|
|
|
|
vb->vb_flags |= VBF_SCROLL;
|
|
|
|
else
|
|
|
|
vb->vb_flags &= ~VBF_SCROLL;
|
|
|
|
nflags = vb->vb_flags;
|
|
|
|
|
|
|
|
if (oflags != nflags)
|
2014-08-10 15:02:51 +00:00
|
|
|
vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
|
|
|
|
VTBUF_UNLOCK(vb);
|
2013-11-13 12:32:41 +00:00
|
|
|
}
|
|
|
|
|