From: Michael D. Lowis Date: Tue, 15 May 2018 01:58:24 +0000 (-0400) Subject: added logic to set file properties X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e711deaf5bc2ce2ef02247e1ef46b4f560008b3e;p=projs%2Ftide.git added logic to set file properties --- diff --git a/inc/win.h b/inc/win.h index 932f4d6..4caff41 100644 --- a/inc/win.h +++ b/inc/win.h @@ -131,6 +131,7 @@ typedef struct { } drawcsr; void win_init(char* title, KeyBinding* bindings); +void win_prop_set(char* xname, char* ename, char* value); void win_save(char* path); void win_loop(void); void win_quit(void); diff --git a/lib/x11.c b/lib/x11.c index 8735b0e..bea6bef 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -561,6 +561,13 @@ void win_init(char* title, KeyBinding* bindings) { buf_logclear(&(view->buffer)); } +void win_prop_set(char* xname, char* ename, char* value) { + Atom propname = XInternAtom(X.display, xname, 0); + XChangeProperty(X.display, X.self, propname, XA_STRING, 8, PropModeReplace, + (const unsigned char *)value, strlen(value)); + if (ename) setenv(ename, value, 1); +} + void win_save(char* path) { View* view = win_view(EDIT); if (!path) path = view->buffer.path; @@ -569,6 +576,7 @@ void win_save(char* path) { free(view->buffer.path); view->buffer.path = path; buf_save(&(view->buffer)); + win_prop_set("TIDE_FILE", "file", path); } void win_loop(void) { diff --git a/tide.c b/tide.c index 9795c74..1b03ca8 100644 --- a/tide.c +++ b/tide.c @@ -497,7 +497,10 @@ int main(int argc, char** argv) { win_init("tide", Bindings); /* if we still have args left we're going to open it in this instance */ - if (*argv) view_init(win_view(EDIT), *argv); + if (*argv) { + view_init(win_view(EDIT), *argv); + win_prop_set("TIDE_FILE", "file", *argv); + } /* now create the window and start the event loop */ win_loop();