From e711deaf5bc2ce2ef02247e1ef46b4f560008b3e Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 14 May 2018 21:58:24 -0400 Subject: [PATCH] added logic to set file properties --- inc/win.h | 1 + lib/x11.c | 8 ++++++++ tide.c | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) 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(); -- 2.49.0