From owner-svn-src-stable@freebsd.org Thu Mar 8 07:57:28 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2879F3E43F; Thu, 8 Mar 2018 07:57:27 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D8E96C77B; Thu, 8 Mar 2018 07:57:27 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4868560DE; Thu, 8 Mar 2018 07:57:27 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w287vR0L075213; Thu, 8 Mar 2018 07:57:27 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w287vQlL075210; Thu, 8 Mar 2018 07:57:26 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803080757.w287vQlL075210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Thu, 8 Mar 2018 07:57:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330641 - stable/11/sys/dev/vt X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/sys/dev/vt X-SVN-Commit-Revision: 330641 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Mar 2018 07:57:28 -0000 Author: eadler Date: Thu Mar 8 07:57:26 2018 New Revision: 330641 URL: https://svnweb.freebsd.org/changeset/base/330641 Log: MFC r326599: Implement "vidcontrol -h " for vt(4) PR: 210415 Modified: stable/11/sys/dev/vt/vt.h stable/11/sys/dev/vt/vt_buf.c stable/11/sys/dev/vt/vt_core.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/vt/vt.h ============================================================================== --- stable/11/sys/dev/vt/vt.h Thu Mar 8 07:55:03 2018 (r330640) +++ stable/11/sys/dev/vt/vt.h Thu Mar 8 07:57:26 2018 (r330641) @@ -194,8 +194,8 @@ struct vt_buf { #define VBF_SCROLL 0x8 /* scroll locked mode. */ #define VBF_HISTORY_FULL 0x10 /* All rows filled. */ unsigned int vb_history_size; - int vb_roffset; /* (b) History rows offset. */ - int vb_curroffset; /* (b) Saved rows offset. */ + unsigned int vb_roffset; /* (b) History rows offset. */ + unsigned int vb_curroffset; /* (b) Saved rows offset. */ term_pos_t vb_cursor; /* (u) Cursor position. */ term_pos_t vb_mark_start; /* (b) Copy region start. */ term_pos_t vb_mark_end; /* (b) Copy region end. */ @@ -221,7 +221,7 @@ void vtbuf_cursor_position(struct vt_buf *, const term void vtbuf_scroll_mode(struct vt_buf *vb, int yes); void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area); void vtbuf_undirty(struct vt_buf *, term_rect_t *); -void vtbuf_sethistory_size(struct vt_buf *, int); +void vtbuf_sethistory_size(struct vt_buf *, unsigned int); int vtbuf_iscursor(const struct vt_buf *vb, int row, int col); void vtbuf_cursor_visibility(struct vt_buf *, int); #ifndef SC_NO_CUTPASTE Modified: stable/11/sys/dev/vt/vt_buf.c ============================================================================== --- stable/11/sys/dev/vt/vt_buf.c Thu Mar 8 07:55:03 2018 (r330640) +++ stable/11/sys/dev/vt/vt_buf.c Thu Mar 8 07:57:26 2018 (r330641) @@ -132,11 +132,10 @@ vthistory_addlines(struct vt_buf *vb, int offset) #endif vb->vb_curroffset += offset; - if (vb->vb_curroffset < 0) - vb->vb_curroffset = 0; - if (vb->vb_curroffset + vb->vb_scr_size.tp_row >= vb->vb_history_size) + if (vb->vb_curroffset + vb->vb_scr_size.tp_row >= vb->vb_history_size) { vb->vb_flags |= VBF_HISTORY_FULL; - vb->vb_curroffset %= vb->vb_history_size; + vb->vb_curroffset %= vb->vb_history_size; + } if ((vb->vb_flags & VBF_SCROLL) == 0) { vb->vb_roffset = vb->vb_curroffset; } @@ -458,7 +457,7 @@ vtbuf_init(struct vt_buf *vb, const term_pos_t *p) } void -vtbuf_sethistory_size(struct vt_buf *vb, int size) +vtbuf_sethistory_size(struct vt_buf *vb, unsigned int size) { term_pos_t p; @@ -472,9 +471,9 @@ void vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size) { term_char_t *old, *new, **rows, **oldrows, **copyrows, *row, *oldrow; - int bufsize, rowssize, w, h, c, r, history_was_full; - unsigned int old_history_size; - term_rect_t rect; + unsigned int w, h, c, r, old_history_size; + size_t bufsize, rowssize; + int history_full; history_size = MAX(history_size, p->tp_row); @@ -493,7 +492,8 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns w = vb->vb_scr_size.tp_col; h = vb->vb_scr_size.tp_row; old_history_size = vb->vb_history_size; - history_was_full = vb->vb_flags & VBF_HISTORY_FULL; + history_full = vb->vb_flags & VBF_HISTORY_FULL || + vb->vb_curroffset + h >= history_size; vb->vb_history_size = history_size; vb->vb_buffer = new; @@ -502,20 +502,16 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns vb->vb_scr_size = *p; vtbuf_init_rows(vb); - /* Copy history and fill extra space if needed. */ + /* + * Copy rows to the new buffer. The first row in the history + * is back to index 0, ie. the new buffer doesn't cycle. + */ if (history_size > old_history_size) { - /* - * Copy rows to the new buffer. The first row in the history - * is back to index 0, ie. the new buffer doesn't cycle. - * - * The rest of the new buffer is initialized with blank - * content. - */ for (r = 0; r < old_history_size; r ++) { row = rows[r]; /* Compute the corresponding row in the old buffer. */ - if (history_was_full) + if (history_full) /* * The buffer is full, the "top" row is * the one just after the viewable area @@ -549,18 +545,29 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns } /* Fill remaining rows. */ - rect.tr_begin.tp_col = 0; - rect.tr_begin.tp_row = old_history_size; - rect.tr_end.tp_col = p->tp_col; - rect.tr_end.tp_row = p->tp_row; - vtbuf_fill(vb, &rect, VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR)); + for (r = old_history_size; r < history_size; r++) { + row = rows[r]; + for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { + row[c] = VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR); + } + } vb->vb_flags &= ~VBF_HISTORY_FULL; - } else { + /* - * Copy rows to the new buffer. The first row in the history - * is back to index 0, ie. the new buffer doesn't cycle. + * If the screen is already filled (there are non-visible lines + * above the current viewable area), adjust curroffset to the + * new viewable area. * + * If the old buffer was full, set curroffset to the + * th most recent line of history in the new, non-cycled + * buffer. Otherwise, it didn't cycle, so the old curroffset + * is the same in the new buffer. + */ + if (history_full) + vb->vb_curroffset = old_history_size - h; + } else { + /* * (old_history_size - history_size) lines of history are * dropped. */ @@ -573,15 +580,13 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns * See the equivalent if{} block above for an * explanation. */ - if (history_was_full) + if (history_full) oldrow = copyrows[ (vb->vb_curroffset + h + r + (old_history_size - history_size)) % old_history_size]; else - oldrow = copyrows[ - (r + (old_history_size - history_size)) % - old_history_size]; + oldrow = copyrows[r]; memmove(row, oldrow, MIN(p->tp_col, w) * sizeof(term_char_t)); @@ -596,23 +601,13 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns } } - if (!history_was_full && - (vb->vb_curroffset + h) >= history_size) + if (history_full) { + vb->vb_curroffset = history_size - h; vb->vb_flags |= VBF_HISTORY_FULL; + } } - /* - * If the screen is already filled (there are non-visible lines - * above the current viewable area), adjust curroffset to the - * new viewable area. - */ - if (!history_was_full && vb->vb_curroffset > 0) { - vb->vb_curroffset = vb->vb_curroffset + h - p->tp_row; - if (vb->vb_curroffset < 0) - vb->vb_curroffset += vb->vb_history_size; - vb->vb_curroffset %= vb->vb_history_size; - vb->vb_roffset = vb->vb_curroffset; - } + vb->vb_roffset = vb->vb_curroffset; /* Adjust cursor position. */ if (vb->vb_cursor.tp_col > p->tp_col - 1) @@ -626,7 +621,6 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns /* Move cursor to the last line on the screen. */ vb->vb_cursor.tp_row = p->tp_row - 1; - vtbuf_make_undirty(vb); VTBUF_UNLOCK(vb); /* Deallocate old buffer. */ Modified: stable/11/sys/dev/vt/vt_core.c ============================================================================== --- stable/11/sys/dev/vt/vt_core.c Thu Mar 8 07:55:03 2018 (r330640) +++ stable/11/sys/dev/vt/vt_core.c Thu Mar 8 07:57:26 2018 (r330641) @@ -2207,6 +2207,13 @@ skip_thunk: case CONS_BLANKTIME: /* XXX */ return (0); + case CONS_HISTORY: + if (*(int *)data < 0) + return EINVAL; + if (*(int *)data != vd->vd_curwindow->vw_buf.vb_history_size) + vtbuf_sethistory_size(&vd->vd_curwindow->vw_buf, + *(int *)data); + return 0; case CONS_GET: /* XXX */ *(int *)data = M_CG640x480;