Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/vt/vt_buf.c
Show First 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | vtbuf_init_rows(struct vt_buf *vb) | ||||
int r; | int r; | ||||
vb->vb_history_size = MAX(vb->vb_history_size, vb->vb_scr_size.tp_row); | vb->vb_history_size = MAX(vb->vb_history_size, vb->vb_scr_size.tp_row); | ||||
for (r = 0; r < vb->vb_history_size; r++) | for (r = 0; r < vb->vb_history_size; r++) | ||||
vb->vb_rows[r] = &vb->vb_buffer[r * vb->vb_scr_size.tp_col]; | vb->vb_rows[r] = &vb->vb_buffer[r * vb->vb_scr_size.tp_col]; | ||||
} | } | ||||
void | static void | ||||
vtbuf_init_early(struct vt_buf *vb) | vtbuf_do_clearhistory(struct vt_buf *vb) | ||||
{ | { | ||||
term_rect_t rect; | term_rect_t rect; | ||||
const teken_attr_t *a; | const teken_attr_t *a; | ||||
term_char_t c; | term_char_t ch; | ||||
a = teken_get_curattr(&vb->vb_terminal->tm_emulator); | |||||
ch = TCOLOR_FG(a->ta_fgcolor) | TCOLOR_BG(a->ta_bgcolor); | |||||
rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0; | |||||
rect.tr_end.tp_col = vb->vb_scr_size.tp_col; | |||||
rect.tr_end.tp_row = vb->vb_history_size; | |||||
vtbuf_do_fill(vb, &rect, VTBUF_SPACE_CHAR(ch)); | |||||
} | |||||
void | |||||
vtbuf_init_early(struct vt_buf *vb) | |||||
{ | |||||
vb->vb_flags |= VBF_CURSOR; | vb->vb_flags |= VBF_CURSOR; | ||||
vb->vb_roffset = 0; | vb->vb_roffset = 0; | ||||
vb->vb_curroffset = 0; | vb->vb_curroffset = 0; | ||||
vb->vb_mark_start.tp_row = 0; | vb->vb_mark_start.tp_row = 0; | ||||
vb->vb_mark_start.tp_col = 0; | vb->vb_mark_start.tp_col = 0; | ||||
vb->vb_mark_end.tp_row = 0; | vb->vb_mark_end.tp_row = 0; | ||||
vb->vb_mark_end.tp_col = 0; | vb->vb_mark_end.tp_col = 0; | ||||
vtbuf_init_rows(vb); | vtbuf_init_rows(vb); | ||||
rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0; | vtbuf_do_clearhistory(vb); | ||||
rect.tr_end.tp_col = vb->vb_scr_size.tp_col; | |||||
rect.tr_end.tp_row = vb->vb_history_size; | |||||
a = teken_get_curattr(&vb->vb_terminal->tm_emulator); | |||||
c = TCOLOR_FG((term_char_t)a->ta_fgcolor) | | |||||
TCOLOR_BG((term_char_t)a->ta_bgcolor); | |||||
vtbuf_do_fill(vb, &rect, VTBUF_SPACE_CHAR(c)); | |||||
vtbuf_make_undirty(vb); | vtbuf_make_undirty(vb); | ||||
if ((vb->vb_flags & VBF_MTX_INIT) == 0) { | if ((vb->vb_flags & VBF_MTX_INIT) == 0) { | ||||
mtx_init(&vb->vb_lock, "vtbuf", NULL, MTX_SPIN); | mtx_init(&vb->vb_lock, "vtbuf", NULL, MTX_SPIN); | ||||
vb->vb_flags |= VBF_MTX_INIT; | vb->vb_flags |= VBF_MTX_INIT; | ||||
} | } | ||||
} | } | ||||
void | void | ||||
vtbuf_init(struct vt_buf *vb, const term_pos_t *p) | vtbuf_init(struct vt_buf *vb, const term_pos_t *p) | ||||
{ | { | ||||
int sz; | int sz; | ||||
vb->vb_scr_size = *p; | vb->vb_scr_size = *p; | ||||
vb->vb_history_size = VBF_DEFAULT_HISTORY_SIZE; | vb->vb_history_size = VBF_DEFAULT_HISTORY_SIZE; | ||||
if ((vb->vb_flags & VBF_STATIC) == 0) { | if ((vb->vb_flags & VBF_STATIC) == 0) { | ||||
sz = vb->vb_history_size * p->tp_col * sizeof(term_char_t); | sz = vb->vb_history_size * p->tp_col * sizeof(term_char_t); | ||||
vb->vb_buffer = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO); | vb->vb_buffer = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO); | ||||
sz = vb->vb_history_size * sizeof(term_char_t *); | sz = vb->vb_history_size * sizeof(term_char_t *); | ||||
vb->vb_rows = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO); | vb->vb_rows = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO); | ||||
} | } | ||||
vtbuf_init_early(vb); | vtbuf_init_early(vb); | ||||
} | |||||
void | |||||
vtbuf_clearhistory(struct vt_buf *vb) | |||||
{ | |||||
VTBUF_LOCK(vb); | |||||
vtbuf_do_clearhistory(vb); | |||||
VTBUF_UNLOCK(vb); | |||||
} | } | ||||
void | void | ||||
vtbuf_sethistory_size(struct vt_buf *vb, unsigned int size) | vtbuf_sethistory_size(struct vt_buf *vb, unsigned int size) | ||||
{ | { | ||||
term_pos_t p; | term_pos_t p; | ||||
/* With same size */ | /* With same size */ | ||||
▲ Show 20 Lines • Show All 389 Lines • Show Last 20 Lines |