mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 08:33:17 +01:00
Merge branch 'obsd-master'
This commit is contained in:
commit
21a2ccc5f1
@ -30,7 +30,7 @@ enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_q *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
"move-window", "movew",
|
||||||
"dkrs:t:", 0, 0,
|
"adkrs:t:", 0, 0,
|
||||||
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dkr] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_move_window_exec
|
cmd_move_window_exec
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_move_window_entry = {
|
|||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
"link-window", "linkw",
|
"link-window", "linkw",
|
||||||
"dks:t:", 0, 0,
|
"adks:t:", 0, 0,
|
||||||
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
"[-dk] " CMD_SRCDST_WINDOW_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_move_window_exec
|
cmd_move_window_exec
|
||||||
@ -72,6 +72,15 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
sflag = args_has(self->args, 's');
|
sflag = args_has(self->args, 's');
|
||||||
|
|
||||||
|
if (args_has(self->args, 'a')) {
|
||||||
|
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
|
||||||
|
if (s == NULL)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
if ((idx = winlink_shuffle_up(s, s->curw)) == -1)
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
|
||||||
&cause) != 0) {
|
&cause) != 0) {
|
||||||
cmdq_error(cmdq, "can't link window: %s", cause);
|
cmdq_error(cmdq, "can't link window: %s", cause);
|
||||||
|
@ -51,7 +51,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
const char *cmd, *path, *template;
|
const char *cmd, *path, *template;
|
||||||
char **argv, *cause, *cp;
|
char **argv, *cause, *cp;
|
||||||
int argc, idx, last, detached, cwd, fd = -1;
|
int argc, idx, detached, cwd, fd = -1;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
|
|
||||||
@ -59,24 +59,10 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
idx = wl->idx + 1;
|
if ((idx = winlink_shuffle_up(s, wl)) == -1) {
|
||||||
|
|
||||||
/* Find the next free index. */
|
|
||||||
for (last = idx; last < INT_MAX; last++) {
|
|
||||||
if (winlink_find_by_index(&s->windows, last) == NULL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (last == INT_MAX) {
|
|
||||||
cmdq_error(cmdq, "no free window indexes");
|
cmdq_error(cmdq, "no free window indexes");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move everything from last - 1 to idx up a bit. */
|
|
||||||
for (; last > idx; last--) {
|
|
||||||
wl = winlink_find_by_index(&s->windows, last - 1);
|
|
||||||
server_link_window(s, wl, s, last, 0, 0, NULL);
|
|
||||||
server_unlink_window(s, wl);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
idx = cmd_find_index(cmdq, args_get(args, 't'), &s);
|
idx = cmd_find_index(cmdq, args_get(args, 't'), &s);
|
||||||
if (idx == -2)
|
if (idx == -2)
|
||||||
|
50
cmd-queue.c
50
cmd-queue.c
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
|
enum cmd_retval cmdq_continue_one(struct cmd_q *);
|
||||||
|
|
||||||
/* Create new command queue. */
|
/* Create new command queue. */
|
||||||
struct cmd_q *
|
struct cmd_q *
|
||||||
cmdq_new(struct client *c)
|
cmdq_new(struct client *c)
|
||||||
@ -160,14 +162,39 @@ cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist, struct mouse_event *m)
|
|||||||
item->mouse.valid = 0;
|
item->mouse.valid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Process one command. */
|
||||||
|
enum cmd_retval
|
||||||
|
cmdq_continue_one(struct cmd_q *cmdq)
|
||||||
|
{
|
||||||
|
struct cmd *cmd = cmdq->cmd;
|
||||||
|
enum cmd_retval retval;
|
||||||
|
char tmp[1024];
|
||||||
|
int flags = !!(cmd->flags & CMD_CONTROL);
|
||||||
|
|
||||||
|
cmd_print(cmd, tmp, sizeof tmp);
|
||||||
|
log_debug("cmdq %p: %s", cmdq, tmp);
|
||||||
|
|
||||||
|
cmdq->time = time(NULL);
|
||||||
|
cmdq->number++;
|
||||||
|
|
||||||
|
cmdq_guard(cmdq, "begin", flags);
|
||||||
|
|
||||||
|
retval = cmd->entry->exec(cmd, cmdq);
|
||||||
|
|
||||||
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
cmdq_guard(cmdq, "error", flags);
|
||||||
|
else
|
||||||
|
cmdq_guard(cmdq, "end", flags);
|
||||||
|
return (retval);
|
||||||
|
}
|
||||||
|
|
||||||
/* Continue processing command queue. Returns 1 if finishes empty. */
|
/* Continue processing command queue. Returns 1 if finishes empty. */
|
||||||
int
|
int
|
||||||
cmdq_continue(struct cmd_q *cmdq)
|
cmdq_continue(struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct cmd_q_item *next;
|
struct cmd_q_item *next;
|
||||||
enum cmd_retval retval;
|
enum cmd_retval retval;
|
||||||
int empty, flags;
|
int empty;
|
||||||
char s[1024];
|
|
||||||
|
|
||||||
cmdq->references++;
|
cmdq->references++;
|
||||||
notify_disable();
|
notify_disable();
|
||||||
@ -184,23 +211,7 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
while (cmdq->cmd != NULL) {
|
while (cmdq->cmd != NULL) {
|
||||||
cmd_print(cmdq->cmd, s, sizeof s);
|
retval = cmdq_continue_one(cmdq);
|
||||||
log_debug("cmdq %p: %s (client %d)", cmdq, s,
|
|
||||||
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
|
|
||||||
|
|
||||||
cmdq->time = time(NULL);
|
|
||||||
cmdq->number++;
|
|
||||||
|
|
||||||
flags = !!(cmdq->cmd->flags & CMD_CONTROL);
|
|
||||||
cmdq_guard(cmdq, "begin", flags);
|
|
||||||
|
|
||||||
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
|
||||||
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
|
||||||
cmdq_guard(cmdq, "error", flags);
|
|
||||||
else
|
|
||||||
cmdq_guard(cmdq, "end", flags);
|
|
||||||
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
break;
|
break;
|
||||||
if (retval == CMD_RETURN_WAIT)
|
if (retval == CMD_RETURN_WAIT)
|
||||||
@ -209,7 +220,6 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
cmdq_flush(cmdq);
|
cmdq_flush(cmdq);
|
||||||
goto empty;
|
goto empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry);
|
||||||
}
|
}
|
||||||
next = TAILQ_NEXT(cmdq->item, qentry);
|
next = TAILQ_NEXT(cmdq->item, qentry);
|
||||||
|
8
tmux.1
8
tmux.1
@ -1548,7 +1548,7 @@ If no
|
|||||||
.Ar target-session
|
.Ar target-session
|
||||||
is specified, select the last window of the current session.
|
is specified, select the last window of the current session.
|
||||||
.It Xo Ic link-window
|
.It Xo Ic link-window
|
||||||
.Op Fl dk
|
.Op Fl adk
|
||||||
.Op Fl s Ar src-window
|
.Op Fl s Ar src-window
|
||||||
.Op Fl t Ar dst-window
|
.Op Fl t Ar dst-window
|
||||||
.Xc
|
.Xc
|
||||||
@ -1562,6 +1562,10 @@ If
|
|||||||
is specified and no such window exists, the
|
is specified and no such window exists, the
|
||||||
.Ar src-window
|
.Ar src-window
|
||||||
is linked there.
|
is linked there.
|
||||||
|
With
|
||||||
|
.Fl a ,
|
||||||
|
the window is moved to the next index up (following windows
|
||||||
|
are moved if necessary).
|
||||||
If
|
If
|
||||||
.Fl k
|
.Fl k
|
||||||
is given and
|
is given and
|
||||||
@ -1627,7 +1631,7 @@ and
|
|||||||
.Ar dst-pane
|
.Ar dst-pane
|
||||||
may belong to the same window.
|
may belong to the same window.
|
||||||
.It Xo Ic move-window
|
.It Xo Ic move-window
|
||||||
.Op Fl rdk
|
.Op Fl ardk
|
||||||
.Op Fl s Ar src-window
|
.Op Fl s Ar src-window
|
||||||
.Op Fl t Ar dst-window
|
.Op Fl t Ar dst-window
|
||||||
.Xc
|
.Xc
|
||||||
|
1
tmux.h
1
tmux.h
@ -2170,6 +2170,7 @@ struct window_pane *window_pane_find_right(struct window_pane *);
|
|||||||
void window_set_name(struct window *, const char *);
|
void window_set_name(struct window *, const char *);
|
||||||
void window_remove_ref(struct window *);
|
void window_remove_ref(struct window *);
|
||||||
void winlink_clear_flags(struct winlink *);
|
void winlink_clear_flags(struct winlink *);
|
||||||
|
int winlink_shuffle_up(struct session *, struct winlink *);
|
||||||
|
|
||||||
/* layout.c */
|
/* layout.c */
|
||||||
u_int layout_count_cells(struct layout_cell *);
|
u_int layout_count_cells(struct layout_cell *);
|
||||||
|
25
window.c
25
window.c
@ -1392,3 +1392,28 @@ winlink_clear_flags(struct winlink *wl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
winlink_shuffle_up(struct session *s, struct winlink *wl)
|
||||||
|
{
|
||||||
|
int idx, last;
|
||||||
|
|
||||||
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
|
/* Find the next free index. */
|
||||||
|
for (last = idx; last < INT_MAX; last++) {
|
||||||
|
if (winlink_find_by_index(&s->windows, last) == NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (last == INT_MAX)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/* Move everything from last - 1 to idx up a bit. */
|
||||||
|
for (; last > idx; last--) {
|
||||||
|
wl = winlink_find_by_index(&s->windows, last - 1);
|
||||||
|
server_link_window(s, wl, s, last, 0, 0, NULL);
|
||||||
|
server_unlink_window(s, wl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (idx);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user