Mercurial > hg > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
16406:7779d9947366 | 16407:4d438dffbfac |
---|---|
34 #include <QFont> | 34 #include <QFont> |
35 #include <QFileDialog> | 35 #include <QFileDialog> |
36 #include <QMessageBox> | 36 #include <QMessageBox> |
37 #include <QStyle> | 37 #include <QStyle> |
38 #include <QTextStream> | 38 #include <QTextStream> |
39 #include <QProcess> | |
39 | 40 |
40 #include "octave-link.h" | 41 #include "octave-link.h" |
41 | 42 |
42 file_editor::file_editor (QWidget *p) | 43 file_editor::file_editor (QWidget *p) |
43 : file_editor_interface (p) | 44 : file_editor_interface (p) |
149 void | 150 void |
150 file_editor::request_open_file (const QString& openFileName, int line, | 151 file_editor::request_open_file (const QString& openFileName, int line, |
151 bool debug_pointer, | 152 bool debug_pointer, |
152 bool dbstop_marker, bool insert) | 153 bool dbstop_marker, bool insert) |
153 { | 154 { |
155 // Check if the user wants to use a custom file editor. | |
156 QSettings *settings = resource_manager::get_settings (); | |
157 if (settings->value ("useCustomFileEditor").toBool ()) | |
158 { | |
159 QString editor = settings->value ("customFileEditor").toString (); | |
160 editor.replace ("%f",openFileName); | |
161 editor.replace ("%l",QString::number (line)); | |
162 QProcess::startDetached (editor); | |
163 if (line < 0) | |
164 handle_mru_add_file(QDir::cleanPath (openFileName)); | |
165 return; | |
166 } | |
167 | |
154 if (openFileName.isEmpty ()) | 168 if (openFileName.isEmpty ()) |
155 { | 169 { |
156 // ?? Not sure this will happen. This routine isn't even called | 170 // ?? Not sure this will happen. This routine isn't even called |
157 // if the user hasn't selected a file. | 171 // if the user hasn't selected a file. |
158 } | 172 } |