diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -239,7 +239,7 @@ #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 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -742,7 +742,7 @@ 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 @@ } 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 @@ 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 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -2153,7 +2153,6 @@ 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 @@ 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 @@ 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;