diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-01 11:42:00 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-01 12:38:40 +0200 |
| commit | eb7279f5b0a0fcfec92857b042f498f935e39af9 (patch) | |
| tree | cab9c02097c1c64d75799c0e80b17560612a87d9 /vis.c | |
| parent | 8b31028096190ce0339e984bf36df5840d868990 (diff) | |
| download | vis-eb7279f5b0a0fcfec92857b042f498f935e39af9.tar.gz vis-eb7279f5b0a0fcfec92857b042f498f935e39af9.tar.xz | |
vis: delay start event until we are fully initialized
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -367,6 +367,8 @@ Vis *vis_new(Ui *ui, VisEvent *event) { goto err; if (!(vis->error_file = file_new_internal(vis, NULL))) goto err; + if (!(vis->actions = map_new())) + goto err; if (!(vis->keymap = map_new())) goto err; if (!sam_init(vis)) @@ -376,8 +378,6 @@ Vis *vis_new(Ui *ui, VisEvent *event) { if (event && event->vis_init) event->vis_init(vis); vis->ui->start(vis->ui); - if (event && event->vis_start) - event->vis_start(vis); return vis; err: vis_free(vis); @@ -449,10 +449,6 @@ void vis_delete(Vis *vis, size_t pos, size_t len) { } bool vis_action_register(Vis *vis, const KeyAction *action) { - if (!vis->actions) - vis->actions = map_new(); - if (!vis->actions) - return false; return map_put(vis->actions, action->name, action); } @@ -717,7 +713,7 @@ static void vis_keys_process(Vis *vis) { for (Mode *mode = vis->mode; mode && !binding && !prefix; mode = mode->parent) { for (int global = 0; global < 2 && !binding && !prefix; global++) { - Mode *mode_local = global ? mode : &vis->win->modes[mode->id]; + Mode *mode_local = global || !vis->win ? mode : &vis->win->modes[mode->id]; if (!mode_local->bindings) continue; binding = map_get(mode_local->bindings, start); @@ -878,6 +874,8 @@ int vis_run(Vis *vis, int argc, char *argv[]) { vis->running = true; vis_args(vis, argc, argv); + if (vis->event && vis->event->vis_start) + vis->event->vis_start(vis); struct timespec idle = { .tv_nsec = 0 }, *timeout = NULL; sigset_t emptyset; |
