1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code

This commit is contained in:
Nicholas Marriott 2013-07-05 16:24:13 +01:00
commit e496a548d7
11 changed files with 53 additions and 10 deletions

View File

@ -157,14 +157,17 @@ int
cmdq_guard(struct cmd_q *cmdq, const char *guard) cmdq_guard(struct cmd_q *cmdq, const char *guard)
{ {
struct client *c = cmdq->client; struct client *c = cmdq->client;
int flags;
if (c == NULL) if (c == NULL)
return 0; return 0;
if (!(c->flags & CLIENT_CONTROL)) if (!(c->flags & CLIENT_CONTROL))
return 0; return 0;
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u\n", guard, flags = !!(cmdq->cmd->flags & CMD_CONTROL);
(long) cmdq->time, cmdq->number);
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
(long) cmdq->time, cmdq->number, flags);
server_push_stdout(c); server_push_stdout(c);
return 1; return 1;
} }

View File

@ -21,6 +21,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h>
#include <stropts.h> #include <stropts.h>
#include <unistd.h> #include <unistd.h>

View File

@ -24,6 +24,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <unistd.h> #include <unistd.h>
#include "tmux.h" #include "tmux.h"

View File

@ -24,6 +24,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <unistd.h> #include <unistd.h>
#include "tmux.h" #include "tmux.h"

View File

@ -55,6 +55,7 @@ control_callback(struct client *c, int closed, unused void *data)
{ {
char *line, *cause; char *line, *cause;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;
struct cmd *cmd;
if (closed) if (closed)
c->flags |= CLIENT_EXIT; c->flags |= CLIENT_EXIT;
@ -78,6 +79,8 @@ control_callback(struct client *c, int closed, unused void *data)
free(cause); free(cause);
} else { } else {
TAILQ_FOREACH(cmd, &cmdlist->list, qentry)
cmd->flags |= CMD_CONTROL;
cmdq_run(c->cmdq, cmdlist); cmdq_run(c->cmdq, cmdlist);
cmd_list_free(cmdlist); cmd_list_free(cmdlist);
} }

View File

@ -1333,7 +1333,7 @@ input_csi_dispatch(struct input_ctx *ictx)
if (s->mode & MODE_FOCUSON) if (s->mode & MODE_FOCUSON)
break; break;
screen_write_mode_set(&ictx->ctx, MODE_FOCUSON); screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);
wp->flags &= ~PANE_FOCUSED; /* force update if needed */ wp->flags |= PANE_FOCUSPUSH; /* force update */
break; break;
case 1005: case 1005:
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8); screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);

View File

@ -75,6 +75,11 @@ const struct options_table_entry server_options_table[] = {
.default_num = 0 .default_num = 0
}, },
{ .name = "focus-events",
.type = OPTIONS_TABLE_FLAG,
.default_num = 0
},
{ .name = "quiet", { .name = "quiet",
.type = OPTIONS_TABLE_FLAG, .type = OPTIONS_TABLE_FLAG,
.default_num = 0 /* overridden in main() */ .default_num = 0 /* overridden in main() */

View File

@ -548,6 +548,15 @@ server_client_check_focus(struct window_pane *wp)
{ {
u_int i; u_int i;
struct client *c; struct client *c;
int push;
/* Are focus events off? */
if (!options_get_number(&global_options, "focus-events"))
return;
/* Do we need to push the focus state? */
push = wp->flags & PANE_FOCUSPUSH;
wp->flags &= ~PANE_FOCUSPUSH;
/* If we don't care about focus, forget it. */ /* If we don't care about focus, forget it. */
if (!(wp->base.mode & MODE_FOCUSON)) if (!(wp->base.mode & MODE_FOCUSON))
@ -580,13 +589,13 @@ server_client_check_focus(struct window_pane *wp)
} }
not_focused: not_focused:
if (wp->flags & PANE_FOCUSED) if (push || (wp->flags & PANE_FOCUSED))
bufferevent_write(wp->event, "\033[O", 3); bufferevent_write(wp->event, "\033[O", 3);
wp->flags &= ~PANE_FOCUSED; wp->flags &= ~PANE_FOCUSED;
return; return;
focused: focused:
if (!(wp->flags & PANE_FOCUSED)) if (push || !(wp->flags & PANE_FOCUSED))
bufferevent_write(wp->event, "\033[I", 3); bufferevent_write(wp->event, "\033[I", 3);
wp->flags |= PANE_FOCUSED; wp->flags |= PANE_FOCUSED;
} }

8
tmux.1
View File

@ -2096,6 +2096,14 @@ The default is 500 milliseconds.
.Op Ic on | off .Op Ic on | off
.Xc .Xc
If enabled, the server will exit when there are no attached clients. If enabled, the server will exit when there are no attached clients.
.It Xo Ic focus-events
.Op Ic on | off
.Xc
When enabled, focus events are requested from the terminal if supported and
passed through to applications running in
.Nm .
Attached clients should be detached and attached again after changing this
option.
.It Xo Ic quiet .It Xo Ic quiet
.Op Ic on | off .Op Ic on | off
.Xc .Xc

8
tmux.h
View File

@ -39,9 +39,6 @@
extern char *__progname; extern char *__progname;
extern char **environ; extern char **environ;
/* Default global configuration file. */
#define TMUX_CONF "/etc/tmux.conf"
/* Default prompt history length. */ /* Default prompt history length. */
#define PROMPT_HISTORY 100 #define PROMPT_HISTORY 100
@ -937,6 +934,7 @@ struct window_pane {
#define PANE_DROP 0x2 #define PANE_DROP 0x2
#define PANE_FOCUSED 0x4 #define PANE_FOCUSED 0x4
#define PANE_RESIZE 0x8 #define PANE_RESIZE 0x8
#define PANE_FOCUSPUSH 0x10
char *cmd; char *cmd;
char *shell; char *shell;
@ -1228,6 +1226,7 @@ struct tty {
#define TTY_UTF8 0x8 #define TTY_UTF8 0x8
#define TTY_STARTED 0x10 #define TTY_STARTED 0x10
#define TTY_OPENED 0x20 #define TTY_OPENED 0x20
#define TTY_FOCUS 0x40
int flags; int flags;
int term_flags; int term_flags;
@ -1379,6 +1378,9 @@ struct cmd {
char *file; char *file;
u_int line; u_int line;
#define CMD_CONTROL 0x1
int flags;
TAILQ_ENTRY(cmd) qentry; TAILQ_ENTRY(cmd) qentry;
}; };
struct cmd_list { struct cmd_list {

14
tty.c
View File

@ -219,8 +219,13 @@ tty_start_tty(struct tty *tty)
if (tty_term_has(tty->term, TTYC_KMOUS)) if (tty_term_has(tty->term, TTYC_KMOUS))
tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l"); tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT)) if (tty_term_has(tty->term, TTYC_XT)) {
if (options_get_number(&global_options, "focus-events")) {
tty->flags |= TTY_FOCUS;
tty_puts(tty, "\033[?1004h");
}
tty_puts(tty, "\033[c\033[>4;1m\033[m"); tty_puts(tty, "\033[c\033[>4;1m\033[m");
}
tty->cx = UINT_MAX; tty->cx = UINT_MAX;
tty->cy = UINT_MAX; tty->cy = UINT_MAX;
@ -282,8 +287,13 @@ tty_stop_tty(struct tty *tty)
if (tty_term_has(tty->term, TTYC_KMOUS)) if (tty_term_has(tty->term, TTYC_KMOUS))
tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l"); tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT)) if (tty_term_has(tty->term, TTYC_XT)) {
if (tty->flags & TTY_FOCUS) {
tty->flags &= ~TTY_FOCUS;
tty_puts(tty, "\033[?1004l");
}
tty_raw(tty, "\033[>4m\033[m"); tty_raw(tty, "\033[>4m\033[m");
}
tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));