diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-12 09:42:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-12 09:42:00 +0000 |
commit | 78e4656b79b4fb75b59ac3007ec2efe0f2389783 (patch) | |
tree | c96b226c20460ff86f0d8bf0b13e449e36ec48d3 | |
parent | 055698d913f2dab1954c11d1e1519de672098990 (diff) |
A tty context must not be modified as it may be reused to update multiple
clients, so make it const.
Also fix an actual modification which caused a hang when a session was
connected to multiple terminals at least one of which was missing ich/ich1.
-rw-r--r-- | usr.bin/tmux/tmux.h | 35 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 42 |
2 files changed, 40 insertions, 37 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 78df2f196f7..d2f2652f100 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.78 2009/08/11 21:28:11 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.79 2009/08/12 09:41:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1168,22 +1168,23 @@ void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int); int tty_open(struct tty *, const char *, char **); void tty_close(struct tty *); void tty_free(struct tty *); -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 *); -void tty_cmd_clearendofscreen(struct tty *, struct tty_ctx *); -void tty_cmd_clearline(struct tty *, struct tty_ctx *); -void tty_cmd_clearscreen(struct tty *, struct tty_ctx *); -void tty_cmd_clearstartofline(struct tty *, struct tty_ctx *); -void tty_cmd_clearstartofscreen(struct tty *, struct tty_ctx *); -void tty_cmd_deletecharacter(struct tty *, struct tty_ctx *); -void tty_cmd_deleteline(struct tty *, struct tty_ctx *); -void tty_cmd_insertcharacter(struct tty *, struct tty_ctx *); -void tty_cmd_insertline(struct tty *, struct tty_ctx *); -void tty_cmd_linefeed(struct tty *, struct tty_ctx *); -void tty_cmd_utf8character(struct tty *, struct tty_ctx *); -void tty_cmd_reverseindex(struct tty *, struct tty_ctx *); +void tty_write(void (*)( + struct tty *, const struct tty_ctx *), const struct tty_ctx *); +void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *); +void tty_cmd_cell(struct tty *, const struct tty_ctx *); +void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *); +void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *); +void tty_cmd_clearline(struct tty *, const struct tty_ctx *); +void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *); +void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *); +void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); +void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); +void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); +void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); +void tty_cmd_insertline(struct tty *, const struct tty_ctx *); +void tty_cmd_linefeed(struct tty *, const struct tty_ctx *); +void tty_cmd_utf8character(struct tty *, const struct tty_ctx *); +void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); /* tty-term.c */ extern struct tty_terms tty_terms; diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index a9dd2251181..7a8ac1c700f 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.23 2009/08/11 22:34:17 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.24 2009/08/12 09:41:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -38,7 +38,7 @@ 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_redraw_region(struct tty *, const struct tty_ctx *); void tty_emulate_repeat( struct tty *, enum tty_code_code, enum tty_code_code, u_int); void tty_cell(struct tty *, @@ -461,7 +461,7 @@ tty_emulate_repeat( * width of the terminal. */ void -tty_redraw_region(struct tty *tty, struct tty_ctx *ctx) +tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -532,7 +532,8 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy) } void -tty_write(void (*cmdfn)(struct tty *, struct tty_ctx *), struct tty_ctx *ctx) +tty_write(void (*cmdfn)( + struct tty *, const struct tty_ctx *), const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct client *c; @@ -563,10 +564,11 @@ tty_write(void (*cmdfn)(struct tty *, struct tty_ctx *), struct tty_ctx *ctx) } void -tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; + u_int i; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); @@ -581,14 +583,14 @@ tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx) tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); else { tty_putcode(tty, TTYC_SMIR); - while (ctx->num-- > 0) + for (i = 0; i < ctx->num; i++) tty_putc(tty, ' '); tty_putcode(tty, TTYC_RMIR); } } void -tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -605,7 +607,7 @@ tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -625,7 +627,7 @@ tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -645,7 +647,7 @@ tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -664,7 +666,7 @@ tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -683,7 +685,7 @@ tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; u_int i; @@ -701,7 +703,7 @@ tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -723,7 +725,7 @@ tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -745,7 +747,7 @@ tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -780,7 +782,7 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -809,7 +811,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_clearscreen(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -838,7 +840,7 @@ tty_cmd_clearscreen(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_alignmenttest(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_alignmenttest(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; @@ -856,7 +858,7 @@ tty_cmd_alignmenttest(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; @@ -866,7 +868,7 @@ tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx) } void -tty_cmd_utf8character(struct tty *tty, struct tty_ctx *ctx) +tty_cmd_utf8character(struct tty *tty, const struct tty_ctx *ctx) { u_char *ptr = ctx->ptr; size_t i; |