From: Michael D. Lowis Date: Wed, 8 May 2019 14:25:59 +0000 (-0400) Subject: checkin tframe stuff X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=2e9c0abab29308c0a227d40ac6476f40c6264016;p=projs%2Ftide.git checkin tframe stuff --- diff --git a/TODO.md b/TODO.md index fcfe8a5..475e3bb 100644 --- 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 diff --git a/src/lib/x11.c b/src/lib/x11.c index 74df7d9..daebeed 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -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); } diff --git a/src/pick.c b/src/pick.c index 9c525cd..503b49d 100644 --- a/src/pick.c +++ b/src/pick.c @@ -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) { diff --git a/src/tframe.c b/src/tframe.c index 90917c9..20b6df0 100644 --- a/src/tframe.c +++ b/src/tframe.c @@ -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); diff --git a/src/tide.c b/src/tide.c index 92e1177..0676171 100644 --- a/src/tide.c +++ b/src/tide.c @@ -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 },