Mercurial > octave-nkf
annotate libgui/src/m-editor/file-editor-tab.cc @ 16704:e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
* file-editor-tab.h: new slot save_apis_info, class variable for lexer's apis
* file-editor-tab.cc(update_lexer): cancel any existing apis preparation,
try to load prepared apis information or prepare and save it
(save_apis_info): new slot for saving apis info when preparation is finished
(constructor): initialize class variable for apis to zero
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 27 May 2013 21:41:57 +0200 |
parents | 5cf19370011d |
children | 96ed7ab44e2e |
rev | line source |
---|---|
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
1 /* |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
2 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
3 Copyright (C) 2011-2012 Jacob Dawid |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
4 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
5 This file is part of Octave. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
6 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
10 option) any later version. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
15 for more details. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
16 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
20 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
21 */ |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
22 |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
24 #include <config.h> |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
25 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
26 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
27 #ifdef HAVE_QSCINTILLA |
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
28 |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
29 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
30 #define HAVE_LEXER_OCTAVE |
16646
025bc6b5080e
use QScintilla's lexer for highlighting Octave programs
John W. Eaton <jwe@octave.org>
parents:
16638
diff
changeset
|
31 #include <Qsci/qscilexeroctave.h> |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
32 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
33 #define HAVE_LEXER_MATLAB |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
34 #include <Qsci/qscilexermatlab.h> |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
35 #endif |
14873
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
36 #include <Qsci/qscilexercpp.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
37 #include <Qsci/qscilexerbash.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
38 #include <Qsci/qscilexerperl.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
39 #include <Qsci/qscilexerbatch.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
40 #include <Qsci/qscilexerdiff.h> |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
41 #include <Qsci/qsciprinter.h> |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
42 #include "resource-manager.h" |
15257
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
43 #include <QApplication> |
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
44 #include <QFileDialog> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 #include <QMessageBox> |
15257
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
46 #include <QTextStream> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
47 #include <QVBoxLayout> |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
48 #include <QInputDialog> |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
49 #include <QPrintDialog> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
50 |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
51 #include "file-editor-tab.h" |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
52 #include "file-editor.h" |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
53 |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
54 #include "debug.h" |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
55 #include "octave-qt-link.h" |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
56 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
57 // Make parent null for the file editor tab so that warning |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
58 // WindowModal messages don't affect grandparents. |
16558 | 59 file_editor_tab::file_editor_tab (const QString& directory_arg) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
60 { |
16558 | 61 QString directory = directory_arg; |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
62 _lexer_apis = 0; |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
63 _app_closing = false; |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
64 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
65 // Make sure there is a slash at the end of the directory name |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
66 // for identification when saved later. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
67 if (directory.count () && directory.at (directory.count () - 1) != '/') |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
68 directory.append ("/"); |
16558 | 69 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
70 _file_name = directory; |
16558 | 71 |
14709
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 = new QsciScintilla (this); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
74 // Leave the find dialog box out of memory until requested. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
75 _find_dialog = 0; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
76 _find_dialog_is_visible = false; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
77 |
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
|
78 // 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
|
79 _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
|
80 _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
|
81 _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark); |
15045
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
82 _edit_area->markerDefine (QPixmap (":/actions/icons/redled.png"), |
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
83 breakpoint); |
14826
ed0f820c7ce0
Changed QImage to QPixmap to allow compilation with QScintilla2 < 2.6.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14825
diff
changeset
|
84 _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
|
85 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
|
86 |
15045
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
87 connect (_edit_area, SIGNAL (marginClicked (int, int, |
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
88 Qt::KeyboardModifiers)), |
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
89 this, SLOT (handle_margin_clicked (int, int, |
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
90 Qt::KeyboardModifiers))); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
91 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
92 // line numbers |
16558 | 93 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96)); |
94 _edit_area->setMarginsBackgroundColor (QColor (232, 232, 220)); | |
15365
b4c32f245da7
GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
15356
diff
changeset
|
95 _edit_area->setMarginType (2, QsciScintilla::TextMargin); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
96 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
97 // 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
|
98 _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
|
99 _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
|
100 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
101 // other features |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
102 _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
|
103 _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
|
104 _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
|
105 _edit_area->setIndentationsUseTabs (false); |
15365
b4c32f245da7
GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
15356
diff
changeset
|
106 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
107 _edit_area->setUtf8 (true); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
108 |
15365
b4c32f245da7
GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
15356
diff
changeset
|
109 // auto completion |
b4c32f245da7
GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
15356
diff
changeset
|
110 _edit_area->autoCompleteFromAll (); |
16558 | 111 _edit_area->setAutoCompletionSource (QsciScintilla::AcsAll); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
112 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
113 QVBoxLayout *edit_area_layout = new QVBoxLayout (); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
114 edit_area_layout->addWidget (_edit_area); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
115 edit_area_layout->setMargin (0); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
116 setLayout (edit_area_layout); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
117 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
118 // 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
|
119 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
|
120 this, SLOT (update_window_title (bool))); |
16558 | 121 |
14715
b4db843b1f26
Done some extra method renaming to fit the overall octave coding style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
122 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
|
123 this, SLOT (handle_copy_available (bool))); |
16558 | 124 |
125 connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)), | |
126 this, SLOT (file_has_changed (const QString&))); | |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
127 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
128 QSettings *settings = resource_manager::get_settings (); |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
129 if (settings) |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
130 notice_settings (settings); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
131 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
132 |
16558 | 133 file_editor_tab::~file_editor_tab (void) |
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
|
134 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
135 // Destroy items attached to _edit_area. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
136 QsciLexer *lexer = _edit_area->lexer (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
137 if (lexer) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
138 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
139 delete lexer; |
16558 | 140 _edit_area->setLexer (0); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
141 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
142 if (_find_dialog) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
143 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
144 delete _find_dialog; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
145 _find_dialog = 0; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
146 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
147 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
148 // Destroy _edit_area. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
149 delete _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
|
150 } |
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
|
151 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
152 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
153 file_editor_tab::closeEvent (QCloseEvent *e) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
154 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
155 // ignore close event if file is not saved and user cancels |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
156 // closing this window |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
157 if (check_file_modified () == QMessageBox::Cancel) |
16558 | 158 e->ignore (); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
159 else |
16558 | 160 e->accept (); |
14676
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 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 void |
15300
fd27e10b9b05
pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents:
15286
diff
changeset
|
164 file_editor_tab::set_file_name (const QString& fileName) |
14690
ca733a66be7a
Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14680
diff
changeset
|
165 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
166 // update tracked file if we really have a file on disk |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
167 QStringList trackedFiles = _file_system_watcher.files (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
168 if (!trackedFiles.isEmpty ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
169 _file_system_watcher.removePath (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
170 if (!fileName.isEmpty ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
171 _file_system_watcher.addPath (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
|
172 _file_name = fileName; |
15425
8ae34ffe5c1b
Retain QsciAPIs lexer_api as part of lexer_octave_gui object (bug #37359)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15402
diff
changeset
|
173 |
8ae34ffe5c1b
Retain QsciAPIs lexer_api as part of lexer_octave_gui object (bug #37359)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15402
diff
changeset
|
174 // update lexer after _file_name change |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
175 update_lexer (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
176 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
177 // update the file editor with current editing directory |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
178 emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name)); |
15860
feba9ff6e6a8
editor: add list of recently used files to the file menu
Torsten <ttl@justmail.de>
parents:
15849
diff
changeset
|
179 // add the new file to the mru list |
feba9ff6e6a8
editor: add list of recently used files to the file menu
Torsten <ttl@justmail.de>
parents:
15849
diff
changeset
|
180 emit mru_add_file (QDir::cleanPath (_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
|
181 } |
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
|
182 |
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
|
183 void |
16558 | 184 file_editor_tab::handle_margin_clicked (int margin, int line, |
15045
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
185 Qt::KeyboardModifiers state) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
186 { |
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
|
187 if (margin == 1) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 { |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
189 unsigned int markers_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
|
190 |
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 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
|
192 { |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
193 if (markers_mask && (1 << bookmark)) |
16558 | 194 _edit_area->markerDelete (line, bookmark); |
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
|
195 else |
16558 | 196 _edit_area->markerAdd (line, bookmark); |
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
|
197 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
198 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
|
199 { |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
200 if (markers_mask && (1 << breakpoint)) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
201 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
|
202 else |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
203 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
|
204 } |
14676
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 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
207 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
208 void |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
209 file_editor_tab::update_lexer () |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
210 { |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
211 if (_lexer_apis) |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
212 _lexer_apis->cancelPreparation (); // stop preparing if apis exists |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
213 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
214 QsciLexer *lexer = _edit_area->lexer (); |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
215 delete lexer; |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
216 lexer = 0; |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
217 |
16559
78765ae325fd
gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents:
16558
diff
changeset
|
218 if (_file_name.endsWith (".m") |
78765ae325fd
gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents:
16558
diff
changeset
|
219 || _file_name.endsWith ("octaverc")) |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
220 { |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
221 #if defined (HAVE_LEXER_OCTAVE) |
16646
025bc6b5080e
use QScintilla's lexer for highlighting Octave programs
John W. Eaton <jwe@octave.org>
parents:
16638
diff
changeset
|
222 lexer = new QsciLexerOctave (); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
223 #elif defined (HAVE_LEXER_MATLAB) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
224 lexer = new QsciLexerMatlab (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
225 #endif |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
226 } |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
227 |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
228 if (! lexer) |
14873
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
229 { |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
230 if (_file_name.endsWith (".c") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
231 || _file_name.endsWith (".cc") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
232 || _file_name.endsWith (".cpp") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
233 || _file_name.endsWith (".cxx") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
234 || _file_name.endsWith (".c++") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
235 || _file_name.endsWith (".h") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
236 || _file_name.endsWith (".hh") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
237 || _file_name.endsWith (".hpp") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
238 || _file_name.endsWith (".h++")) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
239 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
240 lexer = new QsciLexerCPP (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
241 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
242 else if (_file_name.endsWith (".pl")) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
243 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
244 lexer = new QsciLexerPerl (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
245 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
246 else if (_file_name.endsWith (".bat")) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
247 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
248 lexer = new QsciLexerBatch (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
249 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
250 else if (_file_name.endsWith (".diff")) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
251 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
252 lexer = new QsciLexerDiff (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
253 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
254 else |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
255 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
256 // FIXME -- why should the bash lexer be the default? |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
257 lexer = new QsciLexerBash (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
258 } |
14874
5d74d8b982a5
Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14873
diff
changeset
|
259 } |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
260 |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
261 if (lexer) |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
262 { |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
263 _lexer_apis = new QsciAPIs(lexer); |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
264 if (_lexer_apis) |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
265 { |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
266 QString keyword; |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
267 QStringList keyword_list; |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
268 int i; |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
269 for (i=1; i<=3; i++) // load the first 3 keyword sets |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
270 { |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
271 keyword = QString(lexer->keywords (i)); // get list |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
272 keyword_list = keyword.split (QRegExp ("\\s+")); // split |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
273 for (i = 0; i < keyword_list.size (); i++) // add to API |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
274 _lexer_apis->add (keyword_list.at (i)); |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
275 } |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
276 if (!_lexer_apis->loadPrepared ()) |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
277 { |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
278 connect (_lexer_apis, SIGNAL (apiPreparationFinished ()), |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
279 this, SLOT (save_apis_info ())); |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
280 _lexer_apis->prepare (); |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
281 } |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
282 } |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
283 } |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
284 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15080
diff
changeset
|
285 QSettings *settings = resource_manager::get_settings (); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
286 if (settings) |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
287 lexer->readSettings (*settings); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
288 |
16402
7fa90eb41240
gui: individually configurable styles of the editor lexers
Torsten <ttl@justmail.de>
parents:
16395
diff
changeset
|
289 _edit_area->setLexer (lexer); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
290 |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
291 } |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
292 |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
293 void |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
294 file_editor_tab::save_apis_info () |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
295 { |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
296 _lexer_apis->savePrepared (); |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
297 } |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
298 |
15980
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
299 // slot for fetab_set_focus: sets the focus to the current edit area |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
300 void |
16558 | 301 file_editor_tab::set_focus (const QWidget *ID) |
15980
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
302 { |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
303 if (ID != this) |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
304 return; |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
305 _edit_area->setFocus (); |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
306 } |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
307 |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
308 void |
16558 | 309 file_editor_tab::undo (const QWidget *ID) |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
310 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
311 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
312 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
313 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
314 _edit_area->undo (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
315 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
316 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
317 void |
16558 | 318 file_editor_tab::redo (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
319 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
320 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
321 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
322 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
323 _edit_area->redo (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
324 } |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
325 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
326 void |
16558 | 327 file_editor_tab::copy (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
328 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
329 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
330 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
331 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
332 _edit_area->copy (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
333 } |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
334 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
335 void |
16558 | 336 file_editor_tab::cut (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
337 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
338 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
339 return; |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
340 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
341 _edit_area->cut (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
342 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
343 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
344 void |
16558 | 345 file_editor_tab::paste (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
346 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
347 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
348 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
349 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
350 _edit_area->paste (); |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
351 } |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
352 |
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
353 void |
16558 | 354 file_editor_tab::save_file (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
355 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
356 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
357 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
358 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
359 save_file (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
360 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
361 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
362 |
16558 | 363 file_editor_tab::save_file (const QWidget *ID, const QString& fileName, |
364 bool remove_on_success) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
365 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
366 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
367 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
368 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
369 save_file (fileName, remove_on_success); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
370 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
371 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
372 void |
16558 | 373 file_editor_tab::save_file_as (const QWidget *ID) |
14827
6b90737f69cc
Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14826
diff
changeset
|
374 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
375 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
376 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
377 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
378 save_file_as (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
379 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
380 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
381 void |
16558 | 382 file_editor_tab::print_file (const QWidget *ID) |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
383 { |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
384 if (ID != this) |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
385 return; |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
386 |
16558 | 387 QsciPrinter *printer = new QsciPrinter (QPrinter::HighResolution); |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
388 |
16558 | 389 QPrintDialog printDlg (printer, this); |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
390 |
16558 | 391 if (printDlg.exec () == QDialog::Accepted) |
392 printer->printRange (_edit_area); | |
393 | |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
394 delete printer; |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
395 } |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
396 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
397 void |
16558 | 398 file_editor_tab::run_file (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
399 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
400 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
401 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
402 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
403 if (_edit_area->isModified ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
404 save_file (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
405 |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
406 QFileInfo info (_file_name); |
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
407 emit run_file_signal (info); |
15080
4c4f2fb07a50
Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15045
diff
changeset
|
408 } |
4c4f2fb07a50
Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15045
diff
changeset
|
409 |
4c4f2fb07a50
Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15045
diff
changeset
|
410 void |
16558 | 411 file_editor_tab::toggle_bookmark (const QWidget *ID) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
412 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
413 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
414 return; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
415 |
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
|
416 int line, cur; |
16558 | 417 _edit_area->getCursorPosition (&line, &cur); |
418 | |
419 if (_edit_area->markersAtLine (line) && (1 << bookmark)) | |
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
|
420 _edit_area->markerDelete (line, bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
421 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
|
422 _edit_area->markerAdd (line, bookmark); |
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 |
16558 | 426 file_editor_tab::next_bookmark (const QWidget *ID) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
427 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
428 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
429 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
430 |
16558 | 431 int 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
|
432 _edit_area->getCursorPosition (&line, &cur); |
16558 | 433 |
434 if (_edit_area->markersAtLine (line) && (1 << bookmark)) | |
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
|
435 line++; // we have a breakpoint here, so start search from next line |
16558 | 436 |
437 int nextline = _edit_area->markerFindNext (line, (1 << bookmark)); | |
438 | |
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
|
439 _edit_area->setCursorPosition (nextline, 0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
440 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
441 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
442 void |
16558 | 443 file_editor_tab::previous_bookmark (const QWidget *ID) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
444 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
445 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
446 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
447 |
16558 | 448 int 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
|
449 _edit_area->getCursorPosition (&line, &cur); |
16558 | 450 |
451 if (_edit_area->markersAtLine (line) && (1 << bookmark)) | |
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
|
452 line--; // we have a breakpoint here, so start search from prev line |
16558 | 453 |
454 int prevline = _edit_area->markerFindPrevious (line, (1 << bookmark)); | |
455 | |
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
|
456 _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
|
457 } |
eae0e9f2a8c6
Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14804
diff
changeset
|
458 |
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 void |
16558 | 460 file_editor_tab::remove_bookmark (const QWidget *ID) |
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 { |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
462 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
463 return; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
464 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
465 _edit_area->markerDeleteAll (bookmark); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
466 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
467 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
468 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
469 file_editor_tab::add_breakpoint_callback (const bp_info& info) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
470 { |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
471 bp_table::intmap line_info; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
472 line_info[0] = info.line; |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
473 |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
474 if (octave_qt_link::file_in_path (info.file, info.dir)) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
475 bp_table::add_breakpoint (info.function_name, line_info); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
476 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
477 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
478 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
479 file_editor_tab::remove_breakpoint_callback (const bp_info& info) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
480 { |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
481 bp_table::intmap line_info; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
482 line_info[0] = info.line; |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
483 |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
484 if (octave_qt_link::file_in_path (info.file, info.dir)) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
485 bp_table::remove_breakpoint (info.function_name, line_info); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
486 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
487 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
488 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
489 file_editor_tab::remove_all_breakpoints_callback (const bp_info& info) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
490 { |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
491 if (octave_qt_link::file_in_path (info.file, info.dir)) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
492 bp_table::remove_all_breakpoints_in_file (info.function_name, true); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
493 } |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
494 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
495 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
496 file_editor_tab::request_add_breakpoint (int line) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
497 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
498 QFileInfo file_info (_file_name); |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
499 QString dir = file_info.absolutePath (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
500 QString function_name = file_info.fileName (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
501 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
502 // We have to cut off the suffix, because octave appends it. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
503 function_name.chop (file_info.suffix ().length () + 1); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
504 |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
505 bp_info info (_file_name, dir, function_name, line+1); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
506 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
507 octave_link::post_event |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
508 (this, &file_editor_tab::add_breakpoint_callback, info); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
509 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
510 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
511 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
512 file_editor_tab::request_remove_breakpoint (int line) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
513 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
514 QFileInfo file_info (_file_name); |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
515 QString dir = file_info.absolutePath (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
516 QString function_name = file_info.fileName (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
517 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
518 // We have to cut off the suffix, because octave appends it. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
519 function_name.chop (file_info.suffix ().length () + 1); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
520 |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
521 bp_info info (_file_name, dir, function_name, line+1); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
522 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
523 octave_link::post_event |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
524 (this, &file_editor_tab::remove_breakpoint_callback, info); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
525 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
526 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
527 void |
16558 | 528 file_editor_tab::toggle_breakpoint (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
529 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
530 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
531 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
532 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
533 int line, cur; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
534 _edit_area->getCursorPosition (&line, &cur); |
16558 | 535 |
536 if (_edit_area->markersAtLine (line) && (1 << breakpoint)) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
537 request_remove_breakpoint (line); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
538 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
539 request_add_breakpoint (line); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
540 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
541 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
542 void |
16558 | 543 file_editor_tab::next_breakpoint (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
544 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
545 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
546 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
547 |
16558 | 548 int line, cur; |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
549 _edit_area->getCursorPosition (&line, &cur); |
16558 | 550 |
551 if (_edit_area->markersAtLine (line) && (1 << breakpoint)) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
552 line++; // we have a breakpoint here, so start search from next line |
16558 | 553 |
554 int nextline = _edit_area->markerFindNext (line, (1 << breakpoint)); | |
555 | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
556 _edit_area->setCursorPosition (nextline, 0); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
557 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
558 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
559 void |
16558 | 560 file_editor_tab::previous_breakpoint (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
561 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
562 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
563 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
564 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
565 int line, cur, prevline; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
566 _edit_area->getCursorPosition (&line, &cur); |
16558 | 567 |
568 if (_edit_area->markersAtLine (line) && (1 << breakpoint)) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
569 line--; // we have a breakpoint here, so start search from prev line |
16558 | 570 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
571 prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint)); |
16558 | 572 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
573 _edit_area->setCursorPosition (prevline, 0); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
574 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
575 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
576 void |
16558 | 577 file_editor_tab::remove_all_breakpoints (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
578 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
579 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
580 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
581 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
582 QFileInfo file_info (_file_name); |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
583 QString dir = file_info.absolutePath (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
584 QString function_name = file_info.fileName (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
585 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
586 // We have to cut off the suffix, because octave appends it. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
587 function_name.chop (file_info.suffix ().length () + 1); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
588 |
16568
477bfd5d95f5
use dir, not path, to refer to directory name
John W. Eaton <jwe@octave.org>
parents:
16565
diff
changeset
|
589 bp_info info (_file_name, dir, function_name, 0); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
590 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
591 octave_link::post_event |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
592 (this, &file_editor_tab::remove_all_breakpoints_callback, info); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
593 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
594 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
595 void |
16558 | 596 file_editor_tab::comment_selected_text (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
597 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
598 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
599 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
600 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
601 do_comment_selected_text (true); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
602 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
603 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
604 void |
16558 | 605 file_editor_tab::uncomment_selected_text (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
606 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
607 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
608 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
609 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
610 do_comment_selected_text (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
611 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
612 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
613 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
614 file_editor_tab::handle_find_dialog_finished (int) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
615 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
616 // Find dialog is going to hide. Save location of window for |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
617 // when it is reshown. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
618 _find_dialog_geometry = _find_dialog->geometry (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
619 _find_dialog_is_visible = false; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
620 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
621 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
622 void |
16558 | 623 file_editor_tab::find (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
624 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
625 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
626 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
627 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
628 // The find_dialog feature doesn't need a slot for return info. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
629 // Rather than Qt::DeleteOnClose, let the find feature hang about |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
630 // in case it contains useful information like previous searches |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
631 // and so on. Perhaps one find dialog for the whole editor is |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
632 // better, but individual find dialogs has the nice feature of |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
633 // retaining position per file editor tabs, which can be undocked. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
634 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
635 if (!_find_dialog) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
636 { |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16452
diff
changeset
|
637 _find_dialog = new find_dialog (_edit_area, |
16558 | 638 qobject_cast<QWidget *> (sender ())); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
639 connect (_find_dialog, SIGNAL (finished (int)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
640 this, SLOT (handle_find_dialog_finished (int))); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
641 _find_dialog->setWindowModality (Qt::NonModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
642 _find_dialog_geometry = _find_dialog->geometry (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
643 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
644 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
645 if (!_find_dialog->isVisible ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
646 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
647 _find_dialog->setGeometry (_find_dialog_geometry); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
648 _find_dialog->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
649 _find_dialog_is_visible = true; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
650 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
651 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
652 _find_dialog->activateWindow (); |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15984
diff
changeset
|
653 _find_dialog->init_search_text (); |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15984
diff
changeset
|
654 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
655 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
656 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
657 void |
16558 | 658 file_editor_tab::goto_line (const QWidget *ID, int line) |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
659 { |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
660 if (ID != this) |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
661 return; |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
662 |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
663 if (line <= 0) // ask for desired line |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
664 { |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
665 bool ok = false; |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
666 int index; |
16558 | 667 _edit_area->getCursorPosition (&line, &index); |
668 line = QInputDialog::getInt (_edit_area, tr ("Goto line"), | |
669 tr ("Line number"), line+1, 1, | |
670 _edit_area->lines (), 1, &ok); | |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
671 if (ok) |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
672 { |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
673 _edit_area->setCursorPosition (line-1, 0); |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
674 center_current_line (); |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
675 } |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
676 } |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
677 else // go to given line without dialog |
16558 | 678 _edit_area->setCursorPosition (line-1, 0); |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
679 } |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
680 |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
681 |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
682 void |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
683 file_editor_tab::do_comment_selected_text (bool comment) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
684 { |
16558 | 685 if (_edit_area->hasSelectedText ()) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
686 { |
16558 | 687 int lineFrom, lineTo, colFrom, colTo; |
688 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); | |
689 | |
690 if (colTo == 0) // the beginning of last line is not selected | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
691 lineTo--; // stop at line above |
16558 | 692 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
693 _edit_area->beginUndoAction (); |
16558 | 694 |
695 for (int i = lineFrom; i <= lineTo; i++) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
696 { |
16558 | 697 if (comment) |
698 _edit_area->insertAt ("%", i, 0); | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
699 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
700 { |
16558 | 701 QString line (_edit_area->text (i)); |
702 if (line.startsWith ("%")) | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
703 { |
16558 | 704 _edit_area->setSelection (i, 0, i, 1); |
705 _edit_area->removeSelectedText (); | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
706 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
707 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
708 } |
16558 | 709 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
710 _edit_area->endUndoAction (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
711 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
712 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
713 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
714 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
715 file_editor_tab::update_window_title (bool modified) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
716 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
717 QString title (""); |
15984
1eb3c67139f6
Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15982
diff
changeset
|
718 QString tooltip (""); |
16558 | 719 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
720 if (_file_name.isEmpty () || _file_name.at (_file_name.count () - 1) == '/') |
16558 | 721 title = tr ("<unnamed>"); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
722 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
723 { |
16558 | 724 if (_long_title) |
15981
e3873531dd7c
gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents:
15980
diff
changeset
|
725 title = _file_name; |
e3873531dd7c
gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents:
15980
diff
changeset
|
726 else |
e3873531dd7c
gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents:
15980
diff
changeset
|
727 { |
16558 | 728 QFileInfo file (_file_name); |
729 title = file.fileName (); | |
15984
1eb3c67139f6
Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15982
diff
changeset
|
730 tooltip = _file_name; |
15981
e3873531dd7c
gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents:
15980
diff
changeset
|
731 } |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
732 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
733 |
16558 | 734 if (modified) |
735 emit file_name_changed (title.prepend ("* "), tooltip); | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
736 else |
15984
1eb3c67139f6
Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15982
diff
changeset
|
737 emit file_name_changed (title, tooltip); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
738 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
739 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
740 void |
16558 | 741 file_editor_tab::handle_copy_available (bool enableCopy) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
742 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
743 _copy_available = enableCopy; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
744 emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name)); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
745 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
746 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
747 int |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
748 file_editor_tab::check_file_modified () |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
749 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
750 int decision = QMessageBox::Yes; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
751 if (_edit_area->isModified ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
752 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
753 // File is modified but not saved, ask user what to do. The file |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
754 // editor tab can't be made parent because it may be deleted depending |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
755 // upon the response. Instead, change the _edit_area to read only. |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
756 QMessageBox::StandardButtons buttons = QMessageBox::Save | |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
757 QMessageBox::Discard; |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
758 QString available_actions; |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
759 |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
760 if (_app_closing) |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
761 available_actions = tr ("Do you want to save or discard the changes?"); |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
762 else |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
763 { |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
764 buttons = buttons | QMessageBox::Cancel; // cancel is allowed |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
765 available_actions |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
766 = tr ("Do you want to cancel closing, save or discard the changes?"); |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
767 } |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
768 |
16558 | 769 QMessageBox* msgBox |
770 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), | |
771 tr ("The file\n" | |
772 "%1\n" | |
773 "is about to be closed but has been modified.\n" | |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
774 "%2"). |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
775 arg (_file_name). arg (available_actions), |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
776 buttons, qobject_cast<QWidget *> (parent ())); |
16558 | 777 |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
778 msgBox->setDefaultButton (QMessageBox::Save); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
779 _edit_area->setReadOnly (true); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
780 connect (msgBox, SIGNAL (finished (int)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
781 this, SLOT (handle_file_modified_answer (int))); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
782 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
783 if (_app_closing) // app is closing, a non modal dialogs prevent |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
784 msgBox->exec (); // the app of being closed before an answer from user |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
785 else |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
786 { |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
787 msgBox->setWindowModality (Qt::NonModal); |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
788 msgBox->show (); |
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
789 } |
16558 | 790 |
791 return QMessageBox::Cancel; | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
792 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
793 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
794 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
795 // Nothing was modified, just remove from editor. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
796 emit tab_remove_request (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
797 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
798 |
16558 | 799 return decision; |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
800 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
801 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
802 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
803 file_editor_tab::handle_file_modified_answer (int decision) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
804 { |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
805 if (decision == QMessageBox::Save) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
806 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
807 // Save file, then remove from editor. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
808 save_file (_file_name, true); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
809 } |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
810 else if (decision == QMessageBox::Discard) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
811 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
812 // User doesn't want to save, just remove from editor. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
813 emit tab_remove_request (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
814 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
815 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
816 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
817 // User canceled, allow editing again. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
818 _edit_area->setReadOnly (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
819 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
820 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
821 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
822 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
823 file_editor_tab::set_modified (bool modified) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
824 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
825 _edit_area->setModified (modified); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
826 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
827 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
828 QString |
16558 | 829 file_editor_tab::load_file (const QString& fileName) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
830 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
831 QFile file (fileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
832 if (!file.open (QFile::ReadOnly)) |
16558 | 833 return file.errorString (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
834 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
835 QTextStream in (&file); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
836 QApplication::setOverrideCursor (Qt::WaitCursor); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
837 _edit_area->setText (in.readAll ()); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
838 QApplication::restoreOverrideCursor (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
839 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
840 set_file_name (fileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
841 update_window_title (false); // window title (no modification) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
842 _edit_area->setModified (false); // loaded file is not modified yet |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
843 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
844 return QString (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
845 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
846 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
847 void |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16443
diff
changeset
|
848 file_editor_tab::new_file (const QString &commands) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
849 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
850 update_window_title (false); // window title (no modification) |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16443
diff
changeset
|
851 _edit_area->setText (commands); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
852 _edit_area->setModified (false); // new file is not modified yet |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
853 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
854 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
855 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
856 file_editor_tab::save_file (const QString& saveFileName, bool remove_on_success) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
857 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
858 // If it is a new file with no name, signal that saveFileAs |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
859 // should be performed. |
16558 | 860 if (saveFileName.isEmpty () |
861 || saveFileName.at (saveFileName.count () - 1) == '/') | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
862 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
863 save_file_as (remove_on_success); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
864 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
865 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
866 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
867 // stop watching file |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
868 QStringList trackedFiles = _file_system_watcher.files (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
869 if (!trackedFiles.isEmpty ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
870 _file_system_watcher.removePath (saveFileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
871 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
872 // open the file for writing |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
873 QFile file (saveFileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
874 if (!file.open (QIODevice::WriteOnly)) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
875 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
876 // Unsuccessful, begin watching file again if it was being |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
877 // watched previously. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
878 if (trackedFiles.contains (saveFileName)) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
879 _file_system_watcher.addPath (saveFileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
880 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
881 // Create a NonModal message about error. |
16558 | 882 QMessageBox* msgBox |
883 = new QMessageBox (QMessageBox::Critical, | |
884 tr ("Octave Editor"), | |
885 tr ("Could not open file %1 for write:\n%2."). | |
886 arg (saveFileName).arg (file.errorString ()), | |
887 QMessageBox::Ok, 0); | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
888 msgBox->setWindowModality (Qt::NonModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
889 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
890 msgBox->show (); |
16558 | 891 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
892 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
893 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
894 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
895 // save the contents into the file |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
896 QTextStream out (&file); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
897 QApplication::setOverrideCursor (Qt::WaitCursor); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
898 out << _edit_area->text (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
899 QApplication::restoreOverrideCursor (); |
16558 | 900 file.close (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
901 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
902 // save file name after closing file as set_file_name starts watching again |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
903 set_file_name (saveFileName); |
16558 | 904 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
905 // set the window title to actual file name (not modified) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
906 update_window_title (false); |
16558 | 907 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
908 // files is save -> not modified |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
909 _edit_area->setModified (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
910 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
911 if (remove_on_success) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
912 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
913 emit tab_remove_request (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
914 return; // Don't touch member variables after removal |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
915 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
916 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
917 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
918 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
919 file_editor_tab::save_file_as (bool remove_on_success) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
920 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
921 // Simply put up the file chooser dialog box with a slot connection |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
922 // then return control to the system waiting for a file selection. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
923 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
924 // If the tab is removed in response to a QFileDialog signal, the tab |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
925 // can't be a parent. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
926 QFileDialog* fileDialog; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
927 if (remove_on_success) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
928 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
929 // If tab is closed, "this" cannot be parent in which case modality |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
930 // has no effect. Disable editing instead. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
931 _edit_area->setReadOnly (true); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
932 fileDialog = new QFileDialog (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
933 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
934 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
935 fileDialog = new QFileDialog (this); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
936 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
937 if (!_file_name.isEmpty () && _file_name.at (_file_name.count () - 1) != '/') |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
938 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
939 fileDialog->selectFile (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
940 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
941 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
942 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
943 fileDialog->selectFile (""); |
16558 | 944 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
945 if (_file_name.isEmpty ()) |
16558 | 946 fileDialog->setDirectory (QDir::currentPath ()); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
947 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
948 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
949 // The file name is actually the directory name from the |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
950 // constructor argument. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
951 fileDialog->setDirectory (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
952 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
953 } |
16558 | 954 |
16560
ebec000cbfc5
gui: fix editor file name filters to allow all files
Mike Miller <mtmiller@ieee.org>
parents:
16559
diff
changeset
|
955 fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)")); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
956 fileDialog->setDefaultSuffix ("m"); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
957 fileDialog->setAcceptMode (QFileDialog::AcceptSave); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
958 fileDialog->setViewMode (QFileDialog::Detail); |
16558 | 959 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
960 if (remove_on_success) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
961 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
962 connect (fileDialog, SIGNAL (fileSelected (const QString&)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
963 this, SLOT (handle_save_file_as_answer_close (const QString&))); |
16558 | 964 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
965 connect (fileDialog, SIGNAL (rejected ()), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
966 this, SLOT (handle_save_file_as_answer_cancel ())); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
967 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
968 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
969 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
970 connect (fileDialog, SIGNAL (fileSelected (const QString&)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
971 this, SLOT (handle_save_file_as_answer (const QString&))); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
972 } |
16558 | 973 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
974 fileDialog->setWindowModality (Qt::WindowModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
975 fileDialog->setAttribute (Qt::WA_DeleteOnClose); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
976 fileDialog->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
977 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
978 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
979 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
980 file_editor_tab::message_duplicate_file_name (const QString& saveFileName) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
981 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
982 // Could overwrite the file here (and tell user the file was |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
983 // overwritten), but the user could have unintentionally |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
984 // selected the same name not intending to overwrite. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
985 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
986 // Create a NonModal message about error. |
16558 | 987 QMessageBox* msgBox |
988 = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"), | |
989 tr ("File not saved! The selected file name\n%1\n" | |
990 "is the same as the current file name"). | |
991 arg (saveFileName), | |
992 QMessageBox::Ok, 0); | |
993 | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
994 msgBox->setWindowModality (Qt::NonModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
995 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
996 msgBox->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
997 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
998 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
999 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1000 file_editor_tab::handle_save_file_as_answer (const QString& saveFileName) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1001 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1002 if (saveFileName == _file_name) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1003 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1004 message_duplicate_file_name (saveFileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1005 // Nothing done, allow editing again. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1006 _edit_area->setReadOnly (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1007 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1008 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1009 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1010 // Have editor check for conflict, do not delete tab after save. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1011 emit editor_check_conflict_save (saveFileName, false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1012 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1013 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1014 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1015 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1016 file_editor_tab::handle_save_file_as_answer_close (const QString& saveFileName) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1017 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1018 if (saveFileName == _file_name) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1019 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1020 message_duplicate_file_name (saveFileName); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1021 // Nothing done, allow editing again. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1022 _edit_area->setReadOnly (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1023 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1024 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1025 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1026 // Have editor check for conflict, delete tab after save. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1027 emit editor_check_conflict_save (saveFileName, true); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1028 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1029 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1030 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1031 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1032 file_editor_tab::handle_save_file_as_answer_cancel () |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1033 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1034 // User canceled, allow editing again. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1035 _edit_area->setReadOnly (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1036 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1037 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1038 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1039 file_editor_tab::file_has_changed (const QString&) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1040 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1041 // Prevent popping up multiple message boxes when the file has |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1042 // been changed multiple times by temporarily removing from the |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1043 // file watcher. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1044 QStringList trackedFiles = _file_system_watcher.files (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1045 if (!trackedFiles.isEmpty ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1046 _file_system_watcher.removePath (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1047 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1048 if (QFile::exists (_file_name)) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1049 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1050 // Create a WindowModal message that blocks the edit area |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1051 // by making _edit_area parent. |
16558 | 1052 QMessageBox* msgBox |
1053 = new QMessageBox (QMessageBox::Warning, | |
1054 tr ("Octave Editor"), | |
1055 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). | |
1056 arg (_file_name), | |
1057 QMessageBox::Yes | QMessageBox::No, this); | |
1058 | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1059 connect (msgBox, SIGNAL (finished (int)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1060 this, SLOT (handle_file_reload_answer (int))); |
16558 | 1061 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1062 msgBox->setWindowModality (Qt::WindowModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1063 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1064 msgBox->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1065 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1066 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1067 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1068 QString modified = ""; |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1069 if (_edit_area->isModified ()) |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1070 modified = tr ("\n\nWarning: The contents in the editor is modified!"); |
16558 | 1071 |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1072 // Create a WindowModal message. The file editor tab can't be made |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1073 // parent because it may be deleted depending upon the response. |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1074 // Instead, change the _edit_area to read only. |
16558 | 1075 QMessageBox* msgBox |
1076 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), | |
1077 tr ("It seems that the file\n" | |
1078 "%1\n" | |
1079 "has been deleted or renamed. Do you want to save it now?%2"). | |
1080 arg (_file_name).arg (modified), | |
1081 QMessageBox::Save | QMessageBox::Close, 0); | |
1082 | |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1083 _edit_area->setReadOnly (true); |
16558 | 1084 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1085 connect (msgBox, SIGNAL (finished (int)), |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1086 this, SLOT (handle_file_resave_answer (int))); |
16558 | 1087 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1088 msgBox->setWindowModality (Qt::WindowModal); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1089 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1090 msgBox->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1091 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1092 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1093 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1094 void |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
1095 file_editor_tab::notice_settings (const QSettings *settings) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1096 { |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
1097 // QSettings pointer is checked before emitting. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16402
diff
changeset
|
1098 |
16402
7fa90eb41240
gui: individually configurable styles of the editor lexers
Torsten <ttl@justmail.de>
parents:
16395
diff
changeset
|
1099 update_lexer (); |
16558 | 1100 |
16402
7fa90eb41240
gui: individually configurable styles of the editor lexers
Torsten <ttl@justmail.de>
parents:
16395
diff
changeset
|
1101 QFontMetrics lexer_font_metrics (_edit_area->lexer ()->defaultFont (0)); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1102 |
16693
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
1103 //highlight current line color |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
1104 QVariant default_var = QColor (240, 240, 240); |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
1105 QColor setting_color = settings->value ("editor/highlight_current_line_color", |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
1106 default_var).value<QColor> (); |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
1107 _edit_area->setCaretLineBackgroundColor (setting_color); |
16558 | 1108 _edit_area->setCaretLineVisible |
1109 (settings->value ("editor/highlightCurrentLine", true).toBool ()); | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1110 |
16679
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1111 if (settings->value ("editor/codeCompletion", true).toBool ()) // auto compl. |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1112 { |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1113 bool match_keywords = settings->value |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1114 ("editor/codeCompletion_keywords",true).toBool (); |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1115 bool match_document = settings->value |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1116 ("editor/codeCompletion_document",true).toBool (); |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1117 |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1118 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1119 if (match_keywords) |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1120 if (match_document) |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1121 source = QsciScintilla::AcsAll; |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1122 else |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1123 source = QsciScintilla::AcsAPIs; |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1124 else |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1125 if (match_document) |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1126 source = QsciScintilla::AcsDocument; |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1127 _edit_area->setAutoCompletionSource (source); |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1128 |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1129 _edit_area->setAutoCompletionReplaceWord |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1130 (settings->value ("editor/codeCompletion_replace",false).toBool ()); |
16701
ccfbc767ff5a
make case sensitivity of editors auto completion list configurable
Torsten <ttl@justmail.de>
parents:
16693
diff
changeset
|
1131 _edit_area->setAutoCompletionCaseSensitivity |
ccfbc767ff5a
make case sensitivity of editors auto completion list configurable
Torsten <ttl@justmail.de>
parents:
16693
diff
changeset
|
1132 (settings->value ("editor/codeCompletion_case",true).toBool ()); |
16679
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1133 _edit_area->setAutoCompletionThreshold |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1134 (settings->value ("editor/codeCompletion_threshold",2).toInt ()); |
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
1135 } |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1136 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1137 _edit_area->setAutoCompletionThreshold (-1); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1138 |
16702
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1139 if (settings->value ("editor/show_white_space",false).toBool ()) |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1140 if (settings->value ("editor/show_white_space_indent",false).toBool ()) |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1141 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1142 else |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1143 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1144 else |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1145 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
1146 |
16558 | 1147 if (settings->value ("editor/showLineNumbers", true).toBool ()) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1148 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1149 _edit_area->setMarginLineNumbers (2, true); |
16558 | 1150 _edit_area->setMarginWidth (2, lexer_font_metrics.width ("9999")); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1151 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1152 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1153 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1154 _edit_area->setMarginLineNumbers (2, false); |
16558 | 1155 _edit_area->setMarginWidth (2, 0); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1156 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1157 |
16703
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1158 _edit_area->setAutoIndent |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1159 (settings->value ("editor/auto_indent",true).toBool ()); |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1160 _edit_area->setTabIndents |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1161 (settings->value ("editor/tab_indents_line",false).toBool ()); |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1162 _edit_area->setBackspaceUnindents |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1163 (settings->value ("editor/backspace_unindents_line",false).toBool ()); |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1164 _edit_area->setIndentationGuides |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1165 (settings->value ("editor/show_indent_guides",false).toBool ()); |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1166 |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1167 _edit_area->setTabWidth |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1168 (settings->value ("editor/tab_width",2).toInt ()); |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
1169 |
16558 | 1170 _long_title = settings->value ("editor/longWindowTitle", false).toBool (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1171 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1172 update_window_title (false); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1173 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1174 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1175 void |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
1176 file_editor_tab::conditional_close (const QWidget *ID, bool app_closing) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1177 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1178 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1179 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1180 |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
1181 _app_closing = app_closing; |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1182 close (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1183 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1184 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1185 void |
16558 | 1186 file_editor_tab::change_editor_state (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1187 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1188 if (ID != this) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1189 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1190 // Widget may be going out of focus. If so, record location. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1191 if (_find_dialog) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1192 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1193 if (_find_dialog->isVisible ()) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1194 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1195 _find_dialog_geometry = _find_dialog->geometry (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1196 _find_dialog->hide (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1197 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1198 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1199 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1200 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1201 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1202 if (_find_dialog && _find_dialog_is_visible) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1203 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1204 _find_dialog->setGeometry (_find_dialog_geometry); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1205 _find_dialog->show (); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1206 } |
16558 | 1207 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1208 emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name)); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1209 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1210 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1211 void |
16558 | 1212 file_editor_tab::file_name_query (const QWidget *ID) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1213 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1214 // A zero (null pointer) means that all file editor tabs |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1215 // should respond, otherwise just the desired file editor tab. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1216 if (ID != this && ID != 0) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1217 return; |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1218 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1219 // Unnamed files shouldn't be transmitted. |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1220 if (!_file_name.isEmpty ()) |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
1221 emit add_filename_to_list (_file_name, this); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1222 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1223 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1224 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1225 file_editor_tab::handle_file_reload_answer (int decision) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1226 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1227 if (decision == QMessageBox::Yes) |
16558 | 1228 { |
1229 // reload: file is readded to the file watcher in set_file_name () | |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1230 load_file (_file_name); |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1231 } |
15849
e55a64f49346
editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents:
15848
diff
changeset
|
1232 else |
16558 | 1233 { |
1234 // do not reload: readd to the file watche | |
15849
e55a64f49346
editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents:
15848
diff
changeset
|
1235 _file_system_watcher.addPath (_file_name); |
e55a64f49346
editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents:
15848
diff
changeset
|
1236 } |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1237 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1238 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1239 void |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1240 file_editor_tab::handle_file_resave_answer (int decision) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1241 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1242 // check decision of user in dialog |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1243 if (decision == QMessageBox::Save) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1244 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1245 save_file (_file_name); // readds file to watcher in set_file_name () |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1246 _edit_area->setReadOnly (false); // delete read only flag |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1247 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1248 else |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1249 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1250 // Definitely close the file. |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1251 // Set modified to false to prevent the dialog box when the close event |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1252 // is posted. If the user cancels the close in this dialog the tab is |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1253 // left open with a non-existing file. |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1254 _edit_area->setModified (false); |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
1255 close (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1256 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1257 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1258 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1259 void |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1260 file_editor_tab::insert_debugger_pointer (const QWidget *ID, int line) |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1261 { |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
1262 if (ID != this || ID == 0) |
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
1263 return; |
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
1264 |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1265 if (line > 0) |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1266 { |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1267 _edit_area->markerAdd (line-1, debugger_position); |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1268 center_current_line (); |
15848
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1269 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1270 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
1271 |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1272 void |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1273 file_editor_tab::delete_debugger_pointer (const QWidget *ID, int line) |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1274 { |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1275 if (ID != this || ID == 0) |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1276 return; |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1277 |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1278 if (line > 0) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1279 _edit_area->markerDelete (line-1, debugger_position); |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1280 } |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1281 |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
1282 void |
16443
7a2ee6ea7800
rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents:
16440
diff
changeset
|
1283 file_editor_tab::do_breakpoint_marker (bool insert, const QWidget *ID, int line) |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1284 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1285 if (ID != this || ID == 0) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1286 return; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1287 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1288 if (line > 0) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1289 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1290 if (insert) |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1291 _edit_area->markerAdd (line-1, breakpoint); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1292 else |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1293 _edit_area->markerDelete (line-1, breakpoint); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1294 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1295 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
1296 |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1297 |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1298 void |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1299 file_editor_tab::center_current_line () |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1300 { |
16558 | 1301 long int visible_lines |
1302 = _edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN); | |
1303 | |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1304 if (visible_lines > 2) |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1305 { |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1306 int line, index; |
16558 | 1307 _edit_area->getCursorPosition (&line, &index); |
1308 | |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1309 int first_line = _edit_area->firstVisibleLine (); |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1310 first_line = first_line + (line - first_line - (visible_lines-1)/2); |
16558 | 1311 |
16591
2931e9282190
* file-editor-tab.cc: replace setFirstVisibleLine for older Qscintilla-versions
Torsten <ttl@justmail.de>
parents:
16570
diff
changeset
|
1312 _edit_area->SendScintilla (2613,first_line); // SCI_SETFIRSTVISIBLELINE |
16389
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1313 } |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1314 } |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
1315 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
1316 #endif |