From 0341d038cae51415b30381e59b174070c547b05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 11 Apr 2015 12:47:45 +0200 Subject: Eliminate global running variable --- editor.h | 1 + vis.c | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/editor.h b/editor.h index 10da800..bdf2865 100644 --- a/editor.h +++ b/editor.h @@ -242,6 +242,7 @@ struct Editor { Mode *mode; /* currently active mode, used to search for keybindings */ Mode *mode_prev; /* previsouly active user mode */ Mode *mode_before_prompt; /* user mode which was active before entering prompt */ + volatile bool running; /* exit main loop once this becomes false */ }; Editor *editor_new(Ui*); diff --git a/vis.c b/vis.c index 95f04ce..81d1b7d 100644 --- a/vis.c +++ b/vis.c @@ -38,9 +38,7 @@ #include "util.h" #include "map.h" - /** global variables */ -static volatile bool running = true; /* exit main loop once this becomes false */ static Editor *vis; /* global editor instance, keeps track of all windows etc. */ /** operators */ @@ -945,7 +943,7 @@ static void prompt_enter(const Arg *arg) { * on vis->win. */ switchmode_to(vis->mode_before_prompt); - if (s && *s && exec_command(vis->prompt_type, s) && running) + if (s && *s && exec_command(vis->prompt_type, s) && vis->running) switchmode(&(const Arg){ .i = VIS_MODE_NORMAL }); free(s); editor_draw(vis); @@ -981,7 +979,7 @@ static void insert_verbatim(const Arg *arg) { } static void quit(const Arg *arg) { - running = false; + vis->running = false; } static void cmd(const Arg *arg) { @@ -1910,8 +1908,9 @@ static void mainloop() { sigaddset(&blockset, SIGWINCH); sigprocmask(SIG_BLOCK, &blockset, NULL); editor_draw(vis); + vis->running = true; - while (running) { + while (vis->running) { fd_set fds; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); -- cgit v1.2.3