diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-01-05 23:54:53 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-01-05 23:54:53 +0000 |
commit | 4d8d70a846d813390ab5f806f433a28c4315ed7a (patch) | |
tree | 59db7626b39cce39594424c942448a435dfb4dd3 | |
parent | b8bc525afe27b99fcfb19e83830e262d876a8079 (diff) | |
download | rtmux-4d8d70a846d813390ab5f806f433a28c4315ed7a.tar.gz rtmux-4d8d70a846d813390ab5f806f433a28c4315ed7a.tar.bz2 rtmux-4d8d70a846d813390ab5f806f433a28c4315ed7a.zip |
Sync OpenBSD patchset 598:
Fix selection behaviour when the cursor is moved backwards (ie so the selection
start is after the end).
-rw-r--r-- | screen.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.97 2009-12-04 22:14:47 tcunha Exp $ */ +/* $Id: screen.c,v 1.98 2010-01-05 23:54:53 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -233,11 +233,31 @@ screen_set_selection(struct screen *s, struct screen_sel *sel = &s->sel; memcpy(&sel->cell, gc, sizeof sel->cell); - sel->flag = 1; - if (ey < sy || (sy == ey && ex < sx)) { + + /* starting line < ending line -- downward selection. */ + if (sy < ey) { + sel->sx = sx; sel->sy = sy; + sel->ex = ex; sel->ey = ey; + return; + } + + /* starting line > ending line -- upward selection. */ + if (sy > ey) { + if (sx > 0) { + sel->sx = ex; sel->sy = ey; + sel->ex = sx - 1; sel->ey = sy; + } else { + sel->sx = ex; sel->sy = ey; + sel->ex = -1; sel->ey = sy - 1; + } + return; + } + + /* starting line == ending line. */ + if (ex < sx) { sel->sx = ex; sel->sy = ey; - sel->ex = sx; sel->ey = sy; + sel->ex = sx - 1; sel->ey = sy; } else { sel->sx = sx; sel->sy = sy; sel->ex = ex; sel->ey = ey; |