annotate libgui/src/m-editor/file-editor-tab.cc @ 15365:b4c32f245da7

GUI: Settings take immediate effect on the m-editor * main-window.cc (main_window::construct): connect settings change to file-editor * file-editor.h (file-editor::notice_settings): new notice settings method * file-editor.cc (file-editor::notice_settings): new notice settings method and pass-through to all file-editor-tabs * file-editor-tab.h (file-editor::notice_settings): new notice settings method * file-editor-tab.c (file_editor_tab::file_editor_tab): removed all settings to file-editor::notice_settings (file-editor::update_lexer): fix in case settings is 0 (should never happen) (file-editor::notice_settings): all settings moved here
author Thorsten Liebig <thorsten.liebig@gmx.de>
date Tue, 11 Sep 2012 22:19:51 +0200
parents 842ab161c10a
children 501a9cc2c68f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
3 Copyright (C) 2011-2012 Jacob Dawid
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
4
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21 */
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
23 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
24 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
25 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
26
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
27 #include "file-editor-tab.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
28 #include "file-editor.h"
15080
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
29 #include "find-dialog.h"
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
30 #include "octave-link.h"
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
31
14873
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
32
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
33 #include <Qsci/qsciapis.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
34 // Not available in the Debian repos yet!
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
35 // #include <Qsci/qscilexeroctave.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
36 #include "lexer-octave-gui.h"
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
37 #include <Qsci/qscilexercpp.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
38 #include <Qsci/qscilexerbash.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
39 #include <Qsci/qscilexerperl.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
40 #include <Qsci/qscilexerbatch.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
41 #include <Qsci/qscilexerdiff.h>
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
42 #include "resource-manager.h"
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
43 #include <QApplication>
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
44 #include <QFileDialog>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
45 #include <QMessageBox>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
46 #include <QTextStream>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
47 #include <QVBoxLayout>
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
48
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
49 file_editor_tab::file_editor_tab(file_editor *fileEditor)
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
50 : QWidget ((QWidget*)fileEditor), octave_event_observer ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
51 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
52 _file_editor = fileEditor;
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
53 _file_name = "";
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
54 _edit_area = new QsciScintilla (this);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
55
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
56 // symbols
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
57 _edit_area->setMarginType (1, QsciScintilla::SymbolMargin);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
58 _edit_area->setMarginSensitivity (1, true);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
59 _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark);
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
60 _edit_area->markerDefine (QPixmap (":/actions/icons/redled.png"),
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
61 breakpoint);
14826
ed0f820c7ce0 Changed QImage to QPixmap to allow compilation with QScintilla2 < 2.6.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14825
diff changeset
62 _edit_area->markerDefine (QPixmap (":/actions/icons/arrow_right.png"),
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
63 debugger_position);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
64
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
65 connect (_edit_area, SIGNAL (marginClicked (int, int,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
66 Qt::KeyboardModifiers)),
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
67 this, SLOT (handle_margin_clicked (int, int,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
68 Qt::KeyboardModifiers)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
69
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
70 // line numbers
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
71 _edit_area->setMarginsForegroundColor(QColor(96,96,96));
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
72 _edit_area->setMarginsBackgroundColor(QColor(232,232,220));
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
73 _edit_area->setMarginType (2, QsciScintilla::TextMargin);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
74
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
75 // code folding
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
76 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
77 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
78
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
79 //highlight current line color
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
80 _edit_area->setCaretLineBackgroundColor(QColor(245,245,245));
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
81
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
82 // other features
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
83 _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
84 _edit_area->setAutoIndent (true);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
85 _edit_area->setIndentationWidth (2);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
86 _edit_area->setIndentationsUseTabs (false);
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
87
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
88 _edit_area->setUtf8 (true);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
89
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
90 // auto completion
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
91 _edit_area->autoCompleteFromAll ();
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
92 _edit_area->setAutoCompletionSource(QsciScintilla::AcsAll);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
93
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
94 QVBoxLayout *layout = new QVBoxLayout ();
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
95 layout->addWidget (_edit_area);
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
96 layout->setMargin (0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
97 setLayout (layout);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
98
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
99 // connect modified signal
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
100 connect (_edit_area, SIGNAL (modificationChanged (bool)),
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
101 this, SLOT (update_window_title (bool)));
14715
b4db843b1f26 Done some extra method renaming to fit the overall octave coding style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
102 connect (_edit_area, SIGNAL (copyAvailable (bool)),
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
103 this, SLOT (handle_copy_available (bool)));
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
104 connect (&_file_system_watcher, SIGNAL (fileChanged (QString)),
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
105 this, SLOT (file_has_changed (QString)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
106
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
107 _file_name = "";
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
108
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
109 notice_settings ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
110 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
111
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
112 bool
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
113 file_editor_tab::copy_available ()
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
114 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
115 return _copy_available;
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
116 }
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
117
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
118 void
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
119 file_editor_tab::event_accepted (octave_event *e)
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
120 {
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
121 if (dynamic_cast<octave_run_file_event*> (e))
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
122 {
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
123 // File was run successfully.
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
124 }
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
125
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
126 if (octave_add_breakpoint_event *abe
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
127 = dynamic_cast<octave_add_breakpoint_event*> (e))
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
128 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
129 // TODO: Check file.
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
130 _edit_area->markerAdd (abe->get_line (), breakpoint);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
131 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
132
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
133 if (octave_remove_breakpoint_event *rbe
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
134 = dynamic_cast<octave_remove_breakpoint_event*> (e))
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
135 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
136 // TODO: Check file.
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
137 _edit_area->markerDelete (rbe->get_line (), breakpoint);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
138 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
139
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
140 if (octave_remove_all_breakpoints_event *rabe
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
141 = dynamic_cast<octave_remove_all_breakpoints_event*> (e))
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
142 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
143 Q_UNUSED (rabe);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
144 _edit_area->markerDeleteAll (breakpoint);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
145 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
146
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
147 delete e;
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
148 }
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
149
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
150 void
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
151 file_editor_tab::event_reject (octave_event *e)
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
152 {
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
153 if (dynamic_cast<octave_run_file_event*> (e))
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
154 {
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
155 // Running file failed.
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
156 }
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
157 delete e;
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
158 }
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
159
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
160 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
161 file_editor_tab::closeEvent (QCloseEvent *event)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
162 {
14795
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14788
diff changeset
163 if (_file_editor->get_main_window ()->is_closing ())
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
164 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
165 // close whole application: save file or not if modified
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
166 check_file_modified ("Closing Octave", 0); // no cancel possible
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
167 event->accept ();
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
168 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
169 else
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
170 {
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
171 // ignore close event if file is not saved and user cancels
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
172 // closing this window
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
173 if (check_file_modified ("Close File",
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
174 QMessageBox::Cancel) == QMessageBox::Cancel)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
175 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
176 event->ignore ();
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
177 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
178 else
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
179 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
180 event->accept();
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
181 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
182 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
183 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
184
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
185 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
186 file_editor_tab::set_file_name (const QString& fileName)
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
187 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
188 _file_name = fileName;
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
189 update_lexer ();
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
190 update_tracked_file ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
191 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
192
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
193 void
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
194 file_editor_tab::handle_margin_clicked(int margin, int line,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
195 Qt::KeyboardModifiers state)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
196 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
197 Q_UNUSED (state);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
198 if (margin == 1)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
199 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
200 unsigned int mask = _edit_area->markersAtLine (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
201
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
202 if (state & Qt::ControlModifier)
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
203 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
204 if (mask && (1 << bookmark))
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
205 _edit_area->markerDelete(line,bookmark);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
206 else
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
207 _edit_area->markerAdd(line,bookmark);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
208 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
209 else
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
210 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
211 if (mask && (1 << breakpoint))
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
212 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
213 request_remove_breakpoint (line);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
214 }
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
215 else
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
216 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
217 request_add_breakpoint (line);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
218 }
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
219 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
220 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
221 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
222
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
223 void
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
224 file_editor_tab::update_lexer ()
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
225 {
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
226 QsciLexer *lexer = _edit_area->lexer ();
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
227 delete lexer;
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
228
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
229 if (_file_name.endsWith (".m") || _file_name.endsWith (".M"))
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
230 {
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
231 lexer = new lexer_octave_gui ();
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
232
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
233 // The API info that is used for auto completion
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
234 // TODO: Where to store a file with API info (raw or prepared?)?
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
235 // TODO: Also provide infos on octave-forge functions?
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
236 // TODO: Also provide infos on function parameters?
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
237 // By now, use the keywords-list from syntax highlighting
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
238
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
239 QsciAPIs *lexer_api = new QsciAPIs (lexer);
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
240
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
241 QString keyword;
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
242 QStringList keywordList;
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
243
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
244 // get whole string with all keywords
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
245 keyword = lexer->keywords (1);
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
246 // split into single strings
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
247 keywordList = keyword.split (QRegExp ("\\s+"));
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
248
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
249 int i;
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
250 for (i = 0; i < keywordList.size (); i++)
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
251 {
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
252 // add single strings to the API
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
253 lexer_api->add (keywordList.at (i));
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
254 }
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
255 // prepare API info ... this make take some time
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
256 lexer_api->prepare ();
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
257 }
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
258 else if (_file_name.endsWith (".c")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
259 || _file_name.endsWith (".cc")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
260 || _file_name.endsWith (".cpp")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
261 || _file_name.endsWith (".cxx")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
262 || _file_name.endsWith (".c++")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
263 || _file_name.endsWith (".h")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
264 || _file_name.endsWith (".hh")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
265 || _file_name.endsWith (".hpp")
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
266 || _file_name.endsWith (".h++"))
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
267 {
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
268 lexer = new QsciLexerCPP ();
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
269 }
14873
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
270 else if (_file_name.endsWith (".pl"))
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
271 {
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
272 lexer = new QsciLexerPerl ();
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
273 }
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
274 else if (_file_name.endsWith (".bat"))
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
275 {
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
276 lexer = new QsciLexerBatch ();
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
277 }
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
278 else if (_file_name.endsWith (".diff"))
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
279 {
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
280 lexer = new QsciLexerDiff ();
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
281 }
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
282 else // Default to bash lexer.
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
283 {
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
284 lexer = new QsciLexerBash ();
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
285 }
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
286
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15080
diff changeset
287 QSettings *settings = resource_manager::get_settings ();
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
288
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
289 // Editor font (default or from settings)
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
290 if (settings)
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
291 lexer->setDefaultFont (QFont (
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
292 settings->value ("editor/fontName",
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
293 "Courier").toString (),
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
294 settings->value ("editor/fontSize",
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
295 10).toInt ()));
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
296
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
297 // TODO: Autoindent not working as it should
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
298 lexer->setAutoIndentStyle (QsciScintilla::AiMaintain ||
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
299 QsciScintilla::AiOpening ||
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
300 QsciScintilla::AiClosing);
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
301
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
302 _edit_area->setLexer (lexer);
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
303 }
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
304
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
305 void
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
306 file_editor_tab::request_add_breakpoint (int line)
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
307 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
308 QFileInfo file_info (_file_name);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
309 QString path = file_info.absolutePath ();
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
310 QString function_name = file_info.fileName ();
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
311
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
312 // We have to cut off the suffix, because octave appends it.
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
313 function_name.chop (file_info.suffix ().length () + 1);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
314
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
315 octave_link::instance ()->post_event
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
316 (new octave_add_breakpoint_event (*this,
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
317 path.toStdString (),
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
318 function_name.toStdString (),
14833
422b0b2ce5f8 Second attempt to fix setting breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14832
diff changeset
319 line));
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
320 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
321
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
322 void
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
323 file_editor_tab::request_remove_breakpoint (int line)
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
324 {
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
325 QFileInfo file_info (_file_name);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
326 QString path = file_info.absolutePath ();
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
327 QString function_name = file_info.fileName ();
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
328
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
329 // We have to cut off the suffix, because octave appends it.
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
330 function_name.chop (file_info.suffix ().length () + 1);
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
331
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
332 octave_link::instance ()->post_event
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
333 (new octave_remove_breakpoint_event (*this,
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
334 path.toStdString (),
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
335 function_name.toStdString (),
14833
422b0b2ce5f8 Second attempt to fix setting breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14832
diff changeset
336 line));
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
337 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
338
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
339 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
340 file_editor_tab::comment_selected_text ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
341 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
342 do_comment_selected_text (true);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
343 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
344
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
345 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
346 file_editor_tab::uncomment_selected_text ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
347 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
348 do_comment_selected_text (false);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
349 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
350
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
351 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
352 file_editor_tab::do_comment_selected_text (bool comment)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
353 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
354 if ( _edit_area->hasSelectedText() )
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
355 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
356 int lineFrom, lineTo, colFrom, colTo, i;
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
357 _edit_area->getSelection (&lineFrom,&colFrom,&lineTo,&colTo);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
358 if ( colTo == 0 ) // the beginning of last line is not selected
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
359 lineTo--; // stop at line above
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
360 _edit_area->beginUndoAction ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
361 for ( i=lineFrom; i<=lineTo; i++ )
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
362 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
363 if ( comment )
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
364 _edit_area->insertAt("%",i,0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
365 else
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
366 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
367 QString line(_edit_area->text(i));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
368 if ( line.startsWith("%") )
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
369 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
370 _edit_area->setSelection(i,0,i,1);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
371 _edit_area->removeSelectedText();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
372 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
373 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
374 }
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
375 _edit_area->endUndoAction ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
376 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
377 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
378
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
379 void
15080
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
380 file_editor_tab::find ()
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
381 {
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
382 find_dialog dialog (_edit_area);
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
383 dialog.exec ();
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
384 }
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
385
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
386 void
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
387 file_editor_tab::update_window_title (bool modified)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
388 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
389 QString title(_file_name);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
390 if ( !_long_title )
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
391 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
392 QFileInfo file(_file_name);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
393 title = file.fileName();
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
394 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
395
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
396 if ( modified )
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
397 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
398 emit file_name_changed (title.prepend("* "));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
399 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
400 else
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
401 emit file_name_changed (title);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
402 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
403
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
404 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
405 file_editor_tab::handle_copy_available(bool enableCopy)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
406 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
407 _copy_available = enableCopy;
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
408 emit editor_state_changed ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
409 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
410
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
411 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
412 file_editor_tab::update_tracked_file ()
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
413 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
414 QStringList trackedFiles = _file_system_watcher.files ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
415 if (!trackedFiles.isEmpty ())
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
416 _file_system_watcher.removePaths (trackedFiles);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
417
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
418 if (_file_name != UNNAMED_FILE)
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
419 _file_system_watcher.addPath (_file_name);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
420 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
421
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
422 int
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
423 file_editor_tab::check_file_modified (const QString& msg, int cancelButton)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
424 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
425 int decision = QMessageBox::Yes;
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
426 if (_edit_area->isModified ())
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
427 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
428 // file is modified but not saved, aks user what to do
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
429 decision = QMessageBox::warning (this,
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
430 msg,
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
431 tr ("The file %1\n"
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
432 "has been modified. Do you want to save the changes?").
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
433 arg (_file_name),
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
434 QMessageBox::Save,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
435 QMessageBox::Discard, cancelButton );
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
436 if (decision == QMessageBox::Save)
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
437 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
438 save_file ();
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
439 if (_edit_area->isModified ())
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
440 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
441 // If the user attempted to save the file, but it's still
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
442 // modified, then probably something went wrong, so return
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
443 // cancel for cancel this operation or try to save files
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
444 // as if cancel not possible
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
445 if ( cancelButton )
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
446 return (QMessageBox::Cancel);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
447 else
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
448 save_file_as ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
449 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
450 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
451 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
452 return (decision);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
453 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
454
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
455 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
456 file_editor_tab::remove_bookmark ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
457 {
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
458 _edit_area->markerDeleteAll (bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
459 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
460
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
461 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
462 file_editor_tab::toggle_bookmark ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
463 {
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
464 int line, cur;
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
465 _edit_area->getCursorPosition (&line,&cur);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
466 if ( _edit_area->markersAtLine (line) && (1 << bookmark) )
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
467 _edit_area->markerDelete (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
468 else
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
469 _edit_area->markerAdd (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
470 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
471
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
472 void
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
473 file_editor_tab::next_bookmark()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
474 {
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
475 int line, cur, nextline;
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
476 _edit_area->getCursorPosition (&line, &cur);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
477 if ( _edit_area->markersAtLine (line) && (1 << bookmark) )
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
478 line++; // we have a breakpoint here, so start search from next line
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
479 nextline = _edit_area->markerFindNext (line, (1 << bookmark));
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
480 _edit_area->setCursorPosition (nextline, 0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
481 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
482
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
483 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
484 file_editor_tab::previous_bookmark ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
485 {
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
486 int line, cur, prevline;
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
487 _edit_area->getCursorPosition (&line, &cur);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
488 if ( _edit_area->markersAtLine (line) && (1 << bookmark) )
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
489 line--; // we have a breakpoint here, so start search from prev line
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
490 prevline = _edit_area->markerFindPrevious (line, (1 << bookmark));
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
491 _edit_area->setCursorPosition (prevline, 0);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
492 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
493
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
494 void
14829
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
495 file_editor_tab::remove_all_breakpoints ()
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
496 {
14829
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
497 QFileInfo file_info (_file_name);
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
498 QString path = file_info.absolutePath ();
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
499 QString function_name = file_info.fileName ();
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
500
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
501 // We have to cut off the suffix, because octave appends it.
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
502 function_name.chop (file_info.suffix ().length () + 1);
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
503
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
504 octave_link::instance ()->post_event
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
505 (new octave_remove_all_breakpoints_event (*this,
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
506 path.toStdString (),
e97be88fc478 Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14827
diff changeset
507 function_name.toStdString ()));
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
508 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
509
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
510 void
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
511 file_editor_tab::toggle_breakpoint ()
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
512 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
513 int line, cur;
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
514 _edit_area->getCursorPosition (&line, &cur);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
515 if ( _edit_area->markersAtLine (line) && (1 << breakpoint) )
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
516 request_remove_breakpoint (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
517 else
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
518 request_add_breakpoint (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
519 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
520
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
521 void
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
522 file_editor_tab::next_breakpoint ()
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
523 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
524 int line, cur, nextline;
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
525 _edit_area->getCursorPosition (&line, &cur);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
526 if ( _edit_area->markersAtLine (line) && (1 << breakpoint) )
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
527 line++; // we have a breakpoint here, so start search from next line
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
528 nextline = _edit_area->markerFindNext (line, (1 << breakpoint));
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
529 _edit_area->setCursorPosition (nextline, 0);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
530 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
531
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
532 void
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
533 file_editor_tab::previous_breakpoint ()
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
534 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
535 int line, cur, prevline;
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
536 _edit_area->getCursorPosition (&line, &cur);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
537 if ( _edit_area->markersAtLine (line) && (1 << breakpoint) )
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
538 line--; // we have a breakpoint here, so start search from prev line
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
539 prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint));
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
540 _edit_area->setCursorPosition (prevline, 0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
541 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
542
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
543 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
544 file_editor_tab::cut ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
545 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
546 _edit_area->cut ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
547 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
548
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
549 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
550 file_editor_tab::copy ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
551 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
552 _edit_area->copy ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
553 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
554
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
555 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
556 file_editor_tab::paste ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
557 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
558 _edit_area->paste ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
559 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
560
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
561 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
562 file_editor_tab::undo ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
563 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
564 _edit_area->undo ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
565 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
566
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
567 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
568 file_editor_tab::redo ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
569 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
570 _edit_area->redo ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
571 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
572
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
573 void
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
574 file_editor_tab::set_debugger_position (int line)
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
575 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
576 _edit_area->markerDeleteAll (debugger_position);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
577 if (line > 0)
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
578 {
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
579 _edit_area->markerAdd (line, debugger_position);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
580 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
581 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
582
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
583 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
584 file_editor_tab::set_modified (bool modified)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
585 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
586 _edit_area->setModified (modified);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
587 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
588
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
589 bool
15316
ba243f0234b0 file-editor-tab.cc (file_editor_tab::open_file): Make argument const reference
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15314
diff changeset
590 file_editor_tab::open_file (const QString& dir)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
591 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
592 QString openFileName;
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
593 QFileDialog fileDialog(this);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
594 fileDialog.setNameFilter(SAVE_FILE_FILTER);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
595 fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
596 fileDialog.setViewMode(QFileDialog::Detail);
15312
d81105896288 m-editor: open a new file from the directory of the last active tab
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15286
diff changeset
597 fileDialog.setDirectory(dir);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
598 if (fileDialog.exec () == QDialog::Accepted)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
599 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
600 openFileName = fileDialog.selectedFiles().at(0);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
601 if (openFileName.isEmpty ())
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
602 return false;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
603
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
604 load_file(openFileName);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
605 return true;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
606 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
607 else
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
608 {
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
609 return false;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
610 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
611 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
612
15356
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
613 bool
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
614 file_editor_tab::load_file(const QString& fileName, bool silent)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
615 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
616 if (!_file_editor->isVisible ())
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
617 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
618 _file_editor->show ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
619 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
620
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
621 QFile file (fileName);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
622 if (!file.open (QFile::ReadOnly))
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
623 {
15356
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
624 if (silent==false)
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
625 QMessageBox::warning (this, tr ("Octave Editor"),
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
626 tr ("Could not open file %1 for read:\n%2.").arg (fileName).
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
627 arg (file.errorString ()));
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
628 return false;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
629 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
630
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
631 QTextStream in (&file);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
632 QApplication::setOverrideCursor (Qt::WaitCursor);
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
633 _edit_area->setText (in.readAll ());
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
634 QApplication::restoreOverrideCursor ();
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
635
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
636 set_file_name (fileName);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
637 update_tracked_file ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
638
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
639
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
640 update_window_title (false); // window title (no modification)
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
641 _edit_area->setModified (false); // loaded file is not modified yet
15356
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
642
842ab161c10a GUI: new setting to restore tabs from previous session; allow silent load file
Thorsten Liebig <Thorsten.Liebig@gmx.de>
parents: 15355
diff changeset
643 return true;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
644 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
645
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
646 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
647 file_editor_tab::new_file ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
648 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
649 if (!_file_editor->isVisible ())
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
650 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
651 _file_editor->show ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
652 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
653
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
654 set_file_name (UNNAMED_FILE);
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
655 update_window_title (false); // window title (no modification)
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
656 _edit_area->setText ("");
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
657 _edit_area->setModified (false); // new file is not modified yet
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
658 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
659
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
660 bool file_editor_tab::save_file()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
661 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
662 return save_file (_file_name);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
663 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
664
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
665 bool
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
666 file_editor_tab::save_file (const QString& saveFileName)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
667 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
668 // it is a new file with the name "<unnamed>" -> call saveFielAs
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
669 if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ())
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
670 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
671 return save_file_as();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
672 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
673
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
674 QStringList watched_files = _file_system_watcher.files();
14796
e10d7bcfdd9e Now recognizing more symbol types in workspace view. Fixed bug with file system watcher complaining with new files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14795
diff changeset
675 if (!watched_files.isEmpty ())
e10d7bcfdd9e Now recognizing more symbol types in workspace view. Fixed bug with file system watcher complaining with new files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14795
diff changeset
676 _file_system_watcher.removePaths(watched_files);
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
677
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
678 // open the file for writing
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
679 QFile file (saveFileName);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
680 if (!file.open (QFile::WriteOnly))
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
681 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
682 QMessageBox::warning (this, tr ("Octave Editor"),
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
683 tr ("Could not open file %1 for write:\n%2.").
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
684 arg (saveFileName).arg (file.errorString ()));
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
685 _file_system_watcher.addPaths (watched_files);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
686 return false;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
687 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
688
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
689 // save the contents into the file
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
690 QTextStream out (&file);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
691 QApplication::setOverrideCursor (Qt::WaitCursor);
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
692 out << _edit_area->text ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
693 QApplication::restoreOverrideCursor ();
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
694
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
695 // save file name for later use
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
696 _file_name = saveFileName;
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
697 // set the window title to actual file name (not modified)
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
698 update_window_title (false);
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
699 // files is save -> not modified
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
700 _edit_area->setModified (false);
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
701 file.close();
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
702
14796
e10d7bcfdd9e Now recognizing more symbol types in workspace view. Fixed bug with file system watcher complaining with new files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14795
diff changeset
703 if (!watched_files.isEmpty ())
e10d7bcfdd9e Now recognizing more symbol types in workspace view. Fixed bug with file system watcher complaining with new files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14795
diff changeset
704 _file_system_watcher.addPaths (watched_files);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
705 return true;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
706 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
707
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
708 bool
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
709 file_editor_tab::save_file_as ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
710 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
711 QString saveFileName(_file_name);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
712 QFileDialog fileDialog(this);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
713 if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ())
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
714 {
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
715 QString directory = QString::fromStdString
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
716 (octave_link::instance ()->get_last_working_directory ());
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
717
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
718 if (directory.isEmpty ())
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
719 {
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
720 directory = QDir::homePath ();
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
721 }
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
722
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
723 fileDialog.setDirectory (directory);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
724 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
725 else
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
726 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
727 fileDialog.selectFile (saveFileName);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
728 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
729 fileDialog.setNameFilter (SAVE_FILE_FILTER);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
730 fileDialog.setDefaultSuffix ("m");
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
731 fileDialog.setAcceptMode (QFileDialog::AcceptSave);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
732 fileDialog.setViewMode (QFileDialog::Detail);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
733
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
734 if (fileDialog.exec ())
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
735 {
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
736 saveFileName = fileDialog.selectedFiles ().at (0);
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
737 if (saveFileName.isEmpty ())
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
738 return false;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
739
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
740 return save_file (saveFileName);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
741 }
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
742
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
743 return false;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
744 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
745
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
746 void
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
747 file_editor_tab::run_file ()
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
748 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
749 if (_edit_area->isModified ())
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
750 save_file(_file_name);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
751
14830
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
752 QFileInfo file_info (_file_name);
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
753 QString path = file_info.absolutePath ();
14890
3ad363879015 Fixed bug with error message about missing arguments when running a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14877
diff changeset
754 //QString current_path = QString::fromStdString
14830
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
755 (octave_link::instance ()->get_last_working_directory ());
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
756 QString function_name = file_info.fileName ();
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
757
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
758 // We have to cut off the suffix, because octave appends it.
41b86dc61306 Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14829
diff changeset
759 function_name.chop (file_info.suffix ().length () + 1);
14877
bc6c099eacc0 Removed cd'ing back after running a script for compatibility with less.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14874
diff changeset
760 _file_editor->terminal ()->sendText (QString ("cd \'%1\'\n%2\n")
14890
3ad363879015 Fixed bug with error message about missing arguments when running a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14877
diff changeset
761 .arg(path).arg (function_name));
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
762 // TODO: Sending a run event crashes for long scripts. Find out why.
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
763 // octave_link::instance ()
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14796
diff changeset
764 // ->post_event (new octave_run_file_event (*this, _file_name.toStdString ()));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
765 }
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
766
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
767 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
768 file_editor_tab::file_has_changed (const QString& fileName)
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
769 {
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
770 Q_UNUSED (fileName);
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
771 if (QFile::exists (_file_name))
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
772 {
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
773 // Prevent popping up multiple message boxes when the file has
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
774 // been changed multiple times.
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
775 static bool alreadyAsking = false;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
776 if (!alreadyAsking)
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
777 {
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
778 alreadyAsking = true;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
779
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
780 int decision =
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
781 QMessageBox::warning (this, tr ("Octave Editor"),
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
782 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?").
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
783 arg (_file_name), QMessageBox::Yes,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
784 QMessageBox::No);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
785
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
786 if (decision == QMessageBox::Yes)
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
787 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
788 load_file (_file_name);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
789 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
790
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
791 alreadyAsking = false;
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
792 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
793 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
794 else
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
795 {
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
796 int decision =
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
797 QMessageBox::warning (this, tr ("Octave Editor"),
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
798 tr ("It seems that \'%1\' has been deleted or renamed. Do you want to save it now?").
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
799 arg (_file_name), QMessageBox::Save,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
800 QMessageBox::Close);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
801 if (decision == QMessageBox::Save)
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
802 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
803 if (!save_file_as ())
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
804 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
805 set_file_name (UNNAMED_FILE);
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
806 update_window_title (true); // window title (no modification)
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
807 set_modified (true);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
808 update_tracked_file ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
809 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
810 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
811 else
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
812 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
813 emit close_request ();
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
814 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
815 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
816 }
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
817
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
818 void
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
819 file_editor_tab::notice_settings ()
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
820 {
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
821 QSettings *settings = resource_manager::get_settings ();
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
822
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
823 if (settings==NULL)
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
824 return; // this shouldn't happen!
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
825
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
826 _edit_area->setCaretLineVisible(settings->value ("editor/highlightCurrentLine",true).toBool ());
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
827
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
828 if (settings->value ("editor/codeCompletion",true).toBool ())
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
829 _edit_area->setAutoCompletionThreshold (1);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
830 else
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
831 _edit_area->setAutoCompletionThreshold (-1);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
832
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
833 QFont font( settings->value ("editor/fontName","Courier").toString () ,
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
834 settings->value ("editor/fontSize",10).toInt () );
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
835 if (settings->value ("editor/showLineNumbers",true).toBool ())
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
836 {
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
837 _edit_area->setMarginLineNumbers (2, true);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
838 _edit_area->setMarginsFont( font );
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
839 QFontMetrics metrics( font );
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
840 _edit_area->setMarginWidth(2, metrics.width("9999"));
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
841 }
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
842 else
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
843 {
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
844 _edit_area->setMarginLineNumbers (2, false);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
845 _edit_area->setMarginWidth(2, 0);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
846 }
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
847
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
848 update_lexer ();
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
849
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
850 _long_title = settings->value ("editor/longWindowTitle",false).toBool ();
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
851
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
852 update_window_title (false);
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
853 }