]> git.mdlowis.com Git - projs/tide.git/commitdiff
changed proportional font in use and updated to withdraw window on quit, create new...
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 5 Apr 2020 01:53:28 +0000 (21:53 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 5 Apr 2020 01:53:28 +0000 (21:53 -0400)
config.h
inc/x11.h
src/lib/x11.c
src/lib/x11_gc.c
src/lib/x11_sel.c
src/pick.c
src/tide.c
testdocs/ascii.txt [new file with mode: 0644]

index 4be04bda4a524128e85c7460887743cf7215b3e1..fa013f2d62f8eb1a8e451a9b6f23c526cf6be3b0 100644 (file)
--- a/config.h
+++ b/config.h
@@ -36,7 +36,7 @@ static char* TagString = "Del Put Get | Font Tabs Eol | x+ w+ !st !term | Find "
 
 /* List of font patterns available to the editor */
 static char* Fonts[2] = {
-    "Verdana:size=11",
+    "Geneva:size=13",
 #ifdef __MACH__
     "Monaco:size=11"
 #else
index c5a9a0f14ef022a222988f7bdf3429de2e222b8b..4878f9703917358113cdc2c961d65b290dc7373c 100644 (file)
--- a/inc/x11.h
+++ b/inc/x11.h
@@ -8,9 +8,15 @@ AUTOLIB(fontconfig)
 #include <X11/Xatom.h>
 #include <X11/Xft/Xft.h>
 
+enum {
+    RUNNING,
+    SERVE_SEL,
+    QUITTING
+};
+
 typedef struct XConf {
-    Bool running, error;
-    int fd, screen, width, height, mods;
+    Bool error;
+    int state, fd, screen, width, height, mods;
     Window root;
     Display* display;
     Visual* visual;
@@ -157,3 +163,4 @@ int x11_sel_get(XConf* x, int selid, void(*cbfn)(char*));
 int x11_sel_set(XConf* x, int selid, char* str);
 void x11_sel_quit(XConf* x, XEvent* e);
 int x11_sel_ready(XConf* x);
+void x11_sel_serve(XConf* x);
index 4cbc1bf20999664c61948e3552ba03d2e5cb44e6..5220cf2b534cc031a5ef2af41e4a9674c5901512 100644 (file)
@@ -35,7 +35,7 @@ int x11_init(XConf* x)
         x->colormap = wa.colormap;
         x->screen   = DefaultScreen(x->display);
         x->depth    = DefaultDepth(x->display, x->screen);
-        x->running = True;
+        x->state    = RUNNING;
         XSetErrorHandler(onerror);
         ret = 0;
     }
@@ -105,12 +105,13 @@ void x11_process_events(XConf* x)
     {
         telem_send("EV_READ_QUEUE(pending: %d)\n", XPending(x->display));
         XGetMotionEvents(x->display, x->self, CurrentTime, CurrentTime, &nevents);
+
         for (XEvent e; XPending(x->display);)
         {
             XNextEvent(x->display, &e);
             update_state(x, &e);
             if (!XFilterEvent(&e, None) && x->eventfns[e.type])
-            {;
+            {
                 telem_send("EV_HANDLE(type: %d)\n", e.type);
                 (x->eventfns[e.type])(x, &e);
             }
@@ -135,7 +136,7 @@ void x11_process_events(XConf* x)
 void x11_event_loop(XConf* x, void (*redraw)(XConf* x))
 {
     if (redraw) redraw(x);
-    for (XEvent e; x->running;)
+    for (XEvent e; x->state != QUITTING;)
     {
         XNextEvent(x->display, &e);
         if (x->eventfns[e.type])
index ef492cb8f4c97a67b98caffb3cfd0e289471b8a1..ae7640db25e0e4aca03c4626b9aea0f8caf04b35 100644 (file)
@@ -120,6 +120,7 @@ XftFont* x11_font_load(XConf* x, char* name)
             FcPatternDestroy(match);
         }
     }
+//    printf("font: '%s'\n", name);
     return font;
 }
 
index 1c0170b0d7da7bc974e83cff064ee6c5280fb3cd..0b81c9decababcbe24ddfb320625f4a962a08c7a 100644 (file)
@@ -155,7 +155,7 @@ void x11_sel_quit(XConf* x, XEvent* e)
     xselclear(x, e);
     if (!Selections[PRIMARY].text && !Selections[CLIPBOARD].text)
     {
-        x->running = False;
+        x->state = QUITTING;
     }
 }
 
@@ -165,3 +165,19 @@ int x11_sel_ready(XConf* x)
     return (Selections[PRIMARY].text || Selections[CLIPBOARD].text);
 }
 
+void x11_sel_serve(XConf* x)
+{
+    X.eventfns[SelectionClear] = x11_sel_quit;
+    X.self = XCreateSimpleWindow(X.display, X.root, 0, 0, 1, 1, 0, 0, 0);
+    if (Selections[PRIMARY].text)
+    {
+        XSetSelectionOwner(x->display, Selections[PRIMARY].atom, x->self, CurrentTime);
+
+    }
+    if (Selections[CLIPBOARD].text)
+    {
+        XSetSelectionOwner(x->display, Selections[CLIPBOARD].atom, x->self, CurrentTime);
+    }
+    if (fork()) exit(0); /* fork into background */
+}
+
index 1f8b17118245d8cc5c29eb3ffeb669a94257d479..8f0655b2552353900bc5afdea63bf5c182405e26 100644 (file)
@@ -190,11 +190,11 @@ static void xkeypress(XConf* x, XEvent* e)
         XLookupString(&(e->xkey), buf, sizeof(buf), &key, 0);
     if (key == XK_Return)
     {
-        x->running = false;
+        x->state = QUITTING;
     }
     else if (key == XK_Escape)
     {
-        x->running = false;
+        x->state = QUITTING;
         ChoiceIdx = SIZE_MAX;
     }
     else if (key == XK_Up)
@@ -241,11 +241,11 @@ static void xbtnpress(XConf* x, XEvent* e)
     }
     else if (e->xbutton.button == Button2)
     {
-        x->running = false;
+        x->state = QUITTING;
     }
     else if (e->xbutton.button == Button3)
     {
-        x->running = false;
+        x->state = QUITTING;
         ChoiceIdx = SIZE_MAX;
     }
     else if (e->xbutton.button == Button4)
index 8fe3fc97a595fe82f42a27e5c86619c3bbba4a66..b31ff6510c22c436a696fc07414edaf0c9dcd3ac 100644 (file)
@@ -294,7 +294,7 @@ static void xupdate(Job* job)
 {
     /* redraw if we have changes or if we have input from a job */
     x11_process_events(&X);
-    if (!job)
+    if (!job && X.state == RUNNING)
     {
         xredraw(&X);
     }
@@ -369,12 +369,14 @@ void win_loop(void)
     XSync(X.display, False);
     int maxcount = 1000 / Timeout;
     int count = 0;
-    while (X.running)
+    while (X.state != QUITTING)
     {
         bool ready = job_poll(Timeout);
         count += (ready ? -count : 1);
         if (count < maxcount)
+        {
             xupdate(NULL);
+        }
     }
 }
 
@@ -384,17 +386,13 @@ void win_quit(void)
     if ((win_buf(EDIT)->status != MODIFIED) || (X.now - before) <= (uint64_t)ClickTime)
     {
         tide_send("DEL");
-        X.eventfns[SelectionClear] = x11_sel_quit;
-        XUnmapWindow(X.display, X.self);
-        if (!x11_sel_ready(&X))
-        {
-            X.running = False;
-        }
-        else
+        XWithdrawWindow(X.display, X.self, X.screen);
+        X.state = QUITTING;
+        if (x11_sel_ready(&X))
         {
-            if (fork()) exit(0); /* fork into background if we still have selection */
+            X.state = SERVE_SEL;
+            x11_sel_serve(&X);
         }
-
     }
     before = X.now;
 }
diff --git a/testdocs/ascii.txt b/testdocs/ascii.txt
new file mode 100644 (file)
index 0000000..e79402b
--- /dev/null
@@ -0,0 +1,5 @@
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+abcdefghijklmnopqrstuvwxyz
+0123456789
+`-=[]\;',./
+~!@#$%^&*()_+{}|:"<>?