From eb9826f65d5584bc791cb35eb91ab6a5894b888c Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 12 Oct 2009 16:37:43 +0000 Subject: [PATCH] If the vertical cursor movement crosses the scroll region, CUU and CUD shouldn't be used even if VPA isn't present - in that case CUP should be used. --- tty.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tty.c b/tty.c index 665d0871..29c84832 100644 --- a/tty.c +++ b/tty.c @@ -1027,15 +1027,16 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy) change = thisy - cy; /* +ve up, -ve down */ /* - * Use VPA if change is larger than absolute or if this change + * Try to use VPA if change is larger than absolute or if this change * would cross the scroll region, otherwise use CUU/CUD. */ - if ((abs(change) > cy || + if (abs(change) > cy || (change < 0 && cy - change > tty->rlower) || - (change > 0 && cy - change < tty->rupper)) && - tty_term_has(term, TTYC_VPA)) { - tty_putcode1(tty, TTYC_VPA, cy); - goto out; + (change > 0 && cy - change < tty->rupper)) { + if (tty_term_has(term, TTYC_VPA)) { + tty_putcode1(tty, TTYC_VPA, cy); + goto out; + } } else if (change > 0 && tty_term_has(term, TTYC_CUU)) { tty_putcode1(tty, TTYC_CUU, change); goto out;