From: Michael D. Lowis Date: Mon, 27 Mar 2017 12:29:56 +0000 (-0400) Subject: Updated win.c api to allow creating a dialog or a normal window X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=7206a4af29309cc0a967e8bf05a35dd618286425;p=projs%2Ftide.git Updated win.c api to allow creating a dialog or a normal window --- diff --git a/Makefile b/Makefile index 80f3207..a168ef6 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ include config.mk .PHONY: all docs clean install uninstall test -all: $(BIN) test $(MAN1) +all: $(BINS) test $(MAN1) docs: ronn --roff docs/*.md diff --git a/inc/win.h b/inc/win.h index 6128114..1b0ce3d 100644 --- a/inc/win.h +++ b/inc/win.h @@ -32,7 +32,8 @@ typedef struct { MouseFunc right; } MouseConfig; -void win_init(char* name); +void win_window(char* name); +void win_dialog(char* name); void win_loop(void); void win_settext(WinRegion id, char* text); void win_setruler(size_t ruler); diff --git a/lib/win.c b/lib/win.c index 20c783b..69aa0c2 100644 --- a/lib/win.c +++ b/lib/win.c @@ -46,14 +46,23 @@ static Region Regions[NREGIONS] = {0}; static ButtonState MouseBtns[MOUSE_BTN_COUNT] = {0}; KeyBinding* Keys = NULL; -void win_init(char* name) { +static void win_init(void) { for (int i = 0; i < SCROLL; i++) view_init(&(Regions[i].view), NULL); x11_init(&Config); Font = x11_font_load(FONTNAME); +} + +void win_window(char* name) { + win_init(); x11_window(name, Width, Height); } +void win_dialog(char* name) { + win_init(); + x11_dialog(name, Width, Height); +} + void win_loop(void) { x11_show(); x11_loop(); diff --git a/term.c b/term.c index bc52920..6dbdbf3 100644 --- a/term.c +++ b/term.c @@ -26,7 +26,7 @@ void onupdate(void) { #ifndef TEST int main(int argc, char** argv) { - win_init("term"); + win_window("term"); //win_setkeys(&Bindings); //win_setmouse(&MouseHandlers); win_loop(); diff --git a/tests/xedit.c b/tests/xedit.c index 7cc9b35..89fc834 100644 --- a/tests/xedit.c +++ b/tests/xedit.c @@ -23,7 +23,7 @@ Display* XDisplay; static void initialize(void) { ShellCmd[0] = "/bin/sh"; - win_init("edit"); + win_window("edit"); XDisplay = XOpenDisplay(NULL); win_setkeys(Bindings); //win_setmouse(&MouseHandlers); diff --git a/xedit.c b/xedit.c index 4d81018..762ce9e 100644 --- a/xedit.c +++ b/xedit.c @@ -541,7 +541,7 @@ int main(int argc, char** argv) { ShellCmd[0] = getenv("SHELL"); if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh"; /* Create the window and enter the event loop */ - win_init("edit"); + win_window("edit"); char* tags = getenv("EDITTAGS"); win_settext(TAGS, (tags ? tags : DEFAULT_TAGS)); win_setruler(80); diff --git a/xpick.c b/xpick.c index ad3fedd..ee9de8a 100644 --- a/xpick.c +++ b/xpick.c @@ -203,7 +203,7 @@ int main(int argc, char** argv) { char* title = getenv("XPICKTITLE"); load_choices(); if (vec_size(&Choices) > 1) { - win_init("xpick"); + win_dialog("xpick"); win_setkeys(Bindings); win_settext(STATUS, (title ? title : "xpick")); if (argc >= 2) {