Merge IDENTIFY_* flags with CLIENT_* flags.

This commit is contained in:
Nicholas Marriott 2013-10-06 00:10:40 +01:00
parent d66cbf20f7
commit 01a4752503
4 changed files with 25 additions and 28 deletions

View File

@ -236,7 +236,7 @@ client_main(int argc, char **argv, int flags)
setblocking(STDIN_FILENO, 0); setblocking(STDIN_FILENO, 0);
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST, event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
client_stdin_callback, NULL); client_stdin_callback, NULL);
if (flags & IDENTIFY_TERMIOS) { if (flags & CLIENT_CONTROLCONTROL) {
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) { if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
fprintf(stderr, "tcgetattr failed: %s\n", fprintf(stderr, "tcgetattr failed: %s\n",
strerror(errno)); strerror(errno));
@ -293,14 +293,12 @@ client_main(int argc, char **argv, int flags)
ppid = getppid(); ppid = getppid();
if (client_exittype == MSG_DETACHKILL && ppid > 1) if (client_exittype == MSG_DETACHKILL && ppid > 1)
kill(ppid, SIGHUP); kill(ppid, SIGHUP);
} else if (flags & IDENTIFY_TERMIOS) { } else if (flags & CLIENT_CONTROLCONTROL) {
if (flags & IDENTIFY_CONTROL) { if (client_exitreason != CLIENT_EXIT_NONE)
if (client_exitreason != CLIENT_EXIT_NONE) printf("%%exit %s\n", client_exit_message());
printf("%%exit %s\n", client_exit_message()); else
else printf("%%exit\n");
printf("%%exit\n"); printf("\033\\");
printf("\033\\");
}
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio); tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
} }
setblocking(STDIN_FILENO, 1); setblocking(STDIN_FILENO, 1);

View File

@ -956,12 +956,12 @@ server_client_msg_identify(
if (*data->cwd != '\0') if (*data->cwd != '\0')
c->cwd = xstrdup(data->cwd); c->cwd = xstrdup(data->cwd);
if (data->flags & IDENTIFY_CONTROL) { if (data->flags & CLIENT_CONTROL) {
c->stdin_callback = control_callback; c->stdin_callback = control_callback;
evbuffer_free(c->stderr_data); evbuffer_free(c->stderr_data);
c->stderr_data = c->stdout_data; c->stderr_data = c->stdout_data;
c->flags |= CLIENT_CONTROL; c->flags |= CLIENT_CONTROL;
if (data->flags & IDENTIFY_TERMIOS) if (data->flags & CLIENT_CONTROLCONTROL)
evbuffer_add_printf(c->stdout_data, "\033P1000p"); evbuffer_add_printf(c->stdout_data, "\033P1000p");
server_write_client(c, MSG_STDIN, NULL, 0); server_write_client(c, MSG_STDIN, NULL, 0);
@ -980,14 +980,14 @@ server_client_msg_identify(
} }
data->term[(sizeof data->term) - 1] = '\0'; data->term[(sizeof data->term) - 1] = '\0';
tty_init(&c->tty, c, fd, data->term); tty_init(&c->tty, c, fd, data->term);
if (data->flags & IDENTIFY_UTF8) if (data->flags & CLIENT_UTF8)
c->tty.flags |= TTY_UTF8; c->tty.flags |= TTY_UTF8;
if (data->flags & IDENTIFY_256COLOURS) if (data->flags & CLIENT_256COLOURS)
c->tty.term_flags |= TERM_256COLOURS; c->tty.term_flags |= TERM_256COLOURS;
tty_resize(&c->tty); tty_resize(&c->tty);
if (!(data->flags & IDENTIFY_CONTROL)) if (!(data->flags & CLIENT_CONTROL))
c->flags |= CLIENT_TERMINAL; c->flags |= CLIENT_TERMINAL;
} }

16
tmux.c
View File

@ -264,17 +264,17 @@ main(int argc, char **argv)
while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUVv")) != -1) { while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUVv")) != -1) {
switch (opt) { switch (opt) {
case '2': case '2':
flags |= IDENTIFY_256COLOURS; flags |= CLIENT_256COLOURS;
break; break;
case 'c': case 'c':
free(shell_cmd); free(shell_cmd);
shell_cmd = xstrdup(optarg); shell_cmd = xstrdup(optarg);
break; break;
case 'C': case 'C':
if (flags & IDENTIFY_CONTROL) if (flags & CLIENT_CONTROL)
flags |= IDENTIFY_TERMIOS; flags |= CLIENT_CONTROLCONTROL;
else else
flags |= IDENTIFY_CONTROL; flags |= CLIENT_CONTROL;
break; break;
case 'V': case 'V':
printf("%s %s\n", __progname, VERSION); printf("%s %s\n", __progname, VERSION);
@ -298,7 +298,7 @@ main(int argc, char **argv)
path = xstrdup(optarg); path = xstrdup(optarg);
break; break;
case 'u': case 'u':
flags |= IDENTIFY_UTF8; flags |= CLIENT_UTF8;
break; break;
case 'v': case 'v':
debug_level++; debug_level++;
@ -313,7 +313,7 @@ main(int argc, char **argv)
if (shell_cmd != NULL && argc != 0) if (shell_cmd != NULL && argc != 0)
usage(); usage();
if (!(flags & IDENTIFY_UTF8)) { if (!(flags & CLIENT_UTF8)) {
/* /*
* If the user has set whichever of LC_ALL, LC_CTYPE or LANG * If the user has set whichever of LC_ALL, LC_CTYPE or LANG
* exist (in that order) to contain UTF-8, it is a safe * exist (in that order) to contain UTF-8, it is a safe
@ -327,7 +327,7 @@ main(int argc, char **argv)
} }
if (s != NULL && (strcasestr(s, "UTF-8") != NULL || if (s != NULL && (strcasestr(s, "UTF-8") != NULL ||
strcasestr(s, "UTF8") != NULL)) strcasestr(s, "UTF8") != NULL))
flags |= IDENTIFY_UTF8; flags |= CLIENT_UTF8;
} }
environ_init(&global_environ); environ_init(&global_environ);
@ -346,7 +346,7 @@ main(int argc, char **argv)
options_table_populate_tree(window_options_table, &global_w_options); options_table_populate_tree(window_options_table, &global_w_options);
/* Enable UTF-8 if the first client is on UTF-8 terminal. */ /* Enable UTF-8 if the first client is on UTF-8 terminal. */
if (flags & IDENTIFY_UTF8) { if (flags & CLIENT_UTF8) {
options_set_number(&global_s_options, "status-utf8", 1); options_set_number(&global_s_options, "status-utf8", 1);
options_set_number(&global_s_options, "mouse-utf8", 1); options_set_number(&global_s_options, "mouse-utf8", 1);
options_set_number(&global_w_options, "utf8", 1); options_set_number(&global_w_options, "utf8", 1);

11
tmux.h
View File

@ -484,11 +484,6 @@ struct msg_identify_data {
char ttyname[TTY_NAME_MAX]; char ttyname[TTY_NAME_MAX];
#endif #endif
#define IDENTIFY_UTF8 0x1
#define IDENTIFY_256COLOURS 0x2
/* 0x4 unused */
#define IDENTIFY_CONTROL 0x8
#define IDENTIFY_TERMIOS 0x10
int flags; int flags;
}; };
@ -1341,7 +1336,11 @@ struct client {
#define CLIENT_READONLY 0x800 #define CLIENT_READONLY 0x800
#define CLIENT_REDRAWWINDOW 0x1000 #define CLIENT_REDRAWWINDOW 0x1000
#define CLIENT_CONTROL 0x2000 #define CLIENT_CONTROL 0x2000
#define CLIENT_FOCUSED 0x4000 #define CLIENT_CONTROLCONTROL 0x4000
#define CLIENT_FOCUSED 0x8000
#define CLIENT_UTF8 0x10000
#define CLIENT_256COLOURS 0x20000
#define CLIENT_IDENTIFIED 0x40000
int flags; int flags;
struct event identify_timer; struct event identify_timer;