mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
-k on link-window to kill dest window if it exists.
This commit is contained in:
parent
54d01c1a5f
commit
958cd9cb94
6
CHANGES
6
CHANGES
@ -1,3 +1,7 @@
|
||||
17 November 2007
|
||||
|
||||
* (nicm) Add -k option to link-window to kill target window if it exists.
|
||||
|
||||
16 November 2007
|
||||
|
||||
* (nicm) Split in-client display into two columns. This is a hack but not a lot
|
||||
@ -223,4 +227,4 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.72 2007-11-16 22:06:45 nicm Exp $
|
||||
$Id: CHANGES,v 1.73 2007-11-17 08:21:54 nicm Exp $
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-link-window.c,v 1.6 2007-11-16 21:12:31 nicm Exp $ */
|
||||
/* $Id: cmd-link-window.c,v 1.7 2007-11-17 08:21:54 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -34,14 +34,15 @@ void cmd_link_window_recv(void **, struct buffer *);
|
||||
void cmd_link_window_free(void *);
|
||||
|
||||
struct cmd_link_window_data {
|
||||
int flag_detached;
|
||||
int flag_kill;
|
||||
int dstidx;
|
||||
int srcidx;
|
||||
char *srcname;
|
||||
int flag_detached;
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_link_window_entry = {
|
||||
"link-window", "linkw", "[-i index] name index",
|
||||
"link-window", "linkw", "[-dk] [-i index] name index",
|
||||
CMD_NOCLIENT,
|
||||
cmd_link_window_parse,
|
||||
cmd_link_window_exec,
|
||||
@ -59,11 +60,12 @@ cmd_link_window_parse(void **ptr, int argc, char **argv, char **cause)
|
||||
|
||||
*ptr = data = xmalloc(sizeof *data);
|
||||
data->flag_detached = 0;
|
||||
data->flag_kill = 0;
|
||||
data->dstidx = -1;
|
||||
data->srcidx = -1;
|
||||
data->srcname = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "di:")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "dki:")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
data->dstidx = strtonum(optarg, 0, INT_MAX, &errstr);
|
||||
@ -75,6 +77,9 @@ cmd_link_window_parse(void **ptr, int argc, char **argv, char **cause)
|
||||
case 'd':
|
||||
data->flag_detached = 1;
|
||||
break;
|
||||
case 'k':
|
||||
data->flag_kill = 1;
|
||||
break;
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
@ -107,7 +112,7 @@ cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_link_window_data *data = ptr;
|
||||
struct session *dst = ctx->session, *src;
|
||||
struct winlink *wl;
|
||||
struct winlink *wl, *wl2;
|
||||
|
||||
if (data == NULL)
|
||||
return;
|
||||
@ -131,7 +136,30 @@ cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
|
||||
if (data->dstidx < 0)
|
||||
data->dstidx = -1;
|
||||
if ((wl = session_attach(dst, wl->window, data->dstidx)) == NULL) {
|
||||
if (data->flag_kill && data->dstidx != -1) {
|
||||
wl2 = winlink_find_by_index(&dst->windows, data->dstidx);
|
||||
|
||||
/*
|
||||
* Can't use session_detach as it will destroy session if this
|
||||
* makes it empty.
|
||||
*/
|
||||
session_cancelbell(dst, wl2);
|
||||
winlink_remove(&dst->windows, wl2);
|
||||
|
||||
/* Force select/redraw if current. */
|
||||
if (wl2 == dst->curw)
|
||||
data->flag_detached = 0;
|
||||
if (wl2 == dst->lastw)
|
||||
dst->lastw = NULL;
|
||||
|
||||
/*
|
||||
* Can't error out after this or there could be an empty
|
||||
* session!
|
||||
*/
|
||||
}
|
||||
|
||||
wl = session_attach(dst, wl->window, data->dstidx);
|
||||
if (wl == NULL) {
|
||||
ctx->error(ctx, "index in use: %d", data->dstidx);
|
||||
return;
|
||||
}
|
||||
|
12
tmux.1
12
tmux.1
@ -1,4 +1,4 @@
|
||||
.\" $Id: tmux.1,v 1.14 2007-11-16 21:12:31 nicm Exp $
|
||||
.\" $Id: tmux.1,v 1.15 2007-11-17 08:21:54 nicm Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
.\"
|
||||
@ -171,6 +171,7 @@ removing it from any sessions to which it is linked.
|
||||
.D1 (alias: Ic last )
|
||||
Select the last (previously selected) window.
|
||||
.It Xo Ic link-window
|
||||
.Op Fl dk
|
||||
.Op Fl i Ar destination-index
|
||||
.Ar source-name Ar source-index
|
||||
.Xc
|
||||
@ -183,9 +184,14 @@ into the specified session. If
|
||||
.Ar destination-index
|
||||
is specified and no window exists with that index, the window is linked at
|
||||
that index.
|
||||
If a window already exists at
|
||||
If
|
||||
.Fl k
|
||||
is given and a window exists at
|
||||
.Ar destination-index ,
|
||||
an error is generated.
|
||||
it is killed, otherwise an error is generated.
|
||||
If
|
||||
.Fl d
|
||||
is given, the newly linked window is not selected.
|
||||
.It Xo Ic list-clients
|
||||
.Xc
|
||||
.D1 (alias: Ic lsc )
|
||||
|
Loading…
Reference in New Issue
Block a user