2 * Copyright (c) 2009, 2013 The FreeBSD Foundation
5 * This software was developed by Ed Schouten under sponsorship from the
8 * Portions of this software were developed by Oleksandr Rybalko
9 * under sponsorship from the FreeBSD Foundation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/kernel.h>
39 #include <sys/malloc.h>
40 #include <sys/mutex.h>
41 #include <sys/reboot.h>
42 #include <sys/systm.h>
44 #include <dev/vt/vt.h>
46 static MALLOC_DEFINE(M_VTBUF, "vtbuf", "vt buffer");
48 #define VTBUF_LOCK(vb) mtx_lock_spin(&(vb)->vb_lock)
49 #define VTBUF_UNLOCK(vb) mtx_unlock_spin(&(vb)->vb_lock)
51 #define POS_INDEX(c, r) (((r) << 12) + (c))
52 #define POS_COPY(d, s) do { \
53 (d).tp_col = (s).tp_col; \
54 (d).tp_row = (s).tp_row; \
60 * line5 <--- curroffset (terminal output to that line)
62 * line1 <--- roffset (history display from that point)
67 vthistory_seek(struct vt_buf *vb, int offset, int whence)
69 int diff, top, bottom, roffset;
71 /* No scrolling if not enabled. */
72 if ((vb->vb_flags & VBF_SCROLL) == 0) {
73 if (vb->vb_roffset != vb->vb_curroffset) {
74 vb->vb_roffset = vb->vb_curroffset;
77 return (0); /* No changes */
79 top = (vb->vb_flags & VBF_HISTORY_FULL)?
80 (vb->vb_curroffset + vb->vb_scr_size.tp_row):vb->vb_history_size;
81 bottom = vb->vb_curroffset + vb->vb_history_size;
84 * Operate on copy of offset value, since it temporary can be bigger
85 * than amount of rows in buffer.
87 roffset = vb->vb_roffset + vb->vb_history_size;
90 roffset = offset + vb->vb_history_size;
96 /* Go to current offset. */
97 roffset = vb->vb_curroffset + vb->vb_history_size;
101 roffset = (roffset < top)?top:roffset;
102 roffset = (roffset > bottom)?bottom:roffset;
104 roffset %= vb->vb_history_size;
106 if (vb->vb_roffset != roffset) {
107 diff = vb->vb_roffset - roffset;
108 vb->vb_roffset = roffset;
110 * Offset changed, please update Nth lines on sceen.
111 * +N - Nth lines at top;
112 * -N - Nth lines at bottom.
116 return (0); /* No changes */
120 vthistory_addlines(struct vt_buf *vb, int offset)
123 vb->vb_curroffset += offset;
124 if (vb->vb_curroffset < 0)
125 vb->vb_curroffset = 0;
126 vb->vb_curroffset %= vb->vb_history_size;
127 if ((vb->vb_flags & VBF_SCROLL) == 0) {
128 vb->vb_roffset = vb->vb_curroffset;
133 vthistory_getpos(const struct vt_buf *vb, unsigned int *offset)
136 *offset = vb->vb_roffset;
139 #ifndef SC_NO_CUTPASTE /* Only mouse support use it now. */
140 /* Translate current view row number to history row. */
142 vtbuf_wth(struct vt_buf *vb, int row)
145 return ((vb->vb_roffset + row) % vb->vb_history_size);
149 /* Translate history row to current view row number. */
151 vtbuf_htw(const struct vt_buf *vb, int row)
156 * History offset roffset winrow
157 * 205 200 ((205 - 200 + 1000) % 1000) = 5
158 * 90 990 ((90 - 990 + 1000) % 1000) = 100
160 return ((row - vb->vb_roffset + vb->vb_history_size) %
161 vb->vb_history_size);
165 vtbuf_iscursor(const struct vt_buf *vb, int row, int col)
167 int sc, sr, ec, er, tmp;
169 if ((vb->vb_flags & (VBF_CURSOR|VBF_SCROLL)) == VBF_CURSOR &&
170 (vb->vb_cursor.tp_row == row) && (vb->vb_cursor.tp_col == col))
173 /* Mark cut/paste region. */
176 * Luckily screen view is not like circular buffer, so we will
177 * calculate in screen coordinates. Translate first.
179 sc = vb->vb_mark_start.tp_col;
180 sr = vtbuf_htw(vb, vb->vb_mark_start.tp_row);
181 ec = vb->vb_mark_end.tp_col;
182 er = vtbuf_htw(vb, vb->vb_mark_end.tp_row);
185 /* Swap start and end if start > end. */
186 if (POS_INDEX(sc, sr) > POS_INDEX(ec, er)) {
187 tmp = sc; sc = ec; ec = tmp;
188 tmp = sr; sr = er; er = tmp;
191 if ((POS_INDEX(sc, sr) <= POS_INDEX(col, row)) &&
192 (POS_INDEX(col, row) < POS_INDEX(ec, er)))
198 static inline uint64_t
199 vtbuf_dirty_axis(unsigned int begin, unsigned int end)
201 uint64_t left, right, mask;
204 * Mark all bits between begin % 64 and end % 64 dirty.
205 * This code is functionally equivalent to:
207 * for (i = begin; i < end; i++)
208 * mask |= (uint64_t)1 << (i % 64);
211 /* Obvious case. Mark everything dirty. */
212 if (end - begin >= 64)
215 /* 1....0; used bits on the left. */
216 left = VBM_DIRTY << begin % 64;
217 /* 0....1; used bits on the right. */
218 right = VBM_DIRTY >> -end % 64;
221 * Only take the intersection. If the result of that is 0, it
222 * means that the selection crossed a 64 bit boundary along the
223 * way, which means we have to take the complement.
232 vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area)
235 if (vb->vb_dirtyrect.tr_begin.tp_row > area->tr_begin.tp_row)
236 vb->vb_dirtyrect.tr_begin.tp_row = area->tr_begin.tp_row;
237 if (vb->vb_dirtyrect.tr_begin.tp_col > area->tr_begin.tp_col)
238 vb->vb_dirtyrect.tr_begin.tp_col = area->tr_begin.tp_col;
239 if (vb->vb_dirtyrect.tr_end.tp_row < area->tr_end.tp_row)
240 vb->vb_dirtyrect.tr_end.tp_row = area->tr_end.tp_row;
241 if (vb->vb_dirtyrect.tr_end.tp_col < area->tr_end.tp_col)
242 vb->vb_dirtyrect.tr_end.tp_col = area->tr_end.tp_col;
243 vb->vb_dirtymask.vbm_row |=
244 vtbuf_dirty_axis(area->tr_begin.tp_row, area->tr_end.tp_row);
245 vb->vb_dirtymask.vbm_col |=
246 vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col);
250 vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area)
254 vtbuf_dirty_locked(vb, area);
259 vtbuf_dirty_cell_locked(struct vt_buf *vb, const term_pos_t *p)
264 area.tr_end.tp_row = p->tp_row + 1;
265 area.tr_end.tp_col = p->tp_col + 1;
266 vtbuf_dirty_locked(vb, &area);
270 vtbuf_make_undirty(struct vt_buf *vb)
273 vb->vb_dirtyrect.tr_begin = vb->vb_scr_size;
274 vb->vb_dirtyrect.tr_end.tp_row = vb->vb_dirtyrect.tr_end.tp_col = 0;
275 vb->vb_dirtymask.vbm_row = vb->vb_dirtymask.vbm_col = 0;
279 vtbuf_undirty(struct vt_buf *vb, term_rect_t *r, struct vt_bufmask *m)
283 *r = vb->vb_dirtyrect;
284 *m = vb->vb_dirtymask;
285 vtbuf_make_undirty(vb);
290 vtbuf_copy(struct vt_buf *vb, const term_rect_t *r, const term_pos_t *p2)
292 const term_pos_t *p1 = &r->tr_begin;
294 unsigned int rows, cols;
297 KASSERT(r->tr_begin.tp_row < vb->vb_scr_size.tp_row,
298 ("vtbuf_copy begin.tp_row %d must be less than screen width %d",
299 r->tr_begin.tp_row, vb->vb_scr_size.tp_row));
300 KASSERT(r->tr_begin.tp_col < vb->vb_scr_size.tp_col,
301 ("vtbuf_copy begin.tp_col %d must be less than screen height %d",
302 r->tr_begin.tp_col, vb->vb_scr_size.tp_col));
304 KASSERT(r->tr_end.tp_row <= vb->vb_scr_size.tp_row,
305 ("vtbuf_copy end.tp_row %d must be less than screen width %d",
306 r->tr_end.tp_row, vb->vb_scr_size.tp_row));
307 KASSERT(r->tr_end.tp_col <= vb->vb_scr_size.tp_col,
308 ("vtbuf_copy end.tp_col %d must be less than screen height %d",
309 r->tr_end.tp_col, vb->vb_scr_size.tp_col));
311 KASSERT(p2->tp_row < vb->vb_scr_size.tp_row,
312 ("vtbuf_copy tp_row %d must be less than screen width %d",
313 p2->tp_row, vb->vb_scr_size.tp_row));
314 KASSERT(p2->tp_col < vb->vb_scr_size.tp_col,
315 ("vtbuf_copy tp_col %d must be less than screen height %d",
316 p2->tp_col, vb->vb_scr_size.tp_col));
318 rows = r->tr_end.tp_row - r->tr_begin.tp_row;
319 rdiff = r->tr_begin.tp_row - p2->tp_row;
320 cols = r->tr_end.tp_col - r->tr_begin.tp_col;
321 if (r->tr_begin.tp_row > p2->tp_row && r->tr_begin.tp_col == 0 &&
322 r->tr_end.tp_col == vb->vb_scr_size.tp_col && /* Full row. */
323 (rows + rdiff) == vb->vb_scr_size.tp_row && /* Whole screen. */
324 rdiff > 0) { /* Only forward dirrection. Do not eat history. */
325 vthistory_addlines(vb, rdiff);
326 } else if (p2->tp_row < p1->tp_row) {
327 /* Handle overlapping copies of line segments. */
329 for (pr = 0; pr < rows; pr++)
331 &VTBUF_FIELD(vb, p2->tp_row + pr, p2->tp_col),
332 &VTBUF_FIELD(vb, p1->tp_row + pr, p1->tp_col),
333 cols * sizeof(term_char_t));
335 /* Move data down. */
336 for (pr = rows - 1; pr >= 0; pr--)
338 &VTBUF_FIELD(vb, p2->tp_row + pr, p2->tp_col),
339 &VTBUF_FIELD(vb, p1->tp_row + pr, p1->tp_col),
340 cols * sizeof(term_char_t));
344 area.tr_end.tp_row = MIN(p2->tp_row + rows, vb->vb_scr_size.tp_row);
345 area.tr_end.tp_col = MIN(p2->tp_col + cols, vb->vb_scr_size.tp_col);
346 vtbuf_dirty(vb, &area);
350 vtbuf_fill(struct vt_buf *vb, const term_rect_t *r, term_char_t c)
355 for (pr = r->tr_begin.tp_row; pr < r->tr_end.tp_row; pr++) {
356 row = vb->vb_rows[(vb->vb_curroffset + pr) %
357 VTBUF_MAX_HEIGHT(vb)];
358 for (pc = r->tr_begin.tp_col; pc < r->tr_end.tp_col; pc++) {
365 vtbuf_fill_locked(struct vt_buf *vb, const term_rect_t *r, term_char_t c)
367 KASSERT(r->tr_begin.tp_row < vb->vb_scr_size.tp_row,
368 ("vtbuf_fill_locked begin.tp_row %d must be < screen height %d",
369 r->tr_begin.tp_row, vb->vb_scr_size.tp_row));
370 KASSERT(r->tr_begin.tp_col < vb->vb_scr_size.tp_col,
371 ("vtbuf_fill_locked begin.tp_col %d must be < screen width %d",
372 r->tr_begin.tp_col, vb->vb_scr_size.tp_col));
374 KASSERT(r->tr_end.tp_row <= vb->vb_scr_size.tp_row,
375 ("vtbuf_fill_locked end.tp_row %d must be <= screen height %d",
376 r->tr_end.tp_row, vb->vb_scr_size.tp_row));
377 KASSERT(r->tr_end.tp_col <= vb->vb_scr_size.tp_col,
378 ("vtbuf_fill_locked end.tp_col %d must be <= screen width %d",
379 r->tr_end.tp_col, vb->vb_scr_size.tp_col));
382 vtbuf_fill(vb, r, c);
383 vtbuf_dirty_locked(vb, r);
388 vtbuf_init_rows(struct vt_buf *vb)
392 vb->vb_history_size = MAX(vb->vb_history_size, vb->vb_scr_size.tp_row);
394 for (r = 0; r < vb->vb_history_size; r++)
395 vb->vb_rows[r] = &vb->vb_buffer[r * vb->vb_scr_size.tp_col];
399 vtbuf_init_early(struct vt_buf *vb)
403 vb->vb_flags |= VBF_CURSOR;
405 vb->vb_curroffset = 0;
406 vb->vb_mark_start.tp_row = 0;
407 vb->vb_mark_start.tp_col = 0;
408 vb->vb_mark_end.tp_row = 0;
409 vb->vb_mark_end.tp_col = 0;
412 rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0;
413 rect.tr_end = vb->vb_scr_size;
414 vtbuf_fill(vb, &rect, VTBUF_SPACE_CHAR((boothowto & RB_MUTE) == 0 ?
415 TERMINAL_KERN_ATTR : TERMINAL_NORM_ATTR));
416 vtbuf_make_undirty(vb);
417 if ((vb->vb_flags & VBF_MTX_INIT) == 0) {
418 mtx_init(&vb->vb_lock, "vtbuf", NULL, MTX_SPIN);
419 vb->vb_flags |= VBF_MTX_INIT;
424 vtbuf_init(struct vt_buf *vb, const term_pos_t *p)
428 vb->vb_scr_size = *p;
429 vb->vb_history_size = VBF_DEFAULT_HISTORY_SIZE;
431 if ((vb->vb_flags & VBF_STATIC) == 0) {
432 sz = vb->vb_history_size * p->tp_col * sizeof(term_char_t);
433 vb->vb_buffer = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO);
435 sz = vb->vb_history_size * sizeof(term_char_t *);
436 vb->vb_rows = malloc(sz, M_VTBUF, M_WAITOK | M_ZERO);
439 vtbuf_init_early(vb);
443 vtbuf_sethistory_size(struct vt_buf *vb, int size)
448 p.tp_row = vb->vb_scr_size.tp_row;
449 p.tp_col = vb->vb_scr_size.tp_col;
450 vtbuf_grow(vb, &p, size);
454 vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, int history_size)
456 term_char_t *old, *new, **rows, **oldrows, **copyrows, *row;
457 int bufsize, rowssize, w, h, c, r;
460 history_size = MAX(history_size, p->tp_row);
462 /* If new screen/history size bigger or buffer is VBF_STATIC. */
463 if ((history_size > vb->vb_history_size) || (p->tp_col >
464 vb->vb_scr_size.tp_col) || (vb->vb_flags & VBF_STATIC)) {
465 /* Allocate new buffer. */
466 bufsize = history_size * p->tp_col * sizeof(term_char_t);
467 new = malloc(bufsize, M_VTBUF, M_WAITOK | M_ZERO);
468 rowssize = history_size * sizeof(term_pos_t *);
469 rows = malloc(rowssize, M_VTBUF, M_WAITOK | M_ZERO);
473 old = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_buffer;
474 oldrows = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_rows;
475 copyrows = vb->vb_rows;
476 w = vb->vb_scr_size.tp_col;
477 h = vb->vb_history_size;
479 vb->vb_history_size = history_size;
482 vb->vb_flags &= ~VBF_STATIC;
483 vb->vb_scr_size = *p;
486 /* Copy history and fill extra space. */
487 for (r = 0; r < history_size; r ++) {
489 * XXX VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR) will
490 * extended lines of kernel text using the wrong
494 if (r < h) { /* Copy. */
495 memmove(rows[r], copyrows[r],
496 MIN(p->tp_col, w) * sizeof(term_char_t));
497 for (c = MIN(p->tp_col, w); c < p->tp_col;
499 row[c] = VTBUF_SPACE_CHAR(
502 } else { /* Just fill. */
503 rect.tr_begin.tp_col = 0;
504 rect.tr_begin.tp_row = r;
505 rect.tr_end.tp_col = p->tp_col;
506 rect.tr_end.tp_row = p->tp_row;
507 vtbuf_fill(vb, &rect,
508 VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR));
512 vtbuf_make_undirty(vb);
514 /* Deallocate old buffer. */
516 free(oldrows, M_VTBUF);
518 /* Just update the size. */
519 vb->vb_scr_size = *p;
524 vtbuf_putchar(struct vt_buf *vb, const term_pos_t *p, term_char_t c)
528 KASSERT(p->tp_row < vb->vb_scr_size.tp_row,
529 ("vtbuf_putchar tp_row %d must be less than screen width %d",
530 p->tp_row, vb->vb_scr_size.tp_row));
531 KASSERT(p->tp_col < vb->vb_scr_size.tp_col,
532 ("vtbuf_putchar tp_col %d must be less than screen height %d",
533 p->tp_col, vb->vb_scr_size.tp_col));
535 row = vb->vb_rows[(vb->vb_curroffset + p->tp_row) %
536 VTBUF_MAX_HEIGHT(vb)];
537 if (row[p->tp_col] != c) {
540 vtbuf_dirty_cell_locked(vb, p);
546 vtbuf_cursor_position(struct vt_buf *vb, const term_pos_t *p)
549 if (vb->vb_flags & VBF_CURSOR) {
551 vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
553 vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
560 #ifndef SC_NO_CUTPASTE
562 vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row)
566 area.tr_begin.tp_row = MAX(row - 1, 0);
567 area.tr_begin.tp_col = MAX(col - 1, 0);
568 area.tr_end.tp_row = MIN(row + 2, vb->vb_scr_size.tp_row);
569 area.tr_end.tp_col = MIN(col + 2, vb->vb_scr_size.tp_col);
570 vtbuf_dirty(vb, &area);
574 vtbuf_flush_mark(struct vt_buf *vb)
579 /* Notify renderer to update marked region. */
580 if (vb->vb_mark_start.tp_col || vb->vb_mark_end.tp_col ||
581 vb->vb_mark_start.tp_row || vb->vb_mark_end.tp_row) {
583 s = vtbuf_htw(vb, vb->vb_mark_start.tp_row);
584 e = vtbuf_htw(vb, vb->vb_mark_end.tp_row);
586 area.tr_begin.tp_col = 0;
587 area.tr_begin.tp_row = MIN(s, e);
589 area.tr_end.tp_col = vb->vb_scr_size.tp_col;
590 area.tr_end.tp_row = MAX(s, e) + 1;
592 vtbuf_dirty(vb, &area);
597 vtbuf_get_marked_len(struct vt_buf *vb)
602 /* Swap according to window coordinates. */
603 if (POS_INDEX(vtbuf_htw(vb, vb->vb_mark_start.tp_row),
604 vb->vb_mark_start.tp_col) >
605 POS_INDEX(vtbuf_htw(vb, vb->vb_mark_end.tp_row),
606 vb->vb_mark_end.tp_col)) {
607 POS_COPY(e, vb->vb_mark_start);
608 POS_COPY(s, vb->vb_mark_end);
610 POS_COPY(s, vb->vb_mark_start);
611 POS_COPY(e, vb->vb_mark_end);
614 si = s.tp_row * vb->vb_scr_size.tp_col + s.tp_col;
615 ei = e.tp_row * vb->vb_scr_size.tp_col + e.tp_col;
617 /* Number symbols and number of rows to inject \n */
618 sz = ei - si + ((e.tp_row - s.tp_row) * 2) + 1;
620 return (sz * sizeof(term_char_t));
624 vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz)
629 /* Swap according to window coordinates. */
630 if (POS_INDEX(vtbuf_htw(vb, vb->vb_mark_start.tp_row),
631 vb->vb_mark_start.tp_col) >
632 POS_INDEX(vtbuf_htw(vb, vb->vb_mark_end.tp_row),
633 vb->vb_mark_end.tp_col)) {
634 POS_COPY(e, vb->vb_mark_start);
635 POS_COPY(s, vb->vb_mark_end);
637 POS_COPY(s, vb->vb_mark_start);
638 POS_COPY(e, vb->vb_mark_end);
642 for (r = s.tp_row; r <= e.tp_row; r ++) {
643 cs = (r == s.tp_row)?s.tp_col:0;
644 ce = (r == e.tp_row)?e.tp_col:vb->vb_scr_size.tp_col;
645 for (c = cs; c < ce; c ++) {
646 buf[i++] = vb->vb_rows[r][c];
648 /* Add new line for all rows, but not for last one. */
657 vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row)
663 case VTB_MARK_END: /* B1 UP */
664 if (vb->vb_mark_last != VTB_MARK_MOVE)
668 case VTB_MARK_EXTEND:
669 vtbuf_flush_mark(vb); /* Clean old mark. */
670 vb->vb_mark_end.tp_col = col;
671 vb->vb_mark_end.tp_row = vtbuf_wth(vb, row);
674 vtbuf_flush_mark(vb); /* Clean old mark. */
675 vb->vb_mark_start.tp_col = col;
676 vb->vb_mark_start.tp_row = vtbuf_wth(vb, row);
677 /* Start again, so clear end point. */
678 vb->vb_mark_end.tp_col = col;
679 vb->vb_mark_end.tp_row = vtbuf_wth(vb, row);
682 vtbuf_flush_mark(vb); /* Clean old mark. */
683 vb->vb_mark_start.tp_row = vb->vb_mark_end.tp_row =
685 r = vb->vb_rows[vb->vb_mark_start.tp_row];
686 for (i = col; i >= 0; i --) {
687 if (TCHAR_CHARACTER(r[i]) == ' ') {
688 vb->vb_mark_start.tp_col = i + 1;
692 for (i = col; i < vb->vb_scr_size.tp_col; i ++) {
693 if (TCHAR_CHARACTER(r[i]) == ' ') {
694 vb->vb_mark_end.tp_col = i;
698 if (vb->vb_mark_start.tp_col > vb->vb_mark_end.tp_col)
699 vb->vb_mark_start.tp_col = vb->vb_mark_end.tp_col;
702 vtbuf_flush_mark(vb); /* Clean old mark. */
703 vb->vb_mark_start.tp_col = 0;
704 vb->vb_mark_end.tp_col = vb->vb_scr_size.tp_col;
705 vb->vb_mark_start.tp_row = vb->vb_mark_end.tp_row =
709 vb->vb_mark_last = type;
716 vb->vb_mark_last = type;
717 /* Draw new marked region. */
718 vtbuf_flush_mark(vb);
724 vtbuf_cursor_visibility(struct vt_buf *vb, int yes)
729 oflags = vb->vb_flags;
731 vb->vb_flags |= VBF_CURSOR;
733 vb->vb_flags &= ~VBF_CURSOR;
734 nflags = vb->vb_flags;
736 if (oflags != nflags)
737 vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
742 vtbuf_scroll_mode(struct vt_buf *vb, int yes)
747 oflags = vb->vb_flags;
749 vb->vb_flags |= VBF_SCROLL;
751 vb->vb_flags &= ~VBF_SCROLL;
752 nflags = vb->vb_flags;
754 if (oflags != nflags)
755 vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);