mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 09:58:52 +00:00
Sync OpenBSD patchset 159:
There are relatively few arguments to tty_cmd_* functions now, so tidy them up by using a struct rather than hiding everything with varargs.
This commit is contained in:
parent
75a44d856e
commit
b6afa30c39
@ -1,4 +1,4 @@
|
|||||||
/* $Id: screen-write.c,v 1.61 2009-07-22 17:58:42 tcunha Exp $ */
|
/* $Id: screen-write.c,v 1.62 2009-07-22 18:08:56 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -327,7 +327,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
|
|||||||
s->rupper = 0;
|
s->rupper = 0;
|
||||||
s->rlower = screen_size_y(s) - 1;
|
s->rlower = screen_size_y(s) - 1;
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_ALIGNMENTTEST);
|
tty_write0(ctx->wp, TTY_ALIGNMENTTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert nx characters. */
|
/* Insert nx characters. */
|
||||||
@ -349,7 +349,7 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
|
|||||||
if (s->cx <= screen_size_x(s) - 1)
|
if (s->cx <= screen_size_x(s) - 1)
|
||||||
grid_view_insert_cells(s->grid, s->cx, s->cy, nx);
|
grid_view_insert_cells(s->grid, s->cx, s->cy, nx);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_INSERTCHARACTER, nx);
|
tty_writenum(ctx->wp, TTY_INSERTCHARACTER, nx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete nx characters. */
|
/* Delete nx characters. */
|
||||||
@ -371,7 +371,7 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
|
|||||||
if (s->cx <= screen_size_x(s) - 1)
|
if (s->cx <= screen_size_x(s) - 1)
|
||||||
grid_view_delete_cells(s->grid, s->cx, s->cy, nx);
|
grid_view_delete_cells(s->grid, s->cx, s->cy, nx);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_DELETECHARACTER, nx);
|
tty_writenum(ctx->wp, TTY_DELETECHARACTER, nx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert ny lines. */
|
/* Insert ny lines. */
|
||||||
@ -393,7 +393,7 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
|||||||
|
|
||||||
grid_view_insert_lines(s->grid, s->cy, ny);
|
grid_view_insert_lines(s->grid, s->cy, ny);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_INSERTLINE, ny);
|
tty_writenum(ctx->wp, TTY_INSERTLINE, ny);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
|||||||
else
|
else
|
||||||
grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny);
|
grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_INSERTLINE, ny);
|
tty_writenum(ctx->wp, TTY_INSERTLINE, ny);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete ny lines. */
|
/* Delete ny lines. */
|
||||||
@ -431,7 +431,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
|||||||
|
|
||||||
grid_view_delete_lines(s->grid, s->cy, ny);
|
grid_view_delete_lines(s->grid, s->cy, ny);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_DELETELINE, ny);
|
tty_writenum(ctx->wp, TTY_DELETELINE, ny);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
|||||||
else
|
else
|
||||||
grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);
|
grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_DELETELINE, ny);
|
tty_writenum(ctx->wp, TTY_DELETELINE, ny);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear line at cursor. */
|
/* Clear line at cursor. */
|
||||||
@ -460,7 +460,7 @@ screen_write_clearline(struct screen_write_ctx *ctx)
|
|||||||
|
|
||||||
grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);
|
grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARLINE);
|
tty_writenum(ctx->wp, TTY_CLEARLINE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear to end of line from cursor. */
|
/* Clear to end of line from cursor. */
|
||||||
@ -477,7 +477,7 @@ screen_write_clearendofline(struct screen_write_ctx *ctx)
|
|||||||
if (s->cx <= sx - 1)
|
if (s->cx <= sx - 1)
|
||||||
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARENDOFLINE);
|
tty_writenum(ctx->wp, TTY_CLEARENDOFLINE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear to start of line from cursor. */
|
/* Clear to start of line from cursor. */
|
||||||
@ -496,7 +496,7 @@ screen_write_clearstartofline(struct screen_write_ctx *ctx)
|
|||||||
else
|
else
|
||||||
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARSTARTOFLINE);
|
tty_writenum(ctx->wp, TTY_CLEARSTARTOFLINE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move cursor to px,py. */
|
/* Move cursor to px,py. */
|
||||||
@ -539,7 +539,7 @@ screen_write_reverseindex(struct screen_write_ctx *ctx)
|
|||||||
else if (s->cy > 0)
|
else if (s->cy > 0)
|
||||||
s->cy--;
|
s->cy--;
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_REVERSEINDEX);
|
tty_writenum(ctx->wp, TTY_REVERSEINDEX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set scroll region. */
|
/* Set scroll region. */
|
||||||
@ -601,7 +601,7 @@ screen_write_linefeed(struct screen_write_ctx *ctx)
|
|||||||
else if (s->cy < screen_size_y(s) - 1)
|
else if (s->cy < screen_size_y(s) - 1)
|
||||||
s->cy++;
|
s->cy++;
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_LINEFEED);
|
tty_writenum(ctx->wp, TTY_LINEFEED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Carriage return (cursor to start of line). */
|
/* Carriage return (cursor to start of line). */
|
||||||
@ -653,7 +653,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, s->cx, s->cy, sx - s->cx, 1);
|
||||||
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
|
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARENDOFSCREEN);
|
tty_writenum(ctx->wp, TTY_CLEARENDOFSCREEN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear to start of screen. */
|
/* Clear to start of screen. */
|
||||||
@ -674,7 +674,7 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
|
|||||||
else
|
else
|
||||||
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARSTARTOFSCREEN);
|
tty_writenum(ctx->wp, TTY_CLEARSTARTOFSCREEN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear entire screen. */
|
/* Clear entire screen. */
|
||||||
@ -687,7 +687,7 @@ screen_write_clearscreen(struct screen_write_ctx *ctx)
|
|||||||
|
|
||||||
grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
|
grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
|
||||||
|
|
||||||
tty_write_cmd(ctx->wp, TTY_CLEARSCREEN);
|
tty_writenum(ctx->wp, TTY_CLEARSCREEN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write cell data. */
|
/* Write cell data. */
|
||||||
@ -697,6 +697,7 @@ screen_write_cell(
|
|||||||
{
|
{
|
||||||
struct screen *s = ctx->s;
|
struct screen *s = ctx->s;
|
||||||
struct grid *gd = s->grid;
|
struct grid *gd = s->grid;
|
||||||
|
struct tty_ctx ttyctx;
|
||||||
struct grid_utf8 gu, *tmp_gu;
|
struct grid_utf8 gu, *tmp_gu;
|
||||||
u_int width, xx, i;
|
u_int width, xx, i;
|
||||||
struct grid_cell tmp_gc, *tmp_gc2;
|
struct grid_cell tmp_gc, *tmp_gc2;
|
||||||
@ -736,7 +737,7 @@ screen_write_cell(
|
|||||||
memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i);
|
memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i);
|
||||||
|
|
||||||
/* Assume the previous character has just been input. */
|
/* Assume the previous character has just been input. */
|
||||||
tty_write_cmd(ctx->wp, TTY_UTF8CHARACTER, udata);
|
tty_writeptr(ctx->wp, TTY_UTF8CHARACTER, udata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,12 +790,17 @@ screen_write_cell(
|
|||||||
|
|
||||||
/* Draw to the screen if necessary. */
|
/* Draw to the screen if necessary. */
|
||||||
if (insert)
|
if (insert)
|
||||||
tty_write_cmd(ctx->wp, TTY_INSERTCHARACTER, width);
|
tty_writenum(ctx->wp, TTY_INSERTCHARACTER, width);
|
||||||
|
ttyctx.wp = ctx->wp;
|
||||||
|
ttyctx.utf8 = &gu;
|
||||||
if (screen_check_selection(s, s->cx - width, s->cy)) {
|
if (screen_check_selection(s, s->cx - width, s->cy)) {
|
||||||
s->sel.cell.data = gc->data;
|
s->sel.cell.data = gc->data;
|
||||||
tty_write_cmd(ctx->wp, TTY_CELL, &s->sel.cell, &gu);
|
ttyctx.cell = &s->sel.cell;
|
||||||
} else
|
tty_write_cmd(TTY_CELL, &ttyctx);
|
||||||
tty_write_cmd(ctx->wp, TTY_CELL, gc, &gu);
|
} else {
|
||||||
|
ttyctx.cell = gc;
|
||||||
|
tty_write_cmd(TTY_CELL, &ttyctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
20
tmux.h
20
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.381 2009-07-22 17:58:42 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.382 2009-07-22 18:08:56 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -291,6 +291,16 @@ enum tty_cmd {
|
|||||||
TTY_REVERSEINDEX,
|
TTY_REVERSEINDEX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tty_ctx {
|
||||||
|
struct window_pane *wp;
|
||||||
|
|
||||||
|
const struct grid_cell *cell;
|
||||||
|
const struct grid_utf8 *utf8;
|
||||||
|
|
||||||
|
u_int num;
|
||||||
|
void *ptr;
|
||||||
|
};
|
||||||
|
|
||||||
/* Message codes. */
|
/* Message codes. */
|
||||||
enum hdrtype {
|
enum hdrtype {
|
||||||
MSG_COMMAND,
|
MSG_COMMAND,
|
||||||
@ -1047,8 +1057,7 @@ void tty_redraw_region(struct tty *, struct window_pane *);
|
|||||||
int tty_open(struct tty *, char **);
|
int tty_open(struct tty *, char **);
|
||||||
void tty_close(struct tty *, int);
|
void tty_close(struct tty *, int);
|
||||||
void tty_free(struct tty *, int);
|
void tty_free(struct tty *, int);
|
||||||
void tty_vwrite(
|
void tty_write(struct tty *, enum tty_cmd, struct tty_ctx *);
|
||||||
struct tty *, struct window_pane *, enum tty_cmd, va_list);
|
|
||||||
|
|
||||||
/* tty-term.c */
|
/* tty-term.c */
|
||||||
extern struct tty_terms tty_terms;
|
extern struct tty_terms tty_terms;
|
||||||
@ -1071,7 +1080,10 @@ void tty_keys_free(struct tty *);
|
|||||||
int tty_keys_next(struct tty *, int *, u_char *);
|
int tty_keys_next(struct tty *, int *, u_char *);
|
||||||
|
|
||||||
/* tty-write.c */
|
/* tty-write.c */
|
||||||
void tty_write_cmd(struct window_pane *, enum tty_cmd, ...);
|
void tty_write0(struct window_pane *, enum tty_cmd);
|
||||||
|
void tty_writenum(struct window_pane *, enum tty_cmd, u_int);
|
||||||
|
void tty_writeptr(struct window_pane *, enum tty_cmd, void *);
|
||||||
|
void tty_write_cmd(enum tty_cmd, struct tty_ctx *);
|
||||||
|
|
||||||
/* options-cmd.c */
|
/* options-cmd.c */
|
||||||
void set_option_string(struct cmd_ctx *,
|
void set_option_string(struct cmd_ctx *,
|
||||||
|
50
tty-write.c
50
tty-write.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tty-write.c,v 1.19 2009-07-15 17:42:44 nicm Exp $ */
|
/* $Id: tty-write.c,v 1.20 2009-07-22 18:08:56 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -18,26 +18,48 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void tty_vwrite_cmd(struct window_pane *, enum tty_cmd, va_list);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_write_cmd(struct window_pane *wp, enum tty_cmd cmd, ...)
|
tty_write0(struct window_pane *wp, enum tty_cmd cmd)
|
||||||
{
|
{
|
||||||
va_list ap;
|
struct tty_ctx ctx;
|
||||||
|
|
||||||
va_start(ap, cmd);
|
memset(&ctx, 0, sizeof ctx);
|
||||||
tty_vwrite_cmd(wp, cmd, ap);
|
ctx.wp = wp;
|
||||||
va_end(ap);
|
tty_write_cmd(cmd, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_vwrite_cmd(struct window_pane *wp, enum tty_cmd cmd, va_list ap)
|
tty_writenum(struct window_pane *wp, enum tty_cmd cmd, u_int num)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct tty_ctx ctx;
|
||||||
va_list aq;
|
|
||||||
u_int i;
|
memset(&ctx, 0, sizeof ctx);
|
||||||
|
ctx.wp = wp;
|
||||||
|
ctx.num = num;
|
||||||
|
tty_write_cmd(cmd, &ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_writeptr(struct window_pane *wp, enum tty_cmd cmd, void *ptr)
|
||||||
|
{
|
||||||
|
struct tty_ctx ctx;
|
||||||
|
|
||||||
|
memset(&ctx, 0, sizeof ctx);
|
||||||
|
ctx.wp = wp;
|
||||||
|
ctx.ptr = ptr;
|
||||||
|
tty_write_cmd(cmd, &ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_write_cmd(enum tty_cmd cmd, struct tty_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct window_pane *wp = ctx->wp;
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return;
|
return;
|
||||||
@ -57,9 +79,7 @@ tty_vwrite_cmd(struct window_pane *wp, enum tty_cmd cmd, va_list ap)
|
|||||||
if (c->session->curw->window == wp->window) {
|
if (c->session->curw->window == wp->window) {
|
||||||
tty_update_mode(&c->tty, c->tty.mode & ~MODE_CURSOR);
|
tty_update_mode(&c->tty, c->tty.mode & ~MODE_CURSOR);
|
||||||
|
|
||||||
va_copy(aq, ap);
|
tty_write(&c->tty, cmd, ctx);
|
||||||
tty_vwrite(&c->tty, wp, cmd, aq);
|
|
||||||
va_end(aq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
167
tty.c
167
tty.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tty.c,v 1.114 2009-07-22 17:58:42 tcunha Exp $ */
|
/* $Id: tty.c,v 1.115 2009-07-22 18:08:56 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -38,23 +38,23 @@ void tty_attributes(struct tty *, const struct grid_cell *);
|
|||||||
void tty_attributes_fg(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_attributes_bg(struct tty *, const struct grid_cell *);
|
||||||
|
|
||||||
void tty_cmd_alignmenttest(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_alignmenttest(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_cell(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_cell(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearendofline(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearendofline(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearendofscreen(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearendofscreen(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearline(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearline(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearscreen(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearscreen(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearstartofline(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearstartofline(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_clearstartofscreen(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_clearstartofscreen(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_deletecharacter(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_deletecharacter(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_deleteline(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_deleteline(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_insertcharacter(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_insertcharacter(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_insertline(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_insertline(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_linefeed(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_linefeed(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_utf8character(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_utf8character(struct tty *, struct tty_ctx *);
|
||||||
void tty_cmd_reverseindex(struct tty *, struct window_pane *, va_list);
|
void tty_cmd_reverseindex(struct tty *, struct tty_ctx *);
|
||||||
|
|
||||||
void (*tty_cmds[])(struct tty *, struct window_pane *, va_list) = {
|
void (*tty_cmds[])(struct tty *, struct tty_ctx *) = {
|
||||||
tty_cmd_alignmenttest,
|
tty_cmd_alignmenttest,
|
||||||
tty_cmd_cell,
|
tty_cmd_cell,
|
||||||
tty_cmd_clearendofline,
|
tty_cmd_clearendofline,
|
||||||
@ -555,66 +555,61 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_vwrite(
|
tty_write(struct tty *tty, enum tty_cmd cmd, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, enum tty_cmd cmd, va_list ap)
|
|
||||||
{
|
{
|
||||||
if (tty->flags & TTY_FREEZE || tty->term == NULL)
|
if (tty->flags & TTY_FREEZE || tty->term == NULL)
|
||||||
return;
|
return;
|
||||||
if (tty_cmds[cmd] != NULL)
|
if (tty_cmds[cmd] != NULL)
|
||||||
tty_cmds[cmd](tty, wp, ap);
|
tty_cmds[cmd](tty, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_insertcharacter(struct tty *tty, struct window_pane *wp, va_list ap)
|
tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int ua;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
|
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, s->old_cy, wp->xoff, wp->yoff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ua = va_arg(ap, u_int);
|
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||||
if (tty_term_has(tty->term, TTYC_ICH) ||
|
if (tty_term_has(tty->term, TTYC_ICH) ||
|
||||||
tty_term_has(tty->term, TTYC_ICH1))
|
tty_term_has(tty->term, TTYC_ICH1))
|
||||||
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ua);
|
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num);
|
||||||
else {
|
else {
|
||||||
tty_putcode(tty, TTYC_SMIR);
|
tty_putcode(tty, TTYC_SMIR);
|
||||||
while (ua-- > 0)
|
while (ctx->num-- > 0)
|
||||||
tty_putc(tty, ' ');
|
tty_putc(tty, ' ');
|
||||||
tty_putcode(tty, TTYC_RMIR);
|
tty_putcode(tty, TTYC_RMIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_deletecharacter(struct tty *tty, struct window_pane *wp, va_list ap)
|
tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int ua;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
|
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, s->old_cy, wp->xoff, wp->yoff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ua = va_arg(ap, u_int);
|
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||||
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ua);
|
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap)
|
tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int ua;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||||
@ -622,21 +617,19 @@ tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ua = va_arg(ap, u_int);
|
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||||
|
|
||||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||||
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ua);
|
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap)
|
tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int ua;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||||
@ -644,21 +637,20 @@ tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ua = va_arg(ap, u_int);
|
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
|
||||||
|
|
||||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||||
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ua);
|
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearline(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -673,11 +665,11 @@ tty_cmd_clearline(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearendofline(
|
tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -692,11 +684,11 @@ tty_cmd_clearendofline(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearstartofline(
|
tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -711,9 +703,10 @@ tty_cmd_clearstartofline(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_reverseindex(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||||
@ -732,9 +725,10 @@ tty_cmd_reverseindex(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_linefeed(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||||
@ -753,11 +747,11 @@ tty_cmd_linefeed(struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearendofscreen(
|
tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i, j;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -788,11 +782,11 @@ tty_cmd_clearendofscreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearstartofscreen(
|
tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i, j;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -817,11 +811,11 @@ tty_cmd_clearstartofscreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_clearscreen(
|
tty_cmd_clearscreen(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i, j;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -846,11 +840,11 @@ tty_cmd_clearscreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_alignmenttest(
|
tty_cmd_alignmenttest(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, struct window_pane *wp, unused va_list ap)
|
|
||||||
{
|
{
|
||||||
struct screen *s = wp->screen;
|
struct window_pane *wp = ctx->wp;
|
||||||
u_int i, j;
|
struct screen *s = wp->screen;
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
@ -864,33 +858,26 @@ tty_cmd_alignmenttest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_cell(struct tty *tty, struct window_pane *wp, va_list ap)
|
tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
struct window_pane *wp = ctx->wp;
|
||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
struct grid_cell *gc;
|
|
||||||
struct grid_utf8 *gu;
|
|
||||||
|
|
||||||
gc = va_arg(ap, struct grid_cell *);
|
|
||||||
gu = va_arg(ap, struct grid_utf8 *);
|
|
||||||
|
|
||||||
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
|
||||||
|
|
||||||
tty_cell(tty, gc, gu);
|
tty_cell(tty, ctx->cell, ctx->utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_cmd_utf8character(
|
tty_cmd_utf8character(struct tty *tty, struct tty_ctx *ctx)
|
||||||
struct tty *tty, unused struct window_pane *wp, va_list ap)
|
|
||||||
{
|
{
|
||||||
u_char *buf;
|
u_char *ptr = ctx->ptr;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
buf = va_arg(ap, u_char *);
|
|
||||||
|
|
||||||
for (i = 0; i < UTF8_SIZE; i++) {
|
for (i = 0; i < UTF8_SIZE; i++) {
|
||||||
if (buf[i] == 0xff)
|
if (ptr[i] == 0xff)
|
||||||
break;
|
break;
|
||||||
tty_putc(tty, buf[i]);
|
tty_putc(tty, ptr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user