diff libgui/src/m-editor/file-editor.cc @ 16407:4d438dffbfac

gui: call external editor when opening a file and custom editor is selected * file-editor.cc(request_open_file): call custom editor if desired * settings-dialog.ui: custom editor command with %f and %l for file and line
author Torsten <ttl@justmail.de>
date Mon, 01 Apr 2013 21:19:23 +0200
parents f9a737fd8829
children 28136851099a
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc
+++ b/libgui/src/m-editor/file-editor.cc
@@ -36,6 +36,7 @@
 #include <QMessageBox>
 #include <QStyle>
 #include <QTextStream>
+#include <QProcess>
 
 #include "octave-link.h"
 
@@ -151,6 +152,19 @@
                                 bool debug_pointer,
                                 bool dbstop_marker, bool insert)
 {
+  // Check if the user wants to use a custom file editor.
+  QSettings *settings = resource_manager::get_settings ();
+  if (settings->value ("useCustomFileEditor").toBool ())
+    {
+      QString editor = settings->value ("customFileEditor").toString ();
+      editor.replace ("%f",openFileName);
+      editor.replace ("%l",QString::number (line));
+      QProcess::startDetached (editor);
+      if (line < 0)
+        handle_mru_add_file(QDir::cleanPath (openFileName));
+      return;
+    }
+
   if (openFileName.isEmpty ())
     {
       // ??  Not sure this will happen.  This routine isn't even called