git: 7edcf5ac8afb - stable/13 - vt(4): When cutting a line, append a newline character.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 12 Oct 2022 15:54:18 UTC
The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=7edcf5ac8afb49f4532c512839bffa130bcfb985 commit 7edcf5ac8afb49f4532c512839bffa130bcfb985 Author: Ivan Quitschal <tezeka@hotmail.com> AuthorDate: 2022-10-05 09:20:54 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-10-12 15:53:21 +0000 vt(4): When cutting a line, append a newline character. While at it optimise "case 3" into a default. This way there is no need to initialize the "mark" variable in the beginning, because all cases set it. Sponsored by: NVIDIA Networking Differential Revision: https://reviews.freebsd.org/D36042 (cherry picked from commit 90b89100548f7fef4cbd4a8c76dc3d83ab786d7a) --- sys/dev/vt/vt.h | 2 +- sys/dev/vt/vt_buf.c | 6 +++--- sys/dev/vt/vt_core.c | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 7305727804cf..977372f04a7d 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -239,7 +239,7 @@ void vtbuf_cursor_visibility(struct vt_buf *, int); #ifndef SC_NO_CUTPASTE int vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); int vtbuf_get_marked_len(struct vt_buf *vb); -void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz); +void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz, int mark); #endif #define VTB_MARK_NONE 0 diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index b83db85f1cdb..88e4fc472f9d 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -742,7 +742,7 @@ vtbuf_get_marked_len(struct vt_buf *vb) ei = e.tp_row * vb->vb_scr_size.tp_col + e.tp_col; /* Number symbols and number of rows to inject \r */ - sz = ei - si + (e.tp_row - s.tp_row); + sz = ei - si + (1 + e.tp_row - s.tp_row); return (sz * sizeof(term_char_t)); } @@ -771,7 +771,7 @@ tchar_is_word_separator(term_char_t ch) } void -vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz) +vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz, int mark) { int i, j, r, c, cs, ce; term_pos_t s, e; @@ -799,7 +799,7 @@ vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz) buf[i++] = vb->vb_rows[r][c]; /* For all rows, but the last one. */ - if (r != e.tp_row) { + if (r != e.tp_row || mark == VTB_MARK_ROW) { /* Trim trailing word separators, if any. */ for (; i != j; i--) { if (!tchar_is_word_separator(buf[i - 1])) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index cd57e8fc9420..1e0225fc2ea3 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -2153,7 +2153,6 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) vd = main_vd; vw = vd->vd_curwindow; vf = vw->vw_font; - mark = 0; if (vw->vw_flags & (VWF_MOUSE_HIDE | VWF_GRAPHICS)) /* @@ -2217,7 +2216,7 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) case 2: /* double click: cut a word */ mark = VTB_MARK_WORD; break; - case 3: /* triple click: cut a line */ + default: /* triple click: cut a line */ mark = VTB_MARK_ROW; break; } @@ -2286,7 +2285,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), len); + vtbuf_extract_marked(&vw->vw_buf, VD_PASTEBUF(vd), len, mark); VD_PASTEBUFLEN(vd) = len;