diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-04-23 22:40:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-04-23 22:40:48 +0000 |
commit | 1846d17efbbd37fb8dcbb4341fd814bb91e418b7 (patch) | |
tree | c92bd1a08b05acd7e0273379f4403485080d672f | |
parent | 6ab14468caa43986ed1954073a77097843ad346b (diff) |
Use a helper function to fire choose callback.
-rw-r--r-- | usr.bin/tmux/window-choose.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c index 35502e04e9b..846748dfe1d 100644 --- a/usr.bin/tmux/window-choose.c +++ b/usr.bin/tmux/window-choose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-choose.c,v 1.17 2010/12/29 21:49:06 nicm Exp $ */ +/* $OpenBSD: window-choose.c,v 1.18 2012/04/23 22:40:47 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,6 +29,7 @@ void window_choose_key(struct window_pane *, struct session *, int); void window_choose_mouse( struct window_pane *, struct session *, struct mouse_event *); +void window_choose_fire_callback(struct window_pane *, int); void window_choose_redraw_screen(struct window_pane *); void window_choose_write_line( struct window_pane *, struct screen_write_ctx *, u_int); @@ -169,6 +170,20 @@ window_choose_resize(struct window_pane *wp, u_int sx, u_int sy) window_choose_redraw_screen(wp); } +void +window_choose_fire_callback(struct window_pane *wp, int idx) +{ + struct window_choose_mode_data *data = wp->modedata; + const struct window_mode *oldmode; + + oldmode = wp->mode; + wp->mode = NULL; + + data->callbackfn(data->data, idx); + + wp->mode = oldmode; +} + /* ARGSUSED */ void window_choose_key(struct window_pane *wp, unused struct session *sess, int key) @@ -184,12 +199,12 @@ window_choose_key(struct window_pane *wp, unused struct session *sess, int key) switch (mode_key_lookup(&data->mdata, key)) { case MODEKEYCHOICE_CANCEL: - data->callbackfn(data->data, -1); + window_choose_fire_callback(wp, -1); window_pane_reset_mode(wp); break; case MODEKEYCHOICE_CHOOSE: item = &ARRAY_ITEM(&data->list, data->selected); - data->callbackfn(data->data, item->idx); + window_choose_fire_callback(wp, item->idx); window_pane_reset_mode(wp); break; case MODEKEYCHOICE_UP: @@ -295,7 +310,7 @@ window_choose_key(struct window_pane *wp, unused struct session *sess, int key) data->selected = idx; item = &ARRAY_ITEM(&data->list, data->selected); - data->callbackfn(data->data, item->idx); + window_choose_fire_callback(wp, item->idx); window_pane_reset_mode(wp); break; } @@ -324,7 +339,7 @@ window_choose_mouse( data->selected = idx; item = &ARRAY_ITEM(&data->list, data->selected); - data->callbackfn(data->data, item->idx); + window_choose_fire_callback(wp, item->idx); window_pane_reset_mode(wp); } |