]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic to set file properties
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 15 May 2018 01:58:24 +0000 (21:58 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 15 May 2018 01:58:24 +0000 (21:58 -0400)
inc/win.h
lib/x11.c
tide.c

index 932f4d6e320388bc2fee8287a04ed134a31a8555..4caff414dba249e057f3b75577289ebe21c3bfb7 100644 (file)
--- 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);
index 8735b0e819b77cecf7e8f538f5e3d1d874d96319..bea6bef84f0989ad6a9281e67462e8b0a7e20217 100644 (file)
--- 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 9795c74ac4c6942a98bbfba4817310024b842a82..1b03ca877188f947e5173855f670ab4ddae2880f 100644 (file)
--- 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();