From owner-svn-src-head@freebsd.org Tue Jun 2 01:21:49 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CAFC2FA063; Tue, 2 Jun 2020 01:21:49 +0000 (UTC) (envelope-from jah@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49bZ5900CDz4Lpd; Tue, 2 Jun 2020 01:21:49 +0000 (UTC) (envelope-from jah@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 EE41014BFD; Tue, 2 Jun 2020 01:21:48 +0000 (UTC) (envelope-from jah@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0521LmCd032924; Tue, 2 Jun 2020 01:21:48 GMT (envelope-from jah@FreeBSD.org) Received: (from jah@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0521LmUU032921; Tue, 2 Jun 2020 01:21:48 GMT (envelope-from jah@FreeBSD.org) Message-Id: <202006020121.0521LmUU032921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jah set sender to jah@FreeBSD.org using -f From: "Jason A. Harmening" Date: Tue, 2 Jun 2020 01:21:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361719 - in head/sys: dev/vt kern X-SVN-Group: head X-SVN-Commit-Author: jah X-SVN-Commit-Paths: in head/sys: dev/vt kern X-SVN-Commit-Revision: 361719 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 01:21:49 -0000 Author: jah Date: Tue Jun 2 01:21:48 2020 New Revision: 361719 URL: https://svnweb.freebsd.org/changeset/base/361719 Log: vt(4): reset scrollback and cursor position after clearing history buffer r361601 implemented basic support for cleaing the console history buffer. But after clearing the history buffer, it's not especially useful to be able to scroll back through that buffer, or for the cursor position to remain at (very likely) the bottom of the screen. PR: 224436 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D25079 Modified: head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c head/sys/kern/subr_terminal.c Modified: head/sys/dev/vt/vt_buf.c ============================================================================== --- head/sys/dev/vt/vt_buf.c Tue Jun 2 01:04:49 2020 (r361718) +++ head/sys/dev/vt/vt_buf.c Tue Jun 2 01:21:48 2020 (r361719) @@ -433,17 +433,22 @@ vtbuf_do_clearhistory(struct vt_buf *vb) vtbuf_do_fill(vb, &rect, VTBUF_SPACE_CHAR(ch)); } -void -vtbuf_init_early(struct vt_buf *vb) +static void +vtbuf_reset_scrollback(struct vt_buf *vb) { - vb->vb_flags |= VBF_CURSOR; vb->vb_roffset = 0; vb->vb_curroffset = 0; 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; +} +void +vtbuf_init_early(struct vt_buf *vb) +{ + vb->vb_flags |= VBF_CURSOR; + vtbuf_reset_scrollback(vb); vtbuf_init_rows(vb); vtbuf_do_clearhistory(vb); vtbuf_make_undirty(vb); @@ -477,6 +482,8 @@ vtbuf_clearhistory(struct vt_buf *vb) { VTBUF_LOCK(vb); vtbuf_do_clearhistory(vb); + vtbuf_reset_scrollback(vb); + vb->vb_flags &= ~VBF_HISTORY_FULL; VTBUF_UNLOCK(vb); } Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Tue Jun 2 01:04:49 2020 (r361718) +++ head/sys/dev/vt/vt_core.c Tue Jun 2 01:21:48 2020 (r361719) @@ -2332,6 +2332,16 @@ skip_thunk: return (0); case CONS_CLRHIST: vtbuf_clearhistory(&vd->vd_curwindow->vw_buf); + /* + * Invalidate the entire visible window; it is not guaranteed + * that this operation will be immediately followed by a scroll + * event, so it would otherwise be possible for prior artifacts + * to remain visible. + */ + VT_LOCK(vd); + vd->vd_flags |= VDF_INVALID; + VT_UNLOCK(vd); + vt_resume_flush_timer(vd->vd_curwindow, 0); return (0); case CONS_GET: /* XXX */ Modified: head/sys/kern/subr_terminal.c ============================================================================== --- head/sys/kern/subr_terminal.c Tue Jun 2 01:04:49 2020 (r361718) +++ head/sys/kern/subr_terminal.c Tue Jun 2 01:21:48 2020 (r361719) @@ -480,6 +480,16 @@ termtty_ioctl(struct tty *tp, u_long cmd, caddr_t data tty_unlock(tp); error = tm->tm_class->tc_ioctl(tm, cmd, data, td); tty_lock(tp); + if ((error == 0) && (cmd == CONS_CLRHIST)) { + /* + * Scrollback history has been successfully cleared, + * so reset the cursor position to the top left of the screen. + */ + teken_pos_t p; + p.tp_row = 0; + p.tp_col = 0; + teken_set_cursor(&tm->tm_emulator, &p); + } return (error); }