summaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-12 09:09:35 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-12 09:09:35 +0000
commitf05b32f7adc7de4dac3afa59ce91986202f17769 (patch)
treef2d2102cf9a1a64ed6618acef3136b7c6370cd21 /tty.c
parent0a2a3544993a569e277f893ddac610313a42bfde (diff)
Cleanup: use two functions for region setting, one for absolute and one inside
pane.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/tty.c b/tty.c
index 389fe11f..fd271335 100644
--- a/tty.c
+++ b/tty.c
@@ -579,7 +579,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
+ tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
@@ -599,7 +599,7 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
+ tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
@@ -675,8 +675,10 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy == ctx->orupper) {
tty_reset(tty);
- tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
+
+ tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff);
+
tty_putcode(tty, TTYC_RI);
}
}
@@ -695,8 +697,10 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy == ctx->orlower) {
tty_reset(tty);
- tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
+
+ tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+
tty_putc(tty, '\n');
}
}
@@ -710,8 +714,9 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
+ tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL);
@@ -745,8 +750,9 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
+ tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
+
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
for (i = 0; i < ctx->ocy; i++) {
@@ -774,8 +780,9 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
+ tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
+
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
for (i = 0; i < screen_size_y(s); i++) {
@@ -803,7 +810,7 @@ tty_cmd_alignmenttest(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
+ tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
for (j = 0; j < screen_size_y(s); j++) {
tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
@@ -887,17 +894,29 @@ tty_reset(struct tty *tty)
}
void
-tty_region(struct tty *tty, u_int rupper, u_int rlower, u_int oy)
+tty_region_pane(
+ struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower)
+{
+ struct window_pane *wp = ctx->wp;
+
+ tty_region_absolute(tty, wp->yoff + rupper, wp->yoff + rlower);
+}
+
+void
+tty_region_absolute(struct tty *tty, u_int rupper, u_int rlower)
{
+ if (tty->rlower == rlower && tty->rupper == rupper)
+ return;
if (!tty_term_has(tty->term, TTYC_CSR))
return;
- if (tty->rlower != oy + rlower || tty->rupper != oy + rupper) {
- tty->rlower = oy + rlower;
- tty->rupper = oy + rupper;
- tty->cx = 0;
- tty->cy = 0;
- tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower);
- }
+
+ tty->rupper = rupper;
+ tty->rlower = rlower;
+
+ tty->cx = 0;
+ tty->cy = 0;
+
+ tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower);
}
void