vt: Clear cut-paste selection if the area intersects with the filled region
* cut-paste buffer stays unchanged PR: 260069 Reported by: emaste Reviewed by: imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D56922
This commit is contained in:
@@ -248,6 +248,8 @@ void vtbuf_cursor_visibility(struct vt_buf *, int);
|
||||
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, int mark);
|
||||
void vtbuf_unmark(struct vt_buf *vb);
|
||||
void vtbuf_unmark_on_cross(struct vt_buf *vb, int target_begin, int target_end);
|
||||
#endif
|
||||
|
||||
#define VTB_MARK_NONE 0
|
||||
|
||||
@@ -202,6 +202,36 @@ vtbuf_in_this_range(int begin, int test, int end, int sz)
|
||||
else
|
||||
return (test >= begin && test < end);
|
||||
}
|
||||
|
||||
void
|
||||
vtbuf_unmark(struct vt_buf *vb)
|
||||
{
|
||||
|
||||
vtbuf_set_mark(vb, VTB_MARK_START, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
vtbuf_unmark_on_cross(struct vt_buf *vb, int target_begin, int target_end)
|
||||
{
|
||||
int hsz, mb, me, tb, te;
|
||||
|
||||
tb = vtbuf_wth(vb, target_begin);
|
||||
te = vtbuf_wth(vb, target_end);
|
||||
mb = vb->vb_mark_start.tp_row;
|
||||
me = vb->vb_mark_end.tp_row;
|
||||
hsz = vb->vb_history_size;
|
||||
|
||||
/*
|
||||
* Test intersection with vtbuf_in_this_range due to use of
|
||||
* the circular buffer.
|
||||
*/
|
||||
if (vtbuf_in_this_range(tb, mb, te, hsz) ||
|
||||
vtbuf_in_this_range(tb, me, te, hsz) ||
|
||||
vtbuf_in_this_range(mb, tb, me, hsz) ||
|
||||
vtbuf_in_this_range(mb, te, me, hsz)) {
|
||||
vtbuf_unmark(vb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
|
||||
@@ -1197,6 +1197,10 @@ vtterm_fill(struct terminal *tm, const term_rect_t *r, term_char_t c)
|
||||
{
|
||||
struct vt_window *vw = tm->tm_softc;
|
||||
|
||||
#ifndef SC_NO_CUTPASTE
|
||||
vtbuf_unmark_on_cross(&vw->vw_buf, r->tr_begin.tp_row,
|
||||
r->tr_end.tp_row);
|
||||
#endif
|
||||
vtbuf_fill(&vw->vw_buf, r, c);
|
||||
}
|
||||
|
||||
@@ -2465,9 +2469,7 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel)
|
||||
default:
|
||||
vt_mouse_paste();
|
||||
/* clear paste buffer selection after paste */
|
||||
vtbuf_set_mark(&vw->vw_buf, VTB_MARK_START,
|
||||
vd->vd_mx / vf->vf_width,
|
||||
vd->vd_my / vf->vf_height);
|
||||
vtbuf_unmark(&vw->vw_buf);
|
||||
break;
|
||||
}
|
||||
return; /* Done */
|
||||
|
||||
Reference in New Issue
Block a user