diff libinterp/corefcn/octave-link.h @ 25742:d3c6de326bae

close/reload editor tab when file is (re)moved in gui terminal (bug #43922) * file-editor.cc (handle_file_remove): new code structure * main-window.cc (construct): connect new signals from octave_qt_link to the slot handle_file_renamed and the new proxy slot file_remove_proxy; (file_remove_proxy): proxy calling handle_file_remove but protected by the mutex of octave_qt_link synchronizing worker and gui thread * main-window.h: new slot file_remove_proxy * octave-qt-link.cc (do_file_remove): new method for renaming or removing files which signals the editor (gui thread) for closing the files before removing is carried out; (do_file_renamed): new method for re-loading renamed files into editor; * octave-qt-link.h: new methods do_file_remove and do_file_renamed, new signals used in the new methods for signaling the editor slots * dirfns.cc (rmdir): call the new static octave_link method for removing a file, which might be opened in the editor before removing a dir; (rename): call the new static octave_link method for renaming a file, which might be opened in the editor before renaming it and call the method for reloading the new renamed file; * octave-link.h (file_remove): new static method calling purely virtual method do_file_remove, which is implemented in octave_qt_link; (file_renamed): new static method calling purely virtual method do_file_renamed, which is implemented in octave_qt_link * syscalls.cc (unlink): call the new static octave_link method for removing a file, which might be opened in the editor before removing it
author Torsten <mttl@mailbox.org>
date Sun, 17 Sep 2017 05:52:33 +0200
parents b3d357990b52
children 9c47eedc44e2
line wrap: on
line diff
--- a/libinterp/corefcn/octave-link.h	Sat Aug 04 13:35:29 2018 +0200
+++ b/libinterp/corefcn/octave-link.h	Sun Sep 17 05:52:33 2017 +0200
@@ -31,7 +31,7 @@
 #include <string>
 
 #include "oct-mutex.h"
-
+#include "octave.h"
 #include "event-queue.h"
 
 class octave_value;
@@ -221,6 +221,20 @@
       instance->do_change_directory (dir);
   }
 
+  // Methods for removing/renaming files which might be open in editor
+  static void file_remove (const std::string& old_name,
+                           const std::string& new_name)
+  {
+    if (octave::application::is_gui_running () && enabled ())
+      instance->do_file_remove (old_name, new_name);
+  }
+
+  static void file_renamed (bool load_new)
+  {
+    if (octave::application::is_gui_running () && enabled ())
+      instance->do_file_renamed (load_new);
+  }
+
   // Preserves pending input.
   static void execute_command_in_terminal (const std::string& command)
   {
@@ -516,6 +530,10 @@
 
   virtual void do_change_directory (const std::string& dir) = 0;
 
+  virtual void do_file_remove (const std::string& old_name,
+                               const std::string& new_name) = 0;
+  virtual void do_file_renamed (bool) = 0;
+
   virtual void do_execute_command_in_terminal (const std::string& command) = 0;
 
   virtual void