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.
2017-05-30 21:44:59 +00:00
|
|
|
/* $OpenBSD$ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2024-05-24 12:39:06 +00:00
|
|
|
enum mode_tree_search_dir {
|
|
|
|
MODE_TREE_SEARCH_FORWARD,
|
|
|
|
MODE_TREE_SEARCH_BACKWARD
|
|
|
|
};
|
|
|
|
|
2024-10-01 10:10:29 +00:00
|
|
|
enum mode_tree_preview {
|
|
|
|
MODE_TREE_PREVIEW_OFF,
|
|
|
|
MODE_TREE_PREVIEW_NORMAL,
|
|
|
|
MODE_TREE_PREVIEW_BIG
|
|
|
|
};
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
struct mode_tree_item;
|
|
|
|
TAILQ_HEAD(mode_tree_list, mode_tree_item);
|
|
|
|
|
|
|
|
struct mode_tree_data {
|
2017-06-07 14:37:30 +00:00
|
|
|
int dead;
|
|
|
|
u_int references;
|
2018-02-28 08:55:44 +00:00
|
|
|
int zoomed;
|
2017-06-07 14:37:30 +00:00
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
struct window_pane *wp;
|
|
|
|
void *modedata;
|
2019-05-28 07:18:42 +00:00
|
|
|
const struct menu_item *menu;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
const char **sort_list;
|
|
|
|
u_int sort_size;
|
2019-08-16 11:49:12 +00:00
|
|
|
struct mode_tree_sort_criteria sort_crit;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
2017-11-02 22:00:42 +00:00
|
|
|
mode_tree_build_cb buildcb;
|
|
|
|
mode_tree_draw_cb drawcb;
|
|
|
|
mode_tree_search_cb searchcb;
|
2019-05-12 08:58:09 +00:00
|
|
|
mode_tree_menu_cb menucb;
|
2020-05-16 16:02:24 +00:00
|
|
|
mode_tree_height_cb heightcb;
|
2021-04-12 06:50:25 +00:00
|
|
|
mode_tree_key_cb keycb;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
struct mode_tree_list children;
|
|
|
|
struct mode_tree_list saved;
|
|
|
|
|
|
|
|
struct mode_tree_line *line_list;
|
|
|
|
u_int line_size;
|
|
|
|
|
|
|
|
u_int depth;
|
|
|
|
|
|
|
|
u_int width;
|
|
|
|
u_int height;
|
|
|
|
|
|
|
|
u_int offset;
|
|
|
|
u_int current;
|
|
|
|
|
|
|
|
struct screen screen;
|
2017-06-07 14:37:30 +00:00
|
|
|
|
2017-08-23 09:39:11 +00:00
|
|
|
int preview;
|
2017-06-09 16:01:39 +00:00
|
|
|
char *search;
|
|
|
|
char *filter;
|
2018-02-05 06:51:41 +00:00
|
|
|
int no_matches;
|
2024-05-24 12:39:06 +00:00
|
|
|
enum mode_tree_search_dir search_dir;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mode_tree_item {
|
|
|
|
struct mode_tree_item *parent;
|
|
|
|
void *itemdata;
|
|
|
|
u_int line;
|
|
|
|
|
2021-04-12 06:50:25 +00:00
|
|
|
key_code key;
|
|
|
|
const char *keystr;
|
|
|
|
size_t keylen;
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
uint64_t tag;
|
|
|
|
const char *name;
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
int expanded;
|
|
|
|
int tagged;
|
2020-06-16 08:18:34 +00:00
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
int draw_as_parent;
|
2020-06-16 08:18:34 +00:00
|
|
|
int no_tag;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
struct mode_tree_list children;
|
|
|
|
TAILQ_ENTRY(mode_tree_item) entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mode_tree_line {
|
|
|
|
struct mode_tree_item *item;
|
|
|
|
u_int depth;
|
|
|
|
int last;
|
|
|
|
int flat;
|
|
|
|
};
|
|
|
|
|
2019-05-12 08:58:09 +00:00
|
|
|
struct mode_tree_menu {
|
|
|
|
struct mode_tree_data *data;
|
|
|
|
struct client *c;
|
|
|
|
u_int line;
|
|
|
|
};
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
static void mode_tree_free_items(struct mode_tree_list *);
|
|
|
|
|
2019-05-28 07:18:42 +00:00
|
|
|
static const struct menu_item mode_tree_menu_items[] = {
|
|
|
|
{ "Scroll Left", '<', NULL },
|
|
|
|
{ "Scroll Right", '>', NULL },
|
|
|
|
{ "", KEYC_NONE, NULL },
|
|
|
|
{ "Cancel", 'q', NULL },
|
|
|
|
|
|
|
|
{ NULL, KEYC_NONE, NULL }
|
|
|
|
};
|
2019-05-12 08:58:09 +00:00
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
static struct mode_tree_item *
|
|
|
|
mode_tree_find_item(struct mode_tree_list *mtl, uint64_t tag)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *child;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(mti, mtl, entry) {
|
|
|
|
if (mti->tag == tag)
|
|
|
|
return (mti);
|
|
|
|
child = mode_tree_find_item(&mti->children, tag);
|
|
|
|
if (child != NULL)
|
|
|
|
return (child);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_free_item(struct mode_tree_item *mti)
|
|
|
|
{
|
|
|
|
mode_tree_free_items(&mti->children);
|
|
|
|
|
|
|
|
free((void *)mti->name);
|
|
|
|
free((void *)mti->text);
|
2021-04-12 06:50:25 +00:00
|
|
|
free((void *)mti->keystr);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
free(mti);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_free_items(struct mode_tree_list *mtl)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *mti1;
|
|
|
|
|
|
|
|
TAILQ_FOREACH_SAFE(mti, mtl, entry, mti1) {
|
|
|
|
TAILQ_REMOVE(mtl, mti, entry);
|
|
|
|
mode_tree_free_item(mti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 16:28:41 +00:00
|
|
|
static void
|
|
|
|
mode_tree_check_selected(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If the current line would now be off screen reset the offset to the
|
|
|
|
* last visible line.
|
|
|
|
*/
|
|
|
|
if (mtd->current > mtd->height - 1)
|
|
|
|
mtd->offset = mtd->current - mtd->height + 1;
|
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
static void
|
|
|
|
mode_tree_clear_lines(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
free(mtd->line_list);
|
|
|
|
mtd->line_list = NULL;
|
|
|
|
mtd->line_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_build_lines(struct mode_tree_data *mtd,
|
|
|
|
struct mode_tree_list *mtl, u_int depth)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
struct mode_tree_line *line;
|
|
|
|
u_int i;
|
|
|
|
int flat = 1;
|
|
|
|
|
|
|
|
mtd->depth = depth;
|
|
|
|
TAILQ_FOREACH(mti, mtl, entry) {
|
|
|
|
mtd->line_list = xreallocarray(mtd->line_list,
|
|
|
|
mtd->line_size + 1, sizeof *mtd->line_list);
|
|
|
|
|
|
|
|
line = &mtd->line_list[mtd->line_size++];
|
|
|
|
line->item = mti;
|
|
|
|
line->depth = depth;
|
|
|
|
line->last = (mti == TAILQ_LAST(mtl, mode_tree_list));
|
|
|
|
|
|
|
|
mti->line = (mtd->line_size - 1);
|
|
|
|
if (!TAILQ_EMPTY(&mti->children))
|
|
|
|
flat = 0;
|
|
|
|
if (mti->expanded)
|
|
|
|
mode_tree_build_lines(mtd, &mti->children, depth + 1);
|
2021-04-12 06:50:25 +00:00
|
|
|
|
|
|
|
if (mtd->keycb != NULL) {
|
|
|
|
mti->key = mtd->keycb(mtd->modedata, mti->itemdata,
|
|
|
|
mti->line);
|
|
|
|
if (mti->key == KEYC_UNKNOWN)
|
|
|
|
mti->key = KEYC_NONE;
|
|
|
|
} else if (mti->line < 10)
|
|
|
|
mti->key = '0' + mti->line;
|
|
|
|
else if (mti->line < 36)
|
|
|
|
mti->key = KEYC_META|('a' + mti->line - 10);
|
|
|
|
else
|
|
|
|
mti->key = KEYC_NONE;
|
|
|
|
if (mti->key != KEYC_NONE) {
|
|
|
|
mti->keystr = xstrdup(key_string_lookup_key(mti->key,
|
|
|
|
0));
|
|
|
|
mti->keylen = strlen(mti->keystr);
|
|
|
|
} else {
|
|
|
|
mti->keystr = NULL;
|
|
|
|
mti->keylen = 0;
|
|
|
|
}
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
TAILQ_FOREACH(mti, mtl, entry) {
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
line = &mtd->line_list[i];
|
|
|
|
if (line->item == mti)
|
|
|
|
line->flat = flat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_clear_tagged(struct mode_tree_list *mtl)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(mti, mtl, entry) {
|
|
|
|
mti->tagged = 0;
|
|
|
|
mode_tree_clear_tagged(&mti->children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
void
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_up(struct mode_tree_data *mtd, int wrap)
|
|
|
|
{
|
|
|
|
if (mtd->current == 0) {
|
|
|
|
if (wrap) {
|
|
|
|
mtd->current = mtd->line_size - 1;
|
|
|
|
if (mtd->line_size >= mtd->height)
|
|
|
|
mtd->offset = mtd->line_size - mtd->height;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mtd->current--;
|
|
|
|
if (mtd->current < mtd->offset)
|
|
|
|
mtd->offset--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-04 08:53:43 +00:00
|
|
|
int
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_down(struct mode_tree_data *mtd, int wrap)
|
|
|
|
{
|
|
|
|
if (mtd->current == mtd->line_size - 1) {
|
|
|
|
if (wrap) {
|
|
|
|
mtd->current = 0;
|
|
|
|
mtd->offset = 0;
|
2024-08-04 08:53:43 +00:00
|
|
|
} else
|
|
|
|
return (0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
} else {
|
|
|
|
mtd->current++;
|
|
|
|
if (mtd->current > mtd->offset + mtd->height - 1)
|
|
|
|
mtd->offset++;
|
|
|
|
}
|
2024-08-04 08:53:43 +00:00
|
|
|
return (1);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
mode_tree_get_current(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
return (mtd->line_list[mtd->current].item->itemdata);
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
const char *
|
|
|
|
mode_tree_get_current_name(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
return (mtd->line_list[mtd->current].item->name);
|
|
|
|
}
|
|
|
|
|
2017-11-03 17:02:33 +00:00
|
|
|
void
|
|
|
|
mode_tree_expand_current(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
if (!mtd->line_list[mtd->current].item->expanded) {
|
|
|
|
mtd->line_list[mtd->current].item->expanded = 1;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
void
|
|
|
|
mode_tree_collapse_current(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
if (mtd->line_list[mtd->current].item->expanded) {
|
|
|
|
mtd->line_list[mtd->current].item->expanded = 0;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:01:28 +00:00
|
|
|
static int
|
|
|
|
mode_tree_get_tag(struct mode_tree_data *mtd, uint64_t tag, u_int *found)
|
2017-11-03 17:02:33 +00:00
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
if (mtd->line_list[i].item->tag == tag)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i != mtd->line_size) {
|
2020-04-22 21:01:28 +00:00
|
|
|
*found = i;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mode_tree_expand(struct mode_tree_data *mtd, uint64_t tag)
|
|
|
|
{
|
|
|
|
u_int found;
|
|
|
|
|
|
|
|
if (!mode_tree_get_tag(mtd, tag, &found))
|
|
|
|
return;
|
|
|
|
if (!mtd->line_list[found].item->expanded) {
|
|
|
|
mtd->line_list[found].item->expanded = 1;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag)
|
|
|
|
{
|
|
|
|
u_int found;
|
|
|
|
|
|
|
|
if (mode_tree_get_tag(mtd, tag, &found)) {
|
|
|
|
mtd->current = found;
|
2017-11-03 17:02:33 +00:00
|
|
|
if (mtd->current > mtd->height - 1)
|
|
|
|
mtd->offset = mtd->current - mtd->height + 1;
|
|
|
|
else
|
|
|
|
mtd->offset = 0;
|
2020-04-22 21:01:28 +00:00
|
|
|
return (1);
|
2017-11-03 17:02:33 +00:00
|
|
|
}
|
2024-10-06 09:30:22 +00:00
|
|
|
if (mtd->current >= mtd->line_size) {
|
|
|
|
mtd->current = mtd->line_size - 1;
|
|
|
|
if (mtd->current > mtd->height - 1)
|
|
|
|
mtd->offset = mtd->current - mtd->height + 1;
|
|
|
|
else
|
|
|
|
mtd->offset = 0;
|
|
|
|
}
|
2020-04-22 21:01:28 +00:00
|
|
|
return (0);
|
2017-11-03 17:02:33 +00:00
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
u_int
|
|
|
|
mode_tree_count_tagged(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
u_int i, tagged;
|
|
|
|
|
|
|
|
tagged = 0;
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
mti = mtd->line_list[i].item;
|
|
|
|
if (mti->tagged)
|
|
|
|
tagged++;
|
|
|
|
}
|
|
|
|
return (tagged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-11-02 22:00:42 +00:00
|
|
|
mode_tree_each_tagged(struct mode_tree_data *mtd, mode_tree_each_cb cb,
|
|
|
|
struct client *c, key_code key, int current)
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
{
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
u_int i;
|
|
|
|
int fired;
|
|
|
|
|
|
|
|
fired = 0;
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
mti = mtd->line_list[i].item;
|
|
|
|
if (mti->tagged) {
|
|
|
|
fired = 1;
|
2017-10-25 11:26:11 +00:00
|
|
|
cb(mtd->modedata, mti->itemdata, c, key);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!fired && current) {
|
|
|
|
mti = mtd->line_list[mtd->current].item;
|
2017-10-25 11:26:11 +00:00
|
|
|
cb(mtd->modedata, mti->itemdata, c, key);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mode_tree_data *
|
2017-06-09 15:29:15 +00:00
|
|
|
mode_tree_start(struct window_pane *wp, struct args *args,
|
2017-11-02 22:00:42 +00:00
|
|
|
mode_tree_build_cb buildcb, mode_tree_draw_cb drawcb,
|
2020-05-16 16:02:24 +00:00
|
|
|
mode_tree_search_cb searchcb, mode_tree_menu_cb menucb,
|
2021-04-12 06:50:25 +00:00
|
|
|
mode_tree_height_cb heightcb, mode_tree_key_cb keycb, void *modedata,
|
2019-05-28 07:18:42 +00:00
|
|
|
const struct menu_item *menu, const char **sort_list, u_int sort_size,
|
2019-05-12 08:58:09 +00:00
|
|
|
struct screen **s)
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
{
|
|
|
|
struct mode_tree_data *mtd;
|
2017-06-09 15:29:15 +00:00
|
|
|
const char *sort;
|
|
|
|
u_int i;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
mtd = xcalloc(1, sizeof *mtd);
|
2017-06-07 14:37:30 +00:00
|
|
|
mtd->references = 1;
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mtd->wp = wp;
|
|
|
|
mtd->modedata = modedata;
|
2019-05-12 08:58:09 +00:00
|
|
|
mtd->menu = menu;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
mtd->sort_list = sort_list;
|
|
|
|
mtd->sort_size = sort_size;
|
|
|
|
|
2024-10-01 10:10:29 +00:00
|
|
|
if (args_has(args, 'N') > 1)
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_BIG;
|
|
|
|
else if (args_has(args, 'N'))
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_OFF;
|
|
|
|
else
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_NORMAL;
|
2017-08-23 09:39:11 +00:00
|
|
|
|
2017-06-09 15:29:15 +00:00
|
|
|
sort = args_get(args, 'O');
|
|
|
|
if (sort != NULL) {
|
|
|
|
for (i = 0; i < sort_size; i++) {
|
|
|
|
if (strcasecmp(sort, sort_list[i]) == 0)
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->sort_crit.field = i;
|
2017-06-09 15:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->sort_crit.reversed = args_has(args, 'r');
|
2017-06-09 15:29:15 +00:00
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
if (args_has(args, 'f'))
|
|
|
|
mtd->filter = xstrdup(args_get(args, 'f'));
|
|
|
|
else
|
|
|
|
mtd->filter = NULL;
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mtd->buildcb = buildcb;
|
|
|
|
mtd->drawcb = drawcb;
|
2017-06-07 14:37:30 +00:00
|
|
|
mtd->searchcb = searchcb;
|
2019-05-12 08:58:09 +00:00
|
|
|
mtd->menucb = menucb;
|
2020-05-16 16:02:24 +00:00
|
|
|
mtd->heightcb = heightcb;
|
2021-04-12 06:50:25 +00:00
|
|
|
mtd->keycb = keycb;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
TAILQ_INIT(&mtd->children);
|
|
|
|
|
|
|
|
*s = &mtd->screen;
|
|
|
|
screen_init(*s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
|
|
|
|
(*s)->mode &= ~MODE_CURSOR;
|
|
|
|
|
|
|
|
return (mtd);
|
|
|
|
}
|
|
|
|
|
2018-02-28 08:55:44 +00:00
|
|
|
void
|
|
|
|
mode_tree_zoom(struct mode_tree_data *mtd, struct args *args)
|
|
|
|
{
|
|
|
|
struct window_pane *wp = mtd->wp;
|
|
|
|
|
|
|
|
if (args_has(args, 'Z')) {
|
|
|
|
mtd->zoomed = (wp->window->flags & WINDOW_ZOOMED);
|
|
|
|
if (!mtd->zoomed && window_zoom(wp) == 0)
|
|
|
|
server_redraw_window(wp->window);
|
|
|
|
} else
|
|
|
|
mtd->zoomed = -1;
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
static void
|
|
|
|
mode_tree_set_height(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct screen *s = &mtd->screen;
|
|
|
|
u_int height;
|
|
|
|
|
|
|
|
if (mtd->heightcb != NULL) {
|
|
|
|
height = mtd->heightcb(mtd, screen_size_y(s));
|
|
|
|
if (height < screen_size_y(s))
|
|
|
|
mtd->height = screen_size_y(s) - height;
|
|
|
|
} else {
|
2024-10-01 10:10:29 +00:00
|
|
|
if (mtd->preview == MODE_TREE_PREVIEW_NORMAL) {
|
|
|
|
mtd->height = (screen_size_y(s) / 3) * 2;
|
|
|
|
if (mtd->height > mtd->line_size)
|
|
|
|
mtd->height = screen_size_y(s) / 2;
|
|
|
|
if (mtd->height < 10)
|
|
|
|
mtd->height = screen_size_y(s);
|
|
|
|
} else if (mtd->preview == MODE_TREE_PREVIEW_BIG) {
|
|
|
|
mtd->height = screen_size_y(s) / 4;
|
|
|
|
if (mtd->height > mtd->line_size)
|
|
|
|
mtd->height = mtd->line_size;
|
|
|
|
if (mtd->height < 2)
|
|
|
|
mtd->height = 2;
|
|
|
|
} else
|
|
|
|
mtd->height = screen_size_y(s);
|
2020-05-16 16:02:24 +00:00
|
|
|
}
|
|
|
|
if (screen_size_y(s) - mtd->height < 2)
|
|
|
|
mtd->height = screen_size_y(s);
|
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
void
|
|
|
|
mode_tree_build(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct screen *s = &mtd->screen;
|
|
|
|
uint64_t tag;
|
|
|
|
|
|
|
|
if (mtd->line_list != NULL)
|
|
|
|
tag = mtd->line_list[mtd->current].item->tag;
|
|
|
|
else
|
2019-05-27 06:50:04 +00:00
|
|
|
tag = UINT64_MAX;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
TAILQ_CONCAT(&mtd->saved, &mtd->children, entry);
|
|
|
|
TAILQ_INIT(&mtd->children);
|
|
|
|
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->buildcb(mtd->modedata, &mtd->sort_crit, &tag, mtd->filter);
|
2018-02-05 06:51:41 +00:00
|
|
|
mtd->no_matches = TAILQ_EMPTY(&mtd->children);
|
|
|
|
if (mtd->no_matches)
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->buildcb(mtd->modedata, &mtd->sort_crit, &tag, NULL);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
mode_tree_free_items(&mtd->saved);
|
|
|
|
TAILQ_INIT(&mtd->saved);
|
|
|
|
|
|
|
|
mode_tree_clear_lines(mtd);
|
|
|
|
mode_tree_build_lines(mtd, &mtd->children, 0);
|
|
|
|
|
2023-08-11 17:09:00 +00:00
|
|
|
if (mtd->line_list != NULL && tag == UINT64_MAX)
|
2019-05-27 06:50:04 +00:00
|
|
|
tag = mtd->line_list[mtd->current].item->tag;
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_set_current(mtd, tag);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
mtd->width = screen_size_x(s);
|
2024-10-01 10:10:29 +00:00
|
|
|
if (mtd->preview != MODE_TREE_PREVIEW_OFF)
|
2020-05-16 16:02:24 +00:00
|
|
|
mode_tree_set_height(mtd);
|
|
|
|
else
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mtd->height = screen_size_y(s);
|
2017-09-08 16:28:41 +00:00
|
|
|
mode_tree_check_selected(mtd);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
2017-06-07 14:37:30 +00:00
|
|
|
static void
|
|
|
|
mode_tree_remove_ref(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
if (--mtd->references == 0)
|
|
|
|
free(mtd);
|
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
void
|
|
|
|
mode_tree_free(struct mode_tree_data *mtd)
|
|
|
|
{
|
2018-02-28 08:55:44 +00:00
|
|
|
struct window_pane *wp = mtd->wp;
|
|
|
|
|
|
|
|
if (mtd->zoomed == 0)
|
|
|
|
server_unzoom_window(wp->window);
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_free_items(&mtd->children);
|
|
|
|
mode_tree_clear_lines(mtd);
|
|
|
|
screen_free(&mtd->screen);
|
2017-06-07 14:37:30 +00:00
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
free(mtd->search);
|
|
|
|
free(mtd->filter);
|
|
|
|
|
2017-06-07 14:37:30 +00:00
|
|
|
mtd->dead = 1;
|
|
|
|
mode_tree_remove_ref(mtd);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mode_tree_resize(struct mode_tree_data *mtd, u_int sx, u_int sy)
|
|
|
|
{
|
|
|
|
struct screen *s = &mtd->screen;
|
|
|
|
|
|
|
|
screen_resize(s, sx, sy, 0);
|
|
|
|
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
mode_tree_draw(mtd);
|
|
|
|
|
|
|
|
mtd->wp->flags |= PANE_REDRAW;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mode_tree_item *
|
|
|
|
mode_tree_add(struct mode_tree_data *mtd, struct mode_tree_item *parent,
|
|
|
|
void *itemdata, uint64_t tag, const char *name, const char *text,
|
|
|
|
int expanded)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *saved;
|
|
|
|
|
|
|
|
log_debug("%s: %llu, %s %s", __func__, (unsigned long long)tag,
|
2020-05-16 16:02:24 +00:00
|
|
|
name, (text == NULL ? "" : text));
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
mti = xcalloc(1, sizeof *mti);
|
|
|
|
mti->parent = parent;
|
|
|
|
mti->itemdata = itemdata;
|
|
|
|
|
|
|
|
mti->tag = tag;
|
|
|
|
mti->name = xstrdup(name);
|
2020-05-16 16:02:24 +00:00
|
|
|
if (text != NULL)
|
|
|
|
mti->text = xstrdup(text);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
saved = mode_tree_find_item(&mtd->saved, tag);
|
|
|
|
if (saved != NULL) {
|
2019-05-30 20:54:03 +00:00
|
|
|
if (parent == NULL || parent->expanded)
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mti->tagged = saved->tagged;
|
|
|
|
mti->expanded = saved->expanded;
|
|
|
|
} else if (expanded == -1)
|
|
|
|
mti->expanded = 1;
|
|
|
|
else
|
|
|
|
mti->expanded = expanded;
|
|
|
|
|
|
|
|
TAILQ_INIT(&mti->children);
|
|
|
|
|
|
|
|
if (parent != NULL)
|
|
|
|
TAILQ_INSERT_TAIL(&parent->children, mti, entry);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_TAIL(&mtd->children, mti, entry);
|
|
|
|
|
|
|
|
return (mti);
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
void
|
|
|
|
mode_tree_draw_as_parent(struct mode_tree_item *mti)
|
|
|
|
{
|
|
|
|
mti->draw_as_parent = 1;
|
|
|
|
}
|
|
|
|
|
2020-06-16 08:18:34 +00:00
|
|
|
void
|
|
|
|
mode_tree_no_tag(struct mode_tree_item *mti)
|
|
|
|
{
|
|
|
|
mti->no_tag = 1;
|
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
void
|
|
|
|
mode_tree_remove(struct mode_tree_data *mtd, struct mode_tree_item *mti)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *parent = mti->parent;
|
|
|
|
|
|
|
|
if (parent != NULL)
|
|
|
|
TAILQ_REMOVE(&parent->children, mti, entry);
|
|
|
|
else
|
|
|
|
TAILQ_REMOVE(&mtd->children, mti, entry);
|
|
|
|
mode_tree_free_item(mti);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mode_tree_draw(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct window_pane *wp = mtd->wp;
|
2017-11-02 22:00:42 +00:00
|
|
|
struct screen *s = &mtd->screen;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
struct mode_tree_line *line;
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
struct options *oo = wp->window->options;
|
|
|
|
struct screen_write_ctx ctx;
|
|
|
|
struct grid_cell gc0, gc;
|
2019-03-18 20:53:33 +00:00
|
|
|
u_int w, h, i, j, sy, box_x, box_y, width;
|
2021-04-12 06:50:25 +00:00
|
|
|
char *text, *start, *key;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
const char *tag, *symbol;
|
2018-02-05 06:51:41 +00:00
|
|
|
size_t size, n;
|
2021-04-12 06:50:25 +00:00
|
|
|
int keylen, pad;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
if (mtd->line_size == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(&gc0, &grid_default_cell, sizeof gc0);
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
2020-05-16 15:01:30 +00:00
|
|
|
style_apply(&gc, oo, "mode-style", NULL);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
w = mtd->width;
|
|
|
|
h = mtd->height;
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
screen_write_start(&ctx, s);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_clearscreen(&ctx, 8);
|
|
|
|
|
2021-04-12 06:50:25 +00:00
|
|
|
keylen = 0;
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
mti = mtd->line_list[i].item;
|
|
|
|
if (mti->key == KEYC_NONE)
|
|
|
|
continue;
|
|
|
|
if ((int)mti->keylen + 3 > keylen)
|
|
|
|
keylen = mti->keylen + 3;
|
|
|
|
}
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
if (i < mtd->offset)
|
|
|
|
continue;
|
|
|
|
if (i > mtd->offset + h - 1)
|
|
|
|
break;
|
|
|
|
line = &mtd->line_list[i];
|
|
|
|
mti = line->item;
|
|
|
|
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(&ctx, 0, i - mtd->offset, 0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
2021-04-12 06:50:25 +00:00
|
|
|
pad = keylen - 2 - mti->keylen;
|
|
|
|
if (mti->key != KEYC_NONE)
|
|
|
|
xasprintf(&key, "(%s)%*s", mti->keystr, pad, "");
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
else
|
2021-04-12 06:50:25 +00:00
|
|
|
key = xstrdup("");
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
if (line->flat)
|
|
|
|
symbol = "";
|
|
|
|
else if (TAILQ_EMPTY(&mti->children))
|
|
|
|
symbol = " ";
|
|
|
|
else if (mti->expanded)
|
|
|
|
symbol = "- ";
|
|
|
|
else
|
|
|
|
symbol = "+ ";
|
|
|
|
|
|
|
|
if (line->depth == 0)
|
|
|
|
start = xstrdup(symbol);
|
|
|
|
else {
|
|
|
|
size = (4 * line->depth) + 32;
|
|
|
|
|
|
|
|
start = xcalloc(1, size);
|
|
|
|
for (j = 1; j < line->depth; j++) {
|
|
|
|
if (mti->parent != NULL &&
|
|
|
|
mtd->line_list[mti->parent->line].last)
|
|
|
|
strlcat(start, " ", size);
|
|
|
|
else
|
|
|
|
strlcat(start, "\001x\001 ", size);
|
|
|
|
}
|
|
|
|
if (line->last)
|
|
|
|
strlcat(start, "\001mq\001> ", size);
|
|
|
|
else
|
|
|
|
strlcat(start, "\001tq\001> ", size);
|
|
|
|
strlcat(start, symbol, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mti->tagged)
|
|
|
|
tag = "*";
|
|
|
|
else
|
|
|
|
tag = "";
|
2020-05-16 16:02:24 +00:00
|
|
|
xasprintf(&text, "%-*s%s%s%s%s", keylen, key, start, mti->name,
|
|
|
|
tag, (mti->text != NULL) ? ": " : "" );
|
2019-03-18 20:53:33 +00:00
|
|
|
width = utf8_cstrwidth(text);
|
2019-12-12 15:03:13 +00:00
|
|
|
if (width > w)
|
|
|
|
width = w;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
free(start);
|
|
|
|
|
|
|
|
if (mti->tagged) {
|
|
|
|
gc.attr ^= GRID_ATTR_BRIGHT;
|
|
|
|
gc0.attr ^= GRID_ATTR_BRIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != mtd->current) {
|
|
|
|
screen_write_clearendofline(&ctx, 8);
|
2019-12-12 15:03:13 +00:00
|
|
|
screen_write_nputs(&ctx, w, &gc0, "%s", text);
|
2020-05-16 16:02:24 +00:00
|
|
|
if (mti->text != NULL) {
|
|
|
|
format_draw(&ctx, &gc0, w - width, mti->text,
|
2021-10-26 12:22:23 +00:00
|
|
|
NULL, 0);
|
2020-05-16 16:02:24 +00:00
|
|
|
}
|
2017-10-11 11:26:58 +00:00
|
|
|
} else {
|
|
|
|
screen_write_clearendofline(&ctx, gc.bg);
|
2019-12-12 15:03:13 +00:00
|
|
|
screen_write_nputs(&ctx, w, &gc, "%s", text);
|
2020-05-16 16:02:24 +00:00
|
|
|
if (mti->text != NULL) {
|
|
|
|
format_draw(&ctx, &gc, w - width, mti->text,
|
2021-10-26 12:22:23 +00:00
|
|
|
NULL, 0);
|
2020-05-16 16:02:24 +00:00
|
|
|
}
|
2017-10-11 11:26:58 +00:00
|
|
|
}
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
free(text);
|
2021-04-12 06:50:25 +00:00
|
|
|
free(key);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
if (mti->tagged) {
|
|
|
|
gc.attr ^= GRID_ATTR_BRIGHT;
|
|
|
|
gc0.attr ^= GRID_ATTR_BRIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-01 10:10:29 +00:00
|
|
|
if (mtd->preview == MODE_TREE_PREVIEW_OFF)
|
|
|
|
goto done;
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
sy = screen_size_y(s);
|
2024-10-01 10:10:29 +00:00
|
|
|
if (sy <= 4 || h < 2 || sy - h <= 4 || w <= 4)
|
2021-11-15 10:58:13 +00:00
|
|
|
goto done;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
line = &mtd->line_list[mtd->current];
|
|
|
|
mti = line->item;
|
2020-05-16 16:02:24 +00:00
|
|
|
if (mti->draw_as_parent)
|
|
|
|
mti = mti->parent;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(&ctx, 0, h, 0);
|
2021-10-20 09:50:40 +00:00
|
|
|
screen_write_box(&ctx, w, sy - h, BOX_LINES_DEFAULT, NULL, NULL);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
if (mtd->sort_list != NULL) {
|
|
|
|
xasprintf(&text, " %s (sort: %s%s)", mti->name,
|
|
|
|
mtd->sort_list[mtd->sort_crit.field],
|
|
|
|
mtd->sort_crit.reversed ? ", reversed" : "");
|
|
|
|
} else
|
|
|
|
xasprintf(&text, " %s", mti->name);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
if (w - 2 >= strlen(text)) {
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(&ctx, 1, h, 0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_puts(&ctx, &gc0, "%s", text);
|
2018-02-05 06:51:41 +00:00
|
|
|
|
|
|
|
if (mtd->no_matches)
|
|
|
|
n = (sizeof "no matches") - 1;
|
|
|
|
else
|
|
|
|
n = (sizeof "active") - 1;
|
|
|
|
if (mtd->filter != NULL && w - 2 >= strlen(text) + 10 + n + 2) {
|
|
|
|
screen_write_puts(&ctx, &gc0, " (filter: ");
|
|
|
|
if (mtd->no_matches)
|
|
|
|
screen_write_puts(&ctx, &gc, "no matches");
|
|
|
|
else
|
|
|
|
screen_write_puts(&ctx, &gc0, "active");
|
|
|
|
screen_write_puts(&ctx, &gc0, ") ");
|
2020-05-16 16:02:24 +00:00
|
|
|
} else
|
|
|
|
screen_write_puts(&ctx, &gc0, " ");
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
free(text);
|
|
|
|
|
|
|
|
box_x = w - 4;
|
|
|
|
box_y = sy - h - 2;
|
|
|
|
|
2017-11-02 22:00:42 +00:00
|
|
|
if (box_x != 0 && box_y != 0) {
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(&ctx, 2, h + 1, 0);
|
2017-11-02 22:00:42 +00:00
|
|
|
mtd->drawcb(mtd->modedata, mti->itemdata, &ctx, box_x, box_y);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
2021-11-15 10:58:13 +00:00
|
|
|
done:
|
|
|
|
screen_write_cursormove(&ctx, 0, mtd->current - mtd->offset, 0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_stop(&ctx);
|
|
|
|
}
|
|
|
|
|
2017-06-07 14:37:30 +00:00
|
|
|
static struct mode_tree_item *
|
2024-05-24 12:39:06 +00:00
|
|
|
mode_tree_search_backward(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *last, *prev;
|
|
|
|
|
|
|
|
if (mtd->search == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
mti = last = mtd->line_list[mtd->current].item;
|
|
|
|
for (;;) {
|
|
|
|
if ((prev = TAILQ_PREV(mti, mode_tree_list, entry)) != NULL) {
|
|
|
|
/* Point to the last child in the previous subtree. */
|
|
|
|
while (!TAILQ_EMPTY(&prev->children))
|
|
|
|
prev = TAILQ_LAST(&prev->children, mode_tree_list);
|
|
|
|
mti = prev;
|
|
|
|
} else {
|
|
|
|
/* If prev is NULL, jump to the parent. */
|
|
|
|
mti = mti->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mti == NULL) {
|
|
|
|
/* Point to the last child in the last root subtree. */
|
|
|
|
prev = TAILQ_LAST(&mtd->children, mode_tree_list);
|
|
|
|
while (!TAILQ_EMPTY(&prev->children))
|
|
|
|
prev = TAILQ_LAST(&prev->children, mode_tree_list);
|
|
|
|
mti = prev;
|
|
|
|
}
|
|
|
|
if (mti == last)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (mtd->searchcb == NULL) {
|
|
|
|
if (strstr(mti->name, mtd->search) != NULL)
|
|
|
|
return (mti);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (mtd->searchcb(mtd->modedata, mti->itemdata, mtd->search))
|
|
|
|
return (mti);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct mode_tree_item *
|
|
|
|
mode_tree_search_forward(struct mode_tree_data *mtd)
|
2017-06-07 14:37:30 +00:00
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *last, *next;
|
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
if (mtd->search == NULL)
|
2017-06-07 14:37:30 +00:00
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
mti = last = mtd->line_list[mtd->current].item;
|
|
|
|
for (;;) {
|
|
|
|
if (!TAILQ_EMPTY(&mti->children))
|
|
|
|
mti = TAILQ_FIRST(&mti->children);
|
|
|
|
else if ((next = TAILQ_NEXT(mti, entry)) != NULL)
|
|
|
|
mti = next;
|
|
|
|
else {
|
|
|
|
for (;;) {
|
|
|
|
mti = mti->parent;
|
|
|
|
if (mti == NULL)
|
|
|
|
break;
|
|
|
|
if ((next = TAILQ_NEXT(mti, entry)) != NULL) {
|
|
|
|
mti = next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mti == NULL)
|
|
|
|
mti = TAILQ_FIRST(&mtd->children);
|
|
|
|
if (mti == last)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (mtd->searchcb == NULL) {
|
2017-06-09 16:01:39 +00:00
|
|
|
if (strstr(mti->name, mtd->search) != NULL)
|
2017-06-07 14:37:30 +00:00
|
|
|
return (mti);
|
|
|
|
continue;
|
|
|
|
}
|
2017-06-09 16:01:39 +00:00
|
|
|
if (mtd->searchcb(mtd->modedata, mti->itemdata, mtd->search))
|
2017-06-07 15:27:46 +00:00
|
|
|
return (mti);
|
2017-06-07 14:37:30 +00:00
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_search_set(struct mode_tree_data *mtd)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti, *loop;
|
|
|
|
uint64_t tag;
|
|
|
|
|
2024-05-24 12:39:06 +00:00
|
|
|
if (mtd->search_dir == MODE_TREE_SEARCH_FORWARD)
|
|
|
|
mti = mode_tree_search_forward(mtd);
|
|
|
|
else
|
|
|
|
mti = mode_tree_search_backward(mtd);
|
2017-06-07 14:37:30 +00:00
|
|
|
if (mti == NULL)
|
|
|
|
return;
|
|
|
|
tag = mti->tag;
|
|
|
|
|
|
|
|
loop = mti->parent;
|
|
|
|
while (loop != NULL) {
|
|
|
|
loop->expanded = 1;
|
|
|
|
loop = loop->parent;
|
|
|
|
}
|
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
mode_tree_build(mtd);
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_set_current(mtd, tag);
|
|
|
|
mode_tree_draw(mtd);
|
2017-06-09 16:01:39 +00:00
|
|
|
mtd->wp->flags |= PANE_REDRAW;
|
2017-06-07 14:37:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mode_tree_search_callback(__unused struct client *c, void *data, const char *s,
|
|
|
|
__unused int done)
|
|
|
|
{
|
|
|
|
struct mode_tree_data *mtd = data;
|
|
|
|
|
|
|
|
if (mtd->dead)
|
|
|
|
return (0);
|
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
free(mtd->search);
|
|
|
|
if (s == NULL || *s == '\0') {
|
|
|
|
mtd->search = NULL;
|
2017-06-07 14:37:30 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2017-06-09 16:01:39 +00:00
|
|
|
mtd->search = xstrdup(s);
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_search_set(mtd);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_search_free(void *data)
|
|
|
|
{
|
|
|
|
mode_tree_remove_ref(data);
|
|
|
|
}
|
|
|
|
|
2017-06-09 16:01:39 +00:00
|
|
|
static int
|
|
|
|
mode_tree_filter_callback(__unused struct client *c, void *data, const char *s,
|
|
|
|
__unused int done)
|
|
|
|
{
|
|
|
|
struct mode_tree_data *mtd = data;
|
|
|
|
|
|
|
|
if (mtd->dead)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (mtd->filter != NULL)
|
|
|
|
free(mtd->filter);
|
|
|
|
if (s == NULL || *s == '\0')
|
|
|
|
mtd->filter = NULL;
|
|
|
|
else
|
|
|
|
mtd->filter = xstrdup(s);
|
|
|
|
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
mode_tree_draw(mtd);
|
|
|
|
mtd->wp->flags |= PANE_REDRAW;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_filter_free(void *data)
|
|
|
|
{
|
|
|
|
mode_tree_remove_ref(data);
|
|
|
|
}
|
|
|
|
|
2019-05-12 08:58:09 +00:00
|
|
|
static void
|
|
|
|
mode_tree_menu_callback(__unused struct menu *menu, __unused u_int idx,
|
|
|
|
key_code key, void *data)
|
|
|
|
{
|
2022-02-01 18:12:20 +00:00
|
|
|
struct mode_tree_menu *mtm = data;
|
|
|
|
struct mode_tree_data *mtd = mtm->data;
|
2019-05-12 08:58:09 +00:00
|
|
|
|
|
|
|
if (mtd->dead || key == KEYC_NONE)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (mtm->line >= mtd->line_size)
|
|
|
|
goto out;
|
|
|
|
mtd->current = mtm->line;
|
2021-08-20 17:50:42 +00:00
|
|
|
mtd->menucb(mtd->modedata, mtm->c, key);
|
2019-05-12 08:58:09 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
mode_tree_remove_ref(mtd);
|
|
|
|
free(mtm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x,
|
|
|
|
u_int y, int outside)
|
|
|
|
{
|
|
|
|
struct mode_tree_item *mti;
|
|
|
|
struct menu *menu;
|
2019-05-28 07:18:42 +00:00
|
|
|
const struct menu_item *items;
|
2019-05-12 08:58:09 +00:00
|
|
|
struct mode_tree_menu *mtm;
|
|
|
|
char *title;
|
|
|
|
u_int line;
|
|
|
|
|
|
|
|
if (mtd->offset + y > mtd->line_size - 1)
|
|
|
|
line = mtd->current;
|
|
|
|
else
|
|
|
|
line = mtd->offset + y;
|
2019-05-12 18:16:33 +00:00
|
|
|
mti = mtd->line_list[line].item;
|
2019-05-12 08:58:09 +00:00
|
|
|
|
|
|
|
if (!outside) {
|
2019-05-28 07:18:42 +00:00
|
|
|
items = mtd->menu;
|
2019-05-12 08:58:09 +00:00
|
|
|
xasprintf(&title, "#[align=centre]%s", mti->name);
|
|
|
|
} else {
|
2019-05-28 07:18:42 +00:00
|
|
|
items = mode_tree_menu_items;
|
2019-05-12 08:58:09 +00:00
|
|
|
title = xstrdup("");
|
|
|
|
}
|
2019-05-28 07:18:42 +00:00
|
|
|
menu = menu_create(title);
|
2022-02-01 18:12:20 +00:00
|
|
|
menu_add_items(menu, items, NULL, c, NULL);
|
2019-05-12 08:58:09 +00:00
|
|
|
free(title);
|
|
|
|
|
|
|
|
mtm = xmalloc(sizeof *mtm);
|
|
|
|
mtm->data = mtd;
|
|
|
|
mtm->c = c;
|
|
|
|
mtm->line = line;
|
|
|
|
mtd->references++;
|
|
|
|
|
2020-03-20 17:26:14 +00:00
|
|
|
if (x >= (menu->width + 4) / 2)
|
|
|
|
x -= (menu->width + 4) / 2;
|
|
|
|
else
|
|
|
|
x = 0;
|
2023-08-08 08:08:47 +00:00
|
|
|
if (menu_display(menu, 0, 0, NULL, x, y, c, BOX_LINES_DEFAULT, NULL,
|
2024-12-16 08:54:34 +00:00
|
|
|
NULL, NULL, NULL, mode_tree_menu_callback, mtm) != 0) {
|
|
|
|
mode_tree_remove_ref(mtd);
|
|
|
|
free(mtm);
|
2019-05-12 08:58:09 +00:00
|
|
|
menu_free(menu);
|
2024-12-16 08:54:34 +00:00
|
|
|
}
|
2019-05-12 08:58:09 +00:00
|
|
|
}
|
|
|
|
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
int
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
|
2017-11-03 17:02:33 +00:00
|
|
|
struct mouse_event *m, u_int *xp, u_int *yp)
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
{
|
|
|
|
struct mode_tree_line *line;
|
2020-05-16 15:46:01 +00:00
|
|
|
struct mode_tree_item *current, *parent, *mti;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
u_int i, x, y;
|
|
|
|
int choice;
|
|
|
|
|
2019-05-12 08:58:09 +00:00
|
|
|
if (KEYC_IS_MOUSE(*key) && m != NULL) {
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
if (cmd_mouse_at(mtd->wp, m, &x, &y, 0) != 0) {
|
|
|
|
*key = KEYC_NONE;
|
|
|
|
return (0);
|
|
|
|
}
|
2017-11-03 17:02:33 +00:00
|
|
|
if (xp != NULL)
|
|
|
|
*xp = x;
|
|
|
|
if (yp != NULL)
|
|
|
|
*yp = y;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
if (x > mtd->width || y > mtd->height) {
|
2019-05-12 08:58:09 +00:00
|
|
|
if (*key == KEYC_MOUSEDOWN3_PANE)
|
|
|
|
mode_tree_display_menu(mtd, c, x, y, 1);
|
2024-10-01 10:10:29 +00:00
|
|
|
if (mtd->preview == MODE_TREE_PREVIEW_OFF)
|
2017-11-03 17:02:33 +00:00
|
|
|
*key = KEYC_NONE;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (mtd->offset + y < mtd->line_size) {
|
2017-11-03 14:23:44 +00:00
|
|
|
if (*key == KEYC_MOUSEDOWN1_PANE ||
|
2019-05-12 08:58:09 +00:00
|
|
|
*key == KEYC_MOUSEDOWN3_PANE ||
|
2017-11-03 14:23:44 +00:00
|
|
|
*key == KEYC_DOUBLECLICK1_PANE)
|
|
|
|
mtd->current = mtd->offset + y;
|
|
|
|
if (*key == KEYC_DOUBLECLICK1_PANE)
|
|
|
|
*key = '\r';
|
2019-05-12 08:58:09 +00:00
|
|
|
else {
|
|
|
|
if (*key == KEYC_MOUSEDOWN3_PANE)
|
|
|
|
mode_tree_display_menu(mtd, c, x, y, 0);
|
2017-11-03 17:11:20 +00:00
|
|
|
*key = KEYC_NONE;
|
2019-05-12 08:58:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*key == KEYC_MOUSEDOWN3_PANE)
|
|
|
|
mode_tree_display_menu(mtd, c, x, y, 0);
|
2017-11-03 17:11:20 +00:00
|
|
|
*key = KEYC_NONE;
|
2019-05-12 08:58:09 +00:00
|
|
|
}
|
2017-11-03 17:11:20 +00:00
|
|
|
return (0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
line = &mtd->line_list[mtd->current];
|
|
|
|
current = line->item;
|
|
|
|
|
|
|
|
choice = -1;
|
2021-04-12 06:50:25 +00:00
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
|
|
|
if (*key == mtd->line_list[i].item->key) {
|
|
|
|
choice = i;
|
|
|
|
break;
|
|
|
|
}
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
if (choice != -1) {
|
|
|
|
if ((u_int)choice > mtd->line_size - 1) {
|
|
|
|
*key = KEYC_NONE;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
mtd->current = choice;
|
|
|
|
*key = '\r';
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*key) {
|
|
|
|
case 'q':
|
|
|
|
case '\033': /* Escape */
|
2024-08-21 04:17:09 +00:00
|
|
|
case 'g'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
return (1);
|
|
|
|
case KEYC_UP:
|
|
|
|
case 'k':
|
|
|
|
case KEYC_WHEELUP_PANE:
|
2024-08-21 04:17:09 +00:00
|
|
|
case 'p'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_up(mtd, 1);
|
|
|
|
break;
|
|
|
|
case KEYC_DOWN:
|
|
|
|
case 'j':
|
|
|
|
case KEYC_WHEELDOWN_PANE:
|
2024-08-21 04:17:09 +00:00
|
|
|
case 'n'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_down(mtd, 1);
|
|
|
|
break;
|
|
|
|
case KEYC_PPAGE:
|
2024-08-21 04:17:09 +00:00
|
|
|
case 'b'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
for (i = 0; i < mtd->height; i++) {
|
|
|
|
if (mtd->current == 0)
|
|
|
|
break;
|
|
|
|
mode_tree_up(mtd, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KEYC_NPAGE:
|
2024-08-21 04:17:09 +00:00
|
|
|
case 'f'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
for (i = 0; i < mtd->height; i++) {
|
|
|
|
if (mtd->current == mtd->line_size - 1)
|
|
|
|
break;
|
|
|
|
mode_tree_down(mtd, 1);
|
|
|
|
}
|
|
|
|
break;
|
2021-12-06 10:10:52 +00:00
|
|
|
case 'g':
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
case KEYC_HOME:
|
|
|
|
mtd->current = 0;
|
|
|
|
mtd->offset = 0;
|
|
|
|
break;
|
2021-12-06 10:10:52 +00:00
|
|
|
case 'G':
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
case KEYC_END:
|
|
|
|
mtd->current = mtd->line_size - 1;
|
|
|
|
if (mtd->current > mtd->height - 1)
|
2017-09-08 16:28:41 +00:00
|
|
|
mtd->offset = mtd->current - mtd->height + 1;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
else
|
|
|
|
mtd->offset = 0;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
/*
|
|
|
|
* Do not allow parents and children to both be tagged: untag
|
|
|
|
* all parents and children of current.
|
|
|
|
*/
|
2020-06-16 08:18:34 +00:00
|
|
|
if (current->no_tag)
|
|
|
|
break;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
if (!current->tagged) {
|
|
|
|
parent = current->parent;
|
|
|
|
while (parent != NULL) {
|
|
|
|
parent->tagged = 0;
|
|
|
|
parent = parent->parent;
|
|
|
|
}
|
|
|
|
mode_tree_clear_tagged(¤t->children);
|
|
|
|
current->tagged = 1;
|
|
|
|
} else
|
|
|
|
current->tagged = 0;
|
2019-05-12 08:58:09 +00:00
|
|
|
if (m != NULL)
|
|
|
|
mode_tree_down(mtd, 0);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
for (i = 0; i < mtd->line_size; i++)
|
|
|
|
mtd->line_list[i].item->tagged = 0;
|
|
|
|
break;
|
2024-08-21 04:17:09 +00:00
|
|
|
case 't'|KEYC_CTRL:
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
for (i = 0; i < mtd->line_size; i++) {
|
2020-06-16 08:18:34 +00:00
|
|
|
if ((mtd->line_list[i].item->parent == NULL &&
|
|
|
|
!mtd->line_list[i].item->no_tag) ||
|
|
|
|
(mtd->line_list[i].item->parent != NULL &&
|
|
|
|
mtd->line_list[i].item->parent->no_tag))
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mtd->line_list[i].item->tagged = 1;
|
|
|
|
else
|
|
|
|
mtd->line_list[i].item->tagged = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'O':
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->sort_crit.field++;
|
2020-05-16 16:02:24 +00:00
|
|
|
if (mtd->sort_crit.field >= mtd->sort_size)
|
2019-08-16 11:49:12 +00:00
|
|
|
mtd->sort_crit.field = 0;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
mtd->sort_crit.reversed = !mtd->sort_crit.reversed;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
mode_tree_build(mtd);
|
|
|
|
break;
|
|
|
|
case KEYC_LEFT:
|
2017-10-25 12:13:20 +00:00
|
|
|
case 'h':
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
case '-':
|
|
|
|
if (line->flat || !current->expanded)
|
|
|
|
current = current->parent;
|
|
|
|
if (current == NULL)
|
|
|
|
mode_tree_up(mtd, 0);
|
|
|
|
else {
|
|
|
|
current->expanded = 0;
|
|
|
|
mtd->current = current->line;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KEYC_RIGHT:
|
2017-10-25 12:13:20 +00:00
|
|
|
case 'l':
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
case '+':
|
|
|
|
if (line->flat || current->expanded)
|
|
|
|
mode_tree_down(mtd, 0);
|
|
|
|
else if (!line->flat) {
|
|
|
|
current->expanded = 1;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
}
|
|
|
|
break;
|
2020-05-16 16:35:13 +00:00
|
|
|
case '-'|KEYC_META:
|
2020-05-16 15:46:01 +00:00
|
|
|
TAILQ_FOREACH(mti, &mtd->children, entry)
|
|
|
|
mti->expanded = 0;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
break;
|
2020-05-16 16:35:13 +00:00
|
|
|
case '+'|KEYC_META:
|
2020-05-16 15:46:01 +00:00
|
|
|
TAILQ_FOREACH(mti, &mtd->children, entry)
|
|
|
|
mti->expanded = 1;
|
|
|
|
mode_tree_build(mtd);
|
|
|
|
break;
|
2019-07-19 07:20:51 +00:00
|
|
|
case '?':
|
|
|
|
case '/':
|
2024-08-21 04:17:09 +00:00
|
|
|
case 's'|KEYC_CTRL:
|
2017-06-07 14:37:30 +00:00
|
|
|
mtd->references++;
|
2020-05-16 16:16:07 +00:00
|
|
|
status_prompt_set(c, NULL, "(search) ", "",
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_search_callback, mode_tree_search_free, mtd,
|
2021-06-10 07:50:03 +00:00
|
|
|
PROMPT_NOFORMAT, PROMPT_TYPE_SEARCH);
|
2017-06-07 14:37:30 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
2024-05-24 12:39:06 +00:00
|
|
|
mtd->search_dir = MODE_TREE_SEARCH_FORWARD;
|
|
|
|
mode_tree_search_set(mtd);
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
mtd->search_dir = MODE_TREE_SEARCH_BACKWARD;
|
2017-06-07 14:37:30 +00:00
|
|
|
mode_tree_search_set(mtd);
|
|
|
|
break;
|
2017-06-09 16:01:39 +00:00
|
|
|
case 'f':
|
|
|
|
mtd->references++;
|
2020-05-16 16:16:07 +00:00
|
|
|
status_prompt_set(c, NULL, "(filter) ", mtd->filter,
|
2017-06-09 16:01:39 +00:00
|
|
|
mode_tree_filter_callback, mode_tree_filter_free, mtd,
|
2021-06-10 07:50:03 +00:00
|
|
|
PROMPT_NOFORMAT, PROMPT_TYPE_SEARCH);
|
2017-06-09 16:01:39 +00:00
|
|
|
break;
|
2017-08-23 09:39:11 +00:00
|
|
|
case 'v':
|
2024-10-01 10:10:29 +00:00
|
|
|
switch (mtd->preview) {
|
|
|
|
case MODE_TREE_PREVIEW_OFF:
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_BIG;
|
|
|
|
break;
|
|
|
|
case MODE_TREE_PREVIEW_NORMAL:
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_OFF;
|
|
|
|
break;
|
|
|
|
case MODE_TREE_PREVIEW_BIG:
|
|
|
|
mtd->preview = MODE_TREE_PREVIEW_NORMAL;
|
|
|
|
break;
|
|
|
|
}
|
2017-08-23 09:39:11 +00:00
|
|
|
mode_tree_build(mtd);
|
2024-10-01 10:10:29 +00:00
|
|
|
if (mtd->preview != MODE_TREE_PREVIEW_OFF)
|
2017-09-08 16:28:41 +00:00
|
|
|
mode_tree_check_selected(mtd);
|
2017-08-23 09:39:11 +00:00
|
|
|
break;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
|
|
|
|
const char *template, const char *name)
|
|
|
|
{
|
2020-04-13 18:59:41 +00:00
|
|
|
struct cmdq_state *state;
|
|
|
|
char *command, *error;
|
|
|
|
enum cmd_parse_status status;
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
command = cmd_template_replace(template, name, 1);
|
2020-04-13 18:59:41 +00:00
|
|
|
if (command != NULL && *command != '\0') {
|
|
|
|
state = cmdq_new_state(fs, NULL, 0);
|
|
|
|
status = cmd_parse_and_append(command, NULL, c, state, &error);
|
|
|
|
if (status == CMD_PARSE_ERROR) {
|
|
|
|
if (c != NULL) {
|
|
|
|
*error = toupper((u_char)*error);
|
2021-04-12 09:36:12 +00:00
|
|
|
status_message_set(c, -1, 1, 0, "%s", error);
|
2020-04-13 18:59:41 +00:00
|
|
|
}
|
|
|
|
free(error);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
2020-04-13 18:59:41 +00:00
|
|
|
cmdq_free_state(state);
|
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.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
free(command);
|
|
|
|
}
|