diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-30 21:45:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-30 21:45:00 +0000 |
commit | a6666d02f028c9c6260b6049c4270683d9a98c0e (patch) | |
tree | ae9b9c74da4c76b2ad01aa919ee8a7e1b0b46f12 /usr.bin/tmux/tmux.h | |
parent | aef664be42b2524c118e93dfb52b6dd196fe8fbe (diff) |
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.
Diffstat (limited to 'usr.bin/tmux/tmux.h')
-rw-r--r-- | usr.bin/tmux/tmux.h | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 11e0ff55054..a4c11b6a91e 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.774 2017/05/29 20:42:53 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.775 2017/05/30 21:44:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -40,12 +40,13 @@ extern char **environ; struct args; struct client; +struct cmd_find_state; struct cmdq_item; struct cmdq_list; struct environ; struct format_job_tree; struct input_ctx; -struct mode_key_cmdstr; +struct mode_tree_data; struct mouse_event; struct options; struct options_entry; @@ -693,7 +694,8 @@ struct screen_write_ctx { struct window_mode { const char *name; - struct screen *(*init)(struct window_pane *); + struct screen *(*init)(struct window_pane *, struct cmd_find_state *, + struct args *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, u_int, u_int); void (*key)(struct window_pane *, struct client *, @@ -1518,6 +1520,7 @@ char *paste_make_sample(struct paste_buffer *); #define FORMAT_PANE 0x80000000U #define FORMAT_WINDOW 0x40000000U struct format_tree; +int format_true(const char *); struct format_tree *format_create(struct client *, struct cmdq_item *, int, int); void format_free(struct format_tree *); @@ -1717,6 +1720,7 @@ void tty_keys_free(struct tty *); key_code tty_keys_next(struct tty *); /* arguments.c */ +void args_set(struct args *, u_char, const char *); struct args *args_parse(const char *, int, char **); void args_free(struct args *); char *args_print(struct args *); @@ -1997,6 +2001,10 @@ void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *, u_char); void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int, u_int, u_int, u_int, bitstr_t *, const struct grid_cell *); +void screen_write_line(struct screen_write_ctx *, u_int, int, int); +void screen_write_box(struct screen_write_ctx *, u_int, u_int); +void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int, + u_int); void screen_write_backspace(struct screen_write_ctx *); void screen_write_mode_set(struct screen_write_ctx *, int); void screen_write_mode_clear(struct screen_write_ctx *, int); @@ -2119,15 +2127,15 @@ void window_pane_unset_palette(struct window_pane *, u_int); void window_pane_reset_palette(struct window_pane *); int window_pane_get_palette(const struct window_pane *, int); int window_pane_set_mode(struct window_pane *, - const struct window_mode *); + const struct window_mode *, struct cmd_find_state *, + struct args *); void window_pane_reset_mode(struct window_pane *); void window_pane_key(struct window_pane *, struct client *, struct session *, key_code, struct mouse_event *); int window_pane_outside(struct window_pane *); int window_pane_visible(struct window_pane *); u_int window_pane_search(struct window_pane *, const char *); -char *window_pane_search_old(struct window_pane *, const char *, - u_int *); + const char *window_printable_flags(struct winlink *); struct window_pane *window_pane_find_up(struct window_pane *); struct window_pane *window_pane_find_down(struct window_pane *); @@ -2176,10 +2184,43 @@ u_int layout_set_select(struct window *, u_int); u_int layout_set_next(struct window *); u_int layout_set_previous(struct window *); +/* mode-tree.c */ +u_int mode_tree_count_tagged(struct mode_tree_data *); +void *mode_tree_get_current(struct mode_tree_data *); +void mode_tree_each_tagged(struct mode_tree_data *, void (*)(void *, void *, + key_code), key_code, int); +void mode_tree_up(struct mode_tree_data *, int); +void mode_tree_down(struct mode_tree_data *, int); +struct mode_tree_data *mode_tree_start(struct window_pane *, + void (*)(void *, u_int, uint64_t *), struct screen *(*)(void *, + void *, u_int, u_int), void *, const char **, u_int, + struct screen **); +void mode_tree_build(struct mode_tree_data *); +void mode_tree_free(struct mode_tree_data *); +void mode_tree_resize(struct mode_tree_data *, u_int, u_int); +struct mode_tree_item *mode_tree_add(struct mode_tree_data *, + struct mode_tree_item *, void *, uint64_t, const char *, + const char *, int); +void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *); +void mode_tree_draw(struct mode_tree_data *); +int mode_tree_key(struct mode_tree_data *, key_code *, + struct mouse_event *); +void mode_tree_run_command(struct client *, struct cmd_find_state *, + const char *, const char *); + +/* window-buffer.c */ +extern const struct window_mode window_buffer_mode; + +/* window-tree.c */ +extern const struct window_mode window_tree_mode; + /* window-clock.c */ extern const struct window_mode window_clock_mode; extern const char window_clock_table[14][5][5]; +/* window-client.c */ +extern const struct window_mode window_client_mode; + /* window-copy.c */ extern const struct window_mode window_copy_mode; void window_copy_init_from_pane(struct window_pane *, int); @@ -2190,24 +2231,6 @@ void window_copy_pageup(struct window_pane *, int); void window_copy_start_drag(struct client *, struct mouse_event *); int window_copy_scroll_position(struct window_pane *); -/* window-choose.c */ -extern const struct window_mode window_choose_mode; -void window_choose_add(struct window_pane *, - struct window_choose_data *); -void window_choose_ready(struct window_pane *, - u_int, void (*)(struct window_choose_data *)); -struct window_choose_data *window_choose_data_create (int, - struct client *, struct session *); -void window_choose_data_run(struct window_choose_data *); -struct window_choose_data *window_choose_add_window(struct window_pane *, - struct client *, struct session *, struct winlink *, - const char *, const char *, u_int); -struct window_choose_data *window_choose_add_session(struct window_pane *, - struct client *, struct session *, const char *, - const char *, u_int); -void window_choose_expand_all(struct window_pane *); -void window_choose_set_current(struct window_pane *, u_int); - /* names.c */ void check_window_name(struct window *); char *default_window_name(struct window *); |