]> git.mdlowis.com Git - projs/tide.git/commitdiff
resync the view on resize. may want to add logic to only di this if cursor/selection...
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 13 May 2019 01:47:23 +0000 (21:47 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 13 May 2019 01:47:23 +0000 (21:47 -0400)
inc/edit.h
src/lib/view.c
src/tframe.c
src/tide.c

index 434cb325625bef9f877dfb75508cdb2050a8d9e1..9394b523403e5f87ef946ce484db43e0be2c8a37 100644 (file)
@@ -119,6 +119,7 @@ enum {
 };
 
 void view_init(View* view, char* file);
+void view_sync(View* view);
 void view_reload(View* view);
 size_t view_limitrows(View* view, size_t maxrows);
 void view_resize(View* view, size_t width, size_t nrows);
index a77f5e5711a703d1baf98172c339e100e2b5461d..1add82ff24ee7b836ac6e8dbf1506dc84c798f6d 100644 (file)
@@ -86,6 +86,10 @@ void view_reload(View* view) {
     }
 }
 
+void view_sync(View* view) {
+    view->sync_flags |= (CURSOR|CENTER);
+}
+
 static size_t rune_width(View* view, int c, size_t xpos, size_t width) {
     if (c == '\r')
         return 0;
index 553cfd844a413bc1c2b9491177b0aa4f210f66a5..26da11a3814c21eac18bb7bfab203c1a69c96c15 100644 (file)
@@ -85,10 +85,9 @@ static void xdestroy(XConf* x, XEvent* e) {
 
 static void xconfigure(XConf* x, XEvent* e) {
     if (e->xconfigure.window != x->self) return;
-    x11_resize(x, e);
-    if (e->xconfigure.width != x->width || e->xconfigure.height != x->height) {
+    if (e->xconfigure.width != x->width || e->xconfigure.height != x->height)
         retile = 1;
-    }
+    x11_resize(x, e);
 }
 
 static void xclientmsg(XConf* x, XEvent* e) {
index 33b04acb202dc58bbfc3f3d01dc6b86ec32f0b63..628b5e7e97a5a3d4457178a946d843d8d7255d96 100644 (file)
@@ -177,6 +177,12 @@ static void xclientmsg(XConf* x, XEvent* e) {
         win_setln(e->xclient.data.l[0]);
 }
 
+void xresize(XConf* x, XEvent* e) {
+    if (e->xconfigure.width != x->width || e->xconfigure.height != x->height)
+        view_sync(win_view(EDIT));
+    x11_resize(x, e);
+}
+
 static void xredraw(XConf* x) {
     /* force update the title */
     win_title(NULL);
@@ -237,6 +243,7 @@ void win_init(void) {
     X.eventfns[ButtonRelease] = xmousebtn;
     X.eventfns[MotionNotify] = xbtnmotion;
     X.eventfns[ClientMessage] = xclientmsg;
+    X.eventfns[ConfigureNotify] = xresize;
 }
 
 void win_title(char* path) {