]> git.mdlowis.com Git - projs/tide.git/commitdiff
Updated win.c api to allow creating a dialog or a normal window
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 27 Mar 2017 12:29:56 +0000 (08:29 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 27 Mar 2017 12:29:56 +0000 (08:29 -0400)
Makefile
inc/win.h
lib/win.c
term.c
tests/xedit.c
xedit.c
xpick.c

index 80f32071863df5eb2ba65051757fb5d1e001fabd..a168ef6ef1422a949833fdc52c3658a21ae732e5 100644 (file)
--- 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
index 61281144964ef0219f837dfa3c010191ef828a43..1b0ce3d6902f6d963ad43801265ec3d577f38f12 100644 (file)
--- 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);
index 20c783b3f2a732451bc3df4aa597dd2f98647d4b..69aa0c2c913845b5d83fc0245c8a32bc7ed79455 100644 (file)
--- 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 bc52920811a48189efc2ce8357c9cc8f9f86a65f..6dbdbf3500828aa7c49158ca674c295bb30311e9 100644 (file)
--- 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();
index 7cc9b3549580361bdcf1643ef284fc4e1d682365..89fc8348897a1919de047c76da8a1bdc9cf61257 100644 (file)
@@ -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 4d81018520ab77f85c0393fefa289fb96776df28..762ce9e3b3fac18dffcbf53b0d8996b0dc2e1253 100644 (file)
--- 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 ad3feddf27d86277ca6e2e64a096734f05109065..ee9de8adc04fd8c2b22acec32d53f8b96b195ba5 100644 (file)
--- 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) {