summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/screen-write.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-09 17:57:12 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-09 17:57:12 +0000
commitd5ae0275dfbef31f521db90b1ed145e1b3be82dd (patch)
treec4248030db95b2112a55c18506ac46d4aedcc47c /usr.bin/tmux/screen-write.c
parenta85e5447e415236a39bad917051fb81c63e249ad (diff)
Cursor up and down should be limited by the scroll region (cuu should stop at
the scroll region top if starting from below it and cud stop at the bottom if starting from above). Fixes another vttest test.
Diffstat (limited to 'usr.bin/tmux/screen-write.c')
-rw-r--r--usr.bin/tmux/screen-write.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 3ea24263f17..1b78e00c61a 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.11 2009/07/09 07:58:14 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.12 2009/07/09 17:57:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -232,8 +232,15 @@ screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny)
if (ny == 0)
ny = 1;
- if (ny > s->cy)
- ny = s->cy;
+ if (s->cy < s->rupper) {
+ /* Above region. */
+ if (ny > s->cy)
+ ny = s->cy;
+ } else {
+ /* Below region. */
+ if (ny > s->cy - s->rupper)
+ ny = s->cy - s->rupper;
+ }
if (ny == 0)
return;
@@ -249,8 +256,15 @@ screen_write_cursordown(struct screen_write_ctx *ctx, u_int ny)
if (ny == 0)
ny = 1;
- if (ny > screen_size_y(s) - 1 - s->cy)
- ny = screen_size_y(s) - 1 - s->cy;
+ if (s->cy > s->rlower) {
+ /* Below region. */
+ if (ny > screen_size_y(s) - 1 - s->cy)
+ ny = screen_size_y(s) - 1 - s->cy;
+ } else {
+ /* Above region. */
+ if (ny > s->rlower - s->cy)
+ ny = s->rlower - s->cy;
+ }
if (ny == 0)
return;