From 44d1868f00ea963d724a254b4bcd0299a5c77cfc Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 12 May 2019 21:47:23 -0400 Subject: [PATCH] resync the view on resize. may want to add logic to only di this if cursor/selection is on screen --- inc/edit.h | 1 + src/lib/view.c | 4 ++++ src/tframe.c | 5 ++--- src/tide.c | 7 +++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/inc/edit.h b/inc/edit.h index 434cb32..9394b52 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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); diff --git a/src/lib/view.c b/src/lib/view.c index a77f5e5..1add82f 100644 --- a/src/lib/view.c +++ b/src/lib/view.c @@ -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; diff --git a/src/tframe.c b/src/tframe.c index 553cfd8..26da11a 100644 --- a/src/tframe.c +++ b/src/tframe.c @@ -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) { diff --git a/src/tide.c b/src/tide.c index 33b04ac..628b5e7 100644 --- a/src/tide.c +++ b/src/tide.c @@ -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) { -- 2.51.0