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

This commit is contained in:
Nicholas Marriott 2014-10-02 09:29:48 +01:00
commit 931c17ed4f
20 changed files with 140 additions and 52 deletions

View File

@ -124,14 +124,14 @@ cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
struct client *c = cmdq->client;
if (c == NULL)
return 0;
return (0);
if (!(c->flags & CLIENT_CONTROL))
return 0;
return (0);
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
(long) cmdq->time, cmdq->number, flags);
server_push_stdout(c);
return 1;
return (1);
}
/* Add command list to queue and begin processing if needed. */

View File

@ -29,8 +29,8 @@ enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_pane_entry = {
"select-pane", "selectp",
"lDLRt:U", 0, 0,
"[-lDLRU] " CMD_TARGET_PANE_USAGE,
"DdeLlRt:U", 0, 0,
"[-DdeLlRU] " CMD_TARGET_PANE_USAGE,
0,
cmd_select_pane_key_binding,
cmd_select_pane_exec
@ -38,8 +38,8 @@ const struct cmd_entry cmd_select_pane_entry = {
const struct cmd_entry cmd_last_pane_entry = {
"last-pane", "lastp",
"t:", 0, 0,
CMD_TARGET_WINDOW_USAGE,
"det:", 0, 0,
"[-de] " CMD_TARGET_WINDOW_USAGE,
0,
NULL,
cmd_select_pane_exec
@ -78,10 +78,16 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
if (args_has(self->args, 'e'))
wl->window->last->flags &= ~PANE_INPUTOFF;
else if (args_has(self->args, 'd'))
wl->window->last->flags |= PANE_INPUTOFF;
else {
server_unzoom_window(wl->window);
window_set_active_pane(wl->window, wl->window->last);
server_status_window(wl->window);
server_redraw_window_borders(wl->window);
}
return (CMD_RETURN_NORMAL);
}
@ -108,9 +114,15 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
if (args_has(self->args, 'e'))
wp->flags &= ~PANE_INPUTOFF;
else if (args_has(self->args, 'd'))
wp->flags |= PANE_INPUTOFF;
else {
window_set_active_pane(wl->window, wp);
server_status_window(wl->window);
server_redraw_window_borders(wl->window);
}
return (CMD_RETURN_NORMAL);
}

View File

@ -254,7 +254,7 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
if (!args_has(args, 'q')) {
cmdq_error(cmdq, "already set: %s", optstr);
return CMD_RETURN_ERROR;
return (CMD_RETURN_ERROR);
}
return (CMD_RETURN_NORMAL);
}

View File

@ -194,3 +194,25 @@ cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name,
return (CMD_RETURN_NORMAL);
}
void
cmd_wait_for_flush(void)
{
struct wait_channel *wc, *wc1;
struct cmd_q *wq, *wq1;
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) {
TAILQ_REMOVE(&wc->waiters, wq, waitentry);
if (!cmdq_free(wq))
cmdq_continue(wq);
}
while ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) {
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
if (!cmdq_free(wq))
cmdq_continue(wq);
}
RB_REMOVE(wait_channels, &wait_channels, wc);
free((void *)wc->name);
free(wc);
}
}

View File

@ -494,7 +494,10 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
!!(wl->flags & WINLINK_ACTIVITY));
format_add(ft, "window_silence_flag", "%u",
!!(wl->flags & WINLINK_SILENCE));
format_add(ft, "window_last_flag", "%u",
!!(wl == TAILQ_FIRST(&s->lastw)));
format_add(ft, "window_zoomed_flag", "%u",
!!(wl->flags & WINDOW_ZOOMED));
free(flags);
}

10
grid.c
View File

@ -514,20 +514,18 @@ grid_string_cells_code(const struct grid_cell *lastgc,
s[n++] = attrs[i].code;
}
/* If the foreground c changed, append its parameters. */
/* If the foreground colour changed, append its parameters. */
nnewc = grid_string_cells_fg(gc, newc);
noldc = grid_string_cells_fg(lastgc, oldc);
if (nnewc != noldc ||
memcmp(newc,oldc, nnewc * sizeof newc[0]) != 0) {
if (nnewc != noldc || memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0) {
for (i = 0; i < nnewc; i++)
s[n++] = newc[i];
}
/* If the background c changed, append its parameters. */
/* If the background colour changed, append its parameters. */
nnewc = grid_string_cells_bg(gc, newc);
noldc = grid_string_cells_bg(lastgc, oldc);
if (nnewc != noldc ||
memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0) {
if (nnewc != noldc || memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0) {
for (i = 0; i < nnewc; i++)
s[n++] = newc[i];
}

View File

@ -130,6 +130,7 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_NEXTSPACEEND, "next-space-end" },
{ MODEKEYCOPY_NEXTWORD, "next-word" },
{ MODEKEYCOPY_NEXTWORDEND, "next-word-end" },
{ MODEKEYCOPY_OTHEREND, "other-end" },
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
{ MODEKEYCOPY_PREVIOUSSPACE, "previous-space" },
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },

View File

@ -297,6 +297,9 @@ paste_send_pane(struct paste_buffer *pb, struct window_pane *wp,
const char *data = pb->data, *end = data + pb->size, *lf;
size_t seplen;
if (wp->flags & PANE_INPUTOFF)
return;
if (bracket)
bufferevent_write(wp->event, "\033[200~", 6);

View File

@ -277,6 +277,7 @@ int
screen_check_selection(struct screen *s, u_int px, u_int py)
{
struct screen_sel *sel = &s->sel;
u_int xx;
if (!sel->flag)
return (0);
@ -326,16 +327,24 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
if (py < sel->sy || py > sel->ey)
return (0);
if ((py == sel->sy && px < sel->sx)
|| (py == sel->ey && px > sel->ex))
if (py == sel->sy && px < sel->sx)
return (0);
if (py == sel->ey && px > sel->ex)
return (0);
} else if (sel->sy > sel->ey) {
/* starting line > ending line -- upward selection. */
if (py > sel->sy || py < sel->ey)
return (0);
if ((py == sel->sy && px >= sel->sx)
|| (py == sel->ey && px < sel->ex))
if (py == sel->ey && px < sel->ex)
return (0);
if (sel->modekeys == MODEKEY_EMACS)
xx = sel->sx - 1;
else
xx = sel->sx;
if (py == sel->sy && px > xx)
return (0);
} else {
/* starting line == ending line. */
@ -344,7 +353,11 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
if (sel->ex < sel->sx) {
/* cursor (ex) is on the left */
if (px > sel->sx || px < sel->ex)
if (sel->modekeys == MODEKEY_EMACS)
xx = sel->sx - 1;
else
xx = sel->sx;
if (px > xx || px < sel->ex)
return (0);
} else {
/* selection start (sx) is on the left */

View File

@ -218,16 +218,30 @@ server_loop(void)
int
server_should_shutdown(void)
{
struct client *c;
u_int i;
if (!options_get_number(&global_options, "exit-unattached")) {
if (!RB_EMPTY(&sessions))
return (0);
}
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
return (0);
}
/*
* No attached clients therefore want to exit - flush any waiting
* clients but don't actually exit until they've gone.
*/
cmd_wait_for_flush();
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
if (ARRAY_ITEM(&clients, i) != NULL)
return (0);
}
return (1);
}
@ -239,6 +253,8 @@ server_send_shutdown(void)
struct session *s, *next_s;
u_int i;
cmd_wait_for_flush();
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL) {

19
tmux.1
View File

@ -1386,9 +1386,16 @@ The
.Fl a
option kills all but the window given with
.Fl t .
.It Ic last-pane Op Fl t Ar target-window
.It Xo Ic last-pane
.Op Fl de
.Op Fl t Ar target-window
.Xc
.D1 (alias: Ic lastp )
Select the last (previously selected) pane.
.Fl e
enables or
.Fl d
disables input to the pane.
.It Ic last-window Op Fl t Ar target-session
.D1 (alias: Ic last )
Select the last (previously selected) window.
@ -1705,7 +1712,7 @@ and
.Ic previous-layout
commands.
.It Xo Ic select-pane
.Op Fl lDLRU
.Op Fl DdeLlRU
.Op Fl t Ar target-pane
.Xc
.D1 (alias: Ic selectp )
@ -1725,6 +1732,10 @@ target pane is used.
is the same as using the
.Ic last-pane
command.
.Fl e
enables or
.Fl d
disables input to the pane.
.It Xo Ic select-window
.Op Fl lnpT
.Op Fl t Ar target-window
@ -2429,7 +2440,7 @@ see the
option.
Attributes are ignored.
.It Ic pane-border-style Ar style
Set the pane border style for paneas aside from the active pane.
Set the pane border style for panes aside from the active pane.
For how to specify
.Ar style ,
see the
@ -3126,11 +3137,13 @@ The following variables are available, where appropriate:
.It Li "window_height" Ta "" Ta "Height of window"
.It Li "window_id" Ta "" Ta "Unique window ID"
.It Li "window_index" Ta "#I" Ta "Index of window"
.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
.It Li "window_layout" Ta "" Ta "Window layout description"
.It Li "window_name" Ta "#W" Ta "Name of window"
.It Li "window_panes" Ta "" Ta "Number of panes in window"
.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
.It Li "window_width" Ta "" Ta "Width of window"
.It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"
.It Li "wrap_flag" Ta "" Ta "Pane wrap flag"
.El
.Sh NAMES AND TITLES

5
tmux.h
View File

@ -791,6 +791,7 @@ LIST_HEAD(joblist, job);
struct screen_sel {
int flag;
int rectflag;
int modekeys;
u_int sx;
u_int sy;
@ -953,6 +954,7 @@ struct window_pane {
#define PANE_FOCUSED 0x4
#define PANE_RESIZE 0x8
#define PANE_FOCUSPUSH 0x10
#define PANE_INPUTOFF 0x20
int argc;
char **argv;
@ -1919,6 +1921,9 @@ void cmdq_flush(struct cmd_q *);
int cmd_string_parse(const char *, struct cmd_list **, const char *,
u_int, char **);
/* cmd-wait-for.c */
void cmd_wait_for_flush(void);
/* client.c */
int client_main(int, char **, int);

View File

@ -199,6 +199,7 @@ window_copy_init(struct window_pane *wp)
mode_key_init(&data->mdata, &mode_key_tree_emacs_copy);
else
mode_key_init(&data->mdata, &mode_key_tree_vi_copy);
s->sel.modekeys = keys;
data->backing = NULL;
@ -428,7 +429,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
window_pane_reset_mode(wp);
return;
case MODEKEYCOPY_OTHEREND:
for (; np != 0; np--)
if (np % 2)
window_copy_other_end(wp);
break;
case MODEKEYCOPY_LEFT:

View File

@ -1071,8 +1071,9 @@ window_pane_key(struct window_pane *wp, struct session *sess, int key)
return;
}
if (wp->fd == -1)
if (wp->fd == -1 || wp->flags & PANE_INPUTOFF)
return;
input_key(wp, key);
if (options_get_number(&wp->window->options, "synchronize-panes")) {
TAILQ_FOREACH(wp2, &wp->window->panes, entry) {
@ -1085,8 +1086,8 @@ window_pane_key(struct window_pane *wp, struct session *sess, int key)
}
void
window_pane_mouse(
struct window_pane *wp, struct session *sess, struct mouse_event *m)
window_pane_mouse(struct window_pane *wp, struct session *sess,
struct mouse_event *m)
{
if (!window_pane_visible(wp))
return;