summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-09 17:57:11 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-09 17:57:11 +0000
commit5f2f07ed8a0ecaa2aacda59768c55e615b897cfb (patch)
tree8cedb9c711970493b783628fa6bc07d5ad47d44b /screen-write.c
parent81181bfb72b306aed736ad7d8c9aaff0425e6730 (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 'screen-write.c')
-rw-r--r--screen-write.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/screen-write.c b/screen-write.c
index fb0cba6a..5a2a3882 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -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;