diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-07 19:01:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-07 19:01:22 +0000 |
commit | df419e7e1b181177191c282801b4d5447d5f3d41 (patch) | |
tree | ee532cf438876f6f674d254dd4bced8f117485de /usr.bin/tmux | |
parent | 2c4a9f2f7c1b21e42b45745d7aa9165c4c1e4820 (diff) |
Make adding mode formats a function pointer as well.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/format.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 29 |
3 files changed, 20 insertions, 20 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index f788de8da14..e3d35c413fb 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.165 2018/11/19 13:35:41 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.166 2019/03/07 19:01:21 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1552,7 +1552,8 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp) format_add(ft, "scroll_region_upper", "%u", wp->base.rupper); format_add(ft, "scroll_region_lower", "%u", wp->base.rlower); - window_copy_add_formats(wp, ft); + if (wp->mode != NULL && wp->mode->formats != NULL) + wp->mode->formats(wp, ft); format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0); format_add(ft, "alternate_saved_x", "%u", wp->saved_cx); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index fd982ee1db3..a87dd304530 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.853 2019/02/16 11:42:08 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.854 2019/03/07 19:01:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -43,6 +43,7 @@ struct cmdq_item; struct cmdq_list; struct environ; struct format_job_tree; +struct format_tree; struct input_ctx; struct job; struct mode_tree_data; @@ -707,6 +708,7 @@ struct window_mode { void (*command)(struct window_pane *, struct client *, struct session *, struct winlink *, struct args *, struct mouse_event *); + void (*formats)(struct window_pane *, struct format_tree *); }; #define WINDOW_MODE_TIMEOUT 180 @@ -2304,8 +2306,6 @@ void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...); void window_copy_vadd(struct window_pane *, const char *, va_list); void window_copy_pageup(struct window_pane *, int); void window_copy_start_drag(struct client *, struct mouse_event *); -void window_copy_add_formats(struct window_pane *, - struct format_tree *); /* names.c */ void check_window_name(struct window *); diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 2e8e6f56945..a18347b2e23 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.205 2018/12/18 13:20:44 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.206 2019/03/07 19:01:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -31,10 +31,11 @@ static void window_copy_command(struct window_pane *, struct client *, static struct screen *window_copy_init(struct window_pane *, struct cmd_find_state *, struct args *); static void window_copy_free(struct window_pane *); +static void window_copy_resize(struct window_pane *, u_int, u_int); +static void window_copy_formats(struct window_pane *, struct format_tree *); static int window_copy_pagedown(struct window_pane *, int, int); static void window_copy_next_paragraph(struct window_pane *); static void window_copy_previous_paragraph(struct window_pane *); -static void window_copy_resize(struct window_pane *, u_int, u_int); static void window_copy_redraw_selection(struct window_pane *, u_int); static void window_copy_redraw_lines(struct window_pane *, u_int, u_int); @@ -113,6 +114,7 @@ const struct window_mode window_copy_mode = { .resize = window_copy_resize, .key_table = window_copy_key_table, .command = window_copy_command, + .formats = window_copy_formats, }; enum { @@ -473,6 +475,16 @@ window_copy_next_paragraph(struct window_pane *wp) } static void +window_copy_formats(struct window_pane *wp, struct format_tree *ft) +{ + struct window_copy_mode_data *data = wp->modedata; + + format_add(ft, "selection_present", "%d", data->screen.sel != NULL); + format_add(ft, "scroll_position", "%d", data->oy); + format_add(ft, "rectangle_toggle", "%d", data->rectflag); +} + +static void window_copy_resize(struct window_pane *wp, u_int sx, u_int sy) { struct window_copy_mode_data *data = wp->modedata; @@ -2447,19 +2459,6 @@ window_copy_scroll_down(struct window_pane *wp, u_int ny) screen_write_stop(&ctx); } -void -window_copy_add_formats(struct window_pane *wp, struct format_tree *ft) -{ - struct window_copy_mode_data *data = wp->modedata; - - if (wp->mode != &window_copy_mode) - return; - - format_add(ft, "selection_present", "%d", data->screen.sel != NULL); - format_add(ft, "scroll_position", "%d", data->oy); - format_add(ft, "rectangle_toggle", "%d", data->rectflag); -} - static void window_copy_rectangle_toggle(struct window_pane *wp) { |