From 6cc9f1f559ff28f3c5d6344e6f85c49f4b3bdce0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 10 Aug 2017 14:46:41 -0400 Subject: [PATCH] Cleaned up win interface slightly --- inc/win.h | 5 +---- lib/win.c | 12 +++++------- pick.c | 6 +----- tests/tide.c | 2 +- tide.c | 6 +----- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/inc/win.h b/inc/win.h index a54f0aa..70f73b9 100644 --- a/inc/win.h +++ b/inc/win.h @@ -38,8 +38,7 @@ typedef struct { MouseFunc right; } MouseConfig; -void win_window(char* name, void (*errfn)(char*)); -void win_dialog(char* name, void (*errfn)(char*)); +void win_window(char* name, bool isdialog, void (*errfn)(char*)); void win_loop(void); void win_settext(WinRegion id, char* text); void win_setlinenums(bool enable); @@ -67,5 +66,3 @@ void onscroll(double percent); void onmouseleft(WinRegion id, bool pressed, size_t row, size_t col); void onmousemiddle(WinRegion id, bool pressed, size_t row, size_t col); void onmouseright(WinRegion id, bool pressed, size_t row, size_t col); -bool update_needed(void); - diff --git a/lib/win.c b/lib/win.c index 7b6275d..85cf96e 100644 --- a/lib/win.c +++ b/lib/win.c @@ -50,14 +50,12 @@ static void win_init(void (*errfn)(char*)) { Regions[EDIT].clrcsr = config_get_int(ClrEditCsr); } -void win_window(char* name, void (*errfn)(char*)) { +void win_window(char* name, bool isdialog, void (*errfn)(char*)) { win_init(errfn); - x11_window(name, config_get_int(WinWidth), config_get_int(WinHeight)); -} - -void win_dialog(char* name, void (*errfn)(char*)) { - win_init(errfn); - x11_dialog(name, config_get_int(WinWidth), config_get_int(WinHeight)); + if (isdialog) + x11_dialog(name, config_get_int(WinWidth), config_get_int(WinHeight)); + else + x11_window(name, config_get_int(WinWidth), config_get_int(WinHeight)); } static void win_update(int xfd, void* data) { diff --git a/pick.c b/pick.c index 6d1ada5..8892f1d 100644 --- a/pick.c +++ b/pick.c @@ -172,10 +172,6 @@ void onshutdown(void) { x11_deinit(); } -bool update_needed(void) { - return false; -} - /* Main Routine *****************************************************************************/ static void onerror(char* msg) { @@ -229,7 +225,7 @@ int main(int argc, char** argv) { char* title = getenv("PICKTITLE"); load_choices(); if (vec_size(&Choices) > 1) { - win_dialog("pick", onerror); + win_dialog("pick", true, onerror); win_setkeys(Bindings, NULL); win_settext(STATUS, (title ? title : "pick")); if (argc >= 2) { diff --git a/tests/tide.c b/tests/tide.c index 8af7b28..2416477 100644 --- a/tests/tide.c +++ b/tests/tide.c @@ -23,7 +23,7 @@ Display* XDisplay; static void initialize(void) { ShellCmd[0] = "/bin/sh"; - win_window("edit", ondiagmsg); + win_window("edit", false, ondiagmsg); XDisplay = XOpenDisplay(NULL); win_setkeys(Bindings, NULL); } diff --git a/tide.c b/tide.c index 915f5e4..00327b1 100644 --- a/tide.c +++ b/tide.c @@ -527,10 +527,6 @@ void onshutdown(void) { quit(); } -bool update_needed(void) { - return false; -} - static void oninput(Rune rune) { if (win_getregion() == EDIT && pty_active()) pty_send_rune(rune); @@ -603,7 +599,7 @@ int main(int argc, char** argv) { if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh"; /* create the window */ - win_window("tide", ondiagmsg); + win_window("tide", false, ondiagmsg); /* open all but the last file in new instances */ for (argc--, argv++; argc > 1; argc--, argv++) { -- 2.49.0