mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 02:23:15 +01:00
Sync OpenBSD patchset 162:
More tty code tidying: move the saved cursor/region position (from before the screen was updated) out of struct screen and into struct tty_ctx.
This commit is contained in:
parent
9c6fa90857
commit
b72f9bea43
110
screen-write.c
110
screen-write.c
@ -1,4 +1,4 @@
|
||||
/* $Id: screen-write.c,v 1.63 2009-07-23 12:38:01 tcunha Exp $ */
|
||||
/* $Id: screen-write.c,v 1.64 2009-07-23 12:48:18 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
void screen_write_save(struct screen_write_ctx *);
|
||||
void screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *);
|
||||
void screen_write_overwrite(struct screen_write_ctx *);
|
||||
|
||||
/* Initialise writing with a window. */
|
||||
@ -210,17 +210,19 @@ screen_write_copy(struct screen_write_ctx *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* Save cursor and region positions. */
|
||||
/* Set up context for TTY command. */
|
||||
void
|
||||
screen_write_save(struct screen_write_ctx *ctx)
|
||||
screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
|
||||
s->old_cx = s->cx;
|
||||
s->old_cy = s->cy;
|
||||
ttyctx->wp = ctx->wp;
|
||||
|
||||
s->old_rlower = s->rlower;
|
||||
s->old_rupper = s->rupper;
|
||||
ttyctx->ocx = s->cx;
|
||||
ttyctx->ocy = s->cy;
|
||||
|
||||
ttyctx->orlower = s->rlower;
|
||||
ttyctx->orupper = s->rupper;
|
||||
}
|
||||
|
||||
/* Cursor up by ny. */
|
||||
@ -310,9 +312,12 @@ void
|
||||
screen_write_alignmenttest(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
struct grid_cell gc;
|
||||
u_int xx, yy;
|
||||
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
gc.data = 'E';
|
||||
|
||||
@ -327,7 +332,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
|
||||
s->rupper = 0;
|
||||
s->rlower = screen_size_y(s) - 1;
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_alignmenttest);
|
||||
tty_write(tty_cmd_alignmenttest, &ttyctx);
|
||||
}
|
||||
|
||||
/* Insert nx characters. */
|
||||
@ -335,6 +340,7 @@ void
|
||||
screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
if (nx == 0)
|
||||
nx = 1;
|
||||
@ -344,12 +350,13 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
if (nx == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cx <= screen_size_x(s) - 1)
|
||||
grid_view_insert_cells(s->grid, s->cx, s->cy, nx);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_insertcharacter, nx);
|
||||
ttyctx.num = nx;
|
||||
tty_write(tty_cmd_insertcharacter, &ttyctx);
|
||||
}
|
||||
|
||||
/* Delete nx characters. */
|
||||
@ -357,6 +364,7 @@ void
|
||||
screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
if (nx == 0)
|
||||
nx = 1;
|
||||
@ -366,12 +374,13 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
if (nx == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cx <= screen_size_x(s) - 1)
|
||||
grid_view_delete_cells(s->grid, s->cx, s->cy, nx);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_deletecharacter, nx);
|
||||
ttyctx.num = nx;
|
||||
tty_write(tty_cmd_deletecharacter, &ttyctx);
|
||||
}
|
||||
|
||||
/* Insert ny lines. */
|
||||
@ -379,6 +388,7 @@ void
|
||||
screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
if (ny == 0)
|
||||
ny = 1;
|
||||
@ -389,11 +399,12 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
||||
if (ny == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
grid_view_insert_lines(s->grid, s->cy, ny);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_insertline, ny);
|
||||
ttyctx.num = ny;
|
||||
tty_write(tty_cmd_insertline, &ttyctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -402,14 +413,15 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
||||
if (ny == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cy < s->rupper || s->cy > s->rlower)
|
||||
grid_view_insert_lines(s->grid, s->cy, ny);
|
||||
else
|
||||
grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_insertline, ny);
|
||||
ttyctx.num = ny;
|
||||
tty_write(tty_cmd_insertline, &ttyctx);
|
||||
}
|
||||
|
||||
/* Delete ny lines. */
|
||||
@ -417,6 +429,7 @@ void
|
||||
screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
if (ny == 0)
|
||||
ny = 1;
|
||||
@ -427,11 +440,12 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
||||
if (ny == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
grid_view_delete_lines(s->grid, s->cy, ny);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_deleteline, ny);
|
||||
ttyctx.num = ny;
|
||||
tty_write(tty_cmd_deleteline, &ttyctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -440,14 +454,15 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
||||
if (ny == 0)
|
||||
return;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cy < s->rupper || s->cy > s->rlower)
|
||||
grid_view_delete_lines(s->grid, s->cy, ny);
|
||||
else
|
||||
grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);
|
||||
|
||||
tty_writenum(ctx->wp, tty_cmd_deleteline, ny);
|
||||
ttyctx.num = ny;
|
||||
tty_write(tty_cmd_deleteline, &ttyctx);
|
||||
}
|
||||
|
||||
/* Clear line at cursor. */
|
||||
@ -455,12 +470,13 @@ void
|
||||
screen_write_clearline(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearline);
|
||||
tty_write(tty_cmd_clearline, &ttyctx);
|
||||
}
|
||||
|
||||
/* Clear to end of line from cursor. */
|
||||
@ -468,16 +484,17 @@ void
|
||||
screen_write_clearendofline(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
sx = screen_size_x(s);
|
||||
|
||||
if (s->cx <= sx - 1)
|
||||
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearendofline);
|
||||
tty_write(tty_cmd_clearendofline, &ttyctx);
|
||||
}
|
||||
|
||||
/* Clear to start of line from cursor. */
|
||||
@ -485,9 +502,10 @@ void
|
||||
screen_write_clearstartofline(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
sx = screen_size_x(s);
|
||||
|
||||
@ -496,7 +514,7 @@ screen_write_clearstartofline(struct screen_write_ctx *ctx)
|
||||
else
|
||||
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearstartofline);
|
||||
tty_write(tty_cmd_clearstartofline, &ttyctx);
|
||||
}
|
||||
|
||||
/* Move cursor to px,py. */
|
||||
@ -531,15 +549,16 @@ void
|
||||
screen_write_reverseindex(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cy == s->rupper)
|
||||
grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);
|
||||
else if (s->cy > 0)
|
||||
s->cy--;
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_reverseindex);
|
||||
tty_write(tty_cmd_reverseindex, &ttyctx);
|
||||
}
|
||||
|
||||
/* Set scroll region. */
|
||||
@ -593,15 +612,16 @@ void
|
||||
screen_write_linefeed(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
if (s->cy == s->rlower)
|
||||
grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);
|
||||
else if (s->cy < screen_size_y(s) - 1)
|
||||
s->cy++;
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_linefeed);
|
||||
tty_write(tty_cmd_linefeed, &ttyctx);
|
||||
}
|
||||
|
||||
/* Carriage return (cursor to start of line). */
|
||||
@ -642,9 +662,10 @@ void
|
||||
screen_write_clearendofscreen(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx, sy;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
sx = screen_size_x(s);
|
||||
sy = screen_size_y(s);
|
||||
@ -653,7 +674,7 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx)
|
||||
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
||||
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearendofscreen);
|
||||
tty_write(tty_cmd_clearendofscreen, &ttyctx);
|
||||
}
|
||||
|
||||
/* Clear to start of screen. */
|
||||
@ -661,9 +682,10 @@ void
|
||||
screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
sx = screen_size_x(s);
|
||||
|
||||
@ -674,7 +696,7 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
|
||||
else
|
||||
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearstartofscreen);
|
||||
tty_write(tty_cmd_clearstartofscreen, &ttyctx);
|
||||
}
|
||||
|
||||
/* Clear entire screen. */
|
||||
@ -682,12 +704,13 @@ void
|
||||
screen_write_clearscreen(struct screen_write_ctx *ctx)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct tty_ctx ttyctx;
|
||||
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
|
||||
|
||||
tty_write0(ctx->wp, tty_cmd_clearscreen);
|
||||
tty_write(tty_cmd_clearscreen, &ttyctx);
|
||||
}
|
||||
|
||||
/* Write cell data. */
|
||||
@ -737,7 +760,9 @@ screen_write_cell(
|
||||
memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i);
|
||||
|
||||
/* Assume the previous character has just been input. */
|
||||
tty_writeptr(ctx->wp, tty_cmd_utf8character, udata);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
ttyctx.ptr = udata;
|
||||
tty_write(tty_cmd_utf8character, &ttyctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -785,13 +810,14 @@ screen_write_cell(
|
||||
grid_view_set_utf8(gd, s->cx, s->cy, &gu);
|
||||
|
||||
/* Move the cursor. */
|
||||
screen_write_save(ctx);
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
s->cx += width;
|
||||
|
||||
/* Draw to the screen if necessary. */
|
||||
if (insert)
|
||||
tty_writenum(ctx->wp, tty_cmd_insertcharacter, width);
|
||||
ttyctx.wp = ctx->wp;
|
||||
if (insert) {
|
||||
ttyctx.num = width;
|
||||
tty_write(tty_cmd_insertcharacter, &ttyctx);
|
||||
}
|
||||
ttyctx.utf8 = &gu;
|
||||
if (screen_check_selection(s, s->cx - width, s->cy)) {
|
||||
s->sel.cell.data = gc->data;
|
||||
|
28
tmux.h
28
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.383 2009-07-23 12:38:01 tcunha Exp $ */
|
||||
/* $Id: tmux.h,v 1.384 2009-07-23 12:48:18 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -476,15 +476,9 @@ struct screen {
|
||||
u_int cx; /* cursor x */
|
||||
u_int cy; /* cursor y */
|
||||
|
||||
u_int old_cx;
|
||||
u_int old_cy;
|
||||
|
||||
u_int rupper; /* scroll region top */
|
||||
u_int rlower; /* scroll region bottom */
|
||||
|
||||
u_int old_rupper;
|
||||
u_int old_rlower;
|
||||
|
||||
int mode;
|
||||
|
||||
bitstr_t *tabs;
|
||||
@ -782,8 +776,19 @@ struct tty_ctx {
|
||||
const struct grid_cell *cell;
|
||||
const struct grid_utf8 *utf8;
|
||||
|
||||
u_int num;
|
||||
void *ptr;
|
||||
u_int num;
|
||||
void *ptr;
|
||||
|
||||
/*
|
||||
* Cursor and region position before the screen was updated - this is
|
||||
* where the command should be applied; the values in the screen have
|
||||
* already been updated.
|
||||
*/
|
||||
u_int ocx;
|
||||
u_int ocy;
|
||||
|
||||
u_int orupper;
|
||||
u_int orlower;
|
||||
};
|
||||
typedef void tty_cmd_func(struct tty *, struct tty_ctx *);
|
||||
|
||||
@ -1031,10 +1036,10 @@ void tty_detect_utf8(struct tty *);
|
||||
void tty_set_title(struct tty *, const char *);
|
||||
void tty_update_mode(struct tty *, int);
|
||||
void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
|
||||
void tty_redraw_region(struct tty *, struct window_pane *);
|
||||
int tty_open(struct tty *, char **);
|
||||
void tty_close(struct tty *, int);
|
||||
void tty_free(struct tty *, int);
|
||||
void tty_write(void (*)(struct tty *, struct tty_ctx *), struct tty_ctx *);
|
||||
void tty_cmd_alignmenttest(struct tty *, struct tty_ctx *);
|
||||
void tty_cmd_cell(struct tty *, struct tty_ctx *);
|
||||
void tty_cmd_clearendofline(struct tty *, struct tty_ctx *);
|
||||
@ -1072,9 +1077,6 @@ void tty_keys_free(struct tty *);
|
||||
int tty_keys_next(struct tty *, int *, u_char *);
|
||||
|
||||
/* tty-write.c */
|
||||
void tty_write0(struct window_pane *, tty_cmd_func *);
|
||||
void tty_writenum(struct window_pane *, tty_cmd_func *, u_int);
|
||||
void tty_writeptr(struct window_pane *, tty_cmd_func *, void *);
|
||||
void tty_write(tty_cmd_func *, struct tty_ctx *);
|
||||
|
||||
/* options-cmd.c */
|
||||
|
36
tty-write.c
36
tty-write.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tty-write.c,v 1.21 2009-07-23 12:38:01 tcunha Exp $ */
|
||||
/* $Id: tty-write.c,v 1.22 2009-07-23 12:48:18 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -18,42 +18,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
void
|
||||
tty_write0(struct window_pane *wp, tty_cmd_func *cmdfn)
|
||||
{
|
||||
struct tty_ctx ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof ctx);
|
||||
ctx.wp = wp;
|
||||
tty_write(cmdfn, &ctx);
|
||||
}
|
||||
|
||||
void
|
||||
tty_writenum(struct window_pane *wp, tty_cmd_func *cmdfn, u_int num)
|
||||
{
|
||||
struct tty_ctx ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof ctx);
|
||||
ctx.wp = wp;
|
||||
ctx.num = num;
|
||||
tty_write(cmdfn, &ctx);
|
||||
}
|
||||
|
||||
void
|
||||
tty_writeptr(struct window_pane *wp, tty_cmd_func *cmdfn, void *ptr)
|
||||
{
|
||||
struct tty_ctx ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof ctx);
|
||||
ctx.wp = wp;
|
||||
ctx.ptr = ptr;
|
||||
tty_write(cmdfn, &ctx);
|
||||
}
|
||||
|
||||
void
|
||||
tty_write(tty_cmd_func *cmdfn, struct tty_ctx *ctx)
|
||||
{
|
||||
|
92
tty.c
92
tty.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tty.c,v 1.116 2009-07-23 12:38:01 tcunha Exp $ */
|
||||
/* $Id: tty.c,v 1.117 2009-07-23 12:48:18 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -38,10 +38,11 @@ void tty_attributes(struct tty *, const struct grid_cell *);
|
||||
void tty_attributes_fg(struct tty *, const struct grid_cell *);
|
||||
void tty_attributes_bg(struct tty *, const struct grid_cell *);
|
||||
|
||||
void tty_redraw_region(struct tty *, struct tty_ctx *);
|
||||
void tty_emulate_repeat(
|
||||
struct tty *, enum tty_code_code, enum tty_code_code, u_int);
|
||||
void tty_cell(struct tty *,
|
||||
const struct grid_cell *, const struct grid_utf8 *);
|
||||
void tty_cell(struct tty *,
|
||||
const struct grid_cell *, const struct grid_utf8 *);
|
||||
|
||||
void
|
||||
tty_init(struct tty *tty, char *path, char *term)
|
||||
@ -459,10 +460,11 @@ tty_emulate_repeat(
|
||||
* width of the terminal.
|
||||
*/
|
||||
void
|
||||
tty_redraw_region(struct tty *tty, struct window_pane *wp)
|
||||
tty_redraw_region(struct tty *tty, struct tty_ctx *ctx)
|
||||
{
|
||||
struct screen *s = wp->screen;
|
||||
u_int i;
|
||||
struct window_pane *wp = ctx->wp;
|
||||
struct screen *s = wp->screen;
|
||||
u_int i;
|
||||
|
||||
/*
|
||||
* If region is >= 50% of the screen, just schedule a window redraw. In
|
||||
@ -470,16 +472,16 @@ tty_redraw_region(struct tty *tty, struct window_pane *wp)
|
||||
* without this, the entire pane ends up being redrawn many times which
|
||||
* can be much more data.
|
||||
*/
|
||||
if (s->old_rupper - s->old_rlower >= screen_size_y(s) / 2) {
|
||||
if (ctx->orupper - ctx->orlower >= screen_size_y(s) / 2) {
|
||||
wp->flags |= PANE_REDRAW;
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) {
|
||||
for (i = s->old_cy; i < screen_size_y(s); i++)
|
||||
if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) {
|
||||
for (i = ctx->ocy; i < screen_size_y(s); i++)
|
||||
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
|
||||
} else {
|
||||
for (i = s->old_rupper; i <= s->old_rlower; i++)
|
||||
for (i = ctx->orupper; i <= ctx->orlower; i++)
|
||||
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
|
||||
}
|
||||
}
|
||||
@ -532,13 +534,13 @@ tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx)
|
||||
struct screen *s = wp->screen;
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
|
||||
tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
if (tty_term_has(tty->term, TTYC_ICH) ||
|
||||
tty_term_has(tty->term, TTYC_ICH1))
|
||||
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num);
|
||||
@ -557,13 +559,13 @@ tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx)
|
||||
struct screen *s = wp->screen;
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
|
||||
tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
|
||||
}
|
||||
|
||||
@ -575,15 +577,15 @@ tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||
tty_redraw_region(tty, wp);
|
||||
tty_redraw_region(tty, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||
tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
|
||||
}
|
||||
|
||||
@ -595,15 +597,15 @@ tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||
tty_redraw_region(tty, wp);
|
||||
tty_redraw_region(tty, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||
tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
|
||||
}
|
||||
|
||||
@ -616,7 +618,7 @@ tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, 0, 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);
|
||||
@ -635,12 +637,12 @@ tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
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);
|
||||
else {
|
||||
for (i = s->old_cx; i < screen_size_x(s); i++)
|
||||
for (i = ctx->ocx; i < screen_size_x(s); i++)
|
||||
tty_putc(tty, ' ');
|
||||
}
|
||||
}
|
||||
@ -649,17 +651,16 @@ void
|
||||
tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx)
|
||||
{
|
||||
struct window_pane *wp = ctx->wp;
|
||||
struct screen *s = wp->screen;
|
||||
u_int i;
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
tty_putcode(tty, TTYC_EL1);
|
||||
} else {
|
||||
tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
|
||||
for (i = 0; i < s->old_cx + 1; i++)
|
||||
tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff);
|
||||
for (i = 0; i < ctx->ocx + 1; i++)
|
||||
tty_putc(tty, ' ');
|
||||
}
|
||||
}
|
||||
@ -672,16 +673,16 @@ tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||
tty_redraw_region(tty, wp);
|
||||
tty_redraw_region(tty, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||
tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
|
||||
|
||||
if (s->old_cy == s->old_rupper) {
|
||||
tty_cursor(tty, s->old_cx, s->old_rupper, wp->xoff, wp->yoff);
|
||||
if (ctx->ocy == ctx->orupper) {
|
||||
tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff);
|
||||
tty_putcode(tty, TTYC_RI);
|
||||
}
|
||||
}
|
||||
@ -694,16 +695,16 @@ tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx)
|
||||
|
||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||
tty_redraw_region(tty, wp);
|
||||
tty_redraw_region(tty, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
tty_reset(tty);
|
||||
|
||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||
tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
|
||||
|
||||
if (s->old_cy == s->old_rlower) {
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
if (ctx->ocy == ctx->orlower) {
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
tty_putc(tty, '\n');
|
||||
}
|
||||
}
|
||||
@ -718,13 +719,13 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||
tty_reset(tty);
|
||||
|
||||
tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
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);
|
||||
if (s->old_cy != screen_size_y(s) - 1) {
|
||||
tty_cursor(tty, 0, s->old_cy + 1, wp->xoff, wp->yoff);
|
||||
for (i = s->old_cy + 1; i < screen_size_y(s); i++) {
|
||||
if (ctx->ocy != screen_size_y(s) - 1) {
|
||||
tty_cursor(tty, 0, ctx->ocy + 1, wp->xoff, wp->yoff);
|
||||
for (i = ctx->ocy + 1; i < screen_size_y(s); i++) {
|
||||
tty_putcode(tty, TTYC_EL);
|
||||
if (i == screen_size_y(s) - 1)
|
||||
continue;
|
||||
@ -733,9 +734,9 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = s->old_cx; i < screen_size_x(s); i++)
|
||||
for (i = ctx->ocx; i < screen_size_x(s); i++)
|
||||
tty_putc(tty, ' ');
|
||||
for (j = s->old_cy; j < screen_size_y(s); j++) {
|
||||
for (j = ctx->ocy; j < screen_size_y(s); j++) {
|
||||
tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
|
||||
for (i = 0; i < screen_size_x(s); i++)
|
||||
tty_putc(tty, ' ');
|
||||
@ -756,19 +757,19 @@ tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||
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 < s->old_cy; i++) {
|
||||
for (i = 0; i < ctx->ocy; i++) {
|
||||
tty_putcode(tty, TTYC_EL);
|
||||
tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1);
|
||||
tty->cy++;
|
||||
}
|
||||
} else {
|
||||
for (j = 0; j < s->old_cy; j++) {
|
||||
for (j = 0; j < ctx->ocy; j++) {
|
||||
tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
|
||||
for (i = 0; i < screen_size_x(s); i++)
|
||||
tty_putc(tty, ' ');
|
||||
}
|
||||
}
|
||||
for (i = 0; i <= s->old_cx; i++)
|
||||
for (i = 0; i <= ctx->ocx; i++)
|
||||
tty_putc(tty, ' ');
|
||||
}
|
||||
|
||||
@ -823,9 +824,8 @@ void
|
||||
tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx)
|
||||
{
|
||||
struct window_pane *wp = ctx->wp;
|
||||
struct screen *s = wp->screen;
|
||||
|
||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||
tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
|
||||
|
||||
tty_cell(tty, ctx->cell, ctx->utf8);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user