From f79f742101b36f488971b5fc5c246ac6eeb73d82 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Tue, 25 Oct 2016 19:30:26 -0400 Subject: [PATCH] stop-gap to fix the opendir logic --- pd/nw/pdgui.js | 16 +++++++++++++--- pd/src/s_main.c | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 727670b73..9221c7bf2 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -40,7 +40,7 @@ exports.get_lib_dir = function() { return lib_dir; } -exports.get_pd_opendir = function() { +function get_pd_opendir() { if (pd_opendir) { return pd_opendir; } else { @@ -48,6 +48,16 @@ exports.get_pd_opendir = function() { } } +exports.get_pd_opendir = get_pd_opendir; + +function set_pd_opendir(dir) { + pd_opendir = dir; +} + +function gui_set_current_dir(dummy, dir_and_filename) { + set_pd_opendir(path.dirname(dir_and_filename)); +} + function gui_set_gui_preset(name) { skin.set(name); } @@ -543,7 +553,7 @@ exports.menu_saveas = menu_saveas; function menu_new () { // try not to use a global here - untitled_directory = pwd; + untitled_directory = get_pd_opendir(); pdsend("pd filename", "Untitled-" + untitled_number, enquote(defunkify_windows_path(untitled_directory))); @@ -764,7 +774,7 @@ function open_file(file) { if (basename.match(/\.(pd|pat|mxt)$/i) != null) { pdsend("pd open", enquote(basename), (enquote(directory))); - pd_opendir = directory; + set_pd_opendir(directory); //::pd_guiprefs::update_recentfiles "$filename" 1 } } diff --git a/pd/src/s_main.c b/pd/src/s_main.c index e6f503167..b020b81f0 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -171,7 +171,9 @@ static void openit(const char *dirname, const char *filename) { close (fd); glob_evalfile(0, gensym(nameptr), gensym(dirbuf)); - sys_vgui("pdtk_set_current_dir {%s}\n", filename); + //sys_vgui("pdtk_set_current_dir {%s}\n", filename); + gui_vmess("gui_set_current_dir", "xs", + 0, filename); } else error("%s: can't open", filename); -- GitLab