Rewrite of choose mode, both to simplify and tidy the code and to add

some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
  (very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
  (for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
  window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
  is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
  with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.
This commit is contained in:
nicm
2017-05-30 21:44:59 +00:00
parent bd39fcbeea
commit aad4e4ddb1
26 changed files with 2434 additions and 1905 deletions

199
tmux.1
View File

@ -1339,136 +1339,76 @@ the end of the visible pane.
The default is to capture only the visible contents of the pane.
.It Xo
.Ic choose-client
.Op Fl F Ar format
.Op Fl t Ar target-window
.Op Fl t Ar target-pane
.Op Ar template
.Xc
Put a window into client choice mode, allowing a client to be selected
interactively from a list.
Put a pane into client mode, allowing a client to be selected interactively from
a list.
The following keys may be used in client mode:
.Bl -column "Key" "Function" -offset indent
.It Sy "Key" Ta Sy "Function"
.It Li "Enter" Ta "Choose selected client"
.It Li "Up" Ta "Select previous client"
.It Li "Down" Ta "Select next client"
.It Li "t" Ta "Toggle if client is tagged"
.It Li "T" Ta "Tag no clients"
.It Li "C-t" Ta "Tag all clients"
.It Li "d" Ta "Detach selected client"
.It Li "D" Ta "Detach tagged clients"
.It Li "x" Ta "Detach and HUP selected client"
.It Li "X" Ta "Detach and HUP tagged clients"
.It Li "z" Ta "Suspend selected client"
.It Li "Z" Ta "Suspend tagged clients"
.It Li "O" Ta "Change sort order"
.It Li "q" Ta "Exit mode"
.El
.Pp
After a client is chosen,
.Ql %%
is replaced by the client
.Xr pty 4
path in
is replaced by the client name in
.Ar template
and the result executed as a command.
If
.Ar template
is not given, "detach-client -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
.Pp
This command works only if at least one client is attached.
.It Xo
.Ic choose-session
.Op Fl F Ar format
.Op Fl t Ar target-window
.Ic choose-tree
.Op Fl sw
.Op Fl t Ar target-pane
.Op Ar template
.Xc
Put a window into session choice mode, where a session may be selected
Put a pane into tree mode, where a session, window or pane may be chosen
interactively from a list.
When one is chosen,
.Fl s
starts with sessions collapsed and
.Fl w
with windows collapsed.
The following keys may be used in tree mode:
.Bl -column "Key" "Function" -offset indent
.It Sy "Key" Ta Sy "Function"
.It Li "Enter" Ta "Choose selected item"
.It Li "Up" Ta "Select previous item"
.It Li "Down" Ta "Select next item"
.It Li "t" Ta "Toggle if item is tagged"
.It Li "T" Ta "Tag no items"
.It Li "C-t" Ta "Tag all items"
.It Li ":" Ta "Run a command for each tagged item"
.It Li "f" Ta "Enter a format to filter items"
.It Li "O" Ta "Change sort order"
.It Li "q" Ta "Exit mode"
.El
.Pp
After a session, window or pane is chosen,
.Ql %%
is replaced by the session name in
is replaced by the target in
.Ar template
and the result executed as a command.
If
.Ar template
is not given, "switch-client -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only if at least one client is attached.
.It Xo
.Ic choose-tree
.Op Fl suw
.Op Fl b Ar session-template
.Op Fl c Ar window-template
.Op Fl S Ar format
.Op Fl W Ar format
.Op Fl t Ar target-window
.Xc
Put a window into tree choice mode, where either sessions or windows may be
selected interactively from a list.
By default, windows belonging to a session are indented to show their
relationship to a session.
.Pp
Note that the
.Ic choose-window
and
.Ic choose-session
commands are wrappers around
.Ic choose-tree .
.Pp
If
.Fl s
is given, will show sessions.
If
.Fl w
is given, will show windows.
.Pp
By default, the tree is collapsed and sessions must be expanded to windows
with the right arrow key.
The
.Fl u
option will start with all sessions expanded instead.
.Pp
If
.Fl b
is given, will override the default session command.
Note that
.Ql %%
can be used and will be replaced with the session name.
The default option if not specified is "switch-client -t '%%'".
If
.Fl c
is given, will override the default window command.
Like
.Fl b ,
.Ql %%
can be used and will be replaced with the session name and window index.
When a window is chosen from the list, the session command is run before the
window command.
.Pp
.Fl S
uses
.Ar format
instead of the default session
format and
.Fl W
instead of the default window format.
For the meaning of
.Ar format ,
see the
.Sx FORMATS
section.
.Pp
This command works only if at least one client is attached.
.It Xo
.Ic choose-window
.Op Fl F Ar format
.Op Fl t Ar target-window
.Op Ar template
.Xc
Put a window into window choice mode, where a window may be chosen
interactively from a list.
After a window is selected,
.Ql %%
is replaced by the session name and window index in
.Ar template
and the result executed as a command.
If
.Ar template
is not given, "select-window -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only if at least one client is attached.
.It Xo
.Ic display-panes
@ -1498,8 +1438,7 @@ The default
is "select-pane -t '%%'".
.It Xo Ic find-window
.Op Fl CNT
.Op Fl F Ar format
.Op Fl t Ar target-window
.Op Fl t Ar target-pane
.Ar match-string
.Xc
.D1 (alias: Ic findw )
@ -1517,13 +1456,7 @@ matches only the window name and
matches only the window title.
The default is
.Fl CNT .
If only one window is matched, it'll be automatically selected,
otherwise a choice list is shown.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
.Pp
This command works only if at least one client is attached.
.It Xo Ic join-pane
.Op Fl bdhv
@ -3982,13 +3915,27 @@ The buffer commands are as follows:
.Bl -tag -width Ds
.It Xo
.Ic choose-buffer
.Op Fl F Ar format
.Op Fl t Ar target-window
.Op Fl t Ar target-pane
.Op Ar template
.Xc
Put a window into buffer choice mode, where a buffer may be chosen
interactively from a list.
After a buffer is selected,
Put a pane into buffer mode, where a buffer may be chosen interactively from
a list.
The following keys may be used in buffer mode:
.Bl -column "Key" "Function" -offset indent
.It Sy "Key" Ta Sy "Function"
.It Li "Enter" Ta "Choose selected buffer"
.It Li "Up" Ta "Select previous buffer"
.It Li "Down" Ta "Select next buffer"
.It Li "t" Ta "Toggle if buffer is tagged"
.It Li "T" Ta "Tag no buffers"
.It Li "C-t" Ta "Tag all buffers"
.It Li "d" Ta "Delete selected buffer"
.It Li "D" Ta "Delete tagged buffers"
.It Li "O" Ta "Change sort order"
.It Li "q" Ta "Exit mode"
.El
.Pp
After a buffer is chosen,
.Ql %%
is replaced by the buffer name in
.Ar template
@ -3996,11 +3943,7 @@ and the result executed as a command.
If
.Ar template
is not given, "paste-buffer -b '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
.Pp
This command works only if at least one client is attached.
.It Ic clear-history Op Fl t Ar target-pane
.D1 (alias: Ic clearhist )