]> git.mdlowis.com Git - projs/tide.git/commitdiff
checkin tframe stuff
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 8 May 2019 14:25:59 +0000 (10:25 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 8 May 2019 14:25:59 +0000 (10:25 -0400)
TODO.md
src/lib/x11.c
src/pick.c
src/tframe.c
src/tide.c

diff --git a/TODO.md b/TODO.md
index fcfe8a5ad82e7d7a5b0e79381ae0ec2bc776f4c7..475e3bb110fd9725899970dd1b2f2da18dc520c6 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -37,3 +37,14 @@ Maybe think about addressing these later:
 * Find shortcut should select previous word if current char is newline
 * implement command diffing logic to optimize the undo/redo log
 * right click negative numbers should jump to that many lines from the end of file
+
+
+1P                  Move the cursor
+1P 1R 1P            Select clicked on word
+1P 1R 1P 1R 1P      Select whole non whitespace thing
+2P 2R               Execute clicked word
+2P 1P 2R            Execute clicked word with argument
+3P 3R               Fetch clicked word
+3P 1P 3R            ?? Go to definition ??
+1P 2P 2R            Cut the selected text
+1P 3P 3R            Paste the selection
index 74df7d9309a608529c36572e82a894a890fa5cb1..daebeed289406ad973947603e3cff8bf90124745 100644 (file)
@@ -46,15 +46,16 @@ void x11_mkwin(XConf* x, int width, int height, int evmask) {
     x->width = width, x->height = height;
     x->self = XCreateSimpleWindow(
         x->display, x->root, 0, 0, x->width, x->height, 0, x->depth, -1);
+
     /* register interest in the delete window message */
     Atom wmDeleteMessage = XInternAtom(x->display, "WM_DELETE_WINDOW", False);
     XSetWMProtocols(x->display, x->self, &wmDeleteMessage, 1);
     /* setup window attributes and events */
     XSetWindowAttributes swa;
     swa.bit_gravity = NorthWestGravity;
+    swa.do_not_propagate_mask = 0; // do not hide any events from child window
     XChangeWindowAttributes(x->display, x->self,
-        CWBackingStore|CWBitGravity,
-//        CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap,
+        CWBackingStore|CWBitGravity|CWEventMask|NoEventMask|CWBackPixel,
         &swa);
     XSelectInput(x->display, x->self, evmask);
 }
index 9c525cd0d5ff14f4fb4d2f423d2a8d235ef71800..503b49d517e191992519d838b3d5c272b3b53a9d 100644 (file)
@@ -59,7 +59,7 @@ static int by_score(const void* a, const void* b) {
     else if (ca->score > cb->score)
         return -1;
     else
-        return 0;
+        return strcmp(ca->string, cb->string);
 }
 
 static void load_choices(XConf* x) {
index 90917c9690773316f95710838e6fc4499a1b79e5..20b6df007e858688173b876ca2027563a12eab5c 100644 (file)
@@ -14,6 +14,8 @@ static struct XConf X;
 static View Tags;
 static int Divider;
 static int FontSel;
+Window Child = 0;
+int retile = 0;
 
 /* X11 Window Code
  ******************************************************************************/
@@ -33,36 +35,22 @@ size_t glyph_width(View* view, int c) {
         return extents.xOff;
 }
 
-Window child_window = 0;
-
 static void xmaprequest(XConf* x, XEvent* e) {
     (void)x;
     XMapWindow(e->xmaprequest.display, e->xmaprequest.window);
-    child_window = e->xmaprequest.window;
+    Child = e->xmaprequest.window;
+    retile = 1;
 }
 
 static void xconfigure(XConf* x, XEvent* e) {
+    if (e->xconfigure.window != x->self) return;
     if (e->xconfigure.width != x->width || e->xconfigure.height != x->height) {
         x->width  = e->xconfigure.width;
         x->height = e->xconfigure.height;
         x->pixmap = XCreatePixmap(x->display, x->self, x->width, x->height, x->depth);
         x->xft    = XftDrawCreate(x->display, x->pixmap, x->visual, x->colormap);
+        retile = 1;
     }
-
-    if (child_window) {
-        // Get container window attributes
-        XWindowAttributes attrs;
-        XGetWindowAttributes(x->display, x->self, &attrs);
-
-        // Move and resize child
-        XMoveResizeWindow(x->display,
-                          child_window,
-                          0, Divider+2, attrs.width, attrs.height - Divider - 2);
-    }
-}
-
-static void xdestroy(XConf* x, XEvent* e) {
-    (void)x, (void)e;
 }
 
 static void xclientmsg(XConf* x, XEvent* e) {
@@ -70,6 +58,11 @@ static void xclientmsg(XConf* x, XEvent* e) {
         win_quit();
 }
 
+static void xexpose(XConf* x, XEvent* e) {
+    (void)x, (void)e;
+    retile = 1;
+}
+
 static void xupdate(Job* job) {
     int nqueued, nevents;
     do {
@@ -88,11 +81,16 @@ static void xupdate(Job* job) {
             /* draw the regions to the window */
             drawcsr csr = { .w = X.width, .h = X.height };
             csr.x += ScrollWidth + 1;
-            draw_statbox(&X, Tags.buffer.status);
+            draw_statbox(&X, NORMAL);
             draw_view(&X, &Tags, X.font, tagrows, &csr, TagsBg, TagsFg, TagsSel, false);
+            int prev_div = Divider;
             Divider = draw_hrule(&X, &csr);
             draw_rect(&X, EditBg, 0, Divider+2, csr.w, csr.h);
             XCopyArea(X.display, X.pixmap, X.self, X.gc, 0, 0, X.width, X.height, 0, 0);
+            if ((retile || prev_div != Divider) && Child) {
+                XMoveResizeWindow(X.display, Child, -1, Divider, X.width, X.height - Divider);
+                retile = 0;
+            }
             XFlush(X.display);
         }
     } while ((nqueued = XEventsQueued(X.display, QueuedAfterFlush)) > 0);
@@ -134,11 +132,10 @@ void win_init(KeyBinding* bindings) {
 //    X.eventfns[ButtonPress] = xbtnpress;
 //    X.eventfns[ButtonRelease] = xbtnrelease;
 //    X.eventfns[MotionNotify] = xbtnmotion;
-
     X.eventfns[MapRequest] = xmaprequest;
     X.eventfns[ConfigureNotify] = xconfigure;
-    X.eventfns[DestroyNotify] = xdestroy;
     X.eventfns[ClientMessage] = xclientmsg;
+    X.eventfns[Expose] = xexpose;
 }
 
 void win_loop(void) {
@@ -176,12 +173,14 @@ int main(void) {
     sprintf(window_id, "%lu", X.self);
     setenv("TIDE_PARENT", window_id, 1);
 
-    if (fork() == 0) {
-        char* tidecmd[] = { "tide", 0 };
-        execvp(tidecmd[0], tidecmd);
-        fprintf(stderr, "error: can't execute child process!\n");
-        exit(1);
-    }
+//    for (int i = 0; i < 1; i++) {
+        if (fork() == 0) {
+            char* tidecmd[] = { "tide", 0 };
+            execvp(tidecmd[0], tidecmd);
+            fprintf(stderr, "error: can't execute child process!\n");
+            exit(1);
+        }
+//    }
 
     /* now create the window and start the event loop */
     xupdate(NULL);
index 92e1177aeaecc0ed26f9ad8dc4252b672f192f0c..0676171623d854f4f5c63738e1851c324468accd 100644 (file)
@@ -33,7 +33,7 @@ typedef struct {
 } Tag;
 
 char* ARGV0;
-static Tag Builtins[];
+static Tag Builtins[18];
 static Time Now;
 static struct XConf X;
 static int KeyBtnState;
@@ -810,7 +810,7 @@ static void tag_line(char* cmd) {
 
 /* Main Routine
  ******************************************************************************/
-static Tag Builtins[] = {
+static Tag Builtins[18] = {
     { .tag = "Cut",    .action = cut       },
     { .tag = "Copy",   .action = copy      },
     { .tag = "Del",    .action = quit      },