summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-04-23 22:40:47 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-04-23 22:40:47 +0000
commit48e6ebbe1ec8bb2631bbe5afe7c67ea0198d43d4 (patch)
tree2fd1562f5460dae6b8e1b3b427467ee10c964e3e
parente02d1bce98e35b5eeb3073ec9d891363493ed72a (diff)
Use a helper function to fire choose callback.
-rw-r--r--window-choose.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/window-choose.c b/window-choose.c
index ccd09afc..70eb651f 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -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);
}