From nobody Mon Jun 27 08:18:07 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6F6FE873303; Mon, 27 Jun 2022 08:18:07 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LWgb32h5qz4dQw; Mon, 27 Jun 2022 08:18:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656317887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=E8nq7E4Tb/XQyzC++657f1xXGBU2/U0MntXYssVksHM=; b=fBOAfj+xpmrw4smpcFsB9ZqkK+EvZIPoXaxbOqH3rOjzBE2lDfJsIxO0oNKjHiAWcmJe7+ fIgcYm0hheeTBOZqdVVLBMpybymEAFCe+2Lmea0gAwLY9EGhJjT9CqxOQ1pL/LMCnhHPy4 8C7Vq3KGn8YFaq8nLCenYWyshqcwlXUv3ZnfLCcLCXzqvvxSBvZgXYmo4Y8O7RnR3CsEPP jofE71vR9lsXKLHS4RapOxIpTOE6Vldc2QRpjAaqZkEN8PsrIMNI9pjjiaxzwtxUXbz5Qd qa9yWlYpzDsQB3FJp9DCKExX03wCEIQmmX/dakwS6//3Q09A5ubROnVY4p+NSw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C97724A32; Mon, 27 Jun 2022 08:18:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25R8I7xd093360; Mon, 27 Jun 2022 08:18:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25R8I7Sw093359; Mon, 27 Jun 2022 08:18:07 GMT (envelope-from git) Date: Mon, 27 Jun 2022 08:18:07 GMT Message-Id: <202206270818.25R8I7Sw093359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 5fe0a82501cb - main - vt: Fix contents of paste buffer for newcons. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5fe0a82501cb86278b9aa426c4bf11d992e95aaa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656317887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=E8nq7E4Tb/XQyzC++657f1xXGBU2/U0MntXYssVksHM=; b=PMfCEiGb8s3gPu9ZimOF3Pbo602yhODADOsVl11w6WGlx4WQGyLTX8r0WiHw2bP+YeYHmY TmoOlL2WI3oaSuH7xIwU9pdxhA/f6U07HLV8LyNZVst8g/RVDp82TY9Mx+eZDEUoJlyDqo FZfYP2N8iKP7WP2c6vmCCXeEt05EoNRbpsXV+UHurhTRR/lyV7ibjlzta06BwgJpPawM2b Mmzd8OWEV4q3vVWvwj+3VKXX+0nITDeDZu1KWvsBITcJBCME1/+Y8GaJID10yVxznT36bW xx0n1IE9FHZda4y2Qqjozb7DivKFfez0nmu/aCKgJFZz2QkQIrjQec7rszuXmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656317887; a=rsa-sha256; cv=none; b=uAvUBDXvXsmM9O9ooEcB8D7gtMnlGi+S7IMKWZFoQr7xJnqJlBMWuQDj+hkqcJlpHr97hM tSsJdNh6a/cpJolTFj0jPovzTfww8qfbJD9E8PuLwq2/xBK1Uiro7A9BpUcPWj0ZNOZLfF +3n78C8M0fo9euxjN53hIAqnZhebVSv5j0GplSRGtCAJglF5dsuc/NDt1JtC4DBecxRyMF SUibnp8y8hndUASjUDU4sbiAjlrzCanySE4vMtzO4NeCHTbrSBRkycfweH5kQ44J0+fJ1E ZxxmGlnKAX9eXSWmCsoskTokskYBHz6uqydiBrKHhr/u6hofIbUXyJaPvA+GvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=5fe0a82501cb86278b9aa426c4bf11d992e95aaa commit 5fe0a82501cb86278b9aa426c4bf11d992e95aaa Author: Hans Petter Selasky AuthorDate: 2022-06-22 16:38:47 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-27 08:17:16 +0000 vt: Fix contents of paste buffer for newcons. Trim all word separators from end of line, except for last line and only use '\r' to terminate the pasted lines as expected by TTY. Submitted by: Ivan Quitschal Differential Revision: https://reviews.freebsd.org/D35552 PR: 263084 MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/dev/vt/vt_buf.c | 27 ++++++++++++++++++++------- sys/dev/vt/vt_core.c | 5 ++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index 041c8193ca93..fa6c7c8fec5f 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -741,8 +741,8 @@ vtbuf_get_marked_len(struct vt_buf *vb) si = s.tp_row * vb->vb_scr_size.tp_col + s.tp_col; ei = e.tp_row * vb->vb_scr_size.tp_col + e.tp_col; - /* Number symbols and number of rows to inject \n */ - sz = ei - si + ((e.tp_row - s.tp_row) * 2); + /* Number symbols and number of rows to inject \r */ + sz = ei - si + (e.tp_row - s.tp_row); return (sz * sizeof(term_char_t)); } @@ -750,7 +750,7 @@ vtbuf_get_marked_len(struct vt_buf *vb) void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz) { - int i, r, c, cs, ce; + int i, j, r, c, cs, ce; term_pos_t s, e; /* Swap according to window coordinates. */ @@ -769,15 +769,28 @@ vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz) for (r = s.tp_row; r <= e.tp_row; r++) { cs = (r == s.tp_row)?s.tp_col:0; ce = (r == e.tp_row)?e.tp_col:vb->vb_scr_size.tp_col; - for (c = cs; c < ce; c++) { + + /* Copy characters from terminal window. */ + j = i; + for (c = cs; c < ce; c++) buf[i++] = vb->vb_rows[r][c]; - } - /* Add new line for all rows, but not for last one. */ + + /* For all rows, but the last one. */ if (r != e.tp_row) { + /* Trim trailing word separators, if any. */ + for (; i != j; i--) { + if (TCHAR_CHARACTER(buf[i - 1]) != ' ') + break; + } + /* Add newline character as expected by TTY. */ buf[i++] = '\r'; - buf[i++] = '\n'; } } + /* Zero rest of expected buffer size, if any. */ + while ((i * sizeof(buf[0])) < sz) + buf[i++] = '\0'; + + MPASS((i * sizeof(buf[0])) == sz); } int diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index a623f50c9c06..588ebbcbc4e9 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -2135,7 +2135,7 @@ vt_mouse_paste() buf = VD_PASTEBUF(main_vd); len /= sizeof(term_char_t); for (i = 0; i < len; i++) { - if (buf[i] == '\0') + if (TCHAR_CHARACTER(buf[i]) == '\0') continue; terminal_input_char(main_vd->vd_curwindow->vw_terminal, buf[i]); @@ -2287,8 +2287,7 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) VD_PASTEBUFSZ(vd) = len; } /* Request copy/paste buffer data, no more than `len' */ - vtbuf_extract_marked(&vw->vw_buf, VD_PASTEBUF(vd), - VD_PASTEBUFSZ(vd)); + vtbuf_extract_marked(&vw->vw_buf, VD_PASTEBUF(vd), len); VD_PASTEBUFLEN(vd) = len;