From owner-svn-src-head@freebsd.org Thu May 28 21:22:31 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 AF2E02FE56C; Thu, 28 May 2020 21:22:31 +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 49Y0yv45gXz4CdY; Thu, 28 May 2020 21:22:31 +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 87D7DCC3A; Thu, 28 May 2020 21:22:31 +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 04SLMVnc069428; Thu, 28 May 2020 21:22:31 GMT (envelope-from jah@FreeBSD.org) Received: (from jah@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04SLMVrK069426; Thu, 28 May 2020 21:22:31 GMT (envelope-from jah@FreeBSD.org) Message-Id: <202005282122.04SLMVrK069426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jah set sender to jah@FreeBSD.org using -f From: "Jason A. Harmening" Date: Thu, 28 May 2020 21:22:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361601 - head/sys/dev/vt X-SVN-Group: head X-SVN-Commit-Author: jah X-SVN-Commit-Paths: head/sys/dev/vt X-SVN-Commit-Revision: 361601 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: Thu, 28 May 2020 21:22:31 -0000 Author: jah Date: Thu May 28 21:22:30 2020 New Revision: 361601 URL: https://svnweb.freebsd.org/changeset/base/361601 Log: vt(4): Add support for `vidcontrol -C' Extract scrollback buffer initialization into a common routine, used both during vt(4) init and in handling the CONS_CLRHIST ioctl. PR: 224436 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D24815 Modified: head/sys/dev/vt/vt.h head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt.h ============================================================================== --- head/sys/dev/vt/vt.h Thu May 28 21:19:44 2020 (r361600) +++ head/sys/dev/vt/vt.h Thu May 28 21:22:30 2020 (r361601) @@ -231,6 +231,7 @@ 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 *, unsigned int); +void vtbuf_clearhistory(struct vt_buf *); 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: head/sys/dev/vt/vt_buf.c ============================================================================== --- head/sys/dev/vt/vt_buf.c Thu May 28 21:19:44 2020 (r361600) +++ head/sys/dev/vt/vt_buf.c Thu May 28 21:22:30 2020 (r361601) @@ -416,13 +416,26 @@ vtbuf_init_rows(struct vt_buf *vb) vb->vb_rows[r] = &vb->vb_buffer[r * vb->vb_scr_size.tp_col]; } -void -vtbuf_init_early(struct vt_buf *vb) +static void +vtbuf_do_clearhistory(struct vt_buf *vb) { term_rect_t rect; 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_roffset = 0; vb->vb_curroffset = 0; @@ -432,14 +445,7 @@ vtbuf_init_early(struct vt_buf *vb) vb->vb_mark_end.tp_col = 0; vtbuf_init_rows(vb); - 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; - - 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_do_clearhistory(vb); vtbuf_make_undirty(vb); if ((vb->vb_flags & VBF_MTX_INIT) == 0) { mtx_init(&vb->vb_lock, "vtbuf", NULL, MTX_SPIN); @@ -464,6 +470,14 @@ vtbuf_init(struct vt_buf *vb, const term_pos_t *p) } vtbuf_init_early(vb); +} + +void +vtbuf_clearhistory(struct vt_buf *vb) +{ + VTBUF_LOCK(vb); + vtbuf_do_clearhistory(vb); + VTBUF_UNLOCK(vb); } void Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Thu May 28 21:19:44 2020 (r361600) +++ head/sys/dev/vt/vt_core.c Thu May 28 21:22:30 2020 (r361601) @@ -2329,7 +2329,10 @@ skip_thunk: if (*(int *)data != vd->vd_curwindow->vw_buf.vb_history_size) vtbuf_sethistory_size(&vd->vd_curwindow->vw_buf, *(int *)data); - return 0; + return (0); + case CONS_CLRHIST: + vtbuf_clearhistory(&vd->vd_curwindow->vw_buf); + return (0); case CONS_GET: /* XXX */ *(int *)data = M_CG640x480;