Merge branch 'obsd-master'

Conflicts:
	tmux.1
	tmux.c
This commit is contained in:
Thomas Adam 2014-02-16 23:02:07 +00:00
commit b3de4a3dec
14 changed files with 90 additions and 67 deletions

View File

@ -72,7 +72,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
buffer_ptr = xmalloc(sizeof *buffer_ptr);
*buffer_ptr = buffer;
error = server_set_stdin_callback (c, cmd_load_buffer_callback,
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
buffer_ptr, &cause);
if (error != 0) {
cmdq_error(cmdq, "%s: %s", path, cause);

View File

@ -172,7 +172,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
}
/* Start or stop timers when automatic-rename changed. */
if (strcmp (oe->name, "automatic-rename") == 0) {
if (strcmp(oe->name, "automatic-rename") == 0) {
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
if ((w = ARRAY_ITEM(&windows, i)) == NULL)
continue;

View File

@ -48,12 +48,12 @@ const struct cmd_entry cmd_server_info_entry = {
cmd_show_messages_exec
};
void cmd_show_messages_server (struct cmd_q *);
void cmd_show_messages_terminals (struct cmd_q *);
void cmd_show_messages_jobs (struct cmd_q *);
void cmd_show_messages_server(struct cmd_q *);
void cmd_show_messages_terminals(struct cmd_q *);
void cmd_show_messages_jobs(struct cmd_q *);
void
cmd_show_messages_server (struct cmd_q *cmdq)
cmd_show_messages_server(struct cmd_q *cmdq)
{
char *tim;
@ -67,7 +67,7 @@ cmd_show_messages_server (struct cmd_q *cmdq)
}
void
cmd_show_messages_terminals (struct cmd_q *cmdq)
cmd_show_messages_terminals(struct cmd_q *cmdq)
{
struct tty_term *term;
const struct tty_term_code_entry *ent;
@ -110,7 +110,7 @@ cmd_show_messages_terminals (struct cmd_q *cmdq)
}
void
cmd_show_messages_jobs (struct cmd_q *cmdq)
cmd_show_messages_jobs(struct cmd_q *cmdq)
{
struct job *job;
u_int n;
@ -135,20 +135,20 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
int done;
done = 0;
if (args_has (args, 'I') || self->entry == &cmd_server_info_entry) {
cmd_show_messages_server (cmdq);
if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) {
cmd_show_messages_server(cmdq);
done = 1;
}
if (args_has (args, 'T') || self->entry == &cmd_server_info_entry) {
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) {
if (done)
cmdq_print (cmdq, "%s", "");
cmd_show_messages_terminals (cmdq);
cmdq_print(cmdq, "%s", "");
cmd_show_messages_terminals(cmdq);
done = 1;
}
if (args_has (args, 'J') || self->entry == &cmd_server_info_entry) {
if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) {
if (done)
cmdq_print (cmdq, "%s", "");
cmd_show_messages_jobs (cmdq);
cmdq_print(cmdq, "%s", "");
cmd_show_messages_jobs(cmdq);
done = 1;
}
if (done)

View File

@ -61,7 +61,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct client *c;
struct session *s;
struct session *s = NULL;
struct winlink *wl = NULL;
struct window *w = NULL;
struct window_pane *wp = NULL;

2
grid.c
View File

@ -749,7 +749,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
dst_gl->flags |= GRID_LINE_WRAPPED;
/* Copy the data. */
memcpy (&dst_gl->celldata[0], &src_gl->celldata[offset],
memcpy(&dst_gl->celldata[0], &src_gl->celldata[offset],
to_copy * sizeof dst_gl->celldata[0]);
/* Move offset and reduce old line size. */

View File

@ -153,6 +153,7 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE },
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
{ '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE },
{ '\n', 0, MODEKEYEDIT_ENTER },
{ '\r', 0, MODEKEYEDIT_ENTER },
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
{ KEYC_DC, 0, MODEKEYEDIT_DELETE },
@ -176,6 +177,7 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
{ '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE },
{ '\n', 1, MODEKEYEDIT_ENTER },
{ '\r', 1, MODEKEYEDIT_ENTER },
{ '^', 1, MODEKEYEDIT_STARTOFLINE },
{ 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND },
@ -219,6 +221,7 @@ const struct mode_key_entry mode_key_vi_choice[] = {
{ '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN },
{ '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN },
{ '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP },
{ '\n', 0, MODEKEYCHOICE_CHOOSE },
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
{ 'j', 0, MODEKEYCHOICE_DOWN },
{ 'k', 0, MODEKEYCHOICE_UP },
@ -281,6 +284,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP },
{ '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP },
{ '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION },
{ '\n', 0, MODEKEYCOPY_COPYSELECTION },
{ '\r', 0, MODEKEYCOPY_COPYSELECTION },
{ '^', 0, MODEKEYCOPY_BACKTOINDENTATION },
{ 'b', 0, MODEKEYCOPY_PREVIOUSWORD },
@ -329,6 +333,7 @@ const struct mode_key_entry mode_key_emacs_edit[] = {
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
{ '\031' /* C-y */, 0, MODEKEYEDIT_PASTE },
{ '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL },
{ '\n', 0, MODEKEYEDIT_ENTER },
{ '\r', 0, MODEKEYEDIT_ENTER },
{ 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD },
{ 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND },
@ -363,6 +368,7 @@ const struct mode_key_entry mode_key_emacs_choice[] = {
{ '\020' /* C-p */, 0, MODEKEYCHOICE_UP },
{ '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN },
{ '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL },
{ '\n', 0, MODEKEYCHOICE_CHOOSE },
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
{ 'q', 0, MODEKEYCHOICE_CANCEL },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP },

View File

@ -67,9 +67,9 @@ server_client_create(int fd)
c->cmdq = cmdq_new(c);
c->cmdq->client_exit = 1;
c->stdin_data = evbuffer_new ();
c->stdout_data = evbuffer_new ();
c->stderr_data = evbuffer_new ();
c->stdin_data = evbuffer_new();
c->stdout_data = evbuffer_new();
c->stderr_data = evbuffer_new();
c->tty.fd = -1;
c->title = NULL;
@ -122,7 +122,7 @@ server_client_open(struct client *c, struct session *s, char **cause)
return (0);
if (!(c->flags & CLIENT_TERMINAL)) {
*cause = xstrdup ("not a terminal");
*cause = xstrdup("not a terminal");
return (-1);
}
@ -173,7 +173,7 @@ server_client_lost(struct client *c)
evtimer_del(&c->identify_timer);
free(c->message_string);
if (event_initialized (&c->message_timer))
if (event_initialized(&c->message_timer))
evtimer_del(&c->message_timer);
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
msg = &ARRAY_ITEM(&c->message_log, i);
@ -279,7 +279,7 @@ server_client_status_timer(void)
interval = options_get_number(&s->options, "status-interval");
difference = tv.tv_sec - c->status_timer.tv_sec;
if (difference >= interval) {
if (interval != 0 && difference >= interval) {
status_update_jobs(c);
c->flags |= CLIENT_STATUS;
}

View File

@ -454,7 +454,7 @@ server_destroy_session(struct session *s)
}
void
server_check_unattached (void)
server_check_unattached(void)
{
struct session *s;
@ -480,7 +480,7 @@ server_set_identify(struct client *c)
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized (&c->identify_timer))
if (event_initialized(&c->identify_timer))
evtimer_del(&c->identify_timer);
evtimer_set(&c->identify_timer, server_callback_identify, c);
evtimer_add(&c->identify_timer, &tv);
@ -592,7 +592,7 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int,
c->references++;
if (c->stdin_closed)
c->stdin_callback (c, 1, c->stdin_callback_data);
c->stdin_callback(c, 1, c->stdin_callback_data);
server_write_client(c, MSG_STDIN, NULL, 0);

View File

@ -76,7 +76,7 @@ server_window_check_bell(struct session *s, struct winlink *wl)
wl->flags |= WINLINK_BELL;
if (s->flags & SESSION_UNATTACHED)
return (0);
if (s->curw->window == wl->window)
if (s->curw->window == w)
w->flags &= ~WINDOW_BELL;
visual = options_get_number(&s->options, "visual-bell");
@ -93,10 +93,8 @@ server_window_check_bell(struct session *s, struct winlink *wl)
}
if (c->session->curw->window == w)
status_message_set(c, "Bell in current window");
else if (action == BELL_ANY) {
status_message_set(c, "Bell in window %u",
winlink_find_by_window(&s->windows, w)->idx);
}
else if (action == BELL_ANY)
status_message_set(c, "Bell in window %u", wl->idx);
}
return (1);
@ -110,7 +108,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
struct window *w = wl->window;
u_int i;
if (s->curw->window == wl->window)
if (s->curw->window == w)
w->flags &= ~WINDOW_ACTIVITY;
if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_ACTIVITY)
@ -130,8 +128,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
status_message_set(c, "Activity in window %u",
winlink_find_by_window(&s->windows, w)->idx);
status_message_set(c, "Activity in window %u", wl->idx);
}
}
@ -182,8 +179,7 @@ server_window_check_silence(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
status_message_set(c, "Silence in window %u",
winlink_find_by_window(&s->windows, w)->idx);
status_message_set(c, "Silence in window %u", wl->idx);
}
}
@ -225,8 +221,7 @@ server_window_check_content(
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
status_message_set(c, "Content in window %u",
winlink_find_by_window(&s->windows, w)->idx);
status_message_set(c, "Content in window %u", wl->idx);
}
}

View File

@ -445,11 +445,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
if (fmt == NULL)
return (xstrdup(""));
if (s == NULL)
if (s == NULL && c != NULL)
s = c->session;
if (wl == NULL)
if (wl == NULL && s != NULL)
wl = s->curw;
if (wp == NULL)
if (wp == NULL && wl != NULL)
wp = wl->window->active;
len = strftime(in, sizeof in, fmt, localtime(&t));
@ -472,9 +472,13 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
*optr = '\0';
ft = format_create();
if (c != NULL)
format_client(ft, c);
if (s != NULL)
format_session(ft, s);
if (s != NULL && wl != NULL)
format_winlink(ft, s, wl);
if (wp != NULL)
format_window_pane(ft, wp);
expanded = format_expand(ft, out);
format_free(ft);
@ -686,7 +690,7 @@ status_message_set(struct client *c, const char *fmt, ...)
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized (&c->message_timer))
if (event_initialized(&c->message_timer))
evtimer_del(&c->message_timer);
evtimer_set(&c->message_timer, status_message_callback, c);
evtimer_add(&c->message_timer, &tv);

8
tmux.1
View File

@ -787,7 +787,7 @@ With
.Fl t ,
display the log for
.Ar target-client .
.Fl I,
.Fl I ,
.Fl J
and
.Fl T
@ -2503,7 +2503,7 @@ Display
will be passed through
.Xr strftime 3
and formats (see
.Sx FORMATS Ns )
.Sx FORMATS )
will be expanded.
It may also contain any of the following special character sequences:
.Bl -column "Character pair" "Replaced with" -offset indent
@ -2641,9 +2641,9 @@ The terminal entry value is passed through
before interpretation.
The default value forcibly corrects the
.Ql colors
entry for terminals which support 88 or 256 colours:
entry for terminals which support 256 colours:
.Bd -literal -offset indent
"*88col*:colors=88,*256col*:colors=256,xterm*:XT"
"*256col*:colors=256,xterm*:XT"
.Ed
.It Ic update-environment Ar variables
Set a space-separated string containing a list of environment variables to be

View File

@ -479,6 +479,15 @@ tty_keys_next(struct tty *tty)
goto partial_key;
}
/* Look for matching key string and return if found. */
tk = tty_keys_find(tty, buf, len, &size);
if (tk != NULL) {
if (tk->next != NULL)
goto partial_key;
key = tk->key;
goto complete_key;
}
/* Try to parse a key with an xterm-style modifier. */
switch (xterm_keys_find(buf, len, &size, &key)) {
case 0: /* found */
@ -489,15 +498,6 @@ tty_keys_next(struct tty *tty)
goto partial_key;
}
/* Look for matching key string and return if found. */
tk = tty_keys_find(tty, buf, len, &size);
if (tk != NULL) {
if (tk->next != NULL)
goto partial_key;
key = tk->key;
goto complete_key;
}
first_key:
/* Is this a meta key? */
if (len >= 2 && buf[0] == '\033') {

22
tty.c
View File

@ -1581,13 +1581,29 @@ tty_try_256(struct tty *tty, u_char colour, const char *type)
{
char s[32];
if (!(tty->term->flags & TERM_256COLOURS) &&
!(tty->term_flags & TERM_256COLOURS))
return (-1);
/*
* If the terminfo entry has 256 colours, assume that setaf and setab
* work correctly.
*/
if (tty->term->flags & TERM_256COLOURS) {
if (*type == '3')
tty_putcode1(tty, TTYC_SETAF, colour);
else
tty_putcode1(tty, TTYC_SETAB, colour);
return (0);
}
/*
* If the user has specified -2 to the client, setaf and setab may not
* work, so send the usual sequence.
*/
if (tty->term_flags & TERM_256COLOURS) {
xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
tty_puts(tty, s);
return (0);
}
return (-1);
}
void

View File

@ -131,7 +131,9 @@ xterm_keys_match(const char *template, const char *buf, size_t len)
pos = 0;
do {
if (*template != '_' && buf[pos] != *template)
if (*template == '_' && buf[pos] >= '1' && buf[pos] <= '8')
continue;
if (buf[pos] != *template)
return (-1);
} while (*++template != '\0' && ++pos != len);