Mercurial > octave
annotate libgui/src/m-editor/file-editor-tab.cc @ 24109:1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Thu, 28 Sep 2017 10:49:39 +0200 |
parents | a5b20fc6588a |
children | 16c8ec7f0867 |
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 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2011-2017 Jacob Dawid |
15204
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 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
10 (at your option) any later version. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
11 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22743
diff
changeset
|
15 GNU General Public License for more details. |
15204
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 |
24109
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
23 //! @file A single GUI file tab. |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
24 //! |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
25 //! This interfaces QsciScintilla with the rest of Octave. |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
26 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21651
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
28 # include "config.h" |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
29 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
30 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21651
diff
changeset
|
31 #if defined (HAVE_QSCINTILLA) |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
32 |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
33 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
34 # define HAVE_LEXER_OCTAVE 1 |
21203
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
21158
diff
changeset
|
35 # 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
|
36 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
37 # define HAVE_LEXER_MATLAB 1 |
21203
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
21158
diff
changeset
|
38 # include <Qsci/qscilexermatlab.h> |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
39 #endif |
14873
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/qscilexercpp.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
41 #include <Qsci/qscilexerbash.h> |
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
42 #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
|
43 #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
|
44 #include <Qsci/qscilexerdiff.h> |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
45 #include <Qsci/qsciprinter.h> |
15257
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
46 #include <QApplication> |
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
47 #include <QFileDialog> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
48 #include <QMessageBox> |
15257
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15204
diff
changeset
|
49 #include <QTextStream> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
50 #include <QVBoxLayout> |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
51 #include <QInputDialog> |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
52 #include <QPrintDialog> |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
53 #include <QDateTime> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
54 #include <QDesktopServices> |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
55 #include <QTextCodec> |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
56 #include <QStyle> |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
57 #include <QTextBlock> |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
58 #include <QLabel> |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
59 #include <QCheckBox> |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
60 #include <QDialogButtonBox> |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
61 #include <QPushButton> |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
62 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
63 #include "resource-manager.h" |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
64 #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
|
65 #include "file-editor.h" |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
66 #include "octave-txt-lexer.h" |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
67 #include "marker.h" |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
68 |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
69 #include "file-ops.h" |
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
70 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
71 #include "bp-table.h" |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
72 #include "call-stack.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
73 #include "defaults.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
74 #include "interpreter-private.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
75 #include "interpreter.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
76 #include "oct-map.h" |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
77 #include "octave-qt-link.h" |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
78 #include "ov-usr-fcn.h" |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
79 #include "symtab.h" |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
80 #include "unwind-prot.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
81 #include "utils.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
82 #include "version.h" |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
83 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
84 bool file_editor_tab::_cancelled = false; |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
85 |
24109
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
86 //! A file_editor_tab object consists of a text area and three left margins. |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
87 //! The first holds breakpoints, bookmarks, and the debug program counter. |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
88 //! The second holds line numbers. The third holds "fold" marks, to hide |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
89 //! sections of text. |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
90 |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
91 // Make parent null for the file editor tab so that warning WindowModal |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
92 // messages don't affect grandparents. |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
93 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
|
94 { |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
95 _lexer_apis = nullptr; |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
96 _is_octave_file = true; |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
97 _lines_changed = false; |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
98 |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
99 _ced = directory_arg; |
16558 | 100 |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
101 _file_name = ""; |
17737
d3bb7f1e3971
prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents:
17706
diff
changeset
|
102 _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller"); |
16558 | 103 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
16721
diff
changeset
|
104 _edit_area = new octave_qscintilla (this); |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
105 _line = 0; |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
106 _col = 0; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
107 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
108 _bp_lines.clear (); // start with empty lists of breakpoints |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
109 _bp_conditions.clear (); |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
110 |
23340
4eff94123bea
disable qscintilla editor drag and drop so parent will handle it (Bug #50559)
John D
parents:
23219
diff
changeset
|
111 // disable editor drag & drop so parent can handle |
4eff94123bea
disable qscintilla editor drag and drop so parent will handle it (Bug #50559)
John D
parents:
23219
diff
changeset
|
112 _edit_area->setAcceptDrops (false); |
4eff94123bea
disable qscintilla editor drag and drop so parent will handle it (Bug #50559)
John D
parents:
23219
diff
changeset
|
113 |
19608
4b980842edba
clean up some signal-slot combinations in the editor
Torsten <ttl@justmail.de>
parents:
19605
diff
changeset
|
114 connect (_edit_area, SIGNAL (cursorPositionChanged (int, int)), |
4b980842edba
clean up some signal-slot combinations in the editor
Torsten <ttl@justmail.de>
parents:
19605
diff
changeset
|
115 this, SLOT (handle_cursor_moved (int,int))); |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
116 |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
117 connect (_edit_area, SIGNAL (SCN_CHARADDED (int)), |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
118 this, SLOT (handle_char_added (int))); |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
119 |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
120 connect (_edit_area, SIGNAL (SCN_DOUBLECLICK (int, int, int)), |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
121 this, SLOT (handle_double_click (int, int, int))); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
122 |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
123 connect (_edit_area, SIGNAL (linesChanged ()), |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
124 this, SLOT (handle_lines_changed ())); |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
125 |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
126 connect (_edit_area, SIGNAL (context_menu_edit_signal (const QString&)), |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
127 this, SLOT (handle_context_menu_edit (const QString&))); |
18687
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18686
diff
changeset
|
128 |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
129 // create statusbar for row/col indicator and eol mode |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
130 _status_bar = new QStatusBar (this); |
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
131 |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
132 // row- and col-indicator |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
133 _row_indicator = new QLabel ("", this); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
134 QFontMetrics fm = _row_indicator->fontMetrics (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
135 _row_indicator->setMinimumSize (4.5*fm.averageCharWidth (),0); |
19244
05d8e71d20cb
add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents:
19240
diff
changeset
|
136 QLabel *row_label = new QLabel (tr ("line:"), this); |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
137 _col_indicator = new QLabel ("", this); |
19846
72fe9df87fe8
improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents:
19844
diff
changeset
|
138 _col_indicator->setMinimumSize (4*fm.averageCharWidth (),0); |
19244
05d8e71d20cb
add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents:
19240
diff
changeset
|
139 QLabel *col_label = new QLabel (tr ("col:"), this); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
140 _status_bar->addWidget (row_label, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
141 _status_bar->addWidget (_row_indicator, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
142 _status_bar->addWidget (col_label, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
143 _status_bar->addWidget (_col_indicator, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
144 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
145 // status bar: encoding |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
146 QLabel *enc_label = new QLabel (tr ("encoding:"), this); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
147 _enc_indicator = new QLabel ("",this); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
148 _status_bar->addWidget (enc_label, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
149 _status_bar->addWidget (_enc_indicator, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
150 _status_bar->addWidget (new QLabel (" ", this), 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
151 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
152 // status bar: eol mode |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
153 QLabel *eol_label = new QLabel (tr ("eol:"), this); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
154 _eol_indicator = new QLabel ("",this); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
155 _status_bar->addWidget (eol_label, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
156 _status_bar->addWidget (_eol_indicator, 0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
157 _status_bar->addWidget (new QLabel (" ", this), 0); |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
158 |
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
|
159 // Leave the find dialog box out of memory until requested. |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
160 _find_dialog = nullptr; |
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
|
161 _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
|
162 |
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
|
163 // 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
|
164 _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
|
165 _edit_area->setMarginSensitivity (1, true); |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
166 _edit_area->markerDefine (QsciScintilla::RightTriangle, marker::bookmark); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
167 _edit_area->setMarkerBackgroundColor (QColor (0,0,232), marker::bookmark); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
168 _edit_area->markerDefine (QsciScintilla::Circle, marker::breakpoint); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
169 _edit_area->setMarkerBackgroundColor (QColor (192,0,0), marker::breakpoint); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
170 _edit_area->markerDefine (QsciScintilla::Circle, marker::cond_break); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
171 _edit_area->setMarkerBackgroundColor (QColor (255,127,0), marker::cond_break); |
22180
beaacfca0055
Stop bookmarks being hidden by breakpoints / execution point (bug #48292)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22179
diff
changeset
|
172 _edit_area->markerDefine (QsciScintilla::RightArrow, marker::debugger_position); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
173 _edit_area->setMarkerBackgroundColor (QColor (255,255,0), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
174 marker::debugger_position); |
22180
beaacfca0055
Stop bookmarks being hidden by breakpoints / execution point (bug #48292)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22179
diff
changeset
|
175 _edit_area->markerDefine (QsciScintilla::RightArrow, |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
176 marker::unsure_debugger_position); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
177 _edit_area->setMarkerBackgroundColor (QColor (192,192,192), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
178 marker::unsure_debugger_position); |
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
|
179 |
15045
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
180 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
|
181 Qt::KeyboardModifiers)), |
1ffaad442161
Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14890
diff
changeset
|
182 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
|
183 Qt::KeyboardModifiers))); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
184 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
185 connect (_edit_area, SIGNAL (context_menu_break_condition_signal (int)), |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
186 this, SLOT (handle_context_menu_break_condition (int))); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
187 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 // line numbers |
16558 | 189 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96)); |
190 _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
|
191 _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
|
192 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
193 // 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
|
194 _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
|
195 _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
|
196 _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
|
197 _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
|
198 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
199 _edit_area->setUtf8 (true); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
200 |
15365
b4c32f245da7
GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
15356
diff
changeset
|
201 // auto completion |
18483
0f3bc7ccb875
update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents:
18482
diff
changeset
|
202 _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART, false); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
203 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
204 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
|
205 edit_area_layout->addWidget (_edit_area); |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
206 edit_area_layout->addWidget (_status_bar); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
207 edit_area_layout->setMargin (0); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
208 setLayout (edit_area_layout); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
209 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
210 // 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
|
211 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
|
212 this, SLOT (update_window_title (bool))); |
16558 | 213 |
14715
b4db843b1f26
Done some extra method renaming to fit the overall octave coding style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
214 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
|
215 this, SLOT (handle_copy_available (bool))); |
16558 | 216 |
217 connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)), | |
218 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
|
219 |
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
|
220 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
|
221 if (settings) |
19770
35a8e1beac8d
fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents:
19768
diff
changeset
|
222 notice_settings (settings, true); |
20630
802dc52d4d46
improve focus detection of gui (bug #45306)
Torsten <ttl@justmail.de>
parents:
19910
diff
changeset
|
223 |
802dc52d4d46
improve focus detection of gui (bug #45306)
Torsten <ttl@justmail.de>
parents:
19910
diff
changeset
|
224 setFocusProxy (_edit_area); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
225 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
226 // encoding, not updated with the settings |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
227 #if defined (Q_OS_WIN32) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23804
diff
changeset
|
228 _encoding = settings->value ("editor/default_encoding", "SYSTEM") |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
229 .toString (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
230 #else |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23804
diff
changeset
|
231 _encoding = settings->value ("editor/default_encoding", "UTF-8") |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
232 .toString (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
233 #endif |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
234 _enc_indicator->setText (_encoding); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
235 // no changes in encoding yet |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
236 _new_encoding = _encoding; |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
237 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
238 // indicators |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
239 _indicator_highlight_all |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
240 = _edit_area->indicatorDefine (QsciScintilla::StraightBoxIndicator); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
241 if (_indicator_highlight_all == -1) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
242 _indicator_highlight_all = 1; |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
243 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
244 _edit_area->setIndicatorDrawUnder (true, _indicator_highlight_all); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
245 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
246 |
16558 | 247 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
|
248 { |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
249 // Tell all connected markers to self-destruct. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
250 emit remove_all_breakpoints (); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
251 emit remove_all_positions (); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
252 |
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
|
253 // 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
|
254 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
|
255 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
|
256 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
257 delete lexer; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
258 _edit_area->setLexer (nullptr); |
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
|
259 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
260 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
|
261 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
262 delete _find_dialog; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
263 _find_dialog = nullptr; |
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
|
264 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
265 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
266 // 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
|
267 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
|
268 } |
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
|
269 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
270 void |
20793
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
271 file_editor_tab::set_encoding (const QString& new_encoding) |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
272 { |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
273 if (new_encoding.isEmpty ()) |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
274 return; |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
275 |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
276 _encoding = new_encoding; |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
277 _enc_indicator->setText (_encoding); |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
278 if (! _edit_area->text ().isEmpty ()) |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
279 set_modified (true); |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
280 } |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
281 |
f7b0572fff6e
allow to select an encoding when opening a file
Torsten <ttl@justmail.de>
parents:
20783
diff
changeset
|
282 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
283 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
|
284 { |
19844
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
285 _cancelled = false; // prevent unwanted interaction of previous |
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
286 // exits of octave which were canceled by the user |
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
287 |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
288 if (check_file_modified () == QMessageBox::Cancel) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
289 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
290 // ignore close event if file is not saved and user cancels |
19844
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
291 // closing this window |
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
292 e->ignore (); |
a09471d938a5
fix closing a tab with modification
Torsten <ttl@justmail.de>
parents:
19804
diff
changeset
|
293 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
294 else |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
295 { |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
296 e->accept (); |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
297 emit tab_remove_request (); |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
298 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 void |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
302 file_editor_tab::set_current_directory (const QString& dir) |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
303 { |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
304 _ced = dir; |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
305 } |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
306 |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
307 void |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
308 file_editor_tab::handle_context_menu_edit (const QString& word_at_cursor) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
309 { |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
310 // search for a subfunction in actual file (this is done at first because |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
311 // octave finds this function before other with same name in the search path |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
312 QRegExp rxfun1 ("^[\t ]*function[^=]+=[\t ]*" |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
313 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
314 QRegExp rxfun2 ("^[\t ]*function[\t ]+" |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
315 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
316 QRegExp rxfun3 ("^[\t ]*function[\t ]+" |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
317 + word_at_cursor + "[\t ]*$"); |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
318 QRegExp rxfun4 ("^[\t ]*function[^=]+=[\t ]*" |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
319 + word_at_cursor + "[\t ]*$"); |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
320 |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
321 int pos_fct = -1; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
322 QStringList lines = _edit_area->text ().split ("\n"); |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
323 |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
324 int line; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
325 for (line = 0; line < lines.count (); line++) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
326 { |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
327 if ((pos_fct = rxfun1.indexIn (lines.at (line))) != -1) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
328 break; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
329 if ((pos_fct = rxfun2.indexIn (lines.at (line))) != -1) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
330 break; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
331 if ((pos_fct = rxfun3.indexIn (lines.at (line))) != -1) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
332 break; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
333 if ((pos_fct = rxfun4.indexIn (lines.at (line))) != -1) |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
334 break; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
335 } |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
336 |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
337 if (pos_fct > -1) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
338 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
339 // reg expr. found: it is an internal function |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
340 _edit_area->setCursorPosition (line, pos_fct); |
22178
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
341 _edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
342 // SCI_VISIBLEFROMDOCLINE |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
343 int vis_line = _edit_area->SendScintilla (2220, line); |
22178
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
344 _edit_area->SendScintilla (2613, vis_line); // SCI_SETFIRSTVISIBLELINE |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
345 return; |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
346 } |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
347 |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20993
diff
changeset
|
348 emit edit_mfile_request (word_at_cursor, _file_name, _ced, -1); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20993
diff
changeset
|
349 } |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
350 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
351 // If "dbstop if ..." selected from context menu, create a conditional |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
352 // breakpoint. The default condition is (a) the existing condition if there |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
353 // is already a breakpoint (b) any selected text, or (c) empty |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
354 void |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
355 file_editor_tab::handle_context_menu_break_condition (int linenr) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
356 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
357 // Ensure editor line numbers match Octave core's line numbers. |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
358 // Give users the option to save modifications if necessary. |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
359 if (! unchanged_or_saved ()) |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
360 return; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
361 |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
362 QString cond; |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
363 bp_info info (_file_name, linenr+1); // Get function name & dir from filename. |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
364 |
21578
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
365 // Search for previous condition. FIXME: is there a more direct way? |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
366 if (_edit_area->markersAtLine (linenr) & (1 << marker::cond_break)) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
367 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
368 emit report_marker_linenr (_bp_lines, _bp_conditions); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
369 for (int i = 0; i < _bp_lines.length (); i++) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
370 if (_bp_lines.value (i) == linenr) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
371 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
372 cond = _bp_conditions.value (i); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
373 break; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
374 } |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
375 _bp_lines.clear (); |
21651
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
376 _bp_conditions.clear (); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
377 } |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
378 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
379 // If text selected by the mouse, default to that instead |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
380 // If both present, use the OR of them, to avoid accidental overwriting |
21578
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
381 // FIXME: If both are present, show old condition unselected and |
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
382 // the selection (in edit area) selected (in the dialog). |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
383 if (_edit_area->hasSelectedText ()) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
384 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
385 if (cond == "") |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
386 cond = _edit_area->selectedText (); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
387 else |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23804
diff
changeset
|
388 cond = '(' + cond + ") || (" + _edit_area->selectedText () + ')'; |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
389 } |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
390 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
391 bool valid = false; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
392 std::string prompt = "dbstop if"; |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
393 bool ok; |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22422
diff
changeset
|
394 while (! valid) |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
395 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
396 QString new_condition |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
397 = QInputDialog::getText (this, tr ("Breakpoint condition"), |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
398 tr (prompt.c_str ()), QLineEdit::Normal, cond, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
399 &ok); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
400 if (ok) // If cancel, don't change breakpoint condition. |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
401 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
402 try |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
403 { |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
404 // Suppress error messages on the console. |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
405 octave::unwind_protect frame; |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
406 frame.protect_var (buffer_error_messages); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
407 buffer_error_messages++; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
408 |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
409 bp_table::condition_valid (new_condition.toStdString ()); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
410 valid = true; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
411 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
412 catch (const octave::index_exception& e) { } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
413 catch (const octave::execution_exception& e) { } |
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
414 catch (const octave::interrupt_exception&) |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
415 { |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
416 ok = false; |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
417 valid = true; |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
418 } |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
419 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
420 // In case we repeat, set new prompt. |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
421 prompt = "ERROR: " + last_error_message () + "\n\ndbstop if"; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
422 cond = new_condition; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
423 } |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
424 else |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
425 valid = true; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
426 } |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
427 |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
428 if (ok) // If the user didn't cancel, actually set the breakpoint. |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
429 { |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
430 info.condition = cond.toStdString (); |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
431 |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
432 octave_link::post_event |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
433 (this, &file_editor_tab::add_breakpoint_callback, info); |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21310
diff
changeset
|
434 } |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
435 } |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
436 |
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
437 void |
15300
fd27e10b9b05
pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents:
15286
diff
changeset
|
438 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
|
439 { |
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
|
440 // 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
|
441 QStringList trackedFiles = _file_system_watcher.files (); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
442 if (! trackedFiles.isEmpty ()) |
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
|
443 _file_system_watcher.removePath (_file_name); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
444 if (! fileName.isEmpty ()) |
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 _file_system_watcher.addPath (fileName); |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
446 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
447 // update lexer and file name variable if file name changes |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
448 if (_file_name != fileName) |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
449 { |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
450 _file_name = fileName; |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
451 update_lexer (); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
452 } |
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
|
453 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
454 // update the file editor with current editing directory |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
455 emit editor_state_changed (_copy_available, _is_octave_file); |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
456 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
457 // add the new file to the most-recently-used list |
20814
2da4058d65c7
store the encoding of recent editor files in the mru list
Torsten <ttl@justmail.de>
parents:
20796
diff
changeset
|
458 emit mru_add_file (_file_name, _encoding); |
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
|
459 } |
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
|
460 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
461 // valid_file_name (file): checks whether "file" names a file. |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
462 // By default, "file" is empty; then _file_name is checked |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
463 bool |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
464 file_editor_tab::valid_file_name (const QString& file) |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
465 { |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
466 if (file.isEmpty ()) |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
467 { |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
468 if (_file_name.isEmpty ()) |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
469 return false; |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
470 else |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
471 return true; |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
472 } |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
473 |
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
474 return true; |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
475 } |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
476 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
477 // We cannot create a breakpoint when the file is modified |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
478 // because the line number the editor is providing might |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
479 // not match what Octave core is interpreting in the |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
480 // file on disk. This function gives the user the option |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
481 // to save before creating the breakpoint. |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
482 bool |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
483 file_editor_tab::unchanged_or_saved (void) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
484 { |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
485 bool retval = true; |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
486 if (_edit_area->isModified ()) |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
487 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
488 int ans = QMessageBox::question (nullptr, tr ("Octave Editor"), |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
489 tr ("Cannot add breakpoint to modified file.\n" |
22422
0abb58c3b117
file-editor-tab.cc: Fix typo canel -> cancel
Andreas Weber <andy.weber.aw@gmail.com>
parents:
22411
diff
changeset
|
490 "Save and add breakpoint, or cancel?"), |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
491 QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save); |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
492 |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
493 if (ans == QMessageBox::Save) |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
494 save_file (_file_name, false); |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
495 else |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
496 retval = false; |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
497 } |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
498 |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
499 return retval; |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
500 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
501 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
502 // Toggle a breakpoint at the editor_linenr or, if this was called by |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
503 // a click with CTRL pressed, toggle a bookmark at that point. |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
504 void |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
505 file_editor_tab::handle_margin_clicked (int margin, int editor_linenr, |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
506 Qt::KeyboardModifiers state) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
507 { |
14825
eae0e9f2a8c6
Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14804
diff
changeset
|
508 if (margin == 1) |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
509 { |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
510 unsigned int markers_mask = _edit_area->markersAtLine (editor_linenr); |
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
|
511 |
eae0e9f2a8c6
Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14804
diff
changeset
|
512 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
|
513 { |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
514 if (markers_mask & (1 << marker::bookmark)) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
515 _edit_area->markerDelete (editor_linenr, marker::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
|
516 else |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
517 _edit_area->markerAdd (editor_linenr, marker::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
|
518 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
519 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
|
520 { |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
521 if (markers_mask & ((1 << marker::breakpoint) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
522 | (1 << marker::cond_break))) |
21010
9b21039bf63b
fix line number when removing a breakpoint via the gui (bug #46779)
Torsten <ttl@justmail.de>
parents:
21007
diff
changeset
|
523 handle_request_remove_breakpoint (editor_linenr + 1); |
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
|
524 else |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
525 { |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
526 if (unchanged_or_saved ()) |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
527 handle_request_add_breakpoint (editor_linenr + 1, ""); |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
528 } |
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
|
529 } |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
530 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
531 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
532 |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
533 |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
534 void |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
535 file_editor_tab::update_lexer () |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
536 { |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
537 // Create a new lexer |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
538 QsciLexer *lexer = nullptr; |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
539 |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
540 _is_octave_file = false; |
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
541 |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
542 // Find the required lexer from file extensions |
16559
78765ae325fd
gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents:
16558
diff
changeset
|
543 if (_file_name.endsWith (".m") |
78765ae325fd
gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents:
16558
diff
changeset
|
544 || _file_name.endsWith ("octaverc")) |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
545 { |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
546 #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
|
547 lexer = new QsciLexerOctave (); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
548 #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
|
549 lexer = new QsciLexerMatlab (); |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
550 #else |
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
551 lexer = new octave_txt_lexer (); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
552 #endif |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
553 _is_octave_file = true; |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
554 } |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
555 |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
556 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
|
557 { |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
558 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
|
559 || _file_name.endsWith (".cc") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
560 || _file_name.endsWith (".cpp") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
561 || _file_name.endsWith (".cxx") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
562 || _file_name.endsWith (".c++") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
563 || _file_name.endsWith (".h") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
564 || _file_name.endsWith (".hh") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
565 || _file_name.endsWith (".hpp") |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
566 || _file_name.endsWith (".h++")) |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
567 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
568 lexer = new QsciLexerCPP (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
569 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
570 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
|
571 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
572 lexer = new QsciLexerPerl (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
573 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
574 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
|
575 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
576 lexer = new QsciLexerBatch (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
577 } |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
578 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
|
579 { |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
580 lexer = new QsciLexerDiff (); |
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
581 } |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
582 else if (_file_name.endsWith (".sh")) |
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
583 { |
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
584 lexer = new QsciLexerBash (); |
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
585 } |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
586 else if (! valid_file_name ()) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
587 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
588 // new, no yet named file: let us assume it is octave |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
589 #if defined (HAVE_LEXER_OCTAVE) |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
590 lexer = new QsciLexerOctave (); |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
591 _is_octave_file = true; |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
592 #elif defined (HAVE_LEXER_MATLAB) |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
593 lexer = new QsciLexerMatlab (); |
18767
095fdef3d67c
use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents:
18733
diff
changeset
|
594 _is_octave_file = true; |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
595 #else |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
596 lexer = new octave_txt_lexer (); |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
597 #endif |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
598 } |
16720
973fd2367d44
select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents:
16719
diff
changeset
|
599 else |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
600 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
601 // other or no extension |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
602 lexer = new octave_txt_lexer (); |
16720
973fd2367d44
select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents:
16719
diff
changeset
|
603 } |
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
|
604 } |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
605 |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
606 // Get any existing lexer |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
607 QsciLexer *old_lexer = _edit_area->lexer (); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
608 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
609 // If new file, no lexer, or lexer has changed, |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
610 // delete old one and set the newly created as current lexer |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
611 if (! old_lexer || ! valid_file_name () |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
612 || QString(old_lexer->lexer ()) != QString(lexer->lexer ())) |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
613 { |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
614 // Delete and set new lexer |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
615 if (old_lexer) |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
616 delete old_lexer; |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
617 _edit_area->setLexer (lexer); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
618 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
619 // build information for auto completion (APIs) |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
620 _lexer_apis = new QsciAPIs (lexer); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
621 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
622 // Get the settings for this new lexer |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
623 update_lexer_settings (); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
624 } |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
625 else |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
626 { |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
627 // Otherwise, delete the newly created lexer and |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
628 // use the old, exisiting one |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
629 if (lexer) |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
630 delete lexer; |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
631 } |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
632 } |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
633 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
634 |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
635 // Update settings, which are lexer related and have to be updated |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
636 // when a) the lexer changes or b) the settings have changed. |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
637 void |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
638 file_editor_tab::update_lexer_settings () |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
639 { |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
640 QsciLexer *lexer = _edit_area->lexer (); |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
641 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
642 QSettings *settings = resource_manager::get_settings (); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
643 |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
644 if (_lexer_apis) |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
645 { |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
646 _lexer_apis->cancelPreparation (); // stop preparing if apis exists |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
647 |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
648 bool update_apis = false; // flag, whether update of apis files |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
649 |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
650 // get path to prepared api info |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
651 #if defined (HAVE_QT4) |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
652 QString prep_apis_path |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
653 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
654 + "/.config/octave/" + QString (OCTAVE_VERSION) + "/qsci/"; |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
655 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
656 QString prep_apis_path |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
657 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
658 + "/.config/octave/" + QString (OCTAVE_VERSION) + "/qsci/"; |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
659 #endif |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
660 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
661 // get settings which infos are used for octave |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
662 bool octave_builtins = settings->value ( |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
663 "editor/codeCompletion_octave_builtins", true).toBool (); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
664 bool octave_functions = settings->value ( |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
665 "editor/codeCompletion_octave_functions", true).toBool (); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
666 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
667 if (_is_octave_file) |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
668 { |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
669 // Keywords and Builtins do not change, these informations can be |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
670 // stored in prepared form in a file. Information on function are |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
671 // changing frequently, then if functions should also be auto- |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
672 // completed, the date of any existing file is checked. |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
673 |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
674 // Keywords are always used |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
675 _prep_apis_file = prep_apis_path + lexer->lexer () + "_k"; |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
676 |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
677 // Buitlins are only used if the user settings say so |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
678 if (octave_builtins) |
23802
3f7226b07a38
Change string append += "c" to += 'c' to avoid string constructor.
Rik <rik@octave.org>
parents:
23796
diff
changeset
|
679 _prep_apis_file += 'b'; |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
680 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
681 if (octave_functions) |
23802
3f7226b07a38
Change string append += "c" to += 'c' to avoid string constructor.
Rik <rik@octave.org>
parents:
23796
diff
changeset
|
682 _prep_apis_file += 'f'; |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
683 |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
684 _prep_apis_file += ".pap"; // final name of apis file |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
685 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
686 // check whether the APIs info needs to be prepared and saved |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
687 QFileInfo apis_file = QFileInfo (_prep_apis_file); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
688 // flag whether apis file needs update |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
689 update_apis = ! apis_file.exists (); |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
690 |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
691 if (octave_functions) |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
692 { |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
693 // Functions may change frequently. Update the apis data |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
694 // if the file is older than a few minutes preventing from |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
695 // re-preparing data when the user opens several files. |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
696 QDateTime apis_time = apis_file.lastModified (); |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
697 if (QDateTime::currentDateTime () > apis_time.addSecs (180)) |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
698 update_apis = true; |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
699 } |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
700 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
701 } |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
702 else // no octave file, just add extension |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
703 { |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
704 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
705 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
706 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
707 } |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
708 |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
709 if (update_apis || ! _lexer_apis->loadPrepared (_prep_apis_file)) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
710 { |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
711 // either we have decided to update the apis file or |
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
712 // no prepared info was loaded, prepare and save if possible |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
713 |
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
714 // create raw apis info |
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
715 QString keyword; |
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
716 QStringList keyword_list; |
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
717 int i,j; |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
718 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
719 if (_is_octave_file) |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
720 { |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
721 // octave: get keywords from internal informations depending on |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
722 // user preferences |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
723 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
724 // keywords are always used |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
725 add_octave_apis (Fiskeyword ()); // add new entries |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
726 |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
727 octave::interpreter& interp |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
728 = octave::__get_interpreter__ ( |
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
729 "file_editor_tab::update_lexer_settings"); |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
730 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
731 if (octave_builtins) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
732 add_octave_apis (F__builtins__ (interp)); // add new entries |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
733 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
734 if (octave_functions) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
735 add_octave_apis (F__list_functions__ (interp)); // add new entries |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
736 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
737 } |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
738 else |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
739 { |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
740 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
741 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
742 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
743 for (i=1; i<=3; i++) // test the first 5 keyword sets |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
744 { |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23802
diff
changeset
|
745 keyword = QString (lexer->keywords (i)); // get list |
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23802
diff
changeset
|
746 keyword_list = keyword.split (QRegExp (R"(\s+)")); // split |
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23802
diff
changeset
|
747 for (j = 0; j < keyword_list.size (); j++) // add to API |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
748 _lexer_apis->add (keyword_list.at (j)); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
749 } |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
750 } |
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
751 |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
752 // disconnect slot for saving prepared info if already connected |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
753 disconnect (_lexer_apis, SIGNAL (apiPreparationFinished ()), nullptr, nullptr); |
16717
9ad6e7d4fa42
fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents:
16716
diff
changeset
|
754 // check whether path for prepared info exists or can be created |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
755 if (QDir ("/").mkpath (prep_apis_path)) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
756 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
757 // path exists, apis info can be saved there |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
758 connect (_lexer_apis, SIGNAL (apiPreparationFinished ()), |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
759 this, SLOT (save_apis_info ())); |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
760 } |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
761 |
16721
a71a784c7611
* file-editor-tab.cc(update_lexer): redundant code removed
Torsten <ttl@justmail.de>
parents:
16720
diff
changeset
|
762 _lexer_apis->prepare (); // prepare apis info |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
763 |
16678
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
764 } |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
765 } |
518dbe0ae857
fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents:
16662
diff
changeset
|
766 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
767 lexer->readSettings (*settings); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
768 |
19181
e85203f41402
set cursor color of the editor to color of default text (bug #43314)
Torsten <ttl@justmail.de>
parents:
19043
diff
changeset
|
769 _edit_area->setCaretForegroundColor (lexer->color (0)); |
e85203f41402
set cursor color of the editor to color of default text (bug #43314)
Torsten <ttl@justmail.de>
parents:
19043
diff
changeset
|
770 _edit_area->setIndentationGuidesForegroundColor (lexer->color (0)); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15365
diff
changeset
|
771 |
21011
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
772 // set some colors depending on selected background color of the lexer |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
773 QColor bg = lexer->paper (0); |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
774 QColor fg = lexer->color (0); |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
775 |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
776 int bh, bs, bv, fh, fs, fv, h, s, v; |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
777 bg.getHsv (&bh,&bs,&bv); |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
778 fg.getHsv (&fh,&fs,&fv); |
20993
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
779 |
21011
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
780 // margin colors |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
781 h = bh; |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
782 s = bs/2; |
23186
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
783 v = bv + (fv - bv)/5; |
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
784 |
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
785 bg.setHsv (h,s,v); |
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
786 _edit_area->setEdgeColor (bg); |
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
787 |
21011
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
788 v = bv + (fv - bv)/8; |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
789 bg.setHsv (h,s,v); |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
790 v = bv + (fv - bv)/4; |
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
791 fg.setHsv (h,s,v); |
20993
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
792 |
21011
d9f4e4961e09
improved margin and marker colors in the editor
Torsten <ttl@justmail.de>
parents:
21010
diff
changeset
|
793 _edit_area->setMarkerForegroundColor (lexer->color (0)); |
20993
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
794 _edit_area->setMarginsForegroundColor (lexer->color (0)); |
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
795 _edit_area->setMarginsBackgroundColor (bg); |
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
796 _edit_area->setFoldMarginColors (bg,fg); |
31a12af0aaaf
color of editor margins adapted to currently chosen style (bug #46706)
Torsten <ttl@justmail.de>
parents:
20955
diff
changeset
|
797 |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
798 // color indicator for highlighting all occurrences: |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
799 // applications highlight color with more transparency |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
800 QColor hg = QApplication::palette ().color (QPalette::Highlight); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
801 hg.setAlphaF (0.25); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
802 _edit_area->setIndicatorForegroundColor (hg, _indicator_highlight_all); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
803 _edit_area->setIndicatorOutlineColor (hg, _indicator_highlight_all); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
804 |
23490
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
805 // fix line number width with respect to the font size of the lexer and |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
806 // set the line numbers font depending on the lexers font |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
807 if (settings->value ("editor/showLineNumbers", true).toBool ()) |
23490
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
808 { |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
809 // Line numbers width |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
810 auto_margin_width (); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
811 |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
812 // Line numbers font |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
813 QFont line_numbers_font = lexer->defaultFont (); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
814 int font_size = line_numbers_font.pointSize (); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
815 font_size = font_size |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
816 + settings->value ("editor/line_numbers_size", 0).toInt (); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
817 if (font_size < 4) |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
818 font_size = 4; |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
819 line_numbers_font.setPointSize (font_size); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
820 |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
821 _edit_area->setMarginsFont (line_numbers_font); |
7463c8e91dba
customizable size of line numbers in the editor (bug #46959)
Torsten <mttl@mailbox.org>
parents:
23489
diff
changeset
|
822 } |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
823 else |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
824 _edit_area->setMarginWidth (2,0); |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
825 } |
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
826 |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
827 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
828 // function for adding entries to the octave lexer's APIs |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
829 void |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
830 file_editor_tab::add_octave_apis (octave_value_list key_ovl) |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
831 { |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
832 octave_value keys = key_ovl(0); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
833 Cell key_list = keys.cell_value (); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
834 |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
835 for (int idx = 0; idx < key_list.numel (); idx++) |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
836 _lexer_apis->add (QString (key_list.elem (idx).string_value ().data ())); |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
837 } |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
838 |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
839 void |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
840 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
|
841 { |
16715
96ed7ab44e2e
save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents:
16704
diff
changeset
|
842 _lexer_apis->savePrepared (_prep_apis_file); |
16704
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
843 } |
e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents:
16703
diff
changeset
|
844 |
15980
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
845 // 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
|
846 void |
16558 | 847 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
|
848 { |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
849 if (ID != this) |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
850 return; |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
851 _edit_area->setFocus (); |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
852 } |
6c0fce0632a4
gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
853 |
14869
db3c84d38345
Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14833
diff
changeset
|
854 void |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
855 file_editor_tab::context_help (const QWidget *ID, bool doc) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
856 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
857 if (ID != this) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
858 return; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
859 |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
860 _edit_area->context_help_doc (doc); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
861 } |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
862 |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16912
diff
changeset
|
863 void |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
864 file_editor_tab::context_edit (const QWidget *ID) |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
865 { |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
866 if (ID != this) |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
867 return; |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
868 |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
869 _edit_area->context_edit (); |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
870 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
871 |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
872 void |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
873 file_editor_tab::check_modified_file (void) |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
874 { |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
875 if (_cancelled) |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
876 return; |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
877 |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
878 if (check_file_modified () == QMessageBox::Cancel) |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
879 _cancelled = true; |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
880 } |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
881 |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
882 void |
16558 | 883 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
|
884 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
885 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
|
886 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
|
887 |
424edeca3c66
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 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
|
889 } |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
890 |
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
|
891 void |
16558 | 892 file_editor_tab::save_file (const QWidget *ID, const QString& fileName, |
893 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
|
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 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
|
896 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
|
897 |
424edeca3c66
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 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
|
899 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
900 |
424edeca3c66
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 void |
16558 | 902 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
|
903 { |
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
|
904 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
|
905 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
|
906 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
907 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
|
908 } |
424edeca3c66
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 |
424edeca3c66
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 void |
16558 | 911 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
|
912 { |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
913 if (ID != this) |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
914 return; |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
915 |
16558 | 916 QsciPrinter *printer = new QsciPrinter (QPrinter::HighResolution); |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
917 |
16558 | 918 QPrintDialog printDlg (printer, this); |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
919 |
16558 | 920 if (printDlg.exec () == QDialog::Accepted) |
921 printer->printRange (_edit_area); | |
922 | |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
923 delete printer; |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
924 } |
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
925 |
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
|
926 void |
16558 | 927 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
|
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 (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
|
930 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
|
931 |
18838
b43157d085ba
make sure a new and still unnamed file is saved when run from the editor
Torsten <ttl@justmail.de>
parents:
18837
diff
changeset
|
932 if (_edit_area->isModified () | ! valid_file_name ()) |
19910
bb1629e15afe
cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents:
19900
diff
changeset
|
933 { |
bb1629e15afe
cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents:
19900
diff
changeset
|
934 save_file (_file_name); // save file dialog |
bb1629e15afe
cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents:
19900
diff
changeset
|
935 if (! valid_file_name ()) |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20677
diff
changeset
|
936 return; // still invalid filename: "save as" was cancelled |
19910
bb1629e15afe
cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents:
19900
diff
changeset
|
937 } |
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
|
938 |
16635
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
939 QFileInfo info (_file_name); |
25e418d23a4b
fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents:
16591
diff
changeset
|
940 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
|
941 } |
4c4f2fb07a50
Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15045
diff
changeset
|
942 |
4c4f2fb07a50
Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15045
diff
changeset
|
943 void |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
944 file_editor_tab::context_run (const QWidget *ID) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
945 { |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
946 if (ID != this) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
947 return; |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
948 |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
949 _edit_area->context_run (); |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
950 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
951 |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
952 void |
16558 | 953 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
|
954 { |
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
|
955 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
|
956 return; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
957 |
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
|
958 int line, cur; |
16558 | 959 _edit_area->getCursorPosition (&line, &cur); |
960 | |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
961 if (_edit_area->markersAtLine (line) & (1 << marker::bookmark)) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
962 _edit_area->markerDelete (line, marker::bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
963 else |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
964 _edit_area->markerAdd (line, marker::bookmark); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
965 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
966 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
967 // Move the text cursor to the closest bookmark |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
968 // after the current line. |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
969 void |
16558 | 970 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
|
971 { |
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
|
972 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
|
973 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
|
974 |
16558 | 975 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
|
976 _edit_area->getCursorPosition (&line, &cur); |
16558 | 977 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
978 line++; // Find bookmark strictly after the current line. |
16558 | 979 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
980 int nextline = _edit_area->markerFindNext (line, (1 << marker::bookmark)); |
16558 | 981 |
22179
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
982 // Wrap. |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
983 if (nextline == -1) |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
984 nextline = _edit_area->markerFindNext (1, (1 << marker::bookmark)); |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
985 |
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
|
986 _edit_area->setCursorPosition (nextline, 0); |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
987 } |
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
988 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
989 // Move the text cursor to the closest bookmark |
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
990 // before the current line. |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
991 void |
16558 | 992 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
|
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 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
|
995 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
|
996 |
16558 | 997 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
|
998 _edit_area->getCursorPosition (&line, &cur); |
16558 | 999 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1000 line--; // Find bookmark strictly before the current line. |
16558 | 1001 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1002 int prevline = _edit_area->markerFindPrevious (line, (1 << marker::bookmark)); |
16558 | 1003 |
22179
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
1004 // Wrap. Should use the last line of the file, not 1<<15 |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
1005 if (prevline == -1) |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
1006 prevline = _edit_area->markerFindPrevious (_edit_area->lines (), |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
1007 (1 << marker::bookmark)); |
603f0d752de2
Wrap search for "next bookmark" and "prev bookmark" (bug #48044)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22178
diff
changeset
|
1008 |
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
|
1009 _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
|
1010 } |
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
|
1011 |
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
|
1012 void |
16558 | 1013 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
|
1014 { |
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
|
1015 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
|
1016 return; |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1017 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1018 _edit_area->markerDeleteAll (marker::bookmark); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1019 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1020 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1021 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1022 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
|
1023 { |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1024 bp_table::intmap line_info; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1025 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
|
1026 |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
1027 if (octave_qt_link::file_in_path (info.file, info.dir)) |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1028 bp_table::add_breakpoint (info.function_name, line_info, info.condition); |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1029 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1030 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1031 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1032 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
|
1033 { |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1034 bp_table::intmap line_info; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
1035 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
|
1036 |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
1037 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
|
1038 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
|
1039 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1040 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1041 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
1042 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
|
1043 { |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
1044 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
|
1045 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
|
1046 } |
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
|
1047 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1048 file_editor_tab::bp_info::bp_info (const QString& fname, int l, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1049 const QString& cond) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1050 : line (l), file (fname.toStdString ()), condition (cond.toStdString ()) |
18237
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1051 { |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1052 QFileInfo file_info (fname); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1053 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1054 QString q_dir = file_info.absolutePath (); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1055 QString q_function_name = file_info.fileName (); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1056 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1057 // We have to cut off the suffix, because octave appends it. |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1058 q_function_name.chop (file_info.suffix ().length () + 1); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1059 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1060 dir = q_dir.toStdString (); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1061 function_name = q_function_name.toStdString (); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1062 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1063 // Is the last component of DIR @foo? If so, strip it and prepend it |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1064 // to the name of the function. |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1065 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1066 size_t pos = dir.rfind (octave::sys::file_ops::dir_sep_chars ()); |
18237
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1067 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1068 if (pos != std::string::npos && pos < dir.length () - 1) |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1069 { |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1070 if (dir[pos+1] == '@') |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1071 { |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1072 function_name = octave::sys::file_ops::concat (dir.substr (pos+1), function_name); |
18237
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1073 |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1074 dir = dir.substr (0, pos); |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1075 } |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1076 } |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1077 } |
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1078 |
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
|
1079 void |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1080 file_editor_tab::handle_request_add_breakpoint (int line, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1081 const QString& condition) |
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
|
1082 { |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1083 bp_info info (_file_name, line, condition); |
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
|
1084 |
424edeca3c66
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 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
|
1086 (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
|
1087 } |
424edeca3c66
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 |
424edeca3c66
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 void |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1090 file_editor_tab::handle_request_remove_breakpoint (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
|
1091 { |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1092 bp_info info (_file_name, 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
|
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 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
|
1095 (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
|
1096 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1097 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1098 void |
16558 | 1099 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
|
1100 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1101 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
|
1102 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
|
1103 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1104 int editor_linenr, cur; |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1105 _edit_area->getCursorPosition (&editor_linenr, &cur); |
16558 | 1106 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1107 if (_edit_area->markersAtLine (editor_linenr) & (1 << marker::breakpoint)) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1108 request_remove_breakpoint_via_editor_linenr (editor_linenr); |
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
|
1109 else |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1110 { |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1111 if (unchanged_or_saved ()) |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1112 handle_request_add_breakpoint (editor_linenr + 1, ""); |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1113 } |
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
|
1114 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1115 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1116 // Move the text cursor to the closest breakpoint (conditional or unconditional) |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1117 // after the 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
|
1118 void |
16558 | 1119 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
|
1120 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1121 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
|
1122 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
|
1123 |
16558 | 1124 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
|
1125 _edit_area->getCursorPosition (&line, &cur); |
16558 | 1126 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1127 line++; // Find breakpoint strictly after the current line. |
16558 | 1128 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1129 int nextline = _edit_area->markerFindNext (line, (1 << marker::breakpoint)); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1130 int nextcond = _edit_area->markerFindNext (line, (1 << marker::cond_break)); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1131 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1132 // Check if the next conditional breakpoint is before next unconditional one. |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1133 if (nextcond != -1 && (nextcond < nextline || nextline == -1)) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1134 nextline = nextcond; |
16558 | 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 _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
|
1137 } |
424edeca3c66
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 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1139 // Move the text cursor to the closest breakpoint (conditional or unconditional) |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1140 // before the 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
|
1141 void |
16558 | 1142 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
|
1143 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1144 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
|
1145 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
|
1146 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1147 int line, cur, prevline, prevcond; |
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 _edit_area->getCursorPosition (&line, &cur); |
16558 | 1149 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
1150 line--; // Find breakpoint strictly before the current line. |
16558 | 1151 |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1152 prevline = _edit_area->markerFindPrevious (line, (1 << marker::breakpoint)); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1153 prevcond = _edit_area->markerFindPrevious (line, (1 << marker::cond_break)); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1154 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1155 // Check if the prev conditional breakpoint is closer than the unconditional. |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1156 if (prevcond != -1 && prevcond > prevline) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1157 prevline = prevcond; |
16558 | 1158 |
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
|
1159 _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
|
1160 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1161 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1162 void |
16558 | 1163 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
|
1164 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1165 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
|
1166 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
|
1167 |
18237
f26d527c1a71
allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
18082
diff
changeset
|
1168 bp_info info (_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
|
1169 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1170 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
|
1171 (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
|
1172 } |
424edeca3c66
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 void |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1175 file_editor_tab::scintilla_command (const QWidget *ID, unsigned int sci_msg) |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1176 { |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1177 if (ID != this) |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1178 return; |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1179 |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1180 _edit_area->SendScintilla (sci_msg); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1181 } |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1182 |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
1183 void |
16558 | 1184 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
|
1185 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1186 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
|
1187 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
|
1188 |
424edeca3c66
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 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
|
1190 } |
424edeca3c66
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 |
424edeca3c66
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 void |
16558 | 1193 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
|
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 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
|
1196 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
|
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 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
|
1199 } |
424edeca3c66
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 void |
18303
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1202 file_editor_tab::indent_selected_text (const QWidget *ID) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1203 { |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1204 if (ID != this) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1205 return; |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1206 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1207 do_indent_selected_text (true); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1208 } |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1209 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1210 void |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1211 file_editor_tab::unindent_selected_text (const QWidget *ID) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1212 { |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1213 if (ID != this) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1214 return; |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1215 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1216 do_indent_selected_text (false); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1217 } |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1218 |
19247
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1219 void |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1220 file_editor_tab::convert_eol (const QWidget *ID, QsciScintilla::EolMode eol_mode) |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1221 { |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1222 if (ID != this) |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1223 return; |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1224 |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1225 _edit_area->convertEols (eol_mode); |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1226 _edit_area->setEolMode (eol_mode); |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1227 update_eol_indicator (); |
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19245
diff
changeset
|
1228 } |
18303
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1229 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1230 void |
18560
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1231 file_editor_tab::zoom_in (const QWidget *ID) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1232 { |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1233 if (ID != this) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1234 return; |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1235 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1236 _edit_area->zoomIn (1); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1237 auto_margin_width (); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1238 } |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1239 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1240 void |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1241 file_editor_tab::zoom_out (const QWidget *ID) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1242 { |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1243 if (ID != this) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1244 return; |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1245 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1246 _edit_area->zoomOut (1); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1247 auto_margin_width (); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1248 } |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1249 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1250 void |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1251 file_editor_tab::zoom_normal (const QWidget *ID) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1252 { |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1253 if (ID != this) |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1254 return; |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1255 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1256 _edit_area->zoomTo (0); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1257 auto_margin_width (); |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1258 } |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1259 |
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
1260 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
|
1261 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
|
1262 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1263 // 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
|
1264 // 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
|
1265 _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
|
1266 _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
|
1267 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1268 |
424edeca3c66
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 void |
22169
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1270 file_editor_tab::find (const QWidget *ID, QList<QAction *> fetab_actions) |
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
|
1271 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1272 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
|
1273 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
|
1274 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1275 // 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
|
1276 // 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
|
1277 // 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
|
1278 // 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
|
1279 // 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
|
1280 // 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
|
1281 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
1282 if (! _find_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
|
1283 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1284 _find_dialog = new find_dialog (_edit_area, |
22169
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1285 fetab_actions.mid (0,2), |
16558 | 1286 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
|
1287 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
|
1288 this, SLOT (handle_find_dialog_finished (int))); |
22169
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1289 |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1290 connect (this, SIGNAL (request_find_next ()), |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1291 _find_dialog, SLOT (find_next ())); |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1292 |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1293 connect (this, SIGNAL (request_find_previous ()), |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1294 _find_dialog, SLOT (find_prev ())); |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1295 |
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
|
1296 _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
|
1297 _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
|
1298 } |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
1299 else if (! _find_dialog->isVisible ()) |
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
|
1300 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1301 _find_dialog->setGeometry (_find_dialog_geometry); |
19441
521d4959fc42
fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents:
19430
diff
changeset
|
1302 QPoint p = _find_dialog->pos (); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
1303 _find_dialog->move (p.x ()+10, p.y ()+10); |
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
|
1304 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1305 |
19441
521d4959fc42
fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents:
19430
diff
changeset
|
1306 _find_dialog->show (); |
521d4959fc42
fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents:
19430
diff
changeset
|
1307 _find_dialog_is_visible = true; |
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
|
1308 _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
|
1309 _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
|
1310 |
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
|
1311 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1312 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1313 void |
22169
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1314 file_editor_tab::find_next (const QWidget *ID) |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1315 { |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1316 if (ID == this) |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1317 emit request_find_next (); |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1318 } |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1319 |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1320 void |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1321 file_editor_tab::find_previous (const QWidget *ID) |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1322 { |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1323 if (ID == this) |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1324 emit request_find_previous (); |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1325 } |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1326 |
b3ced5e3cebb
Enable shortcuts for find next / find previous
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22022
diff
changeset
|
1327 void |
16558 | 1328 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
|
1329 { |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1330 if (ID != this) |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1331 return; |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1332 |
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
|
1333 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
|
1334 { |
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
|
1335 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
|
1336 int index; |
16558 | 1337 _edit_area->getCursorPosition (&line, &index); |
1338 line = QInputDialog::getInt (_edit_area, tr ("Goto line"), | |
1339 tr ("Line number"), line+1, 1, | |
1340 _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
|
1341 if (ok) |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20993
diff
changeset
|
1342 _edit_area->setCursorPosition (line-1, 0); |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
1343 } |
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
|
1344 else // go to given line without dialog |
16558 | 1345 _edit_area->setCursorPosition (line-1, 0); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20993
diff
changeset
|
1346 |
21044
e2fdbdd00ef9
center line when setting a breakpoint only if line is at top or at bottom
Torsten <ttl@justmail.de>
parents:
21020
diff
changeset
|
1347 center_current_line (false); // only center line if at top or bottom |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1348 } |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1349 |
18303
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1350 void |
19629
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1351 file_editor_tab::move_match_brace (const QWidget *ID, bool select) |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1352 { |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1353 if (ID != this) |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1354 return; |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1355 |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1356 if (select) |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1357 _edit_area->selectToMatchingBrace (); |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1358 else |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1359 _edit_area->moveToMatchingBrace (); |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1360 } |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1361 |
8ef79bc61d8a
add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents:
19608
diff
changeset
|
1362 void |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1363 file_editor_tab::show_auto_completion (const QWidget *ID) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1364 { |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1365 if (ID != this) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1366 return; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1367 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1368 QsciScintilla::AutoCompletionSource s = _edit_area->autoCompletionSource (); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1369 switch (s) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1370 { |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1371 case QsciScintilla::AcsAll: |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1372 _edit_area->autoCompleteFromAll (); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1373 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1374 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1375 case QsciScintilla::AcsAPIs: |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1376 _edit_area->autoCompleteFromAPIs (); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1377 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1378 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1379 case QsciScintilla::AcsDocument: |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1380 _edit_area->autoCompleteFromDocument (); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1381 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1382 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1383 case QsciScintilla::AcsNone: |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1384 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1385 } |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1386 } |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1387 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1388 void |
18303
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1389 file_editor_tab::do_indent_selected_text (bool indent) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1390 { |
21578
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
1391 // FIXME: |
18303
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1392 _edit_area->beginUndoAction (); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1393 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1394 if (_edit_area->hasSelectedText ()) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1395 { |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1396 int lineFrom, lineTo, colFrom, colTo; |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1397 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1398 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1399 if (colTo == 0) // the beginning of last line is not selected |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1400 lineTo--; // stop at line above |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1401 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1402 for (int i = lineFrom; i <= lineTo; i++) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1403 { |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1404 if (indent) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1405 _edit_area->indent (i); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1406 else |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1407 _edit_area->unindent (i); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1408 } |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1409 //set selection on (un)indented section |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1410 _edit_area->setSelection (lineFrom, 0, lineTo, |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1411 _edit_area->text (lineTo).length ()); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1412 } |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1413 else |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1414 { |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1415 int cpline, col; |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1416 _edit_area->getCursorPosition (&cpline, &col); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1417 if (indent) |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1418 _edit_area->indent (cpline); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1419 else |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1420 _edit_area->unindent (cpline); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1421 } |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1422 |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1423 _edit_area->endUndoAction (); |
106da7544504
gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents:
18299
diff
changeset
|
1424 } |
16375
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1425 |
f482302d81c9
editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents:
16018
diff
changeset
|
1426 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
|
1427 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
|
1428 { |
23234
aaf20024db6f
function providing comment strings uses lexer number and not lexer names
Torsten <mttl@mailbox.org>
parents:
23230
diff
changeset
|
1429 QString comment_str = _edit_area->comment_string (); |
16737
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1430 _edit_area->beginUndoAction (); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1431 |
16558 | 1432 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
|
1433 { |
16558 | 1434 int lineFrom, lineTo, colFrom, colTo; |
1435 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); | |
1436 | |
1437 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
|
1438 lineTo--; // stop at line above |
16558 | 1439 |
1440 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
|
1441 { |
16558 | 1442 if (comment) |
16719
0f6f14e3ac6a
commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents:
16717
diff
changeset
|
1443 _edit_area->insertAt (comment_str, 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
|
1444 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
|
1445 { |
16558 | 1446 QString line (_edit_area->text (i)); |
16719
0f6f14e3ac6a
commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents:
16717
diff
changeset
|
1447 if (line.startsWith (comment_str)) |
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
|
1448 { |
16719
0f6f14e3ac6a
commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents:
16717
diff
changeset
|
1449 _edit_area->setSelection (i, 0, i, comment_str.length ()); |
16558 | 1450 _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
|
1451 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1452 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1453 } |
16737
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1454 //set selection on (un)commented section |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1455 _edit_area->setSelection (lineFrom, 0, lineTo, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1456 _edit_area->text (lineTo).length ()); |
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
|
1457 } |
16737
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1458 else |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1459 { |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1460 int cpline, col; |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1461 _edit_area->getCursorPosition (&cpline, &col); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1462 if (comment) |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1463 _edit_area->insertAt (comment_str, cpline, 0); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1464 else |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1465 { |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1466 QString line (_edit_area->text (cpline)); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1467 if (line.startsWith (comment_str)) |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1468 { |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1469 _edit_area->setSelection (cpline, 0, cpline, comment_str.length ()); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1470 _edit_area->removeSelectedText (); |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1471 } |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1472 } |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1473 } |
e81084a745a9
GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents:
16731
diff
changeset
|
1474 _edit_area->endUndoAction (); |
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
|
1475 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1476 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1477 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
|
1478 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
|
1479 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1480 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
|
1481 QString tooltip (""); |
16558 | 1482 |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
1483 if (! valid_file_name ()) |
16558 | 1484 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
|
1485 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
|
1486 { |
16558 | 1487 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
|
1488 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
|
1489 else |
e3873531dd7c
gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents:
15980
diff
changeset
|
1490 { |
16558 | 1491 QFileInfo file (_file_name); |
1492 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
|
1493 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
|
1494 } |
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
|
1495 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1496 |
16558 | 1497 if (modified) |
1498 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
|
1499 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
|
1500 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
|
1501 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1502 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1503 void |
16558 | 1504 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
|
1505 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1506 _copy_available = enableCopy; |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
1507 emit editor_state_changed (_copy_available, _is_octave_file); |
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
|
1508 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1509 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1510 // show_dialog: shows a modal or non modal dialog depending on input arg |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1511 void |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1512 file_editor_tab::show_dialog (QDialog *dlg, bool modal) |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1513 { |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1514 dlg->setAttribute (Qt::WA_DeleteOnClose); |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1515 if (modal) |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1516 dlg->exec (); |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1517 else |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1518 { |
19804
dfa608a9c36e
fix issue when saving a new modified file while closing
Torsten <ttl@justmail.de>
parents:
19803
diff
changeset
|
1519 dlg->setWindowModality (Qt::NonModal); |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1520 dlg->show (); |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1521 } |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1522 } |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1523 |
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
|
1524 int |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
1525 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
|
1526 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1527 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
|
1528 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
|
1529 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1530 // 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
|
1531 // 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
|
1532 // 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
|
1533 QMessageBox::StandardButtons buttons = QMessageBox::Save | |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1534 QMessageBox::Discard | |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1535 QMessageBox::Cancel; |
19411
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
1536 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1537 // For now, just a warning message about closing a tab that has been |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1538 // modified seems sufficient. Exit-condition-specific messages could |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1539 // be achieved by making 'available_actions' a function input string. |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1540 QString available_actions = |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1541 tr ("Do you want to cancel closing, save or discard the changes?"); |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
1542 |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1543 QString file; |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1544 if (valid_file_name ()) |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1545 file = _file_name; |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1546 else |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1547 file = tr ("<unnamed>"); |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1548 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1549 QMessageBox *msgBox |
16558 | 1550 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1551 tr ("The file\n\n" |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1552 " %1\n\n" |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1553 "is about to be closed but has been modified. " |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
1554 "%2"). |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1555 arg (file). arg (available_actions), |
16638
3c2e457eeb72
ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents:
16635
diff
changeset
|
1556 buttons, qobject_cast<QWidget *> (parent ())); |
16558 | 1557 |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
1558 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
|
1559 _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
|
1560 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
|
1561 this, SLOT (handle_file_modified_answer (int))); |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1562 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1563 show_dialog (msgBox, true); |
16558 | 1564 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1565 if (_cancelled) |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1566 return QMessageBox::Cancel; |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1567 else |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1568 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
|
1569 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1570 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
|
1571 { |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1572 // Nothing was modified. Leave tab present in case user |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1573 // decides to cancel some point further along. |
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
|
1574 } |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1575 |
16558 | 1576 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
|
1577 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1578 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1579 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
|
1580 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
|
1581 { |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
1582 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
|
1583 { |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1584 // Save file, but do not remove from editor. |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1585 save_file (_file_name, false, false); |
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
|
1586 } |
16018
e0df71fbe39b
gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents:
16017
diff
changeset
|
1587 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
|
1588 { |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1589 // User doesn't want to save, leave tab and remove subsequently. |
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
|
1590 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1591 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
|
1592 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1593 // 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
|
1594 _edit_area->setReadOnly (false); |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1595 _cancelled = true; |
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
|
1596 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1597 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1598 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1599 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
|
1600 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
|
1601 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1602 _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
|
1603 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1604 |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1605 void |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1606 file_editor_tab::recover_from_exit () |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1607 { |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1608 // reset the possibly still existing read only state |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1609 _edit_area->setReadOnly (false); |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1610 |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1611 // if we are in this slot and the list of breakpoint is not empty, |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1612 // then this tab was saved during an exit of the applications (not |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1613 // restoring the breakpoints and not emptying the list) and the user |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1614 // canceled this closing late on. |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1615 check_restore_breakpoints (); |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1616 } |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1617 |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1618 void |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1619 file_editor_tab::check_restore_breakpoints () |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1620 { |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1621 if (! _bp_lines.isEmpty ()) |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1622 { |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1623 // At least one breakpoint is present. |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1624 // Get rid of breakpoints at old (now possibly invalid) linenumbers |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1625 remove_all_breakpoints (this); |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1626 |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1627 // and set breakpoints at the new linenumbers |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1628 for (int i = 0; i < _bp_lines.length (); i++) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1629 handle_request_add_breakpoint (_bp_lines.value (i) + 1, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1630 _bp_conditions.value (i)); |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1631 |
21651
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
1632 // Keep the list of breakpoints empty, except after explicit requests. |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
1633 _bp_lines.clear (); |
21651
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
1634 _bp_conditions.clear (); |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1635 } |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1636 } |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1637 |
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
|
1638 QString |
16558 | 1639 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
|
1640 { |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1641 // get the absolute path |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1642 QFileInfo file_info = QFileInfo (fileName); |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1643 QString file_to_load; |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1644 if (file_info.exists ()) |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1645 file_to_load = file_info.canonicalFilePath (); |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1646 else |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1647 file_to_load = fileName; |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1648 QFile file (file_to_load); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
1649 if (! file.open (QFile::ReadOnly)) |
16558 | 1650 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
|
1651 |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
1652 // read the file |
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
|
1653 QTextStream in (&file); |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
1654 // set the desired codec |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
1655 QTextCodec *codec = QTextCodec::codecForName (_encoding.toLatin1 ()); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
1656 in.setCodec (codec); |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
1657 |
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
|
1658 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
|
1659 _edit_area->setText (in.readAll ()); |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1660 _edit_area->setEolMode (detect_eol_mode ()); |
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
|
1661 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
|
1662 |
17636
230ffaf80ac9
fix enabling copy, cut and run selection actions depending on selected text
Torsten <ttl@justmail.de>
parents:
17635
diff
changeset
|
1663 _copy_available = false; // no selection yet available |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1664 set_file_name (file_to_load); |
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
|
1665 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
|
1666 _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
|
1667 |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1668 update_eol_indicator (); |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1669 |
21578
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
1670 // FIXME: (BREAKPOINTS) At this point it would be nice to put any set |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1671 // breakpoints on the margin. In order to do this, somehow the |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1672 // "dbstatus" command needs to be accessed. All it would require is a |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
1673 // routine that does "res = feval ("dbstatus") and signals that result |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1674 // to some slot. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1675 // |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1676 // See patch #8016 for a general way to get Octave results from |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1677 // commands processed in the background. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1678 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1679 /* |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1680 connect (octave_link, SIGNAL (fileSelected (QObject *, const QString&, const octave_value_list&)), |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1681 this, SLOT (handle_feval_result (QObject *, const QString&, const octave_value_list&))); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1682 connect (this, SIGNAL (evaluate_octave_command (const QString&)), |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1683 octave_link, SLOT (queue_octave_command (const QString&))); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1684 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1685 emit evaluate_octave_command ("dbstatus"); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1686 */ |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1687 |
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
|
1688 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
|
1689 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1690 |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1691 QsciScintilla::EolMode |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1692 file_editor_tab::detect_eol_mode () |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1693 { |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
1694 QByteArray text = _edit_area->text ().toLatin1 (); |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1695 |
19768
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1696 QByteArray eol_lf = QByteArray (1,0x0a); |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1697 QByteArray eol_cr = QByteArray (1,0x0d); |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1698 QByteArray eol_crlf = eol_cr; |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1699 eol_crlf.append (eol_lf); |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1700 |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1701 int count_crlf = text.count (eol_crlf); |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1702 int count_lf = text.count (eol_lf) - count_crlf; // isolated lf |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1703 int count_cr = text.count (eol_cr) - count_crlf; // isolated cr; |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1704 |
19248
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1705 // get default from OS or from settings |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1706 #if defined (Q_OS_WIN32) |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1707 int os_eol_mode = QsciScintilla::EolWindows; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1708 #elif defined (Q_OS_MAC) |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1709 int os_eol_mode = QsciScintilla::EolMac; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1710 #else |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1711 int os_eol_mode = QsciScintilla::EolUnix; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1712 #endif |
19768
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1713 QSettings *settings = resource_manager::get_settings (); |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1714 QsciScintilla::EolMode eol_mode = static_cast<QsciScintilla::EolMode> ( |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
1715 settings->value ("editor/default_eol_mode",os_eol_mode).toInt ()); |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1716 |
19248
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1717 int count_max = 0; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1718 |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1719 if (count_crlf > count_max) |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1720 { |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1721 eol_mode = QsciScintilla::EolWindows; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1722 count_max = count_crlf; |
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1723 } |
19768
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1724 if (count_lf > count_max) |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1725 { |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1726 eol_mode = QsciScintilla::EolUnix; |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1727 count_max = count_lf; |
95a94c98c884
fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents:
19714
diff
changeset
|
1728 } |
19237
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1729 if (count_cr > count_max) |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1730 { |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1731 eol_mode = QsciScintilla::EolMac; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1732 count_max = count_cr; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1733 } |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1734 |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1735 return eol_mode; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1736 } |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1737 |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1738 void |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1739 file_editor_tab::update_eol_indicator () |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1740 { |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1741 switch (_edit_area->eolMode ()) |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1742 { |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1743 case QsciScintilla::EolWindows: |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1744 _eol_indicator->setText ("CRLF"); |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1745 break; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1746 case QsciScintilla::EolMac: |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1747 _eol_indicator->setText ("CR"); |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1748 break; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1749 case QsciScintilla::EolUnix: |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1750 _eol_indicator->setText ("LF"); |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1751 break; |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1752 } |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1753 } |
c766a1f63c40
detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
1754 |
21578
683a1beee538
maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents:
21565
diff
changeset
|
1755 // FIXME: See patch #8016 for a general way to get Octave results from |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1756 // commands processed in the background, e.g., dbstatus. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1757 void |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1758 file_editor_tab::handle_octave_result (QObject *requester, QString& command, |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1759 octave_value_list&) |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1760 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1761 // Check if this object initiated the command. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1762 if (requester == this) |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1763 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1764 if (command == "dbstatus") |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1765 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1766 // Should be installing breakpoints in this file |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1767 /* |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1768 octave:1> result = dbstatus |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1769 result = |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1770 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1771 0x1 struct array containing the fields: |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1772 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1773 name |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1774 file |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1775 line |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1776 */ |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1777 // Check for results that match "file". |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1778 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1779 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1780 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1781 |
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
|
1782 void |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23341
diff
changeset
|
1783 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
|
1784 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1785 update_window_title (false); // window title (no modification) |
19245
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1786 |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1787 QSettings *settings = resource_manager::get_settings (); |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1788 |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1789 // set the eol mode from the settings or depending on the OS if the entry is |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1790 // missing in the settings |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1791 #if defined (Q_OS_WIN32) |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1792 int eol_mode = QsciScintilla::EolWindows; |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1793 #elif defined (Q_OS_MAC) |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1794 int eol_mode = QsciScintilla::EolMac; |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1795 #else |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1796 int eol_mode = QsciScintilla::EolUnix; |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1797 #endif |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1798 _edit_area->setEolMode ( |
19248
54943eb0ce37
reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents:
19247
diff
changeset
|
1799 static_cast<QsciScintilla::EolMode> ( |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
1800 settings->value ("editor/default_eol_mode",eol_mode).toInt ())); |
19245
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1801 |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1802 update_eol_indicator (); |
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
1803 |
19770
35a8e1beac8d
fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents:
19768
diff
changeset
|
1804 update_lexer (); |
35a8e1beac8d
fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents:
19768
diff
changeset
|
1805 |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16443
diff
changeset
|
1806 _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
|
1807 _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
|
1808 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1809 |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1810 // Force reloading of a file after it is saved. |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1811 // This is needed to get the right line numbers for breakpoints (bug #46632). |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1812 bool |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1813 file_editor_tab::exit_debug_and_clear (const QString& full_name_q, |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1814 const QString& base_name_q) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1815 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23689
diff
changeset
|
1816 octave::symbol_table& symtab |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1817 = octave::__get_symbol_table__ ("file_editor_tab::exit_debug_and_clear"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1818 |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1819 std::string base_name = base_name_q.toStdString (); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1820 octave_value sym; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1821 try |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1822 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1823 sym = symtab.find (base_name); |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1824 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
1825 catch (const octave::execution_exception& e) |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1826 { |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1827 // Ignore syntax error. |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1828 // It was in the old file on disk; the user may have fixed it already. |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1829 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1830 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1831 // Return early if this file is not loaded in the symbol table |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22422
diff
changeset
|
1832 if (! sym.is_defined () || ! sym.is_user_code ()) |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1833 return true; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1834 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1835 octave_user_code *fcn = sym.user_code_value (); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1836 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1837 std::string full_name = full_name_q.toStdString (); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1838 if (octave::sys::canonicalize_file_name (full_name.c_str ()) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1839 != octave::sys::canonicalize_file_name (fcn->fcn_file_name ().c_str ())) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1840 return true; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1841 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1842 // If this file is loaded, check that we aren't currently running it |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1843 bool retval = true; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1844 octave_idx_type curr_frame = -1; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1845 size_t nskip = 0; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
1846 octave::call_stack& cs |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
1847 = octave::__get_call_stack__ ("file_editor_tab::exit_debug_and_clear"); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
1848 octave_map stk = cs.backtrace (nskip, curr_frame, false); |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1849 Cell names = stk.contents ("name"); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1850 for (octave_idx_type i = names.numel () - 1; i >= 0; i--) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1851 { |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1852 if (names(i).string_value () == base_name) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1853 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
1854 int ans = QMessageBox::question (nullptr, tr ("Debug or Save"), |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1855 tr ("This file is currently being executed.\n" |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1856 "Quit debugging and save?"), |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1857 QMessageBox::Save | QMessageBox::Cancel); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1858 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1859 if (ans == QMessageBox::Save) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1860 { |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1861 emit execute_command_in_terminal_signal ("dbquit"); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1862 // Wait until dbquit has actually occurred |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1863 while (names.numel () > i) |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1864 { |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1865 octave_sleep (0.01); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
1866 stk = cs.backtrace (nskip, curr_frame, false); |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1867 names = stk.contents ("name"); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1868 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1869 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1870 else |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1871 retval = false; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1872 break; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1873 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1874 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1875 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1876 // If we aren't currently running it, or have quit above, force a reload. |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1877 if (retval == true) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1878 symtab.clear_user_function (base_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1879 |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1880 return retval; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1881 } |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1882 |
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
|
1883 void |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1884 file_editor_tab::save_file (const QString& saveFileName, |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1885 bool remove_on_success, bool restore_breakpoints) |
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
|
1886 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1887 // 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
|
1888 // should be performed. |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
1889 if (! valid_file_name (saveFileName)) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1890 { |
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
|
1891 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
|
1892 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
|
1893 } |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1894 |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1895 // Get a list of breakpoint line numbers, before exit_debug_and_clear(). |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1896 emit report_marker_linenr (_bp_lines, _bp_conditions); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1897 |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1898 // get the absolute path (if existing) |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1899 QFileInfo file_info = QFileInfo (saveFileName); |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1900 QString file_to_save; |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1901 if (file_info.exists ()) |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1902 { |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1903 file_to_save = file_info.canonicalFilePath (); |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1904 // Force reparse of this function next time it is used (bug #46632) |
22739
4678729e8ae1
Don't re-parse file in editor if in middle of debug session (bug #49171).
Rik <rik@octave.org>
parents:
22422
diff
changeset
|
1905 if ((Fisdebugmode ())(0).is_true () |
4678729e8ae1
Don't re-parse file in editor if in middle of debug session (bug #49171).
Rik <rik@octave.org>
parents:
22422
diff
changeset
|
1906 && ! exit_debug_and_clear (file_to_save, file_info.baseName ())) |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1907 return; |
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
1908 } |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1909 else |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1910 file_to_save = saveFileName; |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1911 QFile file (file_to_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
|
1912 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1913 // 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
|
1914 QStringList trackedFiles = _file_system_watcher.files (); |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1915 if (trackedFiles.contains (file_to_save)) |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1916 _file_system_watcher.removePath (file_to_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
|
1917 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1918 // open the file for writing |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
1919 if (! file.open (QIODevice::WriteOnly)) |
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
|
1920 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1921 // 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
|
1922 // watched previously. |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1923 if (trackedFiles.contains (file_to_save)) |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1924 _file_system_watcher.addPath (file_to_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
|
1925 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1926 // Create a NonModal message about error. |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1927 QMessageBox *msgBox |
16558 | 1928 = new QMessageBox (QMessageBox::Critical, |
1929 tr ("Octave Editor"), | |
1930 tr ("Could not open file %1 for write:\n%2."). | |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1931 arg (file_to_save).arg (file.errorString ()), |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
1932 QMessageBox::Ok, nullptr); |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1933 show_dialog (msgBox, false); |
16558 | 1934 |
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
|
1935 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
|
1936 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1937 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1938 // save the contents into the file |
20783
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1939 |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1940 _encoding = _new_encoding; // consider a possible new encoding |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1941 |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1942 // set the desired codec (if suitable for contents) |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
1943 QTextCodec *codec = QTextCodec::codecForName (_encoding.toLatin1 ()); |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
1944 |
20783
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1945 if (check_valid_codec (codec)) |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1946 { |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1947 save_file_as (remove_on_success); |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1948 return; |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1949 } |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1950 |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1951 // write the file |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1952 QTextStream out (&file); |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
1953 out.setCodec (codec); |
20731
83611b387bc5
provide a user preference for the encoding used by the editor (bug #45597)
Torsten <ttl@justmail.de>
parents:
20713
diff
changeset
|
1954 |
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
|
1955 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
|
1956 out << _edit_area->text (); |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1957 out.flush (); |
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
|
1958 QApplication::restoreOverrideCursor (); |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1959 file.flush (); |
16558 | 1960 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
|
1961 |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1962 // file exists now |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1963 file_info = QFileInfo (file); |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1964 file_to_save = file_info.canonicalFilePath (); |
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1965 |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20677
diff
changeset
|
1966 // save filename after closing file as set_file_name starts watching again |
17706
97ed9dd479ab
make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents:
17699
diff
changeset
|
1967 set_file_name (file_to_save); // make absolute |
16558 | 1968 |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20677
diff
changeset
|
1969 // set the window title to actual filename (not 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
|
1970 update_window_title (false); |
16558 | 1971 |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
1972 // files is save -> not modified, update encoding in statusbar |
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
|
1973 _edit_area->setModified (false); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
1974 _enc_indicator->setText (_encoding); |
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
|
1975 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1976 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
|
1977 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1978 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
|
1979 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
|
1980 } |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1981 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
1982 // Attempt to restore the breakpoints if that is desired. |
21054
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1983 // This is only allowed if the tab is not closing since changing |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1984 // breakpoints would reopen the tab in this case. |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1985 if (restore_breakpoints) |
221847e5f488
fix issues when restoring breakpoints and closing tabs or whole application
Torsten <ttl@justmail.de>
parents:
21052
diff
changeset
|
1986 check_restore_breakpoints (); |
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
|
1987 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1988 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1989 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
|
1990 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
|
1991 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
1992 // 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
|
1993 // 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
|
1994 |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
1995 // reset _new_encoding |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
1996 _new_encoding = _encoding; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
1997 |
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
|
1998 // 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
|
1999 // can't be a parent. |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
2000 QFileDialog *fileDialog; |
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
|
2001 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
|
2002 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2003 // 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
|
2004 // 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
|
2005 _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
|
2006 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
|
2007 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2008 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
|
2009 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
|
2010 |
16912
6bd74153c3ae
no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents:
16757
diff
changeset
|
2011 // Giving trouble under KDE (problem is related to Qt signal handling on unix, |
6bd74153c3ae
no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents:
16757
diff
changeset
|
2012 // see https://bugs.kde.org/show_bug.cgi?id=260719 , |
6bd74153c3ae
no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents:
16757
diff
changeset
|
2013 // it had/has no effect on Windows, though) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2014 fileDialog->setOption (QFileDialog::DontUseNativeDialog, true); |
16912
6bd74153c3ae
no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents:
16757
diff
changeset
|
2015 |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2016 // define a new grid layout with the extra elements |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2017 QGridLayout *extra = new QGridLayout (fileDialog); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2018 QFrame *separator = new QFrame (fileDialog); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2019 separator->setFrameShape (QFrame::HLine); // horizontal line as separator |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2020 separator->setFrameStyle (QFrame::Sunken); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2021 |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2022 // combo box for choosing new line ending chars |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2023 QLabel *label_eol = new QLabel (tr ("Line Endings:")); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2024 QComboBox *combo_eol = new QComboBox (); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2025 combo_eol->addItem ("Windows (CRLF)"); // ensure the same order as in |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2026 combo_eol->addItem ("Mac (CR)"); // the settings dialog |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2027 combo_eol->addItem ("Unix (LF)"); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2028 _save_as_desired_eol = _edit_area->eolMode (); // init with current eol |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2029 combo_eol->setCurrentIndex (_save_as_desired_eol); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2030 |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2031 // combo box for encoding |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2032 QLabel *label_enc = new QLabel (tr ("File Encoding:")); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2033 QComboBox *combo_enc = new QComboBox (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2034 resource_manager::combo_encoding (combo_enc, _encoding); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2035 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2036 // track changes in the combo boxes |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2037 connect (combo_eol, SIGNAL (currentIndexChanged (int)), |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2038 this, SLOT (handle_combo_eol_current_index (int))); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2039 connect (combo_enc, SIGNAL (currentIndexChanged (QString)), |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2040 this, SLOT (handle_combo_enc_current_index (QString))); |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2041 |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2042 // build the extra grid layout |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2043 extra->addWidget (separator,0,0,1,6); |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2044 extra->addWidget (label_eol,1,0); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2045 extra->addWidget (combo_eol,1,1); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2046 extra->addItem (new QSpacerItem (1,20,QSizePolicy::Fixed, |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2047 QSizePolicy::Fixed), 1,2); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2048 extra->addWidget (label_enc,1,3); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2049 extra->addWidget (combo_enc,1,4); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2050 extra->addItem (new QSpacerItem (1,20,QSizePolicy::Expanding, |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2051 QSizePolicy::Fixed), 1,5); |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2052 |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2053 // and add the extra grid layout to the dialog's layout |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
2054 QGridLayout *dialog_layout = dynamic_cast<QGridLayout *> (fileDialog->layout ()); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2055 dialog_layout->addLayout (extra,dialog_layout->rowCount (),0, |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2056 1,dialog_layout->columnCount ()); |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2057 |
19256
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2058 // add the possible filters and the default suffix |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2059 QStringList filters; |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2060 filters << tr ("Octave Files (*.m)") |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2061 << tr ("All Files (*)"); |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2062 fileDialog->setNameFilters (filters); |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2063 fileDialog->setDefaultSuffix ("m"); |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2064 |
17979
a761ba02a52f
some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents:
17973
diff
changeset
|
2065 if (valid_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
|
2066 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2067 fileDialog->selectFile (_file_name); |
19256
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2068 QFileInfo file_info (_file_name); |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2069 if (file_info.suffix () != "m") |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2070 { // it is not an octave file |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2071 fileDialog->selectNameFilter (filters.at (1)); // "All Files" |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2072 fileDialog->setDefaultSuffix (""); // no default suffix |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2073 } |
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
|
2074 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2075 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
|
2076 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2077 fileDialog->selectFile (""); |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
2078 fileDialog->setDirectory (_ced); |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2079 |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2080 // propose a name corresponding to the function name |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2081 QString fname = get_function_name (); |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2082 if (! fname.isEmpty ()) |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2083 fileDialog->selectFile (fname + ".m"); |
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
|
2084 } |
16558 | 2085 |
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
|
2086 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
|
2087 fileDialog->setViewMode (QFileDialog::Detail); |
16558 | 2088 |
19256
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2089 connect (fileDialog, SIGNAL (filterSelected (const QString&)), |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2090 this, SLOT (handle_save_as_filter_selected (const QString&))); |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2091 |
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
|
2092 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
|
2093 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2094 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
|
2095 this, SLOT (handle_save_file_as_answer_close (const QString&))); |
16558 | 2096 |
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
|
2097 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
|
2098 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
|
2099 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2100 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
|
2101 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2102 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
|
2103 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
|
2104 } |
16558 | 2105 |
19804
dfa608a9c36e
fix issue when saving a new modified file while closing
Torsten <ttl@justmail.de>
parents:
19803
diff
changeset
|
2106 show_dialog (fileDialog, ! valid_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
|
2107 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2108 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2109 void |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2110 file_editor_tab::handle_combo_eol_current_index (int index) |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2111 { |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2112 _save_as_desired_eol = static_cast<QsciScintilla::EolMode> (index); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2113 } |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2114 |
19256
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2115 void |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2116 file_editor_tab::handle_combo_enc_current_index (QString text) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2117 { |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2118 _new_encoding = text; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2119 } |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2120 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20753
diff
changeset
|
2121 void |
19256
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2122 file_editor_tab::handle_save_as_filter_selected (const QString& filter) |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2123 { |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2124 QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ()); |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2125 |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2126 QRegExp rx ("\\*\\.([^ ^\\)]*)[ \\)]"); // regexp for suffix in filter |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2127 int index = rx.indexIn (filter,0); // get first suffix in filter |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2128 |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2129 if (index > -1) |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2130 file_dialog->setDefaultSuffix (rx.cap (1)); // found a suffix, set default |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2131 else |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2132 file_dialog->setDefaultSuffix (""); // not found, clear default |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2133 } |
ce9bd5ed44d2
usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents:
19249
diff
changeset
|
2134 |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2135 bool |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2136 file_editor_tab::check_valid_identifier (QString file_name) |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2137 { |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2138 QFileInfo file = QFileInfo (file_name); |
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2139 QString base_name = file.baseName (); |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2140 |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2141 if ((file.suffix () == "m") |
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2142 && (! valid_identifier (base_name.toStdString ()))) |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2143 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
2144 int ans = QMessageBox::question (nullptr, tr ("Octave Editor"), |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2145 tr ("\"%1\"\n" |
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2146 "is not a valid identifier.\n\n" |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20677
diff
changeset
|
2147 "If you keep this filename, you will not be able to\n" |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2148 "call your script using its name as an Octave command.\n\n" |
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2149 "Do you want to choose another name?").arg (base_name), |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2150 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2151 |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2152 if (ans == QMessageBox::Yes) |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2153 return true; |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2154 } |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2155 |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2156 return false; |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2157 } |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2158 |
20783
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2159 bool |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2160 file_editor_tab::check_valid_codec (QTextCodec *codec) |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2161 { |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2162 if (! codec->canEncode (_edit_area->text ())) |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2163 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
2164 int ans = QMessageBox::warning (nullptr, |
20783
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2165 tr ("Octave Editor"), |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2166 tr ("The current editor contents can not be encoded\n" |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2167 "with the selected codec %1.\n" |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2168 "Using it will result in data loss!\n\n" |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2169 "Do you want to chose another codec?").arg (_encoding), |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2170 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2171 |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2172 if (ans == QMessageBox::Yes) |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2173 return true; |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2174 } |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2175 |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2176 return false; |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2177 } |
b6091735f3f5
warning when saving editor file with a codec not suited for current contents
Torsten <ttl@justmail.de>
parents:
20774
diff
changeset
|
2178 |
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
|
2179 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
|
2180 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
|
2181 { |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2182 if (_save_as_desired_eol != _edit_area->eolMode ()) |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2183 convert_eol (this,_save_as_desired_eol); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2184 |
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
|
2185 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
|
2186 { |
18082
c3e7da9836bd
allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents:
17979
diff
changeset
|
2187 save_file (saveFileName); |
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
|
2188 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2189 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
|
2190 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2191 // Have editor check for conflict, do not delete tab after save. |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2192 if (check_valid_identifier (saveFileName)) |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2193 save_file_as (false); |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2194 else |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2195 emit editor_check_conflict_save (saveFileName, false); |
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
|
2196 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2197 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2198 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2199 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
|
2200 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
|
2201 { |
19249
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2202 if (_save_as_desired_eol != _edit_area->eolMode ()) |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2203 { |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2204 _edit_area->setReadOnly (false); // was set to read-only in save_file_as |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2205 convert_eol (this,_save_as_desired_eol); |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2206 _edit_area->setReadOnly (true); // restore read-only mode |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2207 } |
d10c711a08d8
add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents:
19248
diff
changeset
|
2208 |
18082
c3e7da9836bd
allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents:
17979
diff
changeset
|
2209 // saveFileName == _file_name can not happen, because we only can get here |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20677
diff
changeset
|
2210 // when we close a tab and _file_name is not a valid filename yet |
18082
c3e7da9836bd
allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents:
17979
diff
changeset
|
2211 |
c3e7da9836bd
allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents:
17979
diff
changeset
|
2212 // Have editor check for conflict, delete tab after save. |
18318
770c525a1a2b
Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents:
18315
diff
changeset
|
2213 if (check_valid_identifier (saveFileName)) |
18275
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2214 save_file_as (true); |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2215 else |
3a26bb54655e
warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents:
18237
diff
changeset
|
2216 emit editor_check_conflict_save (saveFileName, true); |
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
|
2217 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2218 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2219 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
|
2220 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
|
2221 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2222 // 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
|
2223 _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
|
2224 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2225 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2226 void |
23905
b41792547237
fix editor behavior when files are externally changed/removed
Torsten <mttl@mailbox.org>
parents:
23892
diff
changeset
|
2227 file_editor_tab::file_has_changed (const QString&, bool do_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
|
2228 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2229 // 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
|
2230 // 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
|
2231 // 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
|
2232 QStringList trackedFiles = _file_system_watcher.files (); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20814
diff
changeset
|
2233 if (! trackedFiles.isEmpty ()) |
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
|
2234 _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
|
2235 |
23905
b41792547237
fix editor behavior when files are externally changed/removed
Torsten <mttl@mailbox.org>
parents:
23892
diff
changeset
|
2236 if (QFile::exists (_file_name) && ! do_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
|
2237 { |
23892
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2238 // The file is modified |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2239 if (_always_reload_changed_files) |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2240 |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2241 load_file (_file_name); |
16558 | 2242 |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2243 else |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2244 { |
23177
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2245 // give editor and this tab the focus, |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2246 // possibly making the editor visible if it is hidden |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2247 emit set_focus_editor_signal (this); |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2248 _edit_area->setFocus (); |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2249 |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2250 // Create a WindowModal message that blocks the edit area |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2251 // by making _edit_area parent. |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
2252 QMessageBox *msgBox |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2253 = new QMessageBox (QMessageBox::Warning, |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2254 tr ("Octave Editor"), |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2255 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2256 arg (_file_name), |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2257 QMessageBox::Yes | QMessageBox::No, this); |
16558 | 2258 |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2259 connect (msgBox, SIGNAL (finished (int)), |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2260 this, SLOT (handle_file_reload_answer (int))); |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2261 |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2262 msgBox->setWindowModality (Qt::WindowModal); |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2263 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2264 msgBox->show (); |
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2265 } |
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
|
2266 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2267 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
|
2268 { |
23892
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2269 // If desired and if file is not modified, |
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2270 // close the file without any user interaction |
23905
b41792547237
fix editor behavior when files are externally changed/removed
Torsten <mttl@mailbox.org>
parents:
23892
diff
changeset
|
2271 if (do_close && ! _edit_area->isModified ()) |
23892
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2272 { |
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2273 handle_file_resave_answer (QMessageBox::Cancel); |
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2274 return; |
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2275 } |
ba46a8015b26
close editor tab when related file is deleted in file browser (bug #43922)
Torsten <mttl@mailbox.org>
parents:
23810
diff
changeset
|
2276 |
23177
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2277 // give editor and this tab the focus, |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2278 // possibly making the editor visible if it is hidden |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2279 emit set_focus_editor_signal (this); |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2280 _edit_area->setFocus (); |
0b59e37dd83e
unhide editor when a file was changed by an external application (bug #50106)
Torsten <mttl@mailbox.org>
parents:
23137
diff
changeset
|
2281 |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2282 QString modified = ""; |
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2283 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
|
2284 modified = tr ("\n\nWarning: The contents in the editor is modified!"); |
16558 | 2285 |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2286 // 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
|
2287 // 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
|
2288 // Instead, change the _edit_area to read only. |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
2289 QMessageBox *msgBox |
16558 | 2290 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), |
2291 tr ("It seems that the file\n" | |
2292 "%1\n" | |
2293 "has been deleted or renamed. Do you want to save it now?%2"). | |
2294 arg (_file_name).arg (modified), | |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
2295 QMessageBox::Save | QMessageBox::Close, nullptr); |
16558 | 2296 |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2297 _edit_area->setReadOnly (true); |
16558 | 2298 |
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
|
2299 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
|
2300 this, SLOT (handle_file_resave_answer (int))); |
16558 | 2301 |
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
|
2302 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
|
2303 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
|
2304 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
|
2305 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2306 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2307 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2308 void |
19770
35a8e1beac8d
fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents:
19768
diff
changeset
|
2309 file_editor_tab::notice_settings (const QSettings *settings, bool init) |
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
|
2310 { |
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
|
2311 // 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
|
2312 |
19770
35a8e1beac8d
fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents:
19768
diff
changeset
|
2313 if (! init) |
23772
b6949bdce34f
prevent unnecessary lexer updates in the editor (bug #51396)
Torsten <mttl@mailbox.org>
parents:
23771
diff
changeset
|
2314 update_lexer_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
|
2315 |
18733
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2316 // code folding |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2317 if (settings->value ("editor/code_folding",true).toBool ()) |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2318 { |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2319 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin); |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2320 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2321 } |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2322 else |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2323 { |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2324 _edit_area->setFolding (QsciScintilla::NoFoldStyle, 3); |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2325 } |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2326 |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2327 // status bar |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2328 if (settings->value ("editor/show_edit_status_bar",true).toBool ()) |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2329 _status_bar->show (); |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2330 else |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2331 _status_bar->hide (); |
f6f1f27026bb
status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
2332 |
16693
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
2333 //highlight current line color |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
2334 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
|
2335 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
|
2336 default_var).value<QColor> (); |
e9d0b8252a0a
make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents:
16679
diff
changeset
|
2337 _edit_area->setCaretLineBackgroundColor (setting_color); |
16558 | 2338 _edit_area->setCaretLineVisible |
2339 (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
|
2340 |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2341 bool match_keywords = settings->value |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2342 ("editor/codeCompletion_keywords",true).toBool (); |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2343 bool match_document = settings->value |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2344 ("editor/codeCompletion_document",true).toBool (); |
16679
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
2345 |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2346 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2347 if (match_keywords) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2348 if (match_document) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2349 source = QsciScintilla::AcsAll; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2350 else |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2351 source = QsciScintilla::AcsAPIs; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2352 else if (match_document) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2353 source = QsciScintilla::AcsDocument; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2354 _edit_area->setAutoCompletionSource (source); |
16679
cf939872811c
options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents:
16678
diff
changeset
|
2355 |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2356 _edit_area->setAutoCompletionReplaceWord |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2357 (settings->value ("editor/codeCompletion_replace",false).toBool ()); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2358 _edit_area->setAutoCompletionCaseSensitivity |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2359 (settings->value ("editor/codeCompletion_case",true).toBool ()); |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2360 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2361 if (settings->value ("editor/codeCompletion", true).toBool ()) |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2362 _edit_area->setAutoCompletionThreshold |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2363 (settings->value ("editor/codeCompletion_threshold",2).toInt ()); |
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
|
2364 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
|
2365 _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
|
2366 |
16702
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2367 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
|
2368 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
|
2369 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2370 else |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2371 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2372 else |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2373 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); |
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2374 |
19245
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
2375 _edit_area->setEolVisibility ( |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2376 settings->value ("editor/show_eol_chars",false).toBool ()); |
19245
f3c4b48f3c53
add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents:
19244
diff
changeset
|
2377 |
16558 | 2378 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
|
2379 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2380 _edit_area->setMarginLineNumbers (2, true); |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2381 auto_margin_width (); |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2382 connect (_edit_area, SIGNAL (linesChanged ()), |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2383 this, SLOT (auto_margin_width ())); |
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
|
2384 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2385 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
|
2386 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2387 _edit_area->setMarginLineNumbers (2, false); |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
2388 disconnect (_edit_area, SIGNAL (linesChanged ()), nullptr, nullptr); |
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
|
2389 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2390 |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2391 _smart_indent = settings->value ("editor/auto_indent",true).toBool (); |
23688
cb36684b7a33
In the GUI editor, automatically add "endif" for "if" etc.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
23599
diff
changeset
|
2392 _edit_area->setAutoIndent (_smart_indent); |
16703
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2393 _edit_area->setTabIndents |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2394 (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
|
2395 _edit_area->setBackspaceUnindents |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2396 (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
|
2397 _edit_area->setIndentationGuides |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2398 (settings->value ("editor/show_indent_guides",false).toBool ()); |
19312
5fb4505b84ff
provide option for using tabs for indentations in the editor
Torsten <ttl@justmail.de>
parents:
19256
diff
changeset
|
2399 _edit_area->setIndentationsUseTabs |
5fb4505b84ff
provide option for using tabs for indentations in the editor
Torsten <ttl@justmail.de>
parents:
19256
diff
changeset
|
2400 (settings->value ("editor/indent_uses_tabs",false).toBool ()); |
19328
cd2a75e5cd6e
use indentation width for the editor from the settings (bug #43592)
Torsten <ttl@justmail.de>
parents:
19312
diff
changeset
|
2401 _edit_area->setIndentationWidth |
cd2a75e5cd6e
use indentation width for the editor from the settings (bug #43592)
Torsten <ttl@justmail.de>
parents:
19312
diff
changeset
|
2402 (settings->value ("editor/indent_width",2).toInt ()); |
16703
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2403 |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2404 _edit_area->setTabWidth |
5cf19370011d
add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents:
16702
diff
changeset
|
2405 (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
|
2406 |
19430
472a5572849c
hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents:
19426
diff
changeset
|
2407 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR, |
472a5572849c
hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents:
19426
diff
changeset
|
2408 settings->value ("editor/show_hscroll_bar",true).toBool ()); |
472a5572849c
hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents:
19426
diff
changeset
|
2409 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1); |
19590
6d75f1683ce8
fix scroll width of horizontal scroll bar (bug #44040)
Torsten <ttl@justmail.de>
parents:
19441
diff
changeset
|
2410 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,true); |
19430
472a5572849c
hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents:
19426
diff
changeset
|
2411 |
16558 | 2412 _long_title = settings->value ("editor/longWindowTitle", false).toBool (); |
16757
35d9f1f79f06
update editor tab titles due to changed settings regarding the modifed state
Torsten <ttl@justmail.de>
parents:
16737
diff
changeset
|
2413 update_window_title (_edit_area->isModified ()); |
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
|
2414 |
23771
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2415 _auto_endif = settings->value ("editor/auto_endif",1).toInt (); |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2416 |
23186
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
2417 // long line marker |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2418 int line_length = settings->value ("editor/long_line_column",80).toInt (); |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2419 _edit_area->setEdgeColumn (line_length); |
23996
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2420 |
18489
6eae8ba32e62
provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents:
18483
diff
changeset
|
2421 if (settings->value ("editor/long_line_marker",true).toBool ()) |
23996
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2422 { |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2423 if (settings->value ("editor/long_line_marker_line",true).toBool ()) |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2424 _edit_area->setEdgeMode (QsciScintilla::EdgeLine); |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2425 else |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2426 { |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2427 if (settings->value ("editor/long_line_marker_background",false) |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2428 .toBool ()) |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2429 _edit_area->setEdgeMode (QsciScintilla::EdgeBackground); |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2430 else |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2431 _edit_area->setEdgeMode (QsciScintilla::EdgeLine); |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2432 } |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2433 } |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2434 else |
a5b20fc6588a
editor: more consistent behavior of lon line marker settings in (bug #51872)
Torsten <mttl@mailbox.org>
parents:
23905
diff
changeset
|
2435 _edit_area->setEdgeMode (QsciScintilla::EdgeNone); |
23186
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
2436 |
9da0d6a86914
enable text background as long line marker in the editor
Torsten <mttl@mailbox.org>
parents:
23181
diff
changeset
|
2437 // line wrapping and breaking |
23179
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2438 _edit_area->setWrapVisualFlags (QsciScintilla::WrapFlagByBorder); |
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2439 _edit_area->setWrapIndentMode (QsciScintilla::WrapIndentSame); |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2440 |
23179
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2441 if (settings->value ("editor/wrap_lines",false).toBool ()) |
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2442 _edit_area->setWrapMode (QsciScintilla::WrapWord); |
18489
6eae8ba32e62
provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents:
18483
diff
changeset
|
2443 else |
23179
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2444 _edit_area->setWrapMode (QsciScintilla::WrapNone); |
751c389404b9
enable line wrapping in the editor if desired (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23177
diff
changeset
|
2445 |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2446 if (settings->value ("editor/break_lines",false).toBool ()) |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2447 _line_break = line_length; |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2448 else |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2449 _line_break = 0; |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2450 |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2451 _line_break_comments = |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2452 settings->value ("editor/break_lines_comments",false).toBool (); |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2453 |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2454 // highlight all occurrences of a word selected by a double click |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2455 _highlight_all_occurrences = |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2456 settings->value ("editor/highlight_all_occurrences", true).toBool (); |
18489
6eae8ba32e62
provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents:
18483
diff
changeset
|
2457 |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2458 // reload changed files |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
2459 _always_reload_changed_files = |
18946
0be65bd7f369
add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents:
18838
diff
changeset
|
2460 settings->value ("editor/always_reload_changed_files",false).toBool (); |
23810
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2461 |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2462 // Set cursor blinking depending on the settings. |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2463 // QScintilla ignores the application global settings, so some special |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2464 // handling is required |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2465 bool cursor_blinking; |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2466 |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2467 if (settings->contains ("cursor_blinking")) |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2468 cursor_blinking = settings->value ("cursor_blinking",true).toBool (); |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2469 else |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2470 cursor_blinking = settings->value ("terminal/cursorBlinking",true).toBool (); |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2471 |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2472 if (cursor_blinking) |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2473 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD,500); |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2474 else |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2475 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD,0); |
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2476 |
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
|
2477 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2478 |
23810
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23807
diff
changeset
|
2479 |
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
|
2480 void |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2481 file_editor_tab::auto_margin_width () |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2482 { |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23804
diff
changeset
|
2483 _edit_area->setMarginWidth (2, "1" + QString::number (_edit_area->lines ())); |
16716
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2484 } |
23b5dde25367
make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents:
16715
diff
changeset
|
2485 |
19411
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2486 // the following close request was changed from a signal slot into a |
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2487 // normal function because we need the return value from close whether |
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2488 // the tab really was closed (for canceling exiting octave). |
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2489 // When emitting a signal, only the return value from the last slot |
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2490 // goes back to the sender |
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2491 bool |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
2492 file_editor_tab::conditional_close (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
|
2493 { |
19411
ed0df431631b
allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents:
19348
diff
changeset
|
2494 return 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
|
2495 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2496 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2497 void |
16558 | 2498 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
|
2499 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2500 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
|
2501 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2502 // 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
|
2503 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
|
2504 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2505 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
|
2506 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2507 _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
|
2508 _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
|
2509 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2510 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2511 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
|
2512 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2513 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2514 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
|
2515 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2516 _find_dialog->setGeometry (_find_dialog_geometry); |
19441
521d4959fc42
fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents:
19430
diff
changeset
|
2517 QPoint p = _find_dialog->pos (); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2518 _find_dialog->move (p.x ()+10, p.y ()+10); |
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
|
2519 _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
|
2520 } |
16558 | 2521 |
19803
415864f5b85f
communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents:
19770
diff
changeset
|
2522 emit editor_state_changed (_copy_available, _is_octave_file); |
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
|
2523 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2524 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2525 void |
16558 | 2526 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
|
2527 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2528 // 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
|
2529 // should respond, otherwise just the desired file editor tab. |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2530 if (ID != this && ID != nullptr) |
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
|
2531 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
|
2532 |
21565
08baf0ebc9a9
Reappropriate <unnamed> editor tab when opening a new file (bug #47529)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21311
diff
changeset
|
2533 // This list also includes windows with name "" |
08baf0ebc9a9
Reappropriate <unnamed> editor tab when opening a new file (bug #47529)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21311
diff
changeset
|
2534 emit add_filename_to_list (_file_name, _encoding, 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
|
2535 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2536 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2537 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
|
2538 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
|
2539 { |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2540 if (decision == QMessageBox::Yes) |
16558 | 2541 { |
2542 // 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
|
2543 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
|
2544 } |
15849
e55a64f49346
editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents:
15848
diff
changeset
|
2545 else |
16558 | 2546 { |
2547 // 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
|
2548 _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
|
2549 } |
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
|
2550 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2551 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2552 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
|
2553 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
|
2554 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2555 // 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
|
2556 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
|
2557 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2558 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
|
2559 _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
|
2560 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2561 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
|
2562 { |
16017
06187a0b7a62
gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
2563 // 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
|
2564 // 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
|
2565 // 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
|
2566 // 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
|
2567 _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
|
2568 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
|
2569 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2570 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2571 |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2572 void |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2573 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
|
2574 { |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2575 if (ID != this || ID == nullptr) |
16377
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
2576 return; |
8430ea8c1594
open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents:
16375
diff
changeset
|
2577 |
21058
759fcdf3666d
Test GUI marker flags correctly, and omit unnecessary test finding next marker
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21054
diff
changeset
|
2578 emit remove_all_positions (); // debugger_position, unsure_debugger_position |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2579 |
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
|
2580 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
|
2581 { |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2582 marker *dp; |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2583 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2584 if (_edit_area->isModified ()) |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2585 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2586 // The best that can be done if the editor contents has been |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2587 // modified is to see if there is a match with the original |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2588 // line number of any existing breakpoints. We can put a normal |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2589 // debugger pointer at that breakpoint position. Otherwise, it |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2590 // isn't certain whether the original line number and current line |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2591 // number match. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2592 int editor_linenr = -1; |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2593 marker *dummy; |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2594 emit find_translated_line_number (line, editor_linenr, dummy); |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2595 if (editor_linenr != -1) |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2596 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2597 // Match with an existing breakpoint. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2598 dp = new marker (_edit_area, line, |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2599 marker::debugger_position, editor_linenr); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2600 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2601 else |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2602 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2603 int original_linenr = -1; |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2604 editor_linenr = -1; |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2605 emit find_linenr_just_before (line, original_linenr, editor_linenr); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2606 if (original_linenr >= 0) |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2607 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2608 // Make a guess by using an offset from the breakpoint. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2609 int linenr_guess = editor_linenr + line - original_linenr; |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2610 dp = new marker (_edit_area, line, |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2611 marker::unsure_debugger_position, |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2612 linenr_guess); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2613 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2614 else |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2615 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2616 // Can't make a very good guess, so just use the debugger |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2617 // line number. |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2618 dp = new marker (_edit_area, line, |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2619 marker::unsure_debugger_position); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2620 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2621 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2622 } |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2623 else |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2624 dp = new marker (_edit_area, line, marker::debugger_position); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2625 |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2626 connect (this, SIGNAL (remove_position_via_debugger_linenr (int)), |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2627 dp, SLOT (handle_remove_via_original_linenr (int))); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2628 connect (this, SIGNAL (remove_all_positions (void)), |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2629 dp, SLOT (handle_remove (void))); |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2630 |
21052
5c5af828c248
gui: only center line with debugger pointer if line is at the top or bottom
Torsten <ttl@justmail.de>
parents:
21045
diff
changeset
|
2631 center_current_line (false); |
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
|
2632 } |
424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15449
diff
changeset
|
2633 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
2634 |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2635 void |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2636 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
|
2637 { |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2638 if (ID != this || ID == nullptr) |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2639 return; |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2640 |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2641 if (line > 0) |
22181
acdd8983d308
Force reload of a function after it is saved in the editor (bug #46632)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22180
diff
changeset
|
2642 emit remove_position_via_debugger_linenr (line); |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2643 } |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2644 |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16389
diff
changeset
|
2645 void |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2646 file_editor_tab::do_breakpoint_marker (bool insert, const QWidget *ID, int line, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2647 const QString& cond) |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2648 { |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2649 if (ID != this || ID == nullptr) |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2650 return; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2651 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2652 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
|
2653 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2654 if (insert) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2655 { |
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2656 int editor_linenr = -1; |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
2657 marker *bp = nullptr; |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2658 |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2659 // If comes back indicating a non-zero breakpoint marker, |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2660 // reuse it if possible |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2661 emit find_translated_line_number (line, editor_linenr, bp); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2662 if (bp != nullptr) |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2663 { |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2664 if ((cond == "") != (bp->get_cond () == "")) |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2665 { // can only reuse conditional bp as conditional |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2666 emit remove_breakpoint_via_debugger_linenr (line); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2667 bp = nullptr; |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2668 } |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2669 else |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2670 bp->set_cond (cond); |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2671 } |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
2672 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23772
diff
changeset
|
2673 if (bp == nullptr) |
21651
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2674 { |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2675 bp = new marker (_edit_area, line, |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2676 cond == "" ? marker::breakpoint |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2677 : marker::cond_break, cond); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2678 |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2679 connect (this, SIGNAL (remove_breakpoint_via_debugger_linenr |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2680 (int)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2681 bp, SLOT (handle_remove_via_original_linenr (int))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2682 connect (this, SIGNAL (request_remove_breakpoint_via_editor_linenr |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2683 (int)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2684 bp, SLOT (handle_request_remove_via_editor_linenr |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2685 (int))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2686 connect (this, SIGNAL (remove_all_breakpoints (void)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2687 bp, SLOT (handle_remove (void))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2688 connect (this, SIGNAL (find_translated_line_number (int, int&, |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2689 marker*&)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2690 bp, SLOT (handle_find_translation (int, int&, |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2691 marker*&))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2692 connect (this, SIGNAL (find_linenr_just_before (int, int&, int&)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2693 bp, SLOT (handle_find_just_before (int, int&, int&))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2694 connect (this, SIGNAL (report_marker_linenr (QIntList&, |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2695 QStringList&)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2696 bp, SLOT (handle_report_editor_linenr (QIntList&, |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2697 QStringList&))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2698 connect (bp, SIGNAL (request_remove (int)), |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2699 this, SLOT (handle_request_remove_breakpoint (int))); |
b4354327d2b5
dbstop: Fix confusion when breakpoints are changed by the GUI (bug #47675)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21578
diff
changeset
|
2700 } |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2701 } |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2702 else |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
2703 emit remove_breakpoint_via_debugger_linenr (line); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2704 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2705 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
2706 |
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
|
2707 void |
21044
e2fdbdd00ef9
center line when setting a breakpoint only if line is at top or at bottom
Torsten <ttl@justmail.de>
parents:
21020
diff
changeset
|
2708 file_editor_tab::center_current_line (bool always) |
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
|
2709 { |
16558 | 2710 long int visible_lines |
2711 = _edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN); | |
2712 | |
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
|
2713 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
|
2714 { |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
2715 int line, index; |
16558 | 2716 _edit_area->getCursorPosition (&line, &index); |
22178
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2717 // compensate for "folding": |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2718 // step 1: expand the current line, if it was folded |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2719 _edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2720 |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2721 // step 2: map file line num to "visible" one // SCI_VISIBLEFROMDOCLINE |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2722 int vis_line = _edit_area->SendScintilla (2220, line); |
16558 | 2723 |
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
|
2724 int first_line = _edit_area->firstVisibleLine (); |
16558 | 2725 |
22178
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2726 if (always || vis_line == first_line |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2727 || vis_line > first_line + visible_lines - 2) |
21044
e2fdbdd00ef9
center line when setting a breakpoint only if line is at top or at bottom
Torsten <ttl@justmail.de>
parents:
21020
diff
changeset
|
2728 { |
22178
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2729 first_line += (vis_line - first_line - (visible_lines - 1) / 2); |
30a0756e6318
Go to right editor line number, even with folding (bug #47414)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22169
diff
changeset
|
2730 _edit_area->SendScintilla (2613, first_line); // SCI_SETFIRSTVISIBLELINE |
21044
e2fdbdd00ef9
center line when setting a breakpoint only if line is at top or at bottom
Torsten <ttl@justmail.de>
parents:
21020
diff
changeset
|
2731 } |
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
|
2732 } |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
2733 } |
f5204f486a29
gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents:
16388
diff
changeset
|
2734 |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19237
diff
changeset
|
2735 void |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2736 file_editor_tab::handle_lines_changed () |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2737 { |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2738 // the related signal is emitted before cursor-move-signal! |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2739 _lines_changed = true; |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2740 } |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2741 |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2742 void |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2743 file_editor_tab::handle_cursor_moved (int line, int col) |
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2744 { |
18483
0f3bc7ccb875
update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents:
18482
diff
changeset
|
2745 if (_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE)) |
0f3bc7ccb875
update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents:
18482
diff
changeset
|
2746 show_auto_completion (this); |
0f3bc7ccb875
update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents:
18482
diff
changeset
|
2747 |
23771
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2748 if (_lines_changed) // cursor moved and lines have changed |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2749 { |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2750 _lines_changed = false; |
23771
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2751 if (_is_octave_file && line == _line+1 && col < _col) |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2752 { |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2753 // Obviously, we have a newline here |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2754 if (_smart_indent || _auto_endif) |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2755 _edit_area->smart_indent (_smart_indent, _auto_endif, _line); |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23739
diff
changeset
|
2756 } |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2757 } |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2758 |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2759 _line = line; |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2760 _col = col; |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2761 |
17962
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2762 _row_indicator->setNum (line+1); |
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2763 _col_indicator->setNum (col+1); |
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2764 } |
4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
2765 |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2766 // Slot that is entered each time a new character was typed. |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2767 // It is used for handling line breaking if this is desired. |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2768 // The related signal is emitted after the signal for a moved cursor |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2769 // such that _col and _line can not be used for current position. |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2770 void |
23239
6c691829a24d
* file-editor-tab.cc (handle_char_added): prevent warning on unused parameter
Torsten <mttl@mailbox.org>
parents:
23237
diff
changeset
|
2771 file_editor_tab::handle_char_added (int) |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2772 { |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2773 if (_line_break) |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2774 { |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2775 // If line breaking is desired, get the current line and column. |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2776 // For taking the tab width into consideration, use own function |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2777 int line, col, pos; |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2778 _edit_area->get_current_position (&pos, &line, &col); |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2779 |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2780 // immediately return if line has not reached the max. line length |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2781 if (col <= _line_break) |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2782 return; |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2783 |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2784 // If line breaking is only desired in comments, |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2785 // return if not in a comment |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2786 int style_comment = octave_qscintilla::ST_NONE; |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2787 if (_line_break_comments) |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2788 { |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2789 // line breaking only in comments, check for comment style |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2790 style_comment = _edit_area->is_style_comment (); |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2791 if (! style_comment) |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2792 return; // no comment, return |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2793 } |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2794 |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2795 // Here we go for breaking the current line by inserting a newline. |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2796 // For determining the position of a specific column, we have to get |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2797 // the column from the QScintila function without taking tab lengths |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2798 // into account, since the calculation from line/col to position ignores |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2799 // this, too |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2800 _edit_area->getCursorPosition (&line, &col); |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2801 int c = 0; |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2802 int col_space = col; |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2803 int indentation = _edit_area->indentation (line); |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2804 |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2805 // Search the first occurence of space or tab backwards starting from |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2806 // the current column (col_space). |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2807 while (c != ' ' && c != '\t' && col_space > indentation) |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2808 { |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2809 pos = _edit_area->positionFromLineIndex (line, col_space--); |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2810 c = _edit_area->SendScintilla (QsciScintillaBase::SCI_GETCHARAT, pos); |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2811 } |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2812 |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2813 // If a space or tab was found, break at this char, |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2814 // otherwise break at cursor position |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2815 int col_newline = col - 1; |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2816 if (c == ' ' || c == '\t') |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2817 col_newline = col_space + 1; |
23236
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2818 |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2819 // Insert a newline char for breaking the line possibly followed |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2820 // by a line comment string |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2821 QString newline = QString ("\n"); |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2822 style_comment = _edit_area->is_style_comment (); |
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
2823 if (style_comment == octave_qscintilla::ST_LINE_COMMENT) |
23236
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2824 newline = newline + _edit_area->comment_string (); |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
2825 _edit_area->insertAt (newline, line, col_newline); |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2826 |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2827 // Automatically indent the new line to the indentation of previous line |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2828 // and set the cursor position to the end of the indentation. |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2829 _edit_area->setIndentation (line + 1, indentation); |
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
2830 _edit_area->SendScintilla (QsciScintillaBase::SCI_LINEEND); |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2831 } |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2832 } |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
2833 |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2834 // Slot handling a double click into the text area |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2835 void |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2836 file_editor_tab::handle_double_click (int, int, int modifier) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2837 { |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2838 if (! modifier) |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2839 { |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2840 // double clicks without modifier |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2841 // clear any existing indicators of this type |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2842 _edit_area->clear_indicator (_indicator_highlight_all); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2843 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2844 if (_highlight_all_occurrences) |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2845 { |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2846 // highlighting of all occurrences of the clicked word is enabled |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2847 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2848 // get the resulting cursor position |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2849 // (required if click was beyond a line ending) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2850 int line, col; |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2851 _edit_area->getCursorPosition (&line, &col); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2852 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2853 // get the word at the cursor (if any) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2854 QString word = _edit_area->wordAtLineIndex (line, col); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2855 word = word.trimmed (); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2856 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2857 if (! word.isEmpty ()) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2858 { |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2859 // word is not empty, so find all occurrences of the word |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2860 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2861 // remember first visible line for restoring the view afterwards |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2862 int first_line = _edit_area->firstVisibleLine (); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2863 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2864 // search for first occurrence of the detected word |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2865 bool find_result_available |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2866 = _edit_area->findFirst (word, |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2867 false, // no regexp |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2868 true, // case sensitive |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2869 true, // whole words only |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2870 false, // do not wrap |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2871 true, // forward |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2872 0,0, // from the beginning |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2873 false |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2874 #if defined (HAVE_QSCI_VERSION_2_6_0) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2875 , true |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2876 #endif |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2877 ); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2878 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2879 // loop over all occurrences and set the related indicator |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2880 int oline, ocol; |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2881 int wlen = word.length (); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2882 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2883 while (find_result_available) |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2884 { |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2885 // get cursor position after having found an occurrence |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2886 _edit_area->getCursorPosition (&oline, &ocol); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2887 // set the indicator |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2888 _edit_area->fillIndicatorRange (oline, ocol - wlen, |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2889 oline, ocol, |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2890 _indicator_highlight_all); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2891 // find next occurrence |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2892 find_result_available = _edit_area->findNext (); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2893 } |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2894 |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2895 // restore the visible area of the file, the cursor position, |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2896 // and the selection |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2897 _edit_area->setFirstVisibleLine (first_line); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2898 _edit_area->setCursorPosition (line, col); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2899 _edit_area->setSelection (line, col - wlen, line, col); |
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
2900 } |
20414
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2901 } |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2902 } |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2903 } |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2904 |
046904b54dc4
editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents:
20230
diff
changeset
|
2905 |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2906 QString |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2907 file_editor_tab::get_function_name () |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2908 { |
19005
bf7c5d96d1ff
improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents:
19004
diff
changeset
|
2909 QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
bf7c5d96d1ff
improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents:
19004
diff
changeset
|
2910 QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
19043
2e6b34324d50
fix compile warning in gui editor tab
Torsten <ttl@justmail.de>
parents:
19005
diff
changeset
|
2911 QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$"); |
2e6b34324d50
fix compile warning in gui editor tab
Torsten <ttl@justmail.de>
parents:
19005
diff
changeset
|
2912 QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\\s]+)[\t ]*$"); |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2913 |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2914 QStringList lines = _edit_area->text ().split ("\n"); |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2915 |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2916 for (int i = 0; i < lines.count (); i++) |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2917 { |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2918 if (rxfun1.indexIn (lines.at (i)) != -1) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2919 return rxfun1.cap (1).remove (QRegExp ("[ \t]*")); |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2920 else if (rxfun2.indexIn (lines.at (i)) != -1) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2921 return rxfun2.cap (1).remove (QRegExp ("[ \t]*")); |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2922 else if (rxfun3.indexIn (lines.at (i)) != -1) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2923 return rxfun3.cap (1).remove (QRegExp ("[ \t]*")); |
19005
bf7c5d96d1ff
improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents:
19004
diff
changeset
|
2924 else if (rxfun4.indexIn (lines.at (i)) != -1) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
23066
diff
changeset
|
2925 return rxfun4.cap (1).remove (QRegExp ("[ \t]*")); |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2926 } |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2927 |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2928 return QString (); |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2929 } |
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
2930 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
2931 #endif |