Mercurial > hg > octave-nkf
annotate gui/src/m-editor/file-editor-tab.cc @ 14869:db3c84d38345 gui
Now supporting c/cc/cpp syntax highlighting.
* file-editor-tab: Added updating lexer dependent on the filename suffix..
* file-editor: Removed initializig a single lexer for all editor tabs.
author | Jacob Dawid <jacob.dawid@gmail.com> |
---|---|
date | Tue, 17 Jul 2012 11:38:54 -0400 |
parents | 422b0b2ce5f8 |
children | 355d6c165df0 |
rev | line source |
---|---|
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2 * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
3 * |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 * This program is free software: you can redistribute it and/or modify |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
6 * published by the Free Software Foundation, either version 3 of the |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 * License, or (at your option) any later version. |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
8 * |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
13 * |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 */ |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
18 #include "file-editor-tab.h" |
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
19 #include "file-editor.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
|
20 #include "octave-link.h" |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
21 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
22 #include "resource-manager.h" |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 #include <QMessageBox> |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 #include <QVBoxLayout> |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
26 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
|
27 : 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
|
28 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
29 QSettings *settings = resource_manager::instance ()->get_settings (); |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
30 _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
|
31 _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
|
32 _edit_area = new QsciScintilla (this); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
33 |
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
|
34 // 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
|
35 _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
|
36 _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
|
37 _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark); |
14826
ed0f820c7ce0
Changed QImage to QPixmap to allow compilation with QScintilla2 < 2.6.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14825
diff
changeset
|
38 _edit_area->markerDefine (QPixmap (":/actions/icons/redled.png"), breakpoint); |
ed0f820c7ce0
Changed QImage to QPixmap to allow compilation with QScintilla2 < 2.6.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14825
diff
changeset
|
39 _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
|
40 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
|
41 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
42 connect (_edit_area, SIGNAL (marginClicked (int, int, Qt::KeyboardModifiers)), |
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
43 this, SLOT (handle_margin_clicked (int, int, Qt::KeyboardModifiers))); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 // 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
|
46 _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
|
47 _edit_area->setMarginsBackgroundColor(QColor(232,232,220)); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
48 if (settings->value ("editor/showLineNumbers",true).toBool ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
49 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
50 QFont marginFont( settings->value ("editor/fontName","Courier").toString () , |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
51 settings->value ("editor/fontSize",10).toInt () ); |
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 _edit_area->setMarginsFont( marginFont ); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
53 QFontMetrics metrics(marginFont); |
14709
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->setMarginType (2, QsciScintilla::TextMargin); |
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
|
55 _edit_area->setMarginWidth(2, metrics.width("9999")); |
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 _edit_area->setMarginLineNumbers (2, true); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
57 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
58 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
59 // 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
|
60 _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
|
61 _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
|
62 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 // other features |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 if (settings->value ("editor/highlightCurrentLine",true).toBool ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
66 _edit_area->setCaretLineVisible(true); |
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
67 _edit_area->setCaretLineBackgroundColor(QColor(245,245,245)); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 } |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
69 _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
|
70 _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
|
71 _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
|
72 _edit_area->setIndentationsUseTabs (false); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 if (settings->value ("editor/codeCompletion",true).toBool ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
74 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
75 _edit_area->autoCompleteFromAll (); |
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->setAutoCompletionSource(QsciScintilla::AcsAll); |
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->setAutoCompletionThreshold (1); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 } |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
79 _edit_area->setUtf8 (true); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
80 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 layout->setMargin (0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 setLayout (layout); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
85 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
86 // 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
94 _file_name = ""; |
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
|
95 update_window_title (false); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
97 |
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
|
98 bool |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
99 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
|
100 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
101 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
|
102 } |
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
|
103 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
104 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
|
105 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
|
106 { |
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
|
107 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
|
108 { |
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
|
109 // 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
|
110 } |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
111 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
112 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
|
113 = 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
|
114 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
115 // TODO: Check file. |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
116 _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
|
117 } |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
118 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
119 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
|
120 = 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
|
121 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
122 // TODO: Check file. |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
123 _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
|
124 } |
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_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
|
127 = 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
|
128 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
129 Q_UNUSED (rabe); |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
130 _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
|
131 } |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
132 |
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
|
133 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
|
134 } |
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
|
135 |
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
|
136 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
|
137 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
|
138 { |
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
|
139 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
|
140 { |
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
|
141 // 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
|
142 } |
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
|
143 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
|
144 } |
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
|
145 |
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
|
146 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
|
147 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
|
148 { |
14795
e3ae0850b105
Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14788
diff
changeset
|
149 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
|
150 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
151 // 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
|
152 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
|
153 event->accept (); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
154 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
155 else |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
156 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
157 // ignore close event if file is not saved and user cancels closing this window |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
158 if (check_file_modified ("Close File", QMessageBox::Cancel) == QMessageBox::Cancel) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
159 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
160 event->ignore (); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
161 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
162 else |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
164 event->accept(); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
165 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
166 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
167 } |
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 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
|
170 file_editor_tab::set_file_name (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
|
171 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
172 _file_name = fileName; |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
173 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
|
174 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
|
175 } |
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
|
176 |
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
|
177 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
|
178 file_editor_tab::handle_margin_clicked(int margin, int line, Qt::KeyboardModifiers state) |
14676
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 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
|
181 if (margin == 1) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
182 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
183 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
|
184 |
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
|
185 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
|
186 { |
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
|
187 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
|
188 _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
|
189 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
|
190 _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
|
191 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
192 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
|
193 { |
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
|
194 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
|
195 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
196 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
|
197 } |
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 else |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
199 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
200 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
|
201 } |
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
|
202 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
203 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
204 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
205 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
206 void |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
207 file_editor_tab::update_lexer () |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
208 { |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
209 QsciLexer *lexer = _edit_area->lexer (); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
210 delete lexer; |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
211 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
212 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
|
213 { |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
214 lexer = new lexer_octave_gui (); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
215 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
216 // 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
|
217 // 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
|
218 // 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
|
219 // 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
|
220 // 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
|
221 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
222 QsciAPIs *lexer_api = new QsciAPIs (lexer); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
223 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
224 QString keyword; |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
225 QStringList keywordList; |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
226 keyword = lexer->keywords (1); // get whole string with all keywords |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
227 keywordList = keyword.split (QRegExp ("\\s+")); // split into single strings |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
228 int i; |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
229 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
|
230 { |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
231 lexer_api->add (keywordList.at (i)); // add single strings to the API |
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 lexer_api->prepare (); // prepare API info ... this make take some time |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
234 } |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
235 else if (_file_name.endsWith (".c") || _file_name.endsWith (".cc") || _file_name.endsWith (".cpp")) |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
236 { |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
237 lexer = new QsciLexerCPP (); |
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 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
240 QSettings *settings = resource_manager::instance ()->get_settings (); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
241 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
242 // Editor font (default or from settings) |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
243 lexer->setDefaultFont (QFont ( |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
244 settings->value ("editor/fontName","Courier").toString (), |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
245 settings->value ("editor/fontSize",10).toInt ())); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
246 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
247 // 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
|
248 lexer->setAutoIndentStyle (QsciScintilla::AiMaintain || |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
249 QsciScintilla::AiOpening || |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
250 QsciScintilla::AiClosing); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
251 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
252 _edit_area->setLexer (lexer); |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
253 } |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
254 |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
255 void |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
256 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
|
257 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
262 // 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
|
263 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
|
264 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
265 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
|
266 (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
|
267 path.toStdString (), |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
268 function_name.toStdString (), |
14833
422b0b2ce5f8
Second attempt to fix setting breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14832
diff
changeset
|
269 line)); |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
270 } |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
271 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
272 void |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
273 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
|
274 { |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
279 // 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
|
280 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
|
281 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
282 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
|
283 (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
|
284 path.toStdString (), |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
285 function_name.toStdString (), |
14833
422b0b2ce5f8
Second attempt to fix setting breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14832
diff
changeset
|
286 line)); |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
287 } |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
288 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
289 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
|
290 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
|
291 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
292 do_comment_selected_text (true); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
293 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
294 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
295 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
|
296 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
|
297 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
298 do_comment_selected_text (false); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 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
|
302 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
|
303 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
304 if ( _edit_area->hasSelectedText() ) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
305 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
306 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
|
307 _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
|
308 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
|
309 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
|
310 _edit_area->beginUndoAction (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
311 for ( i=lineFrom; i<=lineTo; i++ ) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
312 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
313 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
|
314 _edit_area->insertAt("%",i,0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
315 else |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
316 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
317 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
|
318 if ( line.startsWith("%") ) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
319 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
320 _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
|
321 _edit_area->removeSelectedText(); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
322 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
323 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
324 } |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
325 _edit_area->endUndoAction (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
326 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
327 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
328 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
329 void |
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
|
330 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
|
331 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
332 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
|
333 if ( !_long_title ) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
334 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
335 QFileInfo file(_file_name); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
336 title = file.fileName(); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
337 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
338 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
339 if ( modified ) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
340 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
341 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
|
342 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
343 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
|
344 emit file_name_changed (title); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
345 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
346 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
347 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
|
348 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
|
349 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
350 _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
|
351 emit editor_state_changed (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
352 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
353 |
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
|
354 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
|
355 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
|
356 { |
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 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
|
358 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
|
359 _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
|
360 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
361 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
|
362 _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
|
363 } |
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
|
364 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
365 int |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
366 file_editor_tab::check_file_modified (QString msg, int cancelButton) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
367 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
368 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
|
369 if (_edit_area->isModified ()) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
370 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
371 // 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
|
372 decision = QMessageBox::warning (this, |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
373 msg, |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
374 tr ("The file %1\n" |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
375 "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
|
376 arg (_file_name), |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
377 QMessageBox::Save, QMessageBox::Discard, cancelButton ); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
378 if (decision == QMessageBox::Save) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
379 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
380 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
|
381 if (_edit_area->isModified ()) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
382 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
383 // If the user attempted to save the file, but it's still |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
384 // modified, then probably something went wrong, so return cancel |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
385 // for cancel this operation or try to save files as if cancel not |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
386 // possible |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
387 if ( cancelButton ) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
388 return (QMessageBox::Cancel); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
389 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
|
390 save_file_as (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
391 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
392 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
393 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
394 return (decision); |
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 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
397 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
|
398 file_editor_tab::remove_bookmark () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
399 { |
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
|
400 _edit_area->markerDeleteAll (bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
401 } |
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 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
|
404 file_editor_tab::toggle_bookmark () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
405 { |
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
|
406 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
|
407 _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
|
408 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
|
409 _edit_area->markerDelete (line, bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
410 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
|
411 _edit_area->markerAdd (line, bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
412 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
413 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
414 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
|
415 file_editor_tab::next_bookmark() |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
416 { |
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
|
417 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
|
418 _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
|
419 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
|
420 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
|
421 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
|
422 _edit_area->setCursorPosition (nextline, 0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
423 } |
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 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
|
426 file_editor_tab::previous_bookmark () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
427 { |
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
|
428 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
|
429 _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
|
430 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
|
431 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
|
432 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
|
433 _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
|
434 } |
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
|
435 |
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
|
436 void |
14829
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
437 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
|
438 { |
14829
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
439 QFileInfo file_info (_file_name); |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
440 QString path = file_info.absolutePath (); |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
441 QString function_name = file_info.fileName (); |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
442 |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
443 // 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
|
444 function_name.chop (file_info.suffix ().length () + 1); |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
445 |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
446 octave_link::instance ()->post_event |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
447 (new octave_remove_all_breakpoints_event (*this, |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
448 path.toStdString (), |
e97be88fc478
Fixed removing all breakpoints.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14827
diff
changeset
|
449 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
|
450 } |
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
|
451 |
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
|
452 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
|
453 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
|
454 { |
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
|
455 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
|
456 _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
|
457 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
|
458 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
|
459 else |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
460 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
|
461 } |
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
|
462 |
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
|
463 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
|
464 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
|
465 { |
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 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
|
467 _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
|
468 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
|
469 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
|
470 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
|
471 _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
|
472 } |
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 |
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
|
474 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
|
475 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
|
476 { |
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 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
|
478 _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
|
479 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
|
480 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
|
481 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
|
482 _edit_area->setCursorPosition (prevline, 0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
483 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
484 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
485 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
|
486 file_editor_tab::cut () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
487 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
488 _edit_area->cut (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
489 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
490 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
491 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
|
492 file_editor_tab::copy () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
493 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
494 _edit_area->copy (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
495 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
496 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
497 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
|
498 file_editor_tab::paste () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
499 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
500 _edit_area->paste (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
501 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
502 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
503 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
|
504 file_editor_tab::undo () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
505 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
506 _edit_area->undo (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
507 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
508 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
509 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
|
510 file_editor_tab::redo () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
511 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
512 _edit_area->redo (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
513 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
514 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
515 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
|
516 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
|
517 { |
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
|
518 _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
|
519 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
|
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 _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
|
522 } |
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 |
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 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
|
526 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
|
527 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
528 _edit_area->setModified (modified); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
529 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
530 |
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
|
531 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
|
532 file_editor_tab::open_file () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
533 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
534 QString openFileName; |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
535 QFileDialog fileDialog(this); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
536 fileDialog.setNameFilter(SAVE_FILE_FILTER); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
537 fileDialog.setAcceptMode(QFileDialog::AcceptOpen); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
538 fileDialog.setViewMode(QFileDialog::Detail); |
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
|
539 if (fileDialog.exec () == QDialog::Accepted) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
540 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
541 openFileName = fileDialog.selectedFiles().at(0); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
542 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
|
543 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
|
544 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
545 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
|
546 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
|
547 } |
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
|
548 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
|
549 { |
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
|
550 return false; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
551 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
552 } |
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 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
|
555 file_editor_tab::load_file (QString fileName) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
556 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
557 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
|
558 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
559 _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
|
560 } |
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
|
561 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
562 QFile file (fileName); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
563 if (!file.open (QFile::ReadOnly)) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
564 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
565 QMessageBox::warning (this, tr ("Octave Editor"), |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
566 tr ("Could not open file %1 for read:\n%2.").arg (fileName). |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
567 arg (file.errorString ())); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
568 return; |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
569 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
570 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
571 QTextStream in (&file); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
572 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
|
573 _edit_area->setText (in.readAll ()); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
574 QApplication::restoreOverrideCursor (); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
575 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
576 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
|
577 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
|
578 |
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
|
579 |
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
|
580 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
|
581 _edit_area->setModified (false); // loaded file is not modified yet |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
582 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
583 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
584 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
|
585 file_editor_tab::new_file () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
586 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
587 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
|
588 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
589 _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
|
590 } |
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
|
591 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
592 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
|
593 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
|
594 _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
|
595 _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
|
596 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
597 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
598 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
|
599 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
600 return save_file (_file_name); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
601 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
602 |
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
|
603 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
|
604 file_editor_tab::save_file (QString saveFileName) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
605 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
606 // 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
|
607 if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
608 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
609 return save_file_as(); |
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 |
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
|
612 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
|
613 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
|
614 _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
|
615 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
616 // open the file for writing |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
617 QFile file (saveFileName); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
618 if (!file.open (QFile::WriteOnly)) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
619 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
620 QMessageBox::warning (this, tr ("Octave Editor"), |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
621 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
|
622 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
|
623 _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
|
624 return false; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
625 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
626 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
627 // save the contents into the file |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
628 QTextStream out (&file); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
629 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
|
630 out << _edit_area->text (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
631 QApplication::restoreOverrideCursor (); |
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
|
632 _file_name = saveFileName; // save file name for later use |
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
|
633 update_window_title (false); // set the window title to actual file name (not 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
|
634 _edit_area->setModified (false); // files is save -> not modified |
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
|
635 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
|
636 |
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
|
637 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
|
638 _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
|
639 return true; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
640 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
641 |
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
|
642 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
|
643 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
|
644 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
645 QString saveFileName(_file_name); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
646 QFileDialog fileDialog(this); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
647 if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
648 { |
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
|
649 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
|
650 (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
|
651 |
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
|
652 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
|
653 { |
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
|
654 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
|
655 } |
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
|
656 |
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
|
657 fileDialog.setDirectory (directory); |
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 else |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
660 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
661 fileDialog.selectFile (saveFileName); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
662 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
663 fileDialog.setNameFilter (SAVE_FILE_FILTER); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
664 fileDialog.setDefaultSuffix ("m"); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
665 fileDialog.setAcceptMode (QFileDialog::AcceptSave); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
666 fileDialog.setViewMode (QFileDialog::Detail); |
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 if (fileDialog.exec ()) |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
669 { |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
670 saveFileName = fileDialog.selectedFiles ().at (0); |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
671 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
|
672 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
|
673 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
674 return save_file (saveFileName); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
675 } |
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
|
676 |
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
|
677 return false; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
678 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
679 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
680 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
|
681 file_editor_tab::run_file () |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
682 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
683 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
|
684 save_file(_file_name); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
685 |
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
|
686 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
|
687 QString path = file_info.absolutePath (); |
41b86dc61306
Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14829
diff
changeset
|
688 QString current_path = QString::fromStdString |
41b86dc61306
Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14829
diff
changeset
|
689 (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
|
690 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
|
691 |
41b86dc61306
Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14829
diff
changeset
|
692 // 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
|
693 function_name.chop (file_info.suffix ().length () + 1); |
41b86dc61306
Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14829
diff
changeset
|
694 _file_editor->terminal ()->sendText (QString ("cd \'%1\'\n%2\ncd \'%3\'\n\n") |
41b86dc61306
Removed run command, instead cding into the script directory and executing script directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14829
diff
changeset
|
695 .arg(path).arg (function_name).arg (current_path)); |
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
|
696 // 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
|
697 // 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
|
698 // ->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
|
699 } |
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
|
700 |
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
|
701 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
|
702 file_editor_tab::file_has_changed (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
|
703 { |
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
|
704 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
|
705 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
|
706 { |
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
|
707 // Prevent popping up multiple message boxes when the file has been changed multiple times. |
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 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
|
709 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
|
710 { |
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
|
711 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
|
712 |
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
|
713 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
|
714 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
|
715 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
716 arg (_file_name), QMessageBox::Yes, 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
|
717 |
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
|
718 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
|
719 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
720 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
|
721 } |
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
|
722 |
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
|
723 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
|
724 } |
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
|
725 } |
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
|
726 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
|
727 { |
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
|
728 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
|
729 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
|
730 tr ("It seems that \'%1\' has been deleted or renamed. Do you want to save it now?"). |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
731 arg (_file_name), QMessageBox::Save, 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
|
732 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
|
733 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
734 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
|
735 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 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
|
740 } |
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
|
741 } |
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 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
|
743 { |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
744 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
|
745 } |
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
|
746 } |
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
|
747 } |