From: Michael D. Lowis Date: Fri, 11 Aug 2017 02:25:51 +0000 (-0400) Subject: set TIDE_FILE property to the real path of the file being edited X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=b97a831ac7ca8434674726bd04109f3d9a274274;p=projs%2Ftide.git set TIDE_FILE property to the real path of the file being edited --- diff --git a/lib/win.c b/lib/win.c index cc63663..31f6b78 100644 --- a/lib/win.c +++ b/lib/win.c @@ -65,11 +65,17 @@ static void win_update(int xfd, void* data) { x11_flush(); } +static void set_path_prop(char* path) { + char *newpath = calloc(1, PATH_MAX+1), + *abspath = realpath(path, newpath); + x11_prop_set("TIDE_FILE", abspath); + free(newpath); +} + void win_load(char* path) { View* view = win_view(EDIT); view_init(view, path, view->buffer.errfn); - if (path) - x11_prop_set("TIDE_FILE", path); + if (path) set_path_prop(path); } void win_save(char* path) { @@ -80,7 +86,7 @@ void win_save(char* path) { free(view->buffer.path); view->buffer.path = path; buf_save(&(view->buffer)); - x11_prop_set("TIDE_FILE", path); + set_path_prop(path); } void win_loop(void) { diff --git a/tctl.c b/tctl.c index 00cd196..99c59eb 100644 --- a/tctl.c +++ b/tctl.c @@ -15,6 +15,11 @@ struct { static void* prop_get(Window win, char* propname, Atom type, unsigned long* nitems); static void prop_set(Window win, char* propname, Atom type, int format, void* items, unsigned long nitems); +char* abspath(char* path) { + char* newpath = calloc(1, PATH_MAX+1); + return realpath(path, newpath); +} + /* Main Routine ******************************************************************************/ int main(int argc, char** argv) { @@ -29,6 +34,10 @@ int main(int argc, char** argv) { printf("Windows: %lu\n", nwindows); XUngrabServer(X.display); + for (int i = 1; i < argc; i++) { + printf("abspath: '%s'\n", abspath(argv[i])); + } + return 0; }