diff --git a/TODO b/TODO index 35912cdf..8331e542 100644 --- a/TODO +++ b/TODO @@ -89,3 +89,4 @@ - document find-window - document split-window -p and -l - attach should have a flag to create session if it doesn't exist +- do mouse mode properly and fix it when window is split diff --git a/screen-write.c b/screen-write.c index 9c3b6654..3d534920 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1,4 +1,4 @@ -/* $Id: screen-write.c,v 1.29 2009-01-26 20:57:44 nicm Exp $ */ +/* $Id: screen-write.c,v 1.30 2009-01-27 21:39:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,13 +33,11 @@ screen_write_start( ctx->data = wp; if (ctx->s == NULL) ctx->s = wp->screen; + tty_write_cursor_off(ctx->data); } else { ctx->write = NULL; ctx->data = NULL; } - - if (ctx->write != NULL) - ctx->write(ctx->data, TTY_CURSORMODE, 0); } /* Finish writing. */ @@ -430,9 +428,6 @@ screen_write_kcursormode(struct screen_write_ctx *ctx, int state) { struct screen *s = ctx->s; - if (ctx->write != NULL) - ctx->write(ctx->data, TTY_KCURSORMODE); - if (state) s->mode |= MODE_KCURSOR; else @@ -445,9 +440,6 @@ screen_write_kkeypadmode(struct screen_write_ctx *ctx, int state) { struct screen *s = ctx->s; - if (ctx->write != NULL) - ctx->write(ctx->data, TTY_KKEYPADMODE); - if (state) s->mode |= MODE_KKEYPAD; else diff --git a/server.c b/server.c index 2ab5951f..460a0e93 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.112 2009-01-27 19:40:56 nicm Exp $ */ +/* $Id: server.c,v 1.113 2009-01-27 21:39:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -713,10 +713,10 @@ server_handle_client(struct client *c) if (c->prompt_string == NULL && c->message_string == NULL && !server_locked && wp->screen->mode & MODE_CURSOR && wp->yoff + wp->screen->cy < c->sy - status) { - tty_write(&c->tty, wp->screen, 0, TTY_CURSORMODE, 1); + tty_cursor_on(&c->tty); tty_cursor(&c->tty, wp->screen->cx, wp->screen->cy, wp->yoff); } else - tty_write(&c->tty, wp->screen, 0, TTY_CURSORMODE, 0); + tty_cursor_off(&c->tty); } /* Lost a client. */ diff --git a/tmux.h b/tmux.h index eac6f739..c6125573 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.252 2009-01-27 20:22:33 nicm Exp $ */ +/* $Id: tmux.h,v 1.253 2009-01-27 21:39:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -335,14 +335,11 @@ enum tty_cmd { TTY_CLEARSCREEN, TTY_CLEARSTARTOFLINE, TTY_CLEARSTARTOFSCREEN, - TTY_CURSORMODE, TTY_DELETECHARACTER, TTY_DELETELINE, TTY_INSERTCHARACTER, TTY_INSERTLINE, TTY_INSERTMODE, - TTY_KCURSORMODE, - TTY_KKEYPADMODE, TTY_LINEFEED, TTY_MOUSEMODE, TTY_REVERSEINDEX, @@ -1013,6 +1010,8 @@ long long options_get_number(struct options *, const char *); /* tty.c */ void tty_cursor(struct tty *, u_int, u_int, u_int); +void tty_cursor_off(struct tty *); +void tty_cursor_on(struct tty *); void tty_putcode(struct tty *, enum tty_code_code); void tty_putcode1(struct tty *, enum tty_code_code, int); void tty_putcode2(struct tty *, enum tty_code_code, int, int); @@ -1028,7 +1027,7 @@ void tty_free(struct tty *, int); void tty_write(struct tty *, struct screen *, u_int, enum tty_cmd, ...); void tty_vwrite(struct tty *, - struct screen *s, u_int, enum tty_cmd, va_list); + struct screen *, u_int, enum tty_cmd, va_list); /* tty-term.c */ extern struct tty_terms tty_terms; @@ -1053,6 +1052,7 @@ int tty_keys_next(struct tty *, int *); /* tty-write.c */ void tty_write_window(void *, enum tty_cmd, ...); void tty_vwrite_window(void *, enum tty_cmd, va_list); +void tty_write_cursor_off(void *); /* options-cmd.c */ void set_option_string(struct cmd_ctx *, diff --git a/tty-write.c b/tty-write.c index 62adb8b2..409ed08c 100644 --- a/tty-write.c +++ b/tty-write.c @@ -1,4 +1,4 @@ -/* $Id: tty-write.c,v 1.7 2009-01-18 12:09:42 nicm Exp $ */ +/* $Id: tty-write.c,v 1.8 2009-01-27 21:39:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -55,3 +55,24 @@ tty_vwrite_window(void *ptr, enum tty_cmd cmd, va_list ap) } } } + +void +tty_write_cursor_off(void *ptr) +{ + struct window_pane *wp = ptr; + struct client *c; + u_int i; + + if (wp->window->flags & WINDOW_HIDDEN || wp->flags & PANE_HIDDEN) + return; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + if (c->flags & CLIENT_SUSPENDED) + continue; + + tty_cursor_off(&c->tty); + } +} diff --git a/tty.c b/tty.c index 0aee1016..cd0a68c7 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.62 2009-01-19 19:01:11 nicm Exp $ */ +/* $Id: tty.c,v 1.63 2009-01-27 21:39:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -50,14 +50,11 @@ void tty_cmd_clearline(struct tty *, struct screen *, u_int, va_list); void tty_cmd_clearscreen(struct tty *, struct screen *, u_int, va_list); void tty_cmd_clearstartofline(struct tty *, struct screen *, u_int, va_list); void tty_cmd_clearstartofscreen(struct tty *, struct screen *, u_int, va_list); -void tty_cmd_cursormode(struct tty *, struct screen *, u_int, va_list); void tty_cmd_deletecharacter(struct tty *, struct screen *, u_int, va_list); void tty_cmd_deleteline(struct tty *, struct screen *, u_int, va_list); void tty_cmd_insertcharacter(struct tty *, struct screen *, u_int, va_list); void tty_cmd_insertline(struct tty *, struct screen *, u_int, va_list); void tty_cmd_insertmode(struct tty *, struct screen *, u_int, va_list); -void tty_cmd_kcursormode(struct tty *, struct screen *, u_int, va_list); -void tty_cmd_kkeypadmode(struct tty *, struct screen *, u_int, va_list); void tty_cmd_linefeed(struct tty *, struct screen *, u_int, va_list); void tty_cmd_mousemode(struct tty *, struct screen *, u_int, va_list); void tty_cmd_reverseindex(struct tty *, struct screen *, u_int, va_list); @@ -70,14 +67,11 @@ void (*tty_cmds[])(struct tty *, struct screen *, u_int, va_list) = { tty_cmd_clearscreen, tty_cmd_clearstartofline, tty_cmd_clearstartofscreen, - tty_cmd_cursormode, tty_cmd_deletecharacter, tty_cmd_deleteline, tty_cmd_insertcharacter, tty_cmd_insertline, tty_cmd_insertmode, - tty_cmd_kcursormode, - tty_cmd_kkeypadmode, tty_cmd_linefeed, tty_cmd_mousemode, tty_cmd_reverseindex, @@ -174,6 +168,8 @@ tty_start_tty(struct tty *tty) tty_putcode(tty, TTYC_SMKX); tty_putcode(tty, TTYC_ENACS); tty_putcode(tty, TTYC_CLEAR); + + tty_putcode(tty, TTYC_CNORM); memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell); @@ -182,6 +178,8 @@ tty_start_tty(struct tty *tty) tty->rlower = UINT_MAX; tty->rupper = UINT_MAX; + + tty->cursor = 1; } void @@ -495,24 +493,6 @@ tty_cmd_clearstartofline( } } -void -tty_cmd_cursormode( - struct tty *tty, unused struct screen *s, unused u_int oy, va_list ap) -{ - int ua; - - ua = va_arg(ap, int); - - if (tty->cursor == ua) - return; - tty->cursor = ua; - - if (ua && !(tty->flags & TTY_NOCURSOR)) - tty_putcode(tty, TTYC_CNORM); - else - tty_putcode(tty, TTYC_CIVIS); -} - void tty_cmd_reverseindex( struct tty *tty, struct screen *s, u_int oy, unused va_list ap) @@ -531,14 +511,6 @@ tty_cmd_insertmode(unused struct tty *tty, int ua; ua = va_arg(ap, int); - -#if 0 - /* XXX */ - if (ua) - tty_puts(tty, enter_insert_mode); - else - tty_puts(tty, exit_insert_mode); -#endif } void @@ -558,18 +530,6 @@ tty_cmd_mousemode( tty_puts(tty, "\033[?1000l"); } -void -tty_cmd_kcursormode(unused struct tty *tty, - unused struct screen *s, unused u_int oy, unused va_list ap) -{ -} - -void -tty_cmd_kkeypadmode(unused struct tty *tty, - unused struct screen *s, unused u_int oy, unused va_list ap) -{ -} - void tty_cmd_linefeed(struct tty *tty, struct screen *s, u_int oy, unused va_list ap) { @@ -748,6 +708,26 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int oy) } } +void +tty_cursor_off(struct tty *tty) +{ + if (!tty->cursor) + return; + tty->cursor = 0; + + tty_putcode(tty, TTYC_CIVIS); +} + +void +tty_cursor_on(struct tty *tty) +{ + if (tty->cursor || tty->flags & TTY_NOCURSOR) + return; + tty->cursor = 1; + + tty_putcode(tty, TTYC_CNORM); +} + void tty_attributes(struct tty *tty, const struct grid_cell *gc) {