Both parameters are only used to access a single element of their respective structures. So pass each desired element directly instead of its parent.
This allows the function to be used elsewhere when the parent structure isn't as readily available. --- input.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/input.c b/input.c index f4e138b..34b1de6 100644 --- a/input.c +++ b/input.c @@ -51,7 +51,7 @@ struct input_transition; int input_split(struct input_ctx *); int input_get(struct input_ctx *, u_int, int, int); void input_reply(struct input_ctx *, const char *, ...); -void input_set_state(struct window_pane *, const struct input_transition *); +void input_set_state(struct input_ctx *, const struct input_state *); /* Transition entry/exit handlers. */ void input_clear(struct input_ctx *); @@ -708,18 +708,20 @@ input_free(struct window_pane *wp) /* Change input state. */ void -input_set_state(struct window_pane *wp, const struct input_transition *itr) +input_set_state(struct input_ctx *ictx, const struct input_state *next_state) { - struct input_ctx *ictx = &wp->ictx; struct evbuffer *ground_evb = ictx->since_ground; + if (next_state == NULL) + return; + if (ictx->state->exit != NULL) ictx->state->exit(ictx); - if (itr->state == &input_state_ground) + if (next_state == &input_state_ground) evbuffer_drain(ground_evb, EVBUFFER_LENGTH(ground_evb)); - ictx->state = itr->state; + ictx->state = next_state; if (ictx->state->enter != NULL) ictx->state->enter(ictx); } @@ -778,9 +780,7 @@ input_parse(struct window_pane *wp) if (itr->handler != NULL && itr->handler(ictx) != 0) continue; - /* And switch state, if necessary. */ - if (itr->state != NULL) - input_set_state(wp, itr); + input_set_state(ictx, itr->state); /* If not in ground state, save input. */ if (ictx->state != &input_state_ground) -- 1.7.10.4 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users