mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 22:26:18 +00:00
Adjustment from feedback and slight touchups.
This commit is contained in:
@@ -115,7 +115,6 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-lock-server.c \
|
cmd-lock-server.c \
|
||||||
cmd-minimise-pane.c \
|
cmd-minimise-pane.c \
|
||||||
cmd-move-window.c \
|
cmd-move-window.c \
|
||||||
cmd-new-pane.c \
|
|
||||||
cmd-new-session.c \
|
cmd-new-session.c \
|
||||||
cmd-new-window.c \
|
cmd-new-window.c \
|
||||||
cmd-parse.y \
|
cmd-parse.y \
|
||||||
@@ -145,6 +144,7 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-show-options.c \
|
cmd-show-options.c \
|
||||||
cmd-show-prompt-history.c \
|
cmd-show-prompt-history.c \
|
||||||
cmd-source-file.c \
|
cmd-source-file.c \
|
||||||
|
cmd-split-window.c \
|
||||||
cmd-swap-pane.c \
|
cmd-swap-pane.c \
|
||||||
cmd-tile-float-pane.c \
|
cmd-tile-float-pane.c \
|
||||||
cmd-swap-window.c \
|
cmd-swap-window.c \
|
||||||
|
|||||||
@@ -1030,7 +1030,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
|||||||
fs->w = fs->wl->window;
|
fs->w = fs->wl->window;
|
||||||
fs->wp = fs->w->active;
|
fs->wp = fs->w->active;
|
||||||
}
|
}
|
||||||
break;
|
goto found;
|
||||||
}
|
}
|
||||||
if (fs->wp == NULL) {
|
if (fs->wp == NULL) {
|
||||||
if (~flags & CMD_FIND_QUIET)
|
if (~flags & CMD_FIND_QUIET)
|
||||||
|
|||||||
@@ -27,70 +27,58 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Split a window (add a new pane).
|
* Create a new pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NEW_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
#define NEW_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||||
|
|
||||||
static enum cmd_retval cmd_new_pane_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_pane_entry = {
|
const struct cmd_entry cmd_new_pane_entry = {
|
||||||
.name = "new-pane",
|
.name = "new-pane",
|
||||||
.alias = "newp",
|
.alias = "newp",
|
||||||
|
|
||||||
.args = { "bc:de:fF:hH:Ikl:m:p:PR:s:S:t:T:w:x:y:vZ", 0, -1, NULL },
|
.args = { "bc:de:fF:hH:Ikl:m:M:p:PR:s:S:t:w:x:y:vZ", 0, -1, NULL },
|
||||||
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
||||||
"[-F format] [-H height] [-l size] [-m message] "
|
"[-F format] [-H height] [-l size] [-m message] "
|
||||||
"[-R inactive-border-style] [-s style] "
|
"[-M mode] [-R inactive-border-style] [-s style] "
|
||||||
"[-S active-border-style] [-w width] [-x x-position] "
|
"[-S active-border-style] [-w width] [-x x-position] "
|
||||||
"[-y y-position]" CMD_TARGET_PANE_USAGE "[-T type] "
|
"[-y y-position]" CMD_TARGET_PANE_USAGE
|
||||||
" [shell-command [argument ...]]",
|
"[shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_new_pane_exec
|
.exec = cmd_split_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
.name = "split-window",
|
.name = "split-window",
|
||||||
.alias = "splitw",
|
.alias = "splitw",
|
||||||
|
|
||||||
.args = { "bc:de:fF:hH:Ikl:m:p:PR:s:S:t:T:w:x:y:vZ", 0, -1, NULL },
|
.args = { "bc:de:fF:hH:Ikl:m:M:p:PR:s:S:t:w:x:y:vZ", 0, -1, NULL },
|
||||||
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
||||||
"[-F format] [-H height] [-l size] [-m message] "
|
"[-F format] [-H height] [-l size] [-m message] "
|
||||||
"[-R inactive-border-style] [-s style] "
|
"[-M mode] [-R inactive-border-style] [-s style] "
|
||||||
"[-S active-border-style] [-w width] [-x x-position] "
|
"[-S active-border-style] [-w width] [-x x-position] "
|
||||||
"[-y y-position]" CMD_TARGET_PANE_USAGE "[-T type] "
|
"[-y y-position]" CMD_TARGET_PANE_USAGE
|
||||||
" [shell-command [argument ...]]",
|
"[shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_new_pane_exec
|
.exec = cmd_split_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum new_pane_type {
|
enum new_pane_mode {
|
||||||
FLOATING,
|
FLOATING,
|
||||||
TILED,
|
TILED,
|
||||||
NONE,
|
NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum new_pane_type
|
|
||||||
cmd_new_pane_get_type(const char* val)
|
|
||||||
{
|
|
||||||
if (strncmp(val, "floating", (sizeof "floating") - 1) == 0 ||
|
|
||||||
strncmp(val, "f", (sizeof "f") - 1) == 0)
|
|
||||||
return FLOATING;
|
|
||||||
if (strncmp(val, "tiled", (sizeof "tiled") - 1) == 0 ||
|
|
||||||
strncmp(val, "t", (sizeof "t") - 1) == 0)
|
|
||||||
return TILED;
|
|
||||||
return NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct layout_cell *
|
static struct layout_cell *
|
||||||
cmd_new_pane_get_floating_layout_cell(struct cmdq_item *item, struct args *args,
|
cmd_split_window_get_floating_layout_cell(struct cmdq_item *item,
|
||||||
struct window *w)
|
struct args *args, struct window *w)
|
||||||
{
|
{
|
||||||
struct layout_cell *lc = NULL;
|
struct layout_cell *lc = NULL;
|
||||||
char *cause = NULL;
|
char *cause = NULL;
|
||||||
@@ -164,8 +152,8 @@ cmd_new_pane_get_floating_layout_cell(struct cmdq_item *item, struct args *args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct layout_cell *
|
static struct layout_cell *
|
||||||
cmd_new_pane_get_tiled_layout_cell(struct cmdq_item *item, struct args *args,
|
cmd_split_window_get_tiled_layout_cell(struct cmdq_item *item,
|
||||||
struct window *w, struct window_pane *wp, int flags)
|
struct args *args, struct window *w, struct window_pane *wp, int flags)
|
||||||
{
|
{
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc = NULL;
|
struct layout_cell *lc = NULL;
|
||||||
@@ -222,7 +210,7 @@ cmd_new_pane_get_tiled_layout_cell(struct cmdq_item *item, struct args *args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = cmd_get_args(self);
|
struct args *args = cmd_get_args(self);
|
||||||
struct cmd_find_state *current = cmdq_get_current(item);
|
struct cmd_find_state *current = cmdq_get_current(item);
|
||||||
@@ -240,20 +228,25 @@ cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
char *cause = NULL, *cp;
|
char *cause = NULL, *cp;
|
||||||
struct args_value *av;
|
struct args_value *av;
|
||||||
u_int count = args_count(args);
|
u_int count = args_count(args);
|
||||||
enum new_pane_type pane_type = NONE;
|
enum new_pane_mode pane_mode = NONE;
|
||||||
|
|
||||||
if (args_has(args, 'T')) {
|
if (args_has(args, 'M')) {
|
||||||
pane_type = cmd_new_pane_get_type(args_get(args, 'T'));
|
if (strcasecmp(args_get(args, 'M'), "f") == 0)
|
||||||
|
pane_mode = FLOATING;
|
||||||
|
else if (strcasecmp(args_get(args, 'M'), "t") == 0)
|
||||||
|
pane_mode = TILED;
|
||||||
|
else
|
||||||
|
pane_mode = NONE;
|
||||||
} else {
|
} else {
|
||||||
if (cmd_get_entry(self) == &cmd_new_pane_entry)
|
if (cmd_get_entry(self) == &cmd_new_pane_entry)
|
||||||
pane_type = FLOATING;
|
pane_mode = FLOATING;
|
||||||
else
|
else
|
||||||
pane_type = TILED;
|
pane_mode = TILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
input = (args_has(args, 'I') && count == 0);
|
input = (args_has(args, 'I') && count == 0);
|
||||||
|
|
||||||
flags = pane_type == FLOATING ? SPAWN_FLOATING : 0;
|
flags = pane_mode == FLOATING ? SPAWN_FLOATING : 0;
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
flags |= SPAWN_BEFORE;
|
flags |= SPAWN_BEFORE;
|
||||||
if (args_has(args, 'f'))
|
if (args_has(args, 'f'))
|
||||||
@@ -262,13 +255,16 @@ cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
flags |= SPAWN_EMPTY;
|
flags |= SPAWN_EMPTY;
|
||||||
|
|
||||||
|
|
||||||
if (pane_type == FLOATING) {
|
if (pane_mode == FLOATING)
|
||||||
lc = cmd_new_pane_get_floating_layout_cell(item, args, w);
|
lc = cmd_split_window_get_floating_layout_cell(item, args, w);
|
||||||
} else if (pane_type == TILED)
|
else if (pane_mode == TILED)
|
||||||
lc = cmd_new_pane_get_tiled_layout_cell(item, args, w, wp,
|
lc = cmd_split_window_get_tiled_layout_cell(item, args, w, wp,
|
||||||
flags);
|
flags);
|
||||||
else
|
else {
|
||||||
cmdq_error(item, "unrecognized pane type '%s'", args_get(args, 'T'));
|
cmdq_error(item, "unrecognized pane mode '%s'",
|
||||||
|
args_get(args, 'M'));
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
if (lc == NULL)
|
if (lc == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
@@ -345,7 +341,7 @@ cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
switch (window_pane_start_input(new_wp, item, &cause)) {
|
switch (window_pane_start_input(new_wp, item, &cause)) {
|
||||||
case -1:
|
case -1:
|
||||||
server_client_remove_pane(new_wp);
|
server_client_remove_pane(new_wp);
|
||||||
if (pane_type == TILED)
|
if (pane_mode == TILED)
|
||||||
layout_close_pane(new_wp);
|
layout_close_pane(new_wp);
|
||||||
window_remove_pane(wp->window, new_wp);
|
window_remove_pane(wp->window, new_wp);
|
||||||
cmdq_error(item, "%s", cause);
|
cmdq_error(item, "%s", cause);
|
||||||
58
tmux.1
58
tmux.1
@@ -3330,34 +3330,39 @@ but a different format may be specified with
|
|||||||
.Op Fl H Ar height
|
.Op Fl H Ar height
|
||||||
.Op Fl l Ar size
|
.Op Fl l Ar size
|
||||||
.Op Fl m Ar message
|
.Op Fl m Ar message
|
||||||
|
.Op Fl M Ar mode
|
||||||
.Op Fl p Ar percentage
|
.Op Fl p Ar percentage
|
||||||
.Op Fl R Ar inactive-border-style
|
.Op Fl R Ar inactive-border-style
|
||||||
.Op Fl s Ar style
|
.Op Fl s Ar style
|
||||||
.Op Fl S Ar active-border-style
|
.Op Fl S Ar active-border-style
|
||||||
.Op Fl t Ar target-pane
|
.Op Fl t Ar target-pane
|
||||||
.Op Fl T Ar type
|
|
||||||
.Op Fl w Ar width
|
.Op Fl w Ar width
|
||||||
.Op Fl x Ar x-position
|
.Op Fl x Ar x-position
|
||||||
.Op Fl y Ar y-position
|
.Op Fl y Ar y-position
|
||||||
.Op Ar shell-command Op Ar argument ...
|
.Op Ar shell-command Op Ar argument ...
|
||||||
.Xc
|
.Xc
|
||||||
.D1 Pq alias: Ic newp
|
.D1 Pq alias: Ic newp
|
||||||
Create a new pane. The new pane may be floating by specifying the
|
Create a new pane.
|
||||||
.Ar type
|
A
|
||||||
with
|
.Ar mode
|
||||||
.Fl Tf
|
may be specified with the
|
||||||
/
|
.Fl M
|
||||||
.Fl Tfloating ,
|
option and must be followed by one of the following special values:
|
||||||
or tiled into the layout by splitting an existing pane with
|
.Bl -column "XXXXX" -offset indent
|
||||||
.Fl Tt
|
.It Sy "Value" Ta Sy "Meaning"
|
||||||
/
|
.It Li "f" Ta "floating pane above the current layout"
|
||||||
.Fl Ttiled .
|
.It Li "t" Ta "tiled into the layout by splitting a pane"
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
If no
|
||||||
|
.Ar mode
|
||||||
|
is specified,
|
||||||
|
.Ic f
|
||||||
|
is assumed.
|
||||||
When creating a tiled pane, a target pane may be specified with
|
When creating a tiled pane, a target pane may be specified with
|
||||||
.Fl t .
|
.Fl t .
|
||||||
Note that some options are related to dimensions/layout. Those options will
|
Note that some options will only affect one
|
||||||
only affect one creation
|
.Ar mode .
|
||||||
.Ar type
|
|
||||||
and will be in their own sections.
|
|
||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
.Fl d
|
.Fl d
|
||||||
@@ -3374,8 +3379,8 @@ sets the border style when the pane is inactive (see
|
|||||||
.Fl k
|
.Fl k
|
||||||
keeps the pane open after the optional
|
keeps the pane open after the optional
|
||||||
.Ar shell-command
|
.Ar shell-command
|
||||||
exits and waits for a keypress (any non-mouse key) before closing it. The
|
exits and waits for a keypress (any non-mouse key) before closing it.
|
||||||
message shown is controlled by the
|
The message shown is controlled by the
|
||||||
.Ic remain-on-exit-format
|
.Ic remain-on-exit-format
|
||||||
option.
|
option.
|
||||||
.Fl m Ar message
|
.Fl m Ar message
|
||||||
@@ -3393,24 +3398,26 @@ The
|
|||||||
flag (if
|
flag (if
|
||||||
.Ar shell-command
|
.Ar shell-command
|
||||||
is not specified or empty)
|
is not specified or empty)
|
||||||
will create an empty pane and forward any output from stdin to it. For example:
|
will create an empty pane and forward any output from stdin to it.
|
||||||
|
For example:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
$ make 2>&1|tmux splitw \-dI &
|
$ make 2>&1|tmux splitw \-dI &
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
For floating panes, the following flags are availible:
|
For floating panes, the following options are availible:
|
||||||
The
|
The
|
||||||
.Fl w ,
|
.Fl w ,
|
||||||
.Fl h ,
|
.Fl h ,
|
||||||
.Fl x ,
|
.Fl x ,
|
||||||
and
|
and
|
||||||
.Fl y
|
.Fl y
|
||||||
options set the width, height, and position of the pane; if not given,
|
options set the width, height, and position of the pane.
|
||||||
the pane is sized to half the window dimensions and offset from the
|
If not given, the pane is sized to half the window dimensions and offset from
|
||||||
previous floating pane. These four options may be followed by '%' to specify
|
the previous floating pane.
|
||||||
a percentage of the current window dimensions.
|
These four options may be followed by '%' to specify a percentage of the
|
||||||
|
current window dimensions.
|
||||||
.Pp
|
.Pp
|
||||||
For tiled panes, the following flags are availible:
|
For tiled panes, the following options are availible:
|
||||||
.Fl h
|
.Fl h
|
||||||
does a horizontal split and
|
does a horizontal split and
|
||||||
.Fl v
|
.Fl v
|
||||||
@@ -3783,7 +3790,8 @@ the command behaves like
|
|||||||
.Op Ar shell-command Op Ar argument ...
|
.Op Ar shell-command Op Ar argument ...
|
||||||
.Xc
|
.Xc
|
||||||
.D1 Pq alias: Ic splitw
|
.D1 Pq alias: Ic splitw
|
||||||
Creates a new pane. Default behavior is to split the pane in a tiled layout.
|
Creates a new pane.
|
||||||
|
Default behavior is to split the pane in a tiled layout.
|
||||||
Shares behavior with
|
Shares behavior with
|
||||||
.Ic new-pane .
|
.Ic new-pane .
|
||||||
.Pp
|
.Pp
|
||||||
|
|||||||
Reference in New Issue
Block a user