Mercurial > octave
annotate libgui/src/m-editor/file-editor-tab.cc @ 31649:deb553ac2c54
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2022 15:45:27 -0500 |
parents | 431f80aba37a 29d734430e5f |
children | c2703504db07 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30398
diff
changeset
|
3 // Copyright (C) 2011-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
14676
35512b788af2
Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 |
24164
44f0ad0e3af5
doc: libgui/src/m-editor/file-editor-tab.cc: fix Doxygen comment.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24123
diff
changeset
|
26 //! @file file-editor-tab.cc A single GUI file tab. |
24109
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
27 //! |
1d6c940a1b37
doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23996
diff
changeset
|
28 //! 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
|
29 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21651
diff
changeset
|
30 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
31 # include "config.h" |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
32 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
33 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21651
diff
changeset
|
34 #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
|
35 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
36 #include <QApplication> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
37 #include <QCheckBox> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
38 #include <QDateTime> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
39 #include <QDesktopServices> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
40 #include <QDialogButtonBox> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
41 #include <QFileDialog> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
42 #include <QInputDialog> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
43 #include <QLabel> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
44 #include <QMessageBox> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
45 #include <QPrintDialog> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
46 #include <QPushButton> |
28360
668b38ab90f7
fix jumping vertical scrollbar when file is saved in editor (bug #58418)
Markus Meisinger <chloros2@gmx.de>
parents:
28301
diff
changeset
|
47 #include <QScrollBar> |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
48 #include <QSaveFile> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
49 #include <QStyle> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
50 #include <QTextBlock> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
51 #include <QTextCodec> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
52 #include <QTextStream> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
53 #include <QVBoxLayout> |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
54 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
55 # 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
|
56 # 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
|
57 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) |
21213
f7d1050b9b53
maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
58 # 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
|
59 # 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
|
60 #endif |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
61 #include <Qsci/qscilexerbash.h> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
62 #include <Qsci/qscilexerbatch.h> |
14873
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
63 #include <Qsci/qscilexercpp.h> |
29165
617d3aa713a4
add java file support in gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29163
diff
changeset
|
64 #include <Qsci/qscilexerjava.h> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27405
diff
changeset
|
65 #include <Qsci/qscilexerdiff.h> |
14873
355d6c165df0
Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14869
diff
changeset
|
66 #include <Qsci/qscilexerperl.h> |
16440
aaf024ac8015
Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16437
diff
changeset
|
67 #include <Qsci/qsciprinter.h> |
25443
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
68 |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15389
diff
changeset
|
69 #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
|
70 #include "file-editor.h" |
27664
bd7decacf32e
avoid unnecessary includes of gui-preference header files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27651
diff
changeset
|
71 #include "gui-preferences-cs.h" |
27560
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27556
diff
changeset
|
72 #include "gui-preferences-ed.h" |
27671
61883a1a80a1
don't include gui-preferences-global.h in gui-preferences.h
John W. Eaton <jwe@octave.org>
parents:
27664
diff
changeset
|
73 #include "gui-preferences-global.h" |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
74 #include "gui-settings.h" |
29220
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
75 #include "gui-utils.h" |
21007
0a09c3cae800
New marker class for modified file breakpoint and position maintenance.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20995
diff
changeset
|
76 #include "marker.h" |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
77 #include "octave-qobject.h" |
29560
5b7e721844df
provide QOverload template if it is not in <QtGlobal> (bug #60416)
John W. Eaton <jwe@octave.org>
parents:
29542
diff
changeset
|
78 #include "octave-qtutils.h" |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
79 #include "octave-txt-lexer.h" |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16520
diff
changeset
|
80 |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
81 #include "cmd-edit.h" |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
82 #include "file-ops.h" |
28118
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27987
diff
changeset
|
83 #include "localcharset-wrapper.h" |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
84 #include "uniconv-wrappers.h" |
21310
fc6a9bd59094
backout changeset e8c3590da9ff
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
85 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
86 #include "bp-table.h" |
27405
646efbb5f407
avoid including builtin-defun-decls.h unless needed
John W. Eaton <jwe@octave.org>
parents:
27403
diff
changeset
|
87 #include "builtin-defun-decls.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
88 #include "interpreter-private.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
89 #include "interpreter.h" |
27396
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
90 #include "load-path.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
91 #include "oct-map.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
|
92 #include "ov-usr-fcn.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
93 #include "qt-interpreter-events.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
|
94 #include "symtab.h" |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21148
diff
changeset
|
95 #include "unwind-prot.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
96 #include "utils.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23490
diff
changeset
|
97 #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
|
98 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
99 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
100 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
101 //! A file_editor_tab object consists of a text area and three left margins. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
102 //! The first holds breakpoints, bookmarks, and the debug program counter. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
103 //! The second holds line numbers. The third holds "fold" marks, to hide |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
104 //! sections of text. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
105 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
106 // Make parent null for the file editor tab so that warning WindowModal |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
107 // messages don't affect grandparents. |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
108 file_editor_tab::file_editor_tab (base_qobject& oct_qobj, |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
109 const QString& directory_arg) |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
110 : m_octave_qobj (oct_qobj) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
111 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
112 m_lexer_apis = nullptr; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
113 m_is_octave_file = true; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
114 m_lines_changed = false; |
28382
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
115 m_autoc_active = false; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
116 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
117 m_ced = directory_arg; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
118 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
119 m_file_name = ""; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
120 m_file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller"); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
121 |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
122 m_edit_area = new octave_qscintilla (this, m_octave_qobj); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
123 m_line = 0; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
124 m_col = 0; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
125 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
126 m_bp_lines.clear (); // start with empty lists of breakpoints |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
127 m_bp_conditions.clear (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
128 m_bp_restore_count = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
129 |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
130 m_breakpoint_info.remove_next = false; |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
131 m_breakpoint_info.remove_line = -1; |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
132 |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
133 // Initialize last modification date to now |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
134 m_last_modified = QDateTime::currentDateTimeUtc(); |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
135 |
29707
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
136 connect (m_edit_area, SIGNAL (cursorPositionChanged (int, int)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
137 this, SLOT (handle_cursor_moved (int,int))); |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
138 |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
139 connect (m_edit_area, SIGNAL (SCN_CHARADDED (int)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
140 this, SLOT (handle_char_added (int))); |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
141 |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
142 connect (m_edit_area, SIGNAL (SCN_DOUBLECLICK (int, int, int)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
143 this, SLOT (handle_double_click (int, int, int))); |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
144 |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
145 connect (m_edit_area, SIGNAL (linesChanged ()), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
146 this, SLOT (handle_lines_changed ())); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
147 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
148 connect (m_edit_area, &octave_qscintilla::context_menu_edit_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
149 this, &file_editor_tab::handle_context_menu_edit); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
150 |
29716
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
151 connect (m_edit_area, &octave_qscintilla::update_rowcol_indicator_signal, |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
152 this, &file_editor_tab::update_rowcol_indicator); |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
153 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
154 // create statusbar for row/col indicator and eol mode |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
155 m_status_bar = new QStatusBar (this); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
156 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
157 // row- and col-indicator |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
158 m_row_indicator = new QLabel ("", this); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
159 QFontMetrics fm = m_row_indicator->fontMetrics (); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
160 m_row_indicator->setMinimumSize (4.5*fm.averageCharWidth (), 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
161 QLabel *row_label = new QLabel (tr ("line:"), this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
162 m_col_indicator = new QLabel ("", this); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
163 m_col_indicator->setMinimumSize (4*fm.averageCharWidth (), 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
164 QLabel *col_label = new QLabel (tr ("col:"), this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
165 m_status_bar->addWidget (row_label, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
166 m_status_bar->addWidget (m_row_indicator, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
167 m_status_bar->addWidget (col_label, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
168 m_status_bar->addWidget (m_col_indicator, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
169 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
170 // status bar: encoding |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
171 QLabel *enc_label = new QLabel (tr ("encoding:"), this); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
172 m_enc_indicator = new QLabel ("", this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
173 m_status_bar->addWidget (enc_label, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
174 m_status_bar->addWidget (m_enc_indicator, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
175 m_status_bar->addWidget (new QLabel (" ", this), 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
176 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
177 // status bar: eol mode |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
178 QLabel *eol_label = new QLabel (tr ("eol:"), this); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
179 m_eol_indicator = new QLabel ("", this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
180 m_status_bar->addWidget (eol_label, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
181 m_status_bar->addWidget (m_eol_indicator, 0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
182 m_status_bar->addWidget (new QLabel (" ", this), 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
183 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
184 // symbols |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
185 m_edit_area->setMarginType (1, QsciScintilla::SymbolMargin); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
186 m_edit_area->setMarginSensitivity (1, true); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
187 m_edit_area->markerDefine (QsciScintilla::RightTriangle, marker::bookmark); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
188 m_edit_area->setMarkerBackgroundColor (QColor (0, 0, 232), marker::bookmark); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
189 m_edit_area->markerDefine (QsciScintilla::Circle, marker::breakpoint); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
190 m_edit_area->setMarkerBackgroundColor (QColor (192, 0, 0), marker::breakpoint); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
191 m_edit_area->markerDefine (QsciScintilla::Circle, marker::cond_break); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
192 m_edit_area->setMarkerBackgroundColor (QColor (255, 127, 0), marker::cond_break); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
193 m_edit_area->markerDefine (QsciScintilla::RightArrow, |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
194 marker::debugger_position); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
195 m_edit_area->setMarkerBackgroundColor (QColor (255, 255, 0), |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
196 marker::debugger_position); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
197 m_edit_area->markerDefine (QsciScintilla::RightArrow, |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
198 marker::unsure_debugger_position); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
199 m_edit_area->setMarkerBackgroundColor (QColor (192, 192, 192), |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
200 marker::unsure_debugger_position); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
201 |
29707
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
202 connect (m_edit_area, SIGNAL (marginClicked (int, int, |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
203 Qt::KeyboardModifiers)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
204 this, SLOT (handle_margin_clicked (int, int, |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
205 Qt::KeyboardModifiers))); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
206 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
207 connect (m_edit_area, &octave_qscintilla::context_menu_break_condition_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
208 this, &file_editor_tab::handle_context_menu_break_condition); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
209 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
210 // line numbers |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
211 m_edit_area->setMarginsForegroundColor (QColor (96, 96, 96)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
212 m_edit_area->setMarginsBackgroundColor (QColor (232, 232, 220)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
213 m_edit_area->setMarginType (2, QsciScintilla::TextMargin); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
214 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
215 // other features |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
216 m_edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
217 m_edit_area->setAutoIndent (true); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
218 m_edit_area->setIndentationWidth (2); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
219 m_edit_area->setIndentationsUseTabs (false); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
220 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
221 m_edit_area->setUtf8 (true); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
222 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
223 // auto completion |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
224 m_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART, false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
225 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
226 QVBoxLayout *edit_area_layout = new QVBoxLayout (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
227 edit_area_layout->addWidget (m_edit_area); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
228 edit_area_layout->addWidget (m_status_bar); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
229 edit_area_layout->setMargin (0); |
27090
e83d3161b256
make editor toolbar, tabs and statusbar more comapct (bug #53902)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27089
diff
changeset
|
230 edit_area_layout->setSpacing (0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
231 setLayout (edit_area_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
232 |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27474
diff
changeset
|
233 // Any interpreter_event signal from a file_editor_tab_widget is |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27474
diff
changeset
|
234 // handled the same as for the parent main_window object. |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27474
diff
changeset
|
235 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
236 connect (m_edit_area, QOverload<const fcn_callback&>::of (&octave_qscintilla::interpreter_event), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
237 this, QOverload<const fcn_callback&>::of (&file_editor_tab::interpreter_event)); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
238 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
239 connect (m_edit_area, QOverload<const meth_callback&>::of (&octave_qscintilla::interpreter_event), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
240 this, QOverload<const meth_callback&>::of (&file_editor_tab::interpreter_event)); |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27474
diff
changeset
|
241 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
242 // connect modified signal |
29707
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
243 connect (m_edit_area, SIGNAL (modificationChanged (bool)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
244 this, SLOT (update_window_title (bool))); |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
245 |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
246 connect (m_edit_area, SIGNAL (copyAvailable (bool)), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
247 this, SLOT (handle_copy_available (bool))); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
248 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
249 connect (&m_file_system_watcher, &QFileSystemWatcher::fileChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
250 this, [=] (const QString& path) { file_has_changed (path); }); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
251 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
252 connect (this, &file_editor_tab::maybe_remove_next, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
253 this, &file_editor_tab::handle_remove_next); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
254 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
255 connect (this, &file_editor_tab::dbstop_if, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
256 this, &file_editor_tab::handle_dbstop_if); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
257 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
258 connect (this, &file_editor_tab::request_add_breakpoint, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
259 this, &file_editor_tab::handle_request_add_breakpoint); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
260 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
261 connect (this, &file_editor_tab::api_entries_added, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
262 this, &file_editor_tab::handle_api_entries_added); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
263 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
264 connect (this, &file_editor_tab::confirm_dbquit_and_save_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
265 this, &file_editor_tab::confirm_dbquit_and_save); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
266 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
267 connect (this, &file_editor_tab::do_save_file_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
268 this, &file_editor_tab::do_save_file); |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
269 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
270 notice_settings (true); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
271 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
272 gui_settings settings; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
273 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
274 // encoding, not updated with the settings |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
275 m_encoding = settings.value (ed_default_enc.key, "UTF-8").toString (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
276 m_enc_indicator->setText (m_encoding); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
277 // no changes in encoding yet |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
278 m_new_encoding = m_encoding; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
279 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
280 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
281 file_editor_tab::~file_editor_tab (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
282 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
283 // Tell all connected markers to self-destruct. |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
284 emit remove_all_breakpoints_signal (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
285 emit remove_all_positions (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
286 |
29177
bd5961abe971
* file-editor-tab.cc (dtor): do not delete m_edit_area (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28497
diff
changeset
|
287 // Destroy lexer attached to m_edit_area, which is not the parent |
bd5961abe971
* file-editor-tab.cc (dtor): do not delete m_edit_area (bug #59628)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28497
diff
changeset
|
288 // of lexer |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
289 QsciLexer *lexer = m_edit_area->lexer (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
290 if (lexer) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
291 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
292 delete lexer; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
293 m_edit_area->setLexer (nullptr); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
294 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
295 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
296 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
297 void file_editor_tab::set_encoding (const QString& new_encoding) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
298 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
299 if (new_encoding.isEmpty ()) |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18946
diff
changeset
|
300 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
301 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
302 m_encoding = new_encoding; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
303 m_enc_indicator->setText (m_encoding); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
304 if (! m_edit_area->text ().isEmpty ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
305 set_modified (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
306 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
307 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
308 void file_editor_tab::closeEvent (QCloseEvent *e) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
309 { |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
310 int save_dialog = check_file_modified (true); |
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
311 if ((save_dialog == QMessageBox::Cancel) || |
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
312 (save_dialog == QMessageBox::Save)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
313 { |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
314 // Ignore close event if file is saved or user cancels |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
315 // closing this window. In case of saving, tab is closed after |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
316 // successful saving. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
317 e->ignore (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
318 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
319 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
320 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
321 e->accept (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
322 emit tab_remove_request (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
323 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
324 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
325 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
326 void file_editor_tab::set_current_directory (const QString& dir) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
327 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
328 m_ced = dir; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
329 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
330 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
331 void file_editor_tab::handle_context_menu_edit (const QString& word_at_cursor) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
332 { |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
333 // Search for a subfunction in actual file (this is done first because |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
334 // Octave finds this function before others with the same name in the |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
335 // search path. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
336 QRegExp rxfun1 ("^[\t ]*function[^=]+=[\t ]*" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
337 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
338 QRegExp rxfun2 ("^[\t ]*function[\t ]+" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
339 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
340 QRegExp rxfun3 ("^[\t ]*function[\t ]+" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
341 + word_at_cursor + "[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
342 QRegExp rxfun4 ("^[\t ]*function[^=]+=[\t ]*" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
343 + word_at_cursor + "[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
344 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
345 int pos_fct = -1; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
346 QStringList lines = m_edit_area->text ().split ("\n"); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
347 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
348 int line; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
349 for (line = 0; line < lines.count (); line++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
350 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
351 if ((pos_fct = rxfun1.indexIn (lines.at (line))) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
352 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
353 if ((pos_fct = rxfun2.indexIn (lines.at (line))) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
354 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
355 if ((pos_fct = rxfun3.indexIn (lines.at (line))) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
356 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
357 if ((pos_fct = rxfun4.indexIn (lines.at (line))) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
358 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
359 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
360 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
361 if (pos_fct > -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
362 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
363 // reg expr. found: it is an internal function |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
364 m_edit_area->setCursorPosition (line, pos_fct); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
365 m_edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
366 // SCI_VISIBLEFROMDOCLINE |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
367 int vis_line = m_edit_area->SendScintilla (2220, line); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
368 m_edit_area->SendScintilla (2613, vis_line); // SCI_SETFIRSTVISIBLELINE |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
369 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
370 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
371 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
372 emit edit_mfile_request (word_at_cursor, m_file_name, m_ced, -1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
373 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
374 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
375 // If "dbstop if ..." selected from context menu, create a conditional |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
376 // breakpoint. The default condition is (a) the existing condition if there |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
377 // is already a breakpoint, (b) any selected text, or (c) empty |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
378 void file_editor_tab::handle_context_menu_break_condition (int linenr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
379 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
380 // Ensure editor line numbers match Octave core's line numbers. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
381 // Give users the option to save modifications if necessary. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
382 if (! unchanged_or_saved ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
383 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
384 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
385 QString cond; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
386 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
387 // Search for previous condition. FIXME: is there a more direct way? |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
388 if (m_edit_area->markersAtLine (linenr) & (1 << marker::cond_break)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
389 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
390 emit report_marker_linenr (m_bp_lines, m_bp_conditions); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
391 for (int i = 0; i < m_bp_lines.length (); i++) |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
392 if (m_bp_lines.value (i) == linenr) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
393 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
394 cond = m_bp_conditions.value (i); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
395 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
396 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
397 m_bp_lines.clear (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
398 m_bp_conditions.clear (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
399 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
400 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
401 // If text selected by the mouse, default to that instead |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
402 // If both present, use the OR of them, to avoid accidental overwriting |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
403 // FIXME: If both are present, show old condition unselected and |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
404 // the selection (in edit area) selected (in the dialog). |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
405 if (m_edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
406 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
407 if (cond == "") |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
408 cond = m_edit_area->selectedText (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
409 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
410 cond = '(' + cond + ") || (" + m_edit_area->selectedText () + ')'; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
411 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
412 |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
413 emit dbstop_if ("dbstop if", linenr+1, cond); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
414 } |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
415 |
27971
ec769a7ab9fb
fix more spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
416 // Display dialog in GUI thread to get condition, then emit |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
417 // interpreter_event signal to check it in the interpreter thread. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
418 // If the dialog returns a valid condition, then either emit a signal |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
419 // to add the breakpoint in the editor tab or a signal to display a |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
420 // new dialog. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
421 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
422 void file_editor_tab::handle_dbstop_if (const QString& prompt, int line, |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
423 const QString& cond) |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
424 { |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
425 bool ok; |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
426 QString new_cond |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
427 = QInputDialog::getText (this, tr ("Breakpoint condition"), |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
428 prompt, QLineEdit::Normal, cond, &ok); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
429 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
430 // If cancel, don't change breakpoint condition. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
431 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
432 if (ok && ! new_cond.isEmpty ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
433 { |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
434 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
435 ([=] (interpreter& interp) |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
436 { |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
437 // INTERPRETER THREAD |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
438 |
27471 | 439 error_system& es = interp.get_error_system (); |
440 | |
441 unwind_protect frame; | |
442 | |
443 // Prevent an error in the evaluation here from sending us | |
444 // into the debugger. | |
445 | |
446 es.interpreter_try (frame); | |
447 | |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
448 bool eval_error = false; |
27471 | 449 std::string msg; |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
450 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
451 try |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
452 { |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
453 tree_evaluator& tw = interp.get_evaluator (); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
454 bp_table& bptab = tw.get_bp_table (); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
455 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
456 bptab.condition_valid (new_cond.toStdString ()); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
457 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
458 // The condition seems OK, so set the conditional |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
459 // breakpoint. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
460 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
461 emit request_add_breakpoint (line, new_cond); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
462 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29162
diff
changeset
|
463 catch (const execution_exception& ee) |
27471 | 464 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
465 interp.recover_from_exception (); |
27471 | 466 |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29162
diff
changeset
|
467 msg = ee.message (); |
27471 | 468 eval_error = true; |
469 } | |
470 catch (const interrupt_exception&) | |
471 { | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
472 interp.recover_from_exception (); |
27471 | 473 |
474 msg = "evaluation interrupted"; | |
475 eval_error = true; | |
476 } | |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
477 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
478 if (eval_error) |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
479 { |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
480 // Try again with a prompt that indicates the last |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
481 // attempt was an error. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
482 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
483 QString new_prompt = (tr ("ERROR: ") |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
484 + QString::fromStdString (msg) |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
485 + "\n\ndbstop if"); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
486 |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
487 emit dbstop_if (new_prompt, line, ""); |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
488 } |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
489 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
490 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
491 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
492 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
493 void file_editor_tab::set_file_name (const QString& fileName) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
494 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
495 // update tracked file if we really have a file on disk |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
496 QStringList trackedFiles = m_file_system_watcher.files (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
497 if (! trackedFiles.isEmpty ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
498 m_file_system_watcher.removePath (m_file_name); |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
499 if (! fileName.isEmpty () && QFile::exists (fileName)) |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
500 { |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
501 m_file_system_watcher.addPath (fileName); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
502 m_last_modified = QFileInfo (fileName).lastModified ().toUTC (); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
503 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
504 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
505 // update lexer and file name variable if file name changes |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
506 if (m_file_name != fileName) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
507 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
508 m_file_name = fileName; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
509 update_lexer (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
510 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
511 |
30745
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
512 // set the window title to actual filename (not modified) |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
513 update_window_title (m_edit_area->isModified ()); |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
514 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
515 // update the file editor with current editing directory |
29698
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
516 emit editor_state_changed (m_copy_available, m_is_octave_file, |
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
517 m_edit_area->isModified ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
518 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
519 // add the new file to the most-recently-used list |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
520 emit mru_add_file (m_file_name, m_encoding); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
521 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
522 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
523 // valid_file_name (file): checks whether "file" names a file. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
524 // By default, "file" is empty; then m_file_name is checked |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
525 bool file_editor_tab::valid_file_name (const QString& file) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
526 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
527 if (file.isEmpty ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
528 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
529 if (m_file_name.isEmpty ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
530 return false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
531 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
532 return true; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
533 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
534 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
535 return true; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
536 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
537 |
30745
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
538 void file_editor_tab::enable_file_watcher (bool do_enable) |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
539 { |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
540 if (do_enable) |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
541 m_file_system_watcher.addPath (m_file_name); |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
542 else |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
543 m_file_system_watcher.removePath (m_file_name); |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
544 } |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
545 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
546 // We cannot create a breakpoint when the file is modified |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
547 // because the line number the editor is providing might |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
548 // not match what Octave core is interpreting in the |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
549 // file on disk. This function gives the user the option |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
550 // to save before creating the breakpoint. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
551 bool file_editor_tab::unchanged_or_saved (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
552 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
553 bool retval = true; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
554 if (m_edit_area->isModified () || ! valid_file_name ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
555 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
556 int ans = QMessageBox::question (nullptr, tr ("Octave Editor"), |
25566
eee01a6e197f
allow setting a breakpoint in an unnamed editor file (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25558
diff
changeset
|
557 tr ("Cannot add breakpoint to modified or unnamed file.\n" |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
558 "Save and add breakpoint, or cancel?"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
559 QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
560 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
561 if (ans == QMessageBox::Save) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
562 save_file (m_file_name, false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
563 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
564 retval = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
565 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
566 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
567 return retval; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
568 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
569 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
570 // Toggle a breakpoint at the editor_linenr or, if this was called by |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
571 // a click with CTRL pressed, toggle a bookmark at that point. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
572 void file_editor_tab::handle_margin_clicked (int margin, int editor_linenr, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
573 Qt::KeyboardModifiers state) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
574 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
575 if (margin == 1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
576 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
577 unsigned int markers_mask = m_edit_area->markersAtLine (editor_linenr); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
578 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
579 if (state & Qt::ControlModifier) |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
580 { |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
581 if (markers_mask & (1 << marker::bookmark)) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
582 m_edit_area->markerDelete (editor_linenr, marker::bookmark); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
583 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
584 m_edit_area->markerAdd (editor_linenr, marker::bookmark); |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
585 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
586 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
587 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
588 if (markers_mask & ((1 << marker::breakpoint) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
589 | (1 << marker::cond_break))) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
590 handle_request_remove_breakpoint (editor_linenr + 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
591 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
592 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
593 if (unchanged_or_saved ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
594 handle_request_add_breakpoint (editor_linenr + 1, ""); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
595 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
596 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
597 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
598 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
599 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
600 void file_editor_tab::update_lexer (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
601 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
602 // Create a new lexer |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
603 QsciLexer *lexer = nullptr; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
604 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
605 m_is_octave_file = false; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
606 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
607 // Find the required lexer from file extensions |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
608 if (m_file_name.endsWith (".m") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
609 || m_file_name.endsWith ("octaverc")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
610 { |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
611 #if defined (HAVE_LEXER_OCTAVE) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
612 lexer = new QsciLexerOctave (); |
16662
72665c4ae25b
allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents:
16646
diff
changeset
|
613 #elif defined (HAVE_LEXER_MATLAB) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
614 lexer = new QsciLexerMatlab (); |
19348
c364b9a44580
provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents:
19328
diff
changeset
|
615 #else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
616 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
|
617 #endif |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
618 m_is_octave_file = true; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
619 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
620 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
621 if (! lexer) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
622 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
623 if (m_file_name.endsWith (".c") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
624 || m_file_name.endsWith (".cc") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
625 || m_file_name.endsWith (".cpp") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
626 || m_file_name.endsWith (".cxx") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
627 || m_file_name.endsWith (".c++") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
628 || m_file_name.endsWith (".h") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
629 || m_file_name.endsWith (".hh") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
630 || m_file_name.endsWith (".hpp") |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
631 || m_file_name.endsWith (".h++")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
632 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
633 lexer = new QsciLexerCPP (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
634 } |
29165
617d3aa713a4
add java file support in gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29163
diff
changeset
|
635 else if (m_file_name.endsWith (".java")) |
617d3aa713a4
add java file support in gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29163
diff
changeset
|
636 { |
617d3aa713a4
add java file support in gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29163
diff
changeset
|
637 lexer = new QsciLexerJava (); |
617d3aa713a4
add java file support in gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29163
diff
changeset
|
638 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
639 else if (m_file_name.endsWith (".pl")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
640 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
641 lexer = new QsciLexerPerl (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
642 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
643 else if (m_file_name.endsWith (".bat")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
644 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
645 lexer = new QsciLexerBatch (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
646 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
647 else if (m_file_name.endsWith (".diff")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
648 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
649 lexer = new QsciLexerDiff (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
650 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
651 else if (m_file_name.endsWith (".sh")) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
652 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
653 lexer = new QsciLexerBash (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
654 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
655 else if (! valid_file_name ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
656 { |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
657 // new, not 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
|
658 #if defined (HAVE_LEXER_OCTAVE) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
659 lexer = new QsciLexerOctave (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
660 m_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
|
661 #elif defined (HAVE_LEXER_MATLAB) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
662 lexer = new QsciLexerMatlab (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
663 m_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
|
664 #else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
665 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
|
666 #endif |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
667 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
668 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
669 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
670 // other or no extension |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
671 lexer = new octave_txt_lexer (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
672 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
673 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
674 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
675 // Get any existing lexer |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
676 QsciLexer *old_lexer = m_edit_area->lexer (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
677 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
678 // If new file, no lexer, or lexer has changed, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
679 // delete old one and set the newly created as current lexer |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
680 if (! old_lexer || ! valid_file_name () |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
681 || QString(old_lexer->lexer ()) != QString(lexer->lexer ())) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
682 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
683 // Delete and set new lexer |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
684 if (old_lexer) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
685 delete old_lexer; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
686 m_edit_area->setLexer (lexer); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
687 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
688 // Build information for auto completion (APIs) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
689 m_lexer_apis = new QsciAPIs (lexer); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
690 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
691 connect (this, &file_editor_tab::request_add_octave_apis, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
692 this, &file_editor_tab::handle_add_octave_apis); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
693 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
694 // Get the settings for this new lexer |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
695 update_lexer_settings (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
696 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
697 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
698 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
699 // Otherwise, delete the newly created lexer and |
26369
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26346
diff
changeset
|
700 // use the old, existing one. |
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26346
diff
changeset
|
701 delete lexer; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
702 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
703 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
704 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
705 // Update settings, which are lexer related and have to be updated |
28788
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
706 // when |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
707 // a) the lexer changes, |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
708 // b) the settings have changed, or |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
709 // c) a package was loaded/unloaded |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
710 void file_editor_tab::update_lexer_settings (bool update_apis_only) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
711 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
712 QsciLexer *lexer = m_edit_area->lexer (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
713 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
714 gui_settings settings; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
715 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
716 if (m_lexer_apis) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
717 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
718 m_lexer_apis->cancelPreparation (); // stop preparing if apis exists |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
719 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
720 bool update_apis = false; // flag, whether update of apis files |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
721 |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
722 // Get path to prepared api info (cache). Temporarily set the |
26927
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
723 // application name to 'octave' instead of 'GNU Octave' name for |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
724 // not having blanks in the path. |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
725 QString tmp_app_name = QCoreApplication::applicationName (); |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
726 QCoreApplication::setApplicationName ("octave"); // Set new name |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
727 |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24738
diff
changeset
|
728 #if defined (HAVE_QSTANDARDPATHS) |
26927
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
729 QString local_data_path |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
730 = QStandardPaths::writableLocation (QStandardPaths::CacheLocation); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
731 #else |
26927
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
732 QString local_data_path |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
733 = QDesktopServices::storageLocation (QDesktopServices::CacheLocation); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22181
diff
changeset
|
734 #endif |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
735 |
26927
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
736 QCoreApplication::setApplicationName ("octave"); // Set temp. name |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
737 |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
738 m_prep_apis_path |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
739 = local_data_path + "/" + QString (OCTAVE_VERSION) + "/qsci/"; |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
740 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
741 // get settings which infos are used for octave |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
742 bool octave_builtins |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
743 = settings.value (ed_code_completion_octave_builtins).toBool (); |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
744 bool octave_functions |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
745 = settings.value (ed_code_completion_octave_functions).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
746 |
26927
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
747 QCoreApplication::setApplicationName (tmp_app_name); // Restore name |
df9fe0026f73
use user cache location for keyword lists for auto completion (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26873
diff
changeset
|
748 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
749 if (m_is_octave_file) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
750 { |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27455
diff
changeset
|
751 // Keywords and Builtins do not change, this information can be |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
752 // stored in prepared form in a file. Information on function are |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
753 // changing frequently, then if functions should also be auto- |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
754 // completed, the date of any existing file is checked. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
755 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
756 // Keywords are always used |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
757 m_prep_apis_file = m_prep_apis_path + lexer->lexer () + "_k"; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
758 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27455
diff
changeset
|
759 // Builtins are only used if the user settings say so |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
760 if (octave_builtins) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
761 m_prep_apis_file += 'b'; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
762 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
763 if (octave_functions) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
764 m_prep_apis_file += 'f'; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
765 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
766 m_prep_apis_file += ".pap"; // final name of apis file |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
767 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
768 // check whether the APIs info needs to be prepared and saved |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
769 QFileInfo apis_file = QFileInfo (m_prep_apis_file); |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
770 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
771 // flag whether apis file needs update |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
772 update_apis = ! apis_file.exists (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
773 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
774 if (octave_functions) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
775 { |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
776 // Functions may change frequently. Update the apis data |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
777 // if the file is older than a few minutes preventing from |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
778 // re-preparing data when the user opens several files. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
779 QDateTime apis_time = apis_file.lastModified (); |
28788
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
780 if (update_apis_only |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
781 || QDateTime::currentDateTime () > apis_time.addSecs (180)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
782 update_apis = true; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
783 } |
23489
1b017f9ee3f1
more frequent preparation of data for autocompletion
Torsten <mttl@mailbox.org>
parents:
23457
diff
changeset
|
784 |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
785 } |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
786 else |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
787 { |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
788 // No octave file, just add extension. |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
789 m_prep_apis_file = m_prep_apis_path + lexer->lexer () + ".pap"; |
18833
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
790 } |
6504a1932637
auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents:
18767
diff
changeset
|
791 |
26841
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
792 // Make sure the apis file is usable, otherwise the gui might crash, |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
793 // e.g., in case of max. number of opened files |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
794 QFile f (m_prep_apis_file); |
26841
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
795 |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
796 bool apis_usable = f.open (QIODevice::ReadOnly); |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
797 if (! apis_usable) |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
798 { |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
799 QDir ().mkpath (QFileInfo (f).absolutePath ()); |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
800 apis_usable = f.open (QIODevice::WriteOnly); |
b6dfe7d192bc
fix creating keyword files for editor autocompletion (bug #55835)
Torsten <mttl@mailbox.org>
parents:
26554
diff
changeset
|
801 } |
26522
d6a4237a26b4
fix crash of gui when too many files are opened (bug #49736)
Torsten <mttl@mailbox.org>
parents:
26518
diff
changeset
|
802 if (apis_usable) |
d6a4237a26b4
fix crash of gui when too many files are opened (bug #49736)
Torsten <mttl@mailbox.org>
parents:
26518
diff
changeset
|
803 f.close (); |
d6a4237a26b4
fix crash of gui when too many files are opened (bug #49736)
Torsten <mttl@mailbox.org>
parents:
26518
diff
changeset
|
804 |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
805 if (apis_usable |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
806 && (update_apis || ! m_lexer_apis->loadPrepared (m_prep_apis_file))) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
807 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
808 // either we have decided to update the apis file or |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
809 // no prepared info was loaded, prepare and save if possible |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
810 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
811 // create raw apis info |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
812 |
28788
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
813 m_lexer_apis->clear (); // Clear current contents |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
814 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
815 if (m_is_octave_file) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
816 { |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
817 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
818 ([=] (interpreter& interp) |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
819 { |
27405
646efbb5f407
avoid including builtin-defun-decls.h unless needed
John W. Eaton <jwe@octave.org>
parents:
27403
diff
changeset
|
820 // INTERPRETER THREAD |
646efbb5f407
avoid including builtin-defun-decls.h unless needed
John W. Eaton <jwe@octave.org>
parents:
27403
diff
changeset
|
821 |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
822 QStringList api_entries; |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
823 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
824 octave_value_list tmp = Fiskeyword (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
825 const Cell ctmp = tmp(0).cell_value (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
826 for (octave_idx_type i = 0; i < ctmp.numel (); i++) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
827 { |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
828 std::string kw = ctmp(i).string_value (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
829 api_entries.append (QString::fromStdString (kw)); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
830 } |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
831 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
832 if (octave_builtins) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
833 { |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
834 symbol_table& symtab = interp.get_symbol_table (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
835 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
836 string_vector bfl = symtab.built_in_function_names (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
837 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
838 for (octave_idx_type i = 0; i < bfl.numel (); i++) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
839 api_entries.append (QString::fromStdString (bfl[i])); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
840 } |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
841 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
842 if (octave_functions) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
843 { |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
844 load_path& lp = interp.get_load_path (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
845 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
846 string_vector ffl = lp.fcn_names (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
847 string_vector afl = interp.autoloaded_functions (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
848 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
849 for (octave_idx_type i = 0; i < ffl.numel (); i++) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
850 api_entries.append (QString::fromStdString (ffl[i])); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
851 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
852 for (octave_idx_type i = 0; i < afl.numel (); i++) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
853 api_entries.append (QString::fromStdString (afl[i])); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
854 } |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
855 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
856 emit request_add_octave_apis (api_entries); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
857 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
858 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
859 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
860 { |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
861 for (int i = 1; i <= 3; i++) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
862 { |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
863 // Get list, split, and add to API. |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
864 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
865 QString keyword = QString (lexer->keywords (i)); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
866 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
867 QStringList keyword_list |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
868 = keyword.split (QRegExp (R"(\s+)")); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
869 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
870 for (int j = 0; j < keyword_list.size (); j++) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
871 m_lexer_apis->add (keyword_list.at (j)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
872 } |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
873 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
874 emit api_entries_added (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
875 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
876 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
877 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
878 |
28788
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
879 if (update_apis_only) |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
880 return; // We are done here |
aba2c4eadb83
add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
881 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
882 int mode = settings.value (ed_color_mode).toInt (); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
883 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
884 rmgr.read_lexer_settings (lexer, mode); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
885 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
886 m_edit_area->setCaretForegroundColor (lexer->color (0)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
887 m_edit_area->setIndentationGuidesForegroundColor (lexer->color (0)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
888 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
889 // set some colors depending on selected background color of the lexer |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
890 QColor bg = lexer->paper (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
891 QColor fg = lexer->color (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
892 |
29498
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29468
diff
changeset
|
893 // margin and current line marker colors |
29220
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
894 QColor bgm, fgm; |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
895 |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
896 bgm = interpolate_color (bg, fg, 0.5, 0.2); |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
897 m_edit_area->setEdgeColor (bgm); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
898 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
899 m_edit_area->setMarkerForegroundColor (lexer->color (0)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
900 m_edit_area->setMarginsForegroundColor (lexer->color (0)); |
29220
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
901 |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
902 bgm = interpolate_color (bg, fg, 0.5, 0.125); |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
903 fgm = interpolate_color (bg, fg, 0.5, 0.25); |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
904 m_edit_area->setMarginsBackgroundColor (bgm); |
ab8aa1bb3c2f
add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29205
diff
changeset
|
905 m_edit_area->setFoldMarginColors (bgm, fgm); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
906 |
31304
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
907 QColor current_line_bg |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
908 = settings.color_value (ed_highlight_current_line_color, mode); |
31304
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
909 if (current_line_bg == settings_color_no_change) |
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
910 bgm = interpolate_color (bg, fg, 0.5, 0.1); // It is the "auto" color |
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
911 else |
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
912 bgm = current_line_bg; // Specific color given |
d3231a604a62
re-enable user preferences for current editor line color (bug #62984)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31181
diff
changeset
|
913 |
29498
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29468
diff
changeset
|
914 m_edit_area->setCaretLineBackgroundColor (bgm); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
915 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
916 // color indicator for highlighting all occurrences: |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
917 // applications highlight color with more transparency |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
918 QColor hg = QApplication::palette ().color (QPalette::Highlight); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
919 m_edit_area->set_selection_marker_color (hg); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
920 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
921 // fix line number width with respect to the font size of the lexer and |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
922 // set the line numbers font depending on the lexer's font |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
923 if (settings.value (ed_show_line_numbers).toBool ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
924 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
925 // Line numbers width |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
926 auto_margin_width (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
927 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
928 // Line numbers font |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
929 QFont line_numbers_font = lexer->defaultFont (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
930 int font_size = line_numbers_font.pointSize (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
931 font_size = font_size |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
932 + settings.value (ed_line_numbers_size).toInt (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
933 if (font_size < 4) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
934 font_size = 4; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
935 line_numbers_font.setPointSize (font_size); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
936 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
937 m_edit_area->setMarginsFont (line_numbers_font); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
938 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
939 else |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
940 m_edit_area->setMarginWidth (2, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
941 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
942 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
943 // function for adding entries to the octave lexer's APIs |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
944 void file_editor_tab::handle_add_octave_apis (const QStringList& api_entries) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
945 { |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
946 for (int idx = 0; idx < api_entries.size (); idx++) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
947 m_lexer_apis->add (api_entries.at (idx)); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
948 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
949 emit api_entries_added (); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
950 } |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
951 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
952 void file_editor_tab::handle_api_entries_added (void) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
953 { |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
954 // disconnect slot for saving prepared info if already connected |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
955 disconnect (m_lexer_apis, &QsciAPIs::apiPreparationFinished, |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
956 nullptr, nullptr); |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
957 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
958 // check whether path for prepared info exists or can be created |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
959 if (QDir ("/").mkpath (m_prep_apis_path)) |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
960 { |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
961 // path exists, apis info can be saved there |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
962 connect (m_lexer_apis, &QsciAPIs::apiPreparationFinished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
963 this, &file_editor_tab::save_apis_info); |
27401
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
964 } |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
965 |
1f595192b5a5
attempt to avoid threading issues when updating lexer in file editor tab
John W. Eaton <jwe@octave.org>
parents:
27399
diff
changeset
|
966 m_lexer_apis->prepare (); // prepare apis info |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
967 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
968 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
969 void file_editor_tab::save_apis_info (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
970 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
971 m_lexer_apis->savePrepared (m_prep_apis_file); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
972 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
973 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
974 // slot for fetab_set_focus: sets the focus to the current edit area |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
975 void file_editor_tab::set_focus (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
976 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
977 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
978 return; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
979 m_edit_area->setFocus (); |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27672
diff
changeset
|
980 emit edit_area_changed (m_edit_area); // update the edit area in find dlg |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
981 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
982 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
983 void file_editor_tab::context_help (const QWidget *ID, bool doc) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
984 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
985 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
986 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
987 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
988 m_edit_area->context_help_doc (doc); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
989 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
990 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
991 void file_editor_tab::context_edit (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
992 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
993 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
994 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
995 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
996 m_edit_area->context_edit (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
997 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
998 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
999 void file_editor_tab::save_file (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1000 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1001 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1002 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1003 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1004 save_file (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1005 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1006 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1007 void file_editor_tab::save_file (const QWidget *ID, const QString& fileName, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1008 bool remove_on_success) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1009 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1010 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1011 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1012 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1013 save_file (fileName, remove_on_success); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1014 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1015 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1016 void file_editor_tab::save_file_as (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1017 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1018 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1019 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1020 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1021 save_file_as (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1022 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1023 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1024 void file_editor_tab::print_file (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1025 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1026 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1027 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1028 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1029 QsciPrinter *printer = new QsciPrinter (QPrinter::HighResolution); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1030 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1031 QPrintDialog printDlg (printer, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1032 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1033 if (printDlg.exec () == QDialog::Accepted) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1034 printer->printRange (m_edit_area); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1035 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1036 delete printer; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1037 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1038 |
26873
9ec36417c262
debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26855
diff
changeset
|
1039 void file_editor_tab::run_file (const QWidget *ID, bool step_into) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1040 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1041 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1042 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1043 |
31361
5cc53fd090c3
build: Silence compilation warning about use of bitwise operators with boolean operands (bug #63210)
Rik <rik@octave.org>
parents:
31304
diff
changeset
|
1044 if (m_edit_area->isModified () || ! valid_file_name ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1045 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1046 save_file (m_file_name); // save file dialog |
29437
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1047 |
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1048 // Running a file is disabled for non-octave files. But when saving |
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1049 // a new file, an octave file is assumed but might actually saved |
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1050 // as another file or with an invalid file name. |
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1051 if (! (m_is_octave_file && valid_file_name ())) |
c24e190ae34f
do not run files that are not saved as octave files (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29436
diff
changeset
|
1052 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1053 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1054 |
26873
9ec36417c262
debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26855
diff
changeset
|
1055 if (step_into) |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1056 { |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1057 // Get current first breakpoint and set breakpoint waiting for |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1058 // the returned line number. Store whether to remove this breakpoint |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1059 // afterwards. |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1060 int first_bp_line |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
1061 = m_edit_area->markerFindNext (0, (1 << marker::breakpoint)) + 1; |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1062 |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1063 // Set flag for storing the line number of the breakpoint |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1064 m_breakpoint_info.remove_next = true; |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1065 m_breakpoint_info.do_not_remove_line = first_bp_line; |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1066 |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1067 // Add breakpoint, storing its line number |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1068 handle_request_add_breakpoint (1, QString ()); |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
1069 } |
26873
9ec36417c262
debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26855
diff
changeset
|
1070 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1071 QFileInfo info (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1072 emit run_file_signal (info); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1073 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1074 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1075 void file_editor_tab::context_run (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1076 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1077 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1078 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1079 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1080 m_edit_area->context_run (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1081 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1082 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1083 void file_editor_tab::toggle_bookmark (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1084 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1085 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1086 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1087 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1088 int line, cur; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1089 m_edit_area->getCursorPosition (&line, &cur); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1090 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1091 if (m_edit_area->markersAtLine (line) & (1 << marker::bookmark)) |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1092 m_edit_area->markerDelete (line, marker::bookmark); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1093 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1094 m_edit_area->markerAdd (line, marker::bookmark); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1095 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1096 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1097 // Move the text cursor to the closest bookmark |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1098 // after the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1099 void file_editor_tab::next_bookmark (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1100 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1101 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1102 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1103 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1104 int line, cur; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1105 m_edit_area->getCursorPosition (&line, &cur); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1106 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1107 line++; // Find bookmark strictly after the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1108 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1109 int nextline = m_edit_area->markerFindNext (line, (1 << marker::bookmark)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1110 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1111 // Wrap. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1112 if (nextline == -1) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1113 nextline = m_edit_area->markerFindNext (1, (1 << marker::bookmark)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1114 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1115 m_edit_area->setCursorPosition (nextline, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1116 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1117 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1118 // Move the text cursor to the closest bookmark |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1119 // before the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1120 void file_editor_tab::previous_bookmark (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1121 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1122 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1123 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1124 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1125 int line, cur; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1126 m_edit_area->getCursorPosition (&line, &cur); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1127 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1128 line--; // Find bookmark strictly before the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1129 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1130 int prevline = m_edit_area->markerFindPrevious (line, (1 << marker::bookmark)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1131 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1132 // Wrap. Should use the last line of the file, not 1<<15 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1133 if (prevline == -1) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1134 prevline = m_edit_area->markerFindPrevious (m_edit_area->lines (), |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1135 (1 << marker::bookmark)); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1136 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1137 m_edit_area->setCursorPosition (prevline, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1138 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1139 |
31181
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1140 QString file_editor_tab::get_all_bookmarks () |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1141 { |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1142 QString bmlist; |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1143 int line = 0; |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1144 |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1145 while (line > -1) |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1146 { |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1147 line = m_edit_area->markerFindNext (line, (1 << marker::bookmark)); |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1148 if (line > -1) |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1149 { |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1150 if (! bmlist.isEmpty ()) |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1151 bmlist += ","; |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1152 bmlist += QString::number (line); |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1153 line++; // search from next line, otherwise same line found again |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1154 } |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1155 } |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1156 |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1157 return bmlist; |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1158 } |
c6c4c6f04170
also restore bookmarks when restoring an editor session at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31079
diff
changeset
|
1159 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1160 void file_editor_tab::remove_bookmark (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1161 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1162 if (ID != this) |
24123
16c8ec7f0867
do not move the cursor when saving a file with breakpoints (bug #51793)
Torsten <mttl@mailbox.org>
parents:
24109
diff
changeset
|
1163 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1164 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1165 m_edit_area->markerDeleteAll (marker::bookmark); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1166 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1167 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1168 void |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1169 file_editor_tab::handle_request_add_breakpoint (int line, |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1170 const QString& condition) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1171 { |
29439
fe06fafb4cac
fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
1172 if (! m_is_octave_file) |
fe06fafb4cac
fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
1173 return; |
fe06fafb4cac
fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
1174 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1175 add_breakpoint_event (line, condition); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1176 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1177 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1178 void file_editor_tab::handle_request_remove_breakpoint (int line) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1179 { |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
1180 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
1181 ([=] (interpreter& interp) |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1182 { |
27393
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1183 // INTERPRETER THREAD |
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1184 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1185 tree_evaluator& tw = interp.get_evaluator (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1186 bp_table& bptab = tw.get_bp_table (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1187 |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1188 bptab.remove_breakpoint_from_file (m_file_name.toStdString (), line); |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1189 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1190 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1191 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1192 void file_editor_tab::toggle_breakpoint (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1193 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1194 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1195 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1196 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1197 int editor_linenr, cur; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1198 m_edit_area->getCursorPosition (&editor_linenr, &cur); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1199 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1200 if (m_edit_area->markersAtLine (editor_linenr) & (1 << marker::breakpoint)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1201 request_remove_breakpoint_via_editor_linenr (editor_linenr); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1202 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1203 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1204 if (unchanged_or_saved ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1205 handle_request_add_breakpoint (editor_linenr + 1, ""); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1206 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1207 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1208 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1209 // Move the text cursor to the closest breakpoint (conditional or unconditional) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1210 // after the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1211 void file_editor_tab::next_breakpoint (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1212 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1213 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1214 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1215 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1216 int line, cur; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1217 m_edit_area->getCursorPosition (&line, &cur); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1218 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1219 line++; // Find breakpoint strictly after the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1220 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1221 int nextline = m_edit_area->markerFindNext (line, (1 << marker::breakpoint)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1222 int nextcond = m_edit_area->markerFindNext (line, (1 << marker::cond_break)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1223 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1224 // Check if the next conditional breakpoint is before next unconditional one. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1225 if (nextcond != -1 && (nextcond < nextline || nextline == -1)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1226 nextline = nextcond; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1227 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1228 m_edit_area->setCursorPosition (nextline, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1229 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1230 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1231 // Move the text cursor to the closest breakpoint (conditional or unconditional) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1232 // before the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1233 void file_editor_tab::previous_breakpoint (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1234 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1235 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1236 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1237 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1238 int line, cur, prevline, prevcond; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1239 m_edit_area->getCursorPosition (&line, &cur); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1240 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1241 line--; // Find breakpoint strictly before the current line. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1242 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1243 prevline = m_edit_area->markerFindPrevious (line, (1 << marker::breakpoint)); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1244 prevcond = m_edit_area->markerFindPrevious (line, (1 << marker::cond_break)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1245 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1246 // Check if the prev conditional breakpoint is closer than the unconditional. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1247 if (prevcond != -1 && prevcond > prevline) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1248 prevline = prevcond; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1249 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1250 m_edit_area->setCursorPosition (prevline, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1251 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1252 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1253 void file_editor_tab::remove_all_breakpoints (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1254 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1255 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1256 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1257 |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
1258 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
1259 ([=] (interpreter& interp) |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1260 { |
27393
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1261 // INTERPRETER THREAD |
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1262 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1263 tree_evaluator& tw = interp.get_evaluator (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1264 bp_table& bptab = tw.get_bp_table (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1265 |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1266 bptab.remove_all_breakpoints_from_file (m_file_name.toStdString (), |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1267 true); |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1268 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1269 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1270 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
1271 void file_editor_tab::scintilla_command (const QWidget *ID, |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
1272 unsigned int sci_msg) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1273 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1274 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1275 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1276 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1277 m_edit_area->SendScintilla (sci_msg); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1278 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1279 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
1280 void file_editor_tab::comment_selected_text (const QWidget *ID, |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
1281 bool input_str) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1282 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1283 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1284 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1285 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1286 do_comment_selected_text (true, input_str); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1287 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1288 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1289 void file_editor_tab::uncomment_selected_text (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1290 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1291 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1292 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1293 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1294 do_comment_selected_text (false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1295 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1296 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1297 void file_editor_tab::indent_selected_text (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1298 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1299 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1300 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1301 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1302 do_indent_selected_text (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1303 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1304 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1305 void file_editor_tab::unindent_selected_text (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1306 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1307 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1308 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1309 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1310 do_indent_selected_text (false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1311 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1312 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1313 void file_editor_tab::smart_indent_line_or_selected_text (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1314 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1315 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1316 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1317 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1318 do_smart_indent_line_or_selected_text (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1319 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1320 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1321 void file_editor_tab::convert_eol (const QWidget *ID, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1322 QsciScintilla::EolMode eol_mode) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1323 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1324 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1325 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1326 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1327 m_edit_area->convertEols (eol_mode); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1328 m_edit_area->setEolMode (eol_mode); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1329 update_eol_indicator (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1330 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1331 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1332 void file_editor_tab::zoom_in (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1333 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1334 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1335 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1336 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1337 m_edit_area->zoomIn (1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1338 auto_margin_width (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1339 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1340 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1341 void file_editor_tab::zoom_out (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1342 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1343 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1344 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1345 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1346 m_edit_area->zoomOut (1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1347 auto_margin_width (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1348 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1349 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1350 void file_editor_tab::zoom_normal (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1351 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1352 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1353 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1354 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1355 m_edit_area->zoomTo (0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1356 auto_margin_width (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1357 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1358 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1359 void file_editor_tab::add_breakpoint_event (int line, const QString& cond) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1360 { |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
1361 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
1362 ([=] (interpreter& interp) |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1363 { |
27393
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1364 // INTERPRETER THREAD |
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27378
diff
changeset
|
1365 |
27398
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
1366 // FIXME: note duplication with the code in |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
1367 // handle_context_menu_break_condition. |
db22b63b9c59
attempt to fix threading issues when setting conditional breakpoints in GUI
John W. Eaton <jwe@octave.org>
parents:
27397
diff
changeset
|
1368 |
29458
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1369 tree_evaluator& tw = interp.get_evaluator (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1370 bp_table& bptab = tw.get_bp_table (); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1371 |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1372 int lineno = bptab.add_breakpoint_in_file (m_file_name.toStdString (), |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1373 line, cond.toStdString ()); |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1374 |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1375 if (lineno) |
c0f86150aa6c
begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents:
29457
diff
changeset
|
1376 emit maybe_remove_next (lineno); |
27247
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1377 }); |
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1378 } |
9e5a825bb966
replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents:
27209
diff
changeset
|
1379 |
27397
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1380 void file_editor_tab::handle_remove_next (int remove_line) |
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1381 { |
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1382 // Store some info breakpoint |
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1383 if (m_breakpoint_info.remove_next) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1384 { |
27397
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1385 m_breakpoint_info.remove_line = remove_line; |
8132797b4a6a
use signal/slot connection in file-editor-tab for thread safety
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
1386 m_breakpoint_info.remove_next = false; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1387 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1388 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1389 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1390 void file_editor_tab::goto_line (const QWidget *ID, int line) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1391 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1392 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1393 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1394 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1395 if (m_bp_restore_count > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1396 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1397 // This goto-line request is invoked by restoring a breakpoint during |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1398 // saving the file, thus, do not go to the related line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1399 m_bp_restore_count--; |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
1400 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1401 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1402 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1403 if (line <= 0) // ask for desired line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1404 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1405 bool ok = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1406 int index; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1407 m_edit_area->getCursorPosition (&line, &index); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1408 line = QInputDialog::getInt (m_edit_area, tr ("Goto line"), |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1409 tr ("Line number"), line+1, 1, |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1410 m_edit_area->lines (), 1, &ok); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1411 if (ok) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1412 m_edit_area->setCursorPosition (line-1, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1413 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1414 else // go to given line without dialog |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1415 m_edit_area->setCursorPosition (line-1, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1416 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1417 center_current_line (false); // only center line if at top or bottom |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1418 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1419 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1420 void file_editor_tab::move_match_brace (const QWidget *ID, bool select) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1421 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1422 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1423 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1424 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1425 if (select) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1426 m_edit_area->selectToMatchingBrace (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1427 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1428 m_edit_area->moveToMatchingBrace (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1429 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1430 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1431 void file_editor_tab::show_auto_completion (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1432 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1433 if (ID != this) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1434 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1435 |
28382
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
1436 m_autoc_active = true; |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
1437 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1438 QsciScintilla::AutoCompletionSource s = m_edit_area->autoCompletionSource (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1439 switch (s) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1440 { |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1441 case QsciScintilla::AcsAll: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1442 m_edit_area->autoCompleteFromAll (); |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1443 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1444 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1445 case QsciScintilla::AcsAPIs: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1446 m_edit_area->autoCompleteFromAPIs (); |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1447 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1448 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1449 case QsciScintilla::AcsDocument: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1450 m_edit_area->autoCompleteFromDocument (); |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1451 break; |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1452 |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1453 case QsciScintilla::AcsNone: |
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
1454 break; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1455 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1456 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1457 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1458 void file_editor_tab::do_indent_selected_text (bool indent) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1459 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1460 // FIXME: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1461 m_edit_area->beginUndoAction (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1462 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1463 if (m_edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1464 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1465 int lineFrom, lineTo, colFrom, colTo; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1466 m_edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1467 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1468 if (colTo == 0) // the beginning of last line is not selected |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1469 lineTo--; // stop at line above |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1470 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1471 for (int i = lineFrom; i <= lineTo; i++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1472 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1473 if (indent) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1474 m_edit_area->indent (i); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1475 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1476 m_edit_area->unindent (i); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1477 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1478 //set selection on (un)indented section |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1479 m_edit_area->setSelection (lineFrom, 0, lineTo, |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
1480 m_edit_area->text (lineTo).length ()-1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1481 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1482 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1483 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1484 int cpline, col; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1485 m_edit_area->getCursorPosition (&cpline, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1486 if (indent) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1487 m_edit_area->indent (cpline); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1488 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1489 m_edit_area->unindent (cpline); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1490 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1491 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1492 m_edit_area->endUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1493 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1494 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1495 void file_editor_tab::do_smart_indent_line_or_selected_text (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1496 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1497 m_edit_area->beginUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1498 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1499 int lineFrom, lineTo; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1500 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1501 if (m_edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1502 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1503 int colFrom, colTo; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1504 m_edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1505 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1506 if (colTo == 0) // the beginning of last line is not selected |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1507 lineTo--; // stop at line above |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1508 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1509 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1510 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1511 int col; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1512 m_edit_area->getCursorPosition (&lineFrom, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1513 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1514 lineTo = lineFrom; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1515 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1516 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1517 m_edit_area->smart_indent_line_or_selected_text (lineFrom, lineTo); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1518 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1519 m_edit_area->endUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1520 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1521 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1522 void file_editor_tab::do_comment_selected_text (bool comment, bool input_str) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1523 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1524 QRegExp rxc; |
27914
a044e50c8dcb
Streamline QRegExp instances in libgu.
Rik <rik@octave.org>
parents:
27893
diff
changeset
|
1525 QString ws = "^(?:[ \\t]*)"; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1526 QStringList comment_str = m_edit_area->comment_string (comment); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1527 QString used_comment_str = comment_str.at (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1528 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1529 if (comment) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1530 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1531 if (input_str) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1532 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1533 bool ok; |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1534 gui_settings settings; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1535 |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1536 used_comment_str |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1537 = QInputDialog::getText (this, tr ("Comment selected text"), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1538 tr ("Comment string to use:\n"), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1539 QLineEdit::Normal, |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1540 settings.value (ed_last_comment_str, comment_str.at (0)).toString (), |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1541 &ok); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1542 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1543 if ((! ok) || used_comment_str.isEmpty ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1544 return; // No input, do nothing |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1545 else |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1546 settings.setValue (ed_last_comment_str, used_comment_str); // Store last |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1547 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1548 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1549 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1550 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1551 // Uncommenting (several strings possible) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1552 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1553 // Sort strings according their length |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1554 QStringList comment_str_sorted (comment_str.at (0)); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1555 bool inserted; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1556 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1557 for (int i = 1; i < comment_str.length (); i++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1558 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1559 inserted = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1560 for (int j = 0; j < comment_str_sorted.length (); j++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1561 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1562 if (comment_str.at (i).length () > comment_str_sorted.at (j).length ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1563 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1564 comment_str_sorted.insert (j, comment_str.at (i)); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1565 inserted = true; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1566 break; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1567 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1568 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1569 if (! inserted) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1570 comment_str_sorted << comment_str.at (i); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1571 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1572 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1573 // Create regular expression |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1574 QString regexp; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1575 for (int i = 0; i < comment_str_sorted.length (); i++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1576 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1577 if (i > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1578 regexp = regexp + QString ("|"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1579 regexp = regexp + comment_str_sorted.at (i); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1580 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1581 rxc = QRegExp (ws + "(" + regexp + ")"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1582 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1583 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1584 // Do the commenting/uncommenting |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1585 int len = 0, lenc = 0; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1586 m_edit_area->beginUndoAction (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1587 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1588 if (m_edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1589 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1590 int lineFrom, lineTo, colFrom, colTo; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1591 int change_col_from = 1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1592 int change_col_to = 1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1593 bool removed; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1594 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1595 m_edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1596 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1597 if (colTo == 0) // the beginning of last line is not selected |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1598 lineTo--; // stop at line above |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1599 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1600 for (int i = lineFrom; i <= lineTo; i++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1601 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1602 if (comment) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1603 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1604 m_edit_area->insertAt (used_comment_str, i, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1605 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1606 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1607 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1608 QString line (m_edit_area->text (i)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1609 if ((removed = line.contains (rxc))) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1610 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1611 len = rxc.matchedLength (); // complete length |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1612 QString matched_text = rxc.capturedTexts ().at (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1613 lenc = matched_text.remove (QRegExp (ws)).length (); // only comment string |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1614 m_edit_area->setSelection (i, len-lenc, i, len); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1615 m_edit_area->removeSelectedText (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1616 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1617 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1618 // handle case, where the selection remains unchanged |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1619 if (i == lineFrom && (colFrom < len-lenc || ! removed)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1620 change_col_from = 0; // do not change start of selection |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1621 if (i == lineTo && (colTo < len-lenc || ! removed)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1622 change_col_to = 0; // do not change end of selection |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1623 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1624 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1625 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1626 // update the selection area |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1627 if (comment) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1628 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1629 colFrom = colFrom + lenc; // shift start position by comment length |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1630 if (colTo > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1631 colTo = colTo + lenc; // shift end position by comment length |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1632 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1633 lineTo++; // colTo == 0 , fully select previous line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1634 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1635 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1636 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1637 if (colTo == 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1638 lineTo++; // colTo == 0 , fully select previous line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1639 colFrom = colFrom - change_col_from*lenc; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1640 colTo = colTo - change_col_to*lenc; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1641 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1642 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1643 // set updated selection area |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1644 m_edit_area->setSelection (lineFrom, colFrom, lineTo, colTo); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1645 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1646 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1647 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1648 int cpline, col; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1649 m_edit_area->getCursorPosition (&cpline, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1650 if (comment) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1651 m_edit_area->insertAt (used_comment_str, cpline, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1652 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1653 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1654 QString line (m_edit_area->text (cpline)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1655 if (line.contains (rxc)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1656 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1657 len = rxc.matchedLength (); // complete length |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1658 QString matched_text = rxc.capturedTexts ().at (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1659 lenc = matched_text.remove (QRegExp (ws)).length (); // only comment string |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1660 m_edit_area->setSelection (cpline, len-lenc, cpline, len); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1661 m_edit_area->removeSelectedText (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1662 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1663 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1664 } |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1665 m_edit_area->endUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1666 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1667 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1668 void file_editor_tab::update_window_title (bool modified) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1669 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1670 QString title (""); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1671 QString tooltip (""); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1672 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1673 if (! valid_file_name ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1674 title = tr ("<unnamed>"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1675 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1676 { |
29468
46def32e6806
do not allow full path in editor tabs
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29458
diff
changeset
|
1677 QFileInfo file (m_file_name); |
46def32e6806
do not allow full path in editor tabs
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29458
diff
changeset
|
1678 title = file.fileName (); |
46def32e6806
do not allow full path in editor tabs
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29458
diff
changeset
|
1679 tooltip = m_file_name; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1680 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1681 |
27053
1bdfd2b523c9
use tab icon for indicating a modified editor file (bug #56158)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27037
diff
changeset
|
1682 emit file_name_changed (title, tooltip, modified); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1683 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1684 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1685 void file_editor_tab::handle_copy_available (bool enableCopy) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1686 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1687 m_copy_available = enableCopy; |
29698
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
1688 emit editor_state_changed (m_copy_available, m_is_octave_file, |
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
1689 m_edit_area->isModified ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1690 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1691 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1692 // show_dialog: shows a modal or non modal dialog depending on input arg |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1693 void file_editor_tab::show_dialog (QDialog *dlg, bool modal) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1694 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1695 dlg->setAttribute (Qt::WA_DeleteOnClose); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1696 if (modal) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1697 dlg->exec (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1698 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1699 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1700 dlg->setWindowModality (Qt::NonModal); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1701 dlg->show (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1702 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1703 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1704 |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1705 int file_editor_tab::check_file_modified (bool remove) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1706 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1707 int decision = QMessageBox::Yes; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1708 if (m_edit_area->isModified ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1709 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1710 // File is modified but not saved, ask user what to do. The file |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1711 // editor tab can't be made parent because it may be deleted depending |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1712 // upon the response. Instead, change the m_edit_area to read only. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1713 QMessageBox::StandardButtons buttons = QMessageBox::Save | |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
1714 QMessageBox::Discard | |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
1715 QMessageBox::Cancel; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1716 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1717 // For now, just a warning message about closing a tab that has been |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1718 // modified seems sufficient. Exit-condition-specific messages could |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1719 // be achieved by making 'available_actions' a function input string. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1720 QString available_actions = |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
1721 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
|
1722 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1723 QString file; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1724 if (valid_file_name ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1725 file = m_file_name; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1726 else |
17973
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1727 file = tr ("<unnamed>"); |
6925dca34807
fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents:
17962
diff
changeset
|
1728 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1729 QMessageBox *msgBox |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1730 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1731 tr ("The file\n\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1732 " %1\n\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1733 "is about to be closed but has been modified. " |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1734 "%2"). |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1735 arg (file). arg (available_actions), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1736 buttons, qobject_cast<QWidget *> (parent ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1737 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1738 msgBox->setDefaultButton (QMessageBox::Save); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1739 m_edit_area->setReadOnly (true); |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1740 |
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1741 decision = msgBox->exec (); // show_dialog (msgBox, true); |
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1742 |
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1743 if (decision == QMessageBox::Cancel) |
27633
fd009322dd9f
eliminate static variable in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
1744 m_edit_area->setReadOnly (false); |
27605
60cecb3fed04
fix saving modified files when closing editor tabs or octave
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27583
diff
changeset
|
1745 else if (decision == QMessageBox::Save) |
27651
c9ebcb9050b4
fix broken storing of editor session data at shutdown
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27639
diff
changeset
|
1746 save_file (m_file_name, remove, false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1747 else |
27651
c9ebcb9050b4
fix broken storing of editor session data at shutdown
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27639
diff
changeset
|
1748 emit tab_ready_to_close (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1749 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1750 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1751 { |
27651
c9ebcb9050b4
fix broken storing of editor session data at shutdown
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27639
diff
changeset
|
1752 emit tab_ready_to_close (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1753 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1754 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1755 return decision; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1756 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1757 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1758 void file_editor_tab::set_modified (bool modified) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1759 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1760 m_edit_area->setModified (modified); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1761 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1762 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1763 void file_editor_tab::recover_from_exit (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1764 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1765 // reset the possibly still existing read only state |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1766 m_edit_area->setReadOnly (false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1767 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
1768 // if we are in this slot and the list of breakpoints is not empty, |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1769 // then this tab was saved during an exit of the applications (not |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1770 // restoring the breakpoints and not emptying the list) and the user |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1771 // canceled this closing late on. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1772 check_restore_breakpoints (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1773 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1774 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1775 void file_editor_tab::check_restore_breakpoints (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1776 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1777 if (! m_bp_lines.isEmpty ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1778 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1779 // At least one breakpoint is present. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1780 // Get rid of breakpoints at old (now possibly invalid) linenumbers |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1781 remove_all_breakpoints (this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1782 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1783 // and set breakpoints at the new linenumbers |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1784 m_bp_restore_count = m_bp_lines.length (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1785 for (int i = 0; i < m_bp_lines.length (); i++) |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1786 handle_request_add_breakpoint (m_bp_lines.value (i) + 1, |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1787 m_bp_conditions.value (i)); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1788 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1789 // Keep the list of breakpoints empty, except after explicit requests. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1790 m_bp_lines.clear (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1791 m_bp_conditions.clear (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1792 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1793 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1794 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1795 QString file_editor_tab::load_file (const QString& fileName) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1796 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1797 // get the absolute path |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1798 QFileInfo file_info = QFileInfo (fileName); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1799 QString file_to_load; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1800 if (file_info.exists ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1801 file_to_load = file_info.canonicalFilePath (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1802 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1803 file_to_load = fileName; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1804 QFile file (file_to_load); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1805 if (!file.open(QIODevice::ReadOnly)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1806 return file.errorString (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1807 |
26131
22edc076543e
restore line/column when reloading externally changed editor files (bug #54961)
Torsten <mttl@mailbox.org>
parents:
26119
diff
changeset
|
1808 int col = 0, line = 0; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1809 if (fileName == m_file_name) |
26131
22edc076543e
restore line/column when reloading externally changed editor files (bug #54961)
Torsten <mttl@mailbox.org>
parents:
26119
diff
changeset
|
1810 { |
22edc076543e
restore line/column when reloading externally changed editor files (bug #54961)
Torsten <mttl@mailbox.org>
parents:
26119
diff
changeset
|
1811 // We have to reload the current file, thus get current cursor position |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1812 line = m_line; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1813 col = m_col; |
26131
22edc076543e
restore line/column when reloading externally changed editor files (bug #54961)
Torsten <mttl@mailbox.org>
parents:
26119
diff
changeset
|
1814 } |
22edc076543e
restore line/column when reloading externally changed editor files (bug #54961)
Torsten <mttl@mailbox.org>
parents:
26119
diff
changeset
|
1815 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1816 QApplication::setOverrideCursor (Qt::WaitCursor); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1817 |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1818 // read the file binary, decoding later |
28134
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1819 QByteArray text_data = file.readAll (); |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1820 |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1821 // remove newline at end of file if we add one again when saving |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1822 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1823 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1824 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1825 if (settings.value (ed_force_newline).toBool ()) |
28134
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1826 { |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
1827 const QByteArray eol_lf = QByteArray (1, 0x0a); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
1828 const QByteArray eol_cr = QByteArray (1, 0x0d); |
28134
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1829 |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1830 if (text_data.endsWith (eol_lf)) |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1831 text_data.chop (1); // remove LF |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1832 |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1833 if (text_data.endsWith (eol_cr)) // remove CR (altogether CRLF, too) |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1834 text_data.chop (1); |
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
1835 } |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1836 |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1837 // decode |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1838 QTextCodec::ConverterState st; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1839 QTextCodec *codec = QTextCodec::codecForName (m_encoding.toLatin1 ()); |
26172
a7be718a9dd3
validate editor file codec derived from name (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26131
diff
changeset
|
1840 if (codec == nullptr) |
a7be718a9dd3
validate editor file codec derived from name (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26131
diff
changeset
|
1841 codec = QTextCodec::codecForLocale (); |
a7be718a9dd3
validate editor file codec derived from name (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26131
diff
changeset
|
1842 |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1843 const QString text = codec->toUnicode(text_data.constData(), |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1844 text_data.size(), &st); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1845 |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1846 // Decoding with invalid characters? |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1847 if (st.invalidChars > 0) |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1848 { |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1849 // Set read only |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1850 m_edit_area->setReadOnly (true); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1851 |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1852 // Message box for user decision |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1853 QString msg = tr ("There were problems reading the file\n" |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1854 "%1\n" |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1855 "with the selected encoding %2.\n\n" |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1856 "Modifying and saving the file might " |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1857 "cause data loss!") |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1858 .arg (file_to_load).arg (m_encoding); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1859 QMessageBox *msg_box = new QMessageBox (); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1860 msg_box->setIcon (QMessageBox::Warning); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1861 msg_box->setText (msg); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1862 msg_box->setWindowTitle (tr ("Octave Editor")); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1863 msg_box->addButton (tr ("&Edit anyway"), QMessageBox::YesRole); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1864 msg_box->addButton (tr ("Chan&ge encoding"), QMessageBox::AcceptRole); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1865 msg_box->addButton (tr ("&Close"), QMessageBox::RejectRole); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1866 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1867 connect (msg_box, &QMessageBox::buttonClicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1868 this, &file_editor_tab::handle_decode_warning_answer); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1869 |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1870 msg_box->setWindowModality (Qt::WindowModal); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1871 msg_box->setAttribute (Qt::WA_DeleteOnClose); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1872 msg_box->show (); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1873 } |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1874 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1875 m_edit_area->setText (text); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1876 m_edit_area->setEolMode (detect_eol_mode ()); |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1877 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1878 QApplication::restoreOverrideCursor (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1879 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1880 m_copy_available = false; // no selection yet available |
30745
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
1881 m_edit_area->setModified (false); // loaded file is not modified yet |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1882 set_file_name (file_to_load); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1883 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1884 update_eol_indicator (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1885 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1886 m_edit_area->setCursorPosition (line, col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1887 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1888 return QString (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1889 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1890 |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1891 void file_editor_tab::handle_decode_warning_answer (QAbstractButton *btn) |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1892 { |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1893 QString txt = btn->text (); |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1894 |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1895 if (txt == tr ("&Close")) |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1896 { |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1897 // Just close the file |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1898 close (); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1899 return; |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1900 } |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1901 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1902 if (txt == tr ("Chan&ge encoding")) |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1903 { |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1904 // Dialog for reloading the file with another encoding |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1905 QDialog dlg; |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1906 dlg.setWindowTitle (tr ("Select new default encoding")); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1907 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1908 QLabel *text |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1909 = new QLabel (tr ("Please select a new encoding\n" |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1910 "for reloading the current file.\n\n" |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1911 "This does not change the default encoding.\n")); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1912 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1913 QComboBox *enc_combo = new QComboBox (); |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
1914 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
1915 rmgr.combo_encoding (enc_combo); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1916 m_new_encoding = enc_combo->currentText (); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1917 connect (enc_combo, &QComboBox::currentTextChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1918 this, &file_editor_tab::handle_current_enc_changed); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1919 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1920 QDialogButtonBox *buttons |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1921 = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1922 Qt::Horizontal); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1923 connect (buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
1924 connect (buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1925 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1926 QGridLayout *main_layout = new QGridLayout; |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1927 main_layout->setSizeConstraint (QLayout::SetFixedSize); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1928 main_layout->addWidget (text, 0, 0); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1929 main_layout->addWidget (enc_combo, 1, 0); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1930 main_layout->addWidget (buttons, 2, 0); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1931 dlg.setLayout (main_layout); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1932 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1933 int answer = dlg.exec (); |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1934 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1935 if (answer == QDialog::Accepted) |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1936 { |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1937 // Reload the file with new encoding but using the same tab |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1938 QString reload_file_name = m_file_name; // store file name |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1939 m_file_name = ""; // force reuse of this tab when opening a new file |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1940 emit request_open_file (reload_file_name, m_new_encoding); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1941 } |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1942 } |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1943 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1944 // Continue editing, set writable again |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1945 m_edit_area->setReadOnly (false); |
25895
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1946 } |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1947 |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1948 void file_editor_tab::handle_current_enc_changed (const QString& enc) |
bb0c58796275
allow to change the encoding when editor detects decoding errors (bug #54607)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
1949 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1950 m_new_encoding = enc; |
25883
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1951 } |
cfdc768b661c
allow native dialogs for remaining file open/save dialogs (bug #5
Torsten <mttl@mailbox.org>
parents:
25811
diff
changeset
|
1952 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1953 QsciScintilla::EolMode file_editor_tab::detect_eol_mode (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1954 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1955 QByteArray text = m_edit_area->text ().toLatin1 (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1956 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
1957 QByteArray eol_lf = QByteArray (1, 0x0a); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
1958 QByteArray eol_cr = QByteArray (1, 0x0d); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1959 QByteArray eol_crlf = eol_cr; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1960 eol_crlf.append (eol_lf); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1961 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1962 int count_crlf = text.count (eol_crlf); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1963 int count_lf = text.count (eol_lf) - count_crlf; // isolated lf |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
1964 int count_cr = text.count (eol_cr) - count_crlf; // isolated cr |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1965 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1966 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1967 |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
1968 QsciScintilla::EolMode eol_mode |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
1969 = static_cast<QsciScintilla::EolMode> (settings.value (ed_default_eol_mode).toInt ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1970 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1971 int count_max = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1972 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1973 if (count_crlf > count_max) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1974 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1975 eol_mode = QsciScintilla::EolWindows; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1976 count_max = count_crlf; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1977 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1978 if (count_lf > count_max) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1979 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1980 eol_mode = QsciScintilla::EolUnix; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1981 count_max = count_lf; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1982 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1983 if (count_cr > count_max) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1984 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1985 eol_mode = QsciScintilla::EolMac; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1986 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1987 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1988 return eol_mode; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1989 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1990 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1991 void file_editor_tab::update_eol_indicator (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1992 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1993 switch (m_edit_area->eolMode ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
1994 { |
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
|
1995 case QsciScintilla::EolWindows: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1996 m_eol_indicator->setText ("CRLF"); |
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
|
1997 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
|
1998 case QsciScintilla::EolMac: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
1999 m_eol_indicator->setText ("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
|
2000 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
|
2001 case QsciScintilla::EolUnix: |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2002 m_eol_indicator->setText ("LF"); |
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
|
2003 break; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2004 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2005 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2006 |
25923
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2007 void file_editor_tab::update_breakpoints () |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2008 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2009 if (m_file_name.isEmpty ()) |
25923
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2010 return; |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2011 |
27255
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2012 // Create and queue the command object. |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2013 |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
2014 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
2015 ([=] (interpreter& interp) |
27255
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2016 { |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2017 // INTERPRETER THREAD |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2018 |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2019 octave_value_list argout = Fdbstatus (interp, ovl (), 1); |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2020 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2021 connect (this, &file_editor_tab::update_breakpoints_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2022 this, &file_editor_tab::update_breakpoints_handler, |
27255
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2023 Qt::QueuedConnection); |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2024 |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2025 emit update_breakpoints_signal (argout); |
420611c61298
eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents:
27247
diff
changeset
|
2026 }); |
25923
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2027 } |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2028 |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2029 void file_editor_tab::update_breakpoints_handler (const octave_value_list& argout) |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2030 { |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2031 octave_map dbg = argout(0).map_value (); |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2032 octave_idx_type n_dbg = dbg.numel (); |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2033 |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2034 Cell file = dbg.contents ("file"); |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2035 Cell line = dbg.contents ("line"); |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2036 Cell cond = dbg.contents ("cond"); |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2037 |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2038 for (octave_idx_type i = 0; i < n_dbg; i++) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2039 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2040 if (file (i).string_value () == m_file_name.toStdString ()) |
25923
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2041 do_breakpoint_marker (true, this, line (i).int_value (), |
a7511a1489b8
call octave functions with return value from GUI (bug #47585)
Torsten <mttl@mailbox.org>
parents:
25914
diff
changeset
|
2042 QString::fromStdString (cond (i).string_value ())); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2043 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2044 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2045 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2046 void file_editor_tab::new_file (const QString& commands) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2047 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2048 update_window_title (false); // window title (no modification) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2049 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2050 gui_settings settings; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2051 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2052 // set the eol mode from the settings or depending on the OS if the entry is |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2053 // missing in the settings |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2054 m_edit_area->setEolMode (static_cast<QsciScintilla::EolMode> (settings.value (ed_default_eol_mode).toInt ())); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2055 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2056 update_eol_indicator (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2057 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2058 update_lexer (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2059 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2060 m_edit_area->setText (commands); |
29201
6695a6bf4836
mark script created with commands from history as modified
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29177
diff
changeset
|
2061 m_edit_area->setModified (!commands.isEmpty ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2062 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2063 |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2064 void file_editor_tab::confirm_dbquit_and_save (const QString& file_to_save, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2065 const QString& base_name, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2066 bool remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2067 bool restore_breakpoints) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2068 { |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2069 int ans = QMessageBox::question (nullptr, tr ("Debug or Save"), |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2070 tr ("This file is currently being executed.\n" |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2071 "Quit debugging and save?"), |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2072 QMessageBox::Save | QMessageBox::Cancel); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2073 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2074 if (ans == QMessageBox::Save) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2075 { |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2076 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
2077 ([=] (interpreter& interp) |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2078 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2079 // INTERPRETER THREAD |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2080 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2081 tree_evaluator& tw = interp.get_evaluator (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2082 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2083 tw.dbquit (true); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2084 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2085 command_editor::interrupt (true); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2086 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2087 std::string std_base_name = base_name.toStdString (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2088 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2089 symbol_table& symtab = interp.get_symbol_table (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2090 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2091 symtab.clear_user_function (std_base_name); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2092 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2093 emit do_save_file_signal (file_to_save, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2094 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2095 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2096 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2097 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2098 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2099 void file_editor_tab::save_file (const QString& saveFileName, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2100 bool remove_on_success, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2101 bool restore_breakpoints) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2102 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2103 // If it is a new file with no name, signal that saveFileAs |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2104 // should be performed. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2105 if (! valid_file_name (saveFileName)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2106 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2107 save_file_as (remove_on_success); |
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
|
2108 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2109 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2110 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2111 m_encoding = m_new_encoding; // consider a possible new encoding |
26393
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2112 |
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2113 // set the desired codec (if suitable for contents) |
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2114 QTextCodec *codec = check_valid_codec (); |
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2115 if (! codec) |
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2116 return; // No valid codec |
1e3c42fbf4d3
Don't overwrite content of non-encodable .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
2117 |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2118 // Get a list of breakpoint line numbers, before exiting debug mode |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2119 // and clearing function in interpreter_event action below. |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2120 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2121 emit report_marker_linenr (m_bp_lines, m_bp_conditions); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2122 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2123 // get the absolute path (if existing) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2124 QFileInfo file_info = QFileInfo (saveFileName); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2125 QString file_to_save; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2126 if (file_info.exists ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2127 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2128 file_to_save = file_info.canonicalFilePath (); |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2129 QString base_name = file_info.baseName (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2130 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2131 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28788
diff
changeset
|
2132 ([=] (interpreter& interp) |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2133 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2134 // INTERPRETER THREAD |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2135 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2136 // Force reloading of a file after it is saved. |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2137 // This is needed to get the right line numbers for |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2138 // breakpoints (bug #46632). |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2139 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2140 tree_evaluator& tw = interp.get_evaluator (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2141 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2142 symbol_table& symtab = interp.get_symbol_table (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2143 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2144 std::string std_base_name = base_name.toStdString (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2145 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2146 if (tw.in_debug_repl ()) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2147 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2148 octave_value sym; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2149 try |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2150 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2151 sym = symtab.find_user_function (std_base_name); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2152 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29162
diff
changeset
|
2153 catch (const execution_exception&) |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2154 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
2155 interp.recover_from_exception (); |
27471 | 2156 |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2157 // Ignore syntax error. It was in the old file on disk; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2158 // the user may have fixed it already. |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2159 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2160 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2161 // Return early if this file is not loaded in the symbol table |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2162 if (! sym.is_defined () || ! sym.is_user_code ()) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2163 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2164 emit do_save_file_signal (file_to_save, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2165 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2166 return; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2167 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2168 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2169 octave_user_code *fcn = sym.user_code_value (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2170 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2171 std::string full_name = file_to_save.toStdString (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2172 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2173 if (sys::canonicalize_file_name (full_name) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2174 != sys::canonicalize_file_name (fcn->fcn_file_name ())) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2175 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2176 emit do_save_file_signal (file_to_save, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2177 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2178 return; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2179 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2180 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2181 // If this file is loaded, check that we aren't currently |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2182 // running it. |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2183 // FIXME: is there a better way to get this info? |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2184 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2185 octave_idx_type curr_frame = -1; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2186 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2187 octave_map stk = tw.backtrace (curr_frame, false); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2188 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2189 Cell names = stk.contents ("name"); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2190 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2191 for (octave_idx_type i = names.numel () - 1; i >= 0; i--) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2192 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2193 if (names(i).string_value () == std_base_name) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2194 { |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2195 emit confirm_dbquit_and_save_signal |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2196 (file_to_save, base_name, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2197 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2198 return; |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2199 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2200 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2201 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2202 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2203 symtab.clear_user_function (std_base_name); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2204 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2205 emit do_save_file_signal (file_to_save, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2206 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2207 }); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2208 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2209 else |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2210 emit do_save_file_signal (saveFileName, remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2211 restore_breakpoints); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2212 } |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2213 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2214 void file_editor_tab::do_save_file (const QString& file_to_save, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2215 bool remove_on_success, |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2216 bool restore_breakpoints) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2217 { |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2218 QSaveFile file (file_to_save); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2219 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2220 // stop watching file |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2221 QStringList trackedFiles = m_file_system_watcher.files (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2222 if (trackedFiles.contains (file_to_save)) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2223 m_file_system_watcher.removePath (file_to_save); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2224 |
31004
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2225 // Remove trailing white spaces if desired |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2226 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2227 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2228 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2229 if (settings.value (ed_rm_trailing_spaces).toBool ()) |
31004
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2230 { |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2231 // Replace trailing spaces, make sure edit area is writable, |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2232 // which is not the case when saving at exit or when closing |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2233 // the modified file. |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2234 bool ro = m_edit_area->isReadOnly (); |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2235 m_edit_area->setReadOnly (false); // allow writing for replace_all |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2236 m_edit_area->replace_all ("[ \\t]+$", "", true, false, false); |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2237 m_edit_area->setReadOnly (ro); // recover read only state |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2238 } |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2239 |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2240 // open the file for writing (use QIODevice::ReadWrite for avoiding |
2b4f7287aa3a
fix removing trailing spaces on closing a modified file (bug #62271)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
2241 // truncating the previous file contents) |
31047
c55c6b91447f
fix error on saving an editor file
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31009
diff
changeset
|
2242 if (! file.open (QIODevice::WriteOnly)) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2243 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2244 // Unsuccessful, begin watching file again if it was being |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2245 // watched previously. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2246 if (trackedFiles.contains (file_to_save)) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2247 m_file_system_watcher.addPath (file_to_save); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2248 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2249 // Create a NonModal message about error. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2250 QMessageBox *msgBox |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2251 = new QMessageBox (QMessageBox::Critical, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2252 tr ("Octave Editor"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2253 tr ("Could not open file %1 for write:\n%2."). |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2254 arg (file_to_save).arg (file.errorString ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2255 QMessageBox::Ok, nullptr); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2256 show_dialog (msgBox, false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2257 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2258 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2259 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2260 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2261 // save the contents into the file |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2262 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2263 // write the file |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2264 QTextStream out (&file); |
27403
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2265 |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2266 // set the desired codec (if suitable for contents) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2267 QTextCodec *codec = check_valid_codec (); |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2268 if (! codec) |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2269 return; // No valid codec |
27967cb3dea5
attempt to avoid threading issues when saving a file in the file editor tab
John W. Eaton <jwe@octave.org>
parents:
27401
diff
changeset
|
2270 |
28132
4cfe24f56336
add editor prefs for forcing coding standards (bug #57860, bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
2271 // Save the file |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2272 out.setCodec (codec); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2273 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2274 QApplication::setOverrideCursor (Qt::WaitCursor); |
28134
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
2275 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2276 out << m_edit_area->text (); |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2277 if (settings.value (ed_force_newline).toBool () |
28142
908bdd05398a
do not add a newline on empty editor files (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28141
diff
changeset
|
2278 && m_edit_area->text ().length ()) |
28364
44f2d73df4b3
remove trailing spaces without replacing full editor text (bug #58417)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28361
diff
changeset
|
2279 out << m_edit_area->eol_string (); // Add newline if desired |
28134
480490faf659
change behavior for handling newline at end of file (bug #57861)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28132
diff
changeset
|
2280 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2281 out.flush (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2282 QApplication::restoreOverrideCursor (); |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2283 |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2284 // Finish writing by committing the changes to disk, |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2285 // where nothing is done when an error occurred while writing above |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2286 bool writing_ok = file.commit (); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2287 |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2288 if (writing_ok) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2289 { |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2290 // Writing was successful: file exists now |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2291 QFileInfo file_info = QFileInfo (file.fileName ()); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2292 QString full_file_to_save = file_info.canonicalFilePath (); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2293 |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2294 // file is save -> not modified, update encoding in statusbar |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2295 m_edit_area->setModified (false); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2296 m_enc_indicator->setText (m_encoding); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2297 |
30745
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
2298 // save filename after closing file as set_file_name starts watching again |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
2299 set_file_name (full_file_to_save); // make absolute |
2f6904439d3c
fix updating the name of renamed editor files
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30565
diff
changeset
|
2300 |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2301 emit tab_ready_to_close (); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2302 |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2303 if (remove_on_success) |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2304 { |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2305 emit tab_remove_request (); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2306 return; // Don't touch member variables after removal |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2307 } |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2308 |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2309 // Attempt to restore the breakpoints if that is desired. |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2310 // This is only allowed if the tab is not closing since changing |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2311 // breakpoints would reopen the tab in this case. |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2312 if (restore_breakpoints) |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2313 check_restore_breakpoints (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2314 } |
30553
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2315 else |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2316 { |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2317 QMessageBox::critical (nullptr, |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2318 tr ("Octave Editor"), |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2319 tr ("The changes could not be saved to the file\n" |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2320 "%1") |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2321 .arg (file.fileName ()) |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2322 ); |
2dc31151ca27
make saving editor files more robust against failures while writing
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
2323 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2324 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2325 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2326 void file_editor_tab::save_file_as (bool remove_on_success) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2327 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2328 // Simply put up the file chooser dialog box with a slot connection |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2329 // then return control to the system waiting for a file selection. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2330 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2331 // reset m_new_encoding |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2332 m_new_encoding = m_encoding; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2333 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2334 // If the tab is removed in response to a QFileDialog signal, the tab |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2335 // can't be a parent. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2336 QFileDialog *fileDialog; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2337 if (remove_on_success) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2338 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2339 // If tab is closed, "this" cannot be parent in which case modality |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2340 // has no effect. Disable editing instead. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2341 m_edit_area->setReadOnly (true); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2342 fileDialog = new QFileDialog (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2343 } |
18482
3a509de8e791
automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
2344 else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2345 fileDialog = new QFileDialog (this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2346 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2347 // add the possible filters and the default suffix |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2348 QStringList filters; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2349 filters << tr ("Octave Files (*.m)") |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2350 << tr ("All Files (*)"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2351 fileDialog->setNameFilters (filters); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2352 fileDialog->setDefaultSuffix ("m"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2353 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2354 if (valid_file_name ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2355 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2356 fileDialog->selectFile (m_file_name); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2357 QFileInfo file_info (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2358 if (file_info.suffix () != "m") |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
2359 { |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
2360 // it is not an octave file |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2361 fileDialog->selectNameFilter (filters.at (1)); // "All Files" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2362 fileDialog->setDefaultSuffix (""); // no default suffix |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2363 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2364 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2365 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2366 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2367 fileDialog->selectFile (""); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2368 fileDialog->setDirectory (m_ced); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2369 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2370 // propose a name corresponding to the function name |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2371 // if the new file contains a function |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2372 QString fname = get_function_name (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2373 if (! fname.isEmpty ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2374 fileDialog->selectFile (fname + ".m"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2375 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2376 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2377 fileDialog->setAcceptMode (QFileDialog::AcceptSave); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2378 fileDialog->setViewMode (QFileDialog::Detail); |
29438
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2379 fileDialog->setOption (QFileDialog::HideNameFilterDetails, false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2380 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26065
diff
changeset
|
2381 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2382 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2383 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2384 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2385 if (! settings.value (global_use_native_dialogs).toBool ()) |
29438
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2386 { |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2387 // Qt file dialogs |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2388 fileDialog->setOption(QFileDialog::DontUseNativeDialog); |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2389 } |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2390 else |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2391 { |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2392 // Native file dialogs: Test for already existing files is done manually |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2393 // since native file dialogs might not consider the automatically |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2394 // appended default extension when checking if the file already exists |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2395 fileDialog->setOption(QFileDialog::DontConfirmOverwrite); |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2396 } |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26065
diff
changeset
|
2397 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2398 connect (fileDialog, &QFileDialog::filterSelected, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2399 this, &file_editor_tab::handle_save_as_filter_selected); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2400 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2401 if (remove_on_success) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2402 { |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2403 connect (fileDialog, &QFileDialog::fileSelected, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2404 this, &file_editor_tab::handle_save_file_as_answer_close); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2405 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2406 connect (fileDialog, &QFileDialog::rejected, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2407 this, &file_editor_tab::handle_save_file_as_answer_cancel); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2408 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2409 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2410 { |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2411 connect (fileDialog, &QFileDialog::fileSelected, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2412 this, &file_editor_tab::handle_save_file_as_answer); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2413 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2414 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2415 show_dialog (fileDialog, ! valid_file_name ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2416 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2417 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2418 void file_editor_tab::handle_save_as_filter_selected (const QString& filter) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2419 { |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2420 // On some systems, the filterSelected signal is emitted without user |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2421 // action and with an empty filter string when the file dialog is shown. |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2422 // Just return in this case and do not remove the current default suffix. |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2423 if (filter.isEmpty ()) |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
2424 return; |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2425 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2426 QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2427 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2428 QRegExp rx ("\\*\\.([^ ^\\)]*)[ \\)]"); // regexp for suffix in filter |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
2429 int index = rx.indexIn (filter, 0); // get first suffix in filter |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2430 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2431 if (index > -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2432 file_dialog->setDefaultSuffix (rx.cap (1)); // found a suffix, set default |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2433 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2434 file_dialog->setDefaultSuffix (""); // not found, clear default |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2435 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2436 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2437 bool file_editor_tab::check_valid_identifier (QString file_name) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2438 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2439 QFileInfo file = QFileInfo (file_name); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2440 QString base_name = file.baseName (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2441 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2442 if ((file.suffix () == "m") |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2443 && (! valid_identifier (base_name.toStdString ()))) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2444 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2445 int ans = QMessageBox::question (nullptr, tr ("Octave Editor"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2446 tr ("\"%1\"\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2447 "is not a valid identifier.\n\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2448 "If you keep this filename, you will not be able to\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2449 "call your script using its name as an Octave command.\n\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2450 "Do you want to choose another name?").arg (base_name), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2451 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2452 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2453 if (ans == QMessageBox::Yes) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2454 return true; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2455 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2456 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2457 return false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2458 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2459 |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2460 QTextCodec* file_editor_tab::check_valid_codec () |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2461 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2462 QTextCodec *codec = QTextCodec::codecForName (m_encoding.toLatin1 ()); |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2463 |
27272
9de4741a896e
Do not ignore user preferences for locale encoding on non-Windows platforms.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27271
diff
changeset
|
2464 // "SYSTEM" is used as alias for the locale encoding. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2465 if ((! codec) && m_encoding.startsWith("SYSTEM")) |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2466 codec = QTextCodec::codecForLocale (); |
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2467 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2468 if (! codec) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2469 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2470 QMessageBox::critical (nullptr, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2471 tr ("Octave Editor"), |
25062 | 2472 tr ("The current encoding %1\n" |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2473 "can not be applied.\n\n" |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2474 "Please select another one!").arg (m_encoding)); |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2475 |
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2476 return nullptr; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2477 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2478 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2479 QString editor_text = m_edit_area->text (); |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2480 bool can_encode = codec->canEncode (editor_text); |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2481 |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2482 // We cannot rely on QTextCodec::canEncode because it uses the |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2483 // ConverterState of convertFromUnicode which isn't updated by some |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2484 // implementations. |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2485 if (can_encode) |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2486 { |
26346
fd890481c408
file-editor-tab.cc: Use function available since Qt4.2.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26331
diff
changeset
|
2487 QVector<uint> u32_str = editor_text.toUcs4 (); |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2488 const uint32_t *src = reinterpret_cast<const uint32_t *> |
26346
fd890481c408
file-editor-tab.cc: Use function available since Qt4.2.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26331
diff
changeset
|
2489 (u32_str.data ()); |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2490 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29649
diff
changeset
|
2491 std::size_t length; |
29608
dc171e0452cf
libgui: Avoid dangling reference with QString::toStdString.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29572
diff
changeset
|
2492 const std::string encoding = m_encoding.toStdString (); |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2493 char *res_str = |
29608
dc171e0452cf
libgui: Avoid dangling reference with QString::toStdString.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29572
diff
changeset
|
2494 octave_u32_conv_to_encoding_strict (encoding.c_str (), src, |
dc171e0452cf
libgui: Avoid dangling reference with QString::toStdString.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29572
diff
changeset
|
2495 u32_str.size (), &length); |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2496 if (! res_str) |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2497 { |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2498 if (errno == EILSEQ) |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2499 can_encode = false; |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2500 } |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2501 else |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2502 ::free (static_cast<void *> (res_str)); |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2503 } |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2504 |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26291
diff
changeset
|
2505 if (! can_encode) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2506 { |
26394
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2507 QMessageBox::StandardButton pressed_button |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2508 = QMessageBox::critical (nullptr, |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2509 tr ("Octave Editor"), |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2510 tr ("The current editor contents can not be encoded\n" |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2511 "with the selected encoding %1.\n" |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2512 "Using it would result in data loss!\n\n" |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2513 "Please select another one!").arg (m_encoding), |
26394
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2514 QMessageBox::Cancel | QMessageBox::Ignore, |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2515 QMessageBox::Cancel); |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2516 |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2517 if (pressed_button == QMessageBox::Ignore) |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2518 return codec; |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2519 else |
6323979ee312
Optionally, ignore data loss when saving .m file (bug #55364).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26393
diff
changeset
|
2520 return nullptr; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2521 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2522 |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
2523 return codec; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2524 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2525 |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2526 void file_editor_tab::handle_save_file_as_answer (const QString& save_file_name) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2527 { |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2528 QString saveFileName = save_file_name; |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2529 QFileInfo file (saveFileName); |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2530 QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ()); |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2531 |
29438
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2532 // Test if the file dialog should have added a default file |
29436
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2533 // suffix, but the selected file still has no suffix (see Qt bug |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2534 // https://bugreports.qt.io/browse/QTBUG-59401) |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2535 if ((! file_dialog->defaultSuffix ().isEmpty ()) && file.suffix ().isEmpty ()) |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2536 { |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2537 saveFileName = saveFileName + "." + file_dialog->defaultSuffix (); |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2538 } |
2c60e63ff1db
fix missing file suffix m when saving a new script (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29358
diff
changeset
|
2539 |
29438
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2540 file.setFile (saveFileName); |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2541 |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2542 // If overwrite confirmation was not done by the file dialog (in case |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2543 // of native file dialogs, see above), do it here |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
2544 if (file_dialog->testOption (QFileDialog::DontConfirmOverwrite) && file.exists ()) |
29438
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2545 { |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2546 int ans = QMessageBox::question (file_dialog, |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2547 tr ("Octave Editor"), |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2548 tr ("%1\n already exists\n" |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2549 "Do you want to overwrite it?").arg (saveFileName), |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2550 QMessageBox::Yes | QMessageBox::No); |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2551 if (ans != QMessageBox::Yes) |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2552 { |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2553 // Try again, if edit area is read only, remove on success |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2554 save_file_as (m_edit_area->isReadOnly ()); |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2555 return; |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2556 } |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2557 } |
23424aa7a11a
fix confirm overwrite for native editor file save as dialogs (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29437
diff
changeset
|
2558 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2559 if (saveFileName == m_file_name) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2560 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2561 save_file (saveFileName); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2562 } |
16702
553cfdd5d660
make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents:
16701
diff
changeset
|
2563 else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2564 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2565 // Have editor check for conflict, do not delete tab after save. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2566 if (check_valid_identifier (saveFileName)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2567 save_file_as (false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2568 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2569 emit editor_check_conflict_save (saveFileName, false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2570 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2571 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2572 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2573 void file_editor_tab::handle_save_file_as_answer_close (const QString& saveFileName) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2574 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2575 // saveFileName == m_file_name can not happen, because we only can get here |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2576 // when we close a tab and m_file_name is not a valid filename yet |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2577 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2578 // Have editor check for conflict, delete tab after save. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2579 if (check_valid_identifier (saveFileName)) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2580 save_file_as (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2581 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2582 emit editor_check_conflict_save (saveFileName, true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2583 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2584 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2585 void file_editor_tab::handle_save_file_as_answer_cancel (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2586 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2587 // User canceled, allow editing again. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2588 m_edit_area->setReadOnly (false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2589 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2590 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2591 void file_editor_tab::file_has_changed (const QString&, bool do_close) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2592 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2593 bool file_exists = QFile::exists (m_file_name); |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2594 |
25741
a3f2b06c599a
fix broken file closing when deleted/renamed in file browser
Torsten <mttl@mailbox.org>
parents:
25646
diff
changeset
|
2595 if (file_exists && ! do_close) |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2596 { |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2597 // Test if file is really modified or if just the timezone has |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
2598 // changed. In the latter, just return without doing anything. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2599 QDateTime modified = QFileInfo (m_file_name).lastModified ().toUTC (); |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2600 |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2601 if (modified <= m_last_modified) |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2602 return; |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2603 |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2604 m_last_modified = modified; |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2605 } |
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2606 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2607 // Prevent popping up multiple message boxes when the file has |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2608 // been changed multiple times by temporarily removing from the |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2609 // file watcher. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2610 QStringList trackedFiles = m_file_system_watcher.files (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2611 if (! trackedFiles.isEmpty ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2612 m_file_system_watcher.removePath (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2613 |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2614 if (file_exists && ! do_close) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2615 { |
25369
c89fa0989e7b
prevent notifications on externally changed editor files (bug 53539)
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
2616 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2617 // The file is modified |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2618 if (m_always_reload_changed_files) |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2619 load_file (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2620 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2621 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2622 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2623 // give editor and this tab the focus, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2624 // possibly making the editor visible if it is hidden |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2625 emit set_focus_editor_signal (this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2626 m_edit_area->setFocus (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2627 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2628 // Create a WindowModal message that blocks the edit area |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2629 // by making m_edit_area parent. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2630 QMessageBox *msgBox |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2631 = new QMessageBox (QMessageBox::Warning, |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
2632 tr ("Octave Editor"), |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2633 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2634 arg (m_file_name), |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2635 QMessageBox::Yes | QMessageBox::No, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2636 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2637 connect (msgBox, &QMessageBox::finished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2638 this, &file_editor_tab::handle_file_reload_answer); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2639 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2640 msgBox->setWindowModality (Qt::WindowModal); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2641 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2642 msgBox->show (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2643 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2644 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2645 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2646 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2647 // If desired and if file is not modified, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2648 // close the file without any user interaction |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2649 if (do_close && ! m_edit_area->isModified ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2650 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2651 handle_file_resave_answer (QMessageBox::Cancel); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2652 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2653 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2654 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2655 // give editor and this tab the focus, |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
2656 // possibly making the editor visible if it is hidden |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2657 emit set_focus_editor_signal (this); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2658 m_edit_area->setFocus (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2659 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2660 QString modified = ""; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2661 if (m_edit_area->isModified ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2662 modified = tr ("\n\nWarning: The contents in the editor is modified!"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2663 |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
2664 // Create a WindowModal message. The file editor tab can't be made |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2665 // parent because it may be deleted depending upon the response. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2666 // Instead, change the m_edit_area to read only. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2667 QMessageBox *msgBox |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2668 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2669 tr ("It seems that the file\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2670 "%1\n" |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2671 "has been deleted or renamed. Do you want to save it now?%2"). |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2672 arg (m_file_name).arg (modified), |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2673 QMessageBox::Save | QMessageBox::Close, nullptr); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2674 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2675 m_edit_area->setReadOnly (true); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2676 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2677 connect (msgBox, &QMessageBox::finished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2678 this, &file_editor_tab::handle_file_resave_answer); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2679 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2680 msgBox->setWindowModality (Qt::WindowModal); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2681 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2682 msgBox->show (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2683 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2684 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2685 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2686 void file_editor_tab::notice_settings (bool init) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2687 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2688 gui_settings settings; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2689 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2690 if (! init) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2691 update_lexer_settings (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2692 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2693 // code folding |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2694 if (settings.value (ed_code_folding).toBool ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2695 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2696 m_edit_area->setMarginType (3, QsciScintilla::SymbolMargin); |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
2697 m_edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle, 3); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2698 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2699 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2700 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2701 m_edit_area->setFolding (QsciScintilla::NoFoldStyle, 3); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2702 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2703 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2704 // status bar |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2705 if (settings.value (ed_show_edit_status_bar).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2706 m_status_bar->show (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2707 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2708 m_status_bar->hide (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2709 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2710 //highlight current line color |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2711 m_edit_area->setCaretLineVisible |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2712 (settings.value (ed_highlight_current_line).toBool ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2713 |
29498
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29468
diff
changeset
|
2714 // auto completion |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2715 bool match_keywords = settings.value |
27861
3fada47cc58a
replacing literals for editor prefs by symbolic constants
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
2716 (ed_code_completion_keywords).toBool (); |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2717 bool match_document = settings.value |
27861
3fada47cc58a
replacing literals for editor prefs by symbolic constants
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
2718 (ed_code_completion_document).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2719 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2720 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2721 if (match_keywords) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2722 if (match_document) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2723 source = QsciScintilla::AcsAll; |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
2724 else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2725 source = QsciScintilla::AcsAPIs; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2726 else if (match_document) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2727 source = QsciScintilla::AcsDocument; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2728 m_edit_area->setAutoCompletionSource (source); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2729 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2730 m_edit_area->setAutoCompletionReplaceWord |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2731 (settings.value (ed_code_completion_replace).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2732 m_edit_area->setAutoCompletionCaseSensitivity |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2733 (settings.value (ed_code_completion_case).toBool ()); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2734 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2735 if (settings.value (ed_code_completion).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2736 m_edit_area->setAutoCompletionThreshold |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2737 (settings.value (ed_code_completion_threshold).toInt ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2738 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2739 m_edit_area->setAutoCompletionThreshold (-1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2740 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2741 if (settings.value (ed_show_white_space).toBool ()) |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2742 if (settings.value (ed_show_white_space_indent).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2743 m_edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent); |
31648
29d734430e5f
maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents:
31646
diff
changeset
|
2744 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2745 m_edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2746 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2747 m_edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2748 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2749 m_edit_area->setEolVisibility (settings.value (ed_show_eol_chars).toBool ()); |
27861
3fada47cc58a
replacing literals for editor prefs by symbolic constants
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
2750 |
29649
1583728a5819
fix eol mode when saving files under new names (bug #60585)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29438
diff
changeset
|
2751 m_save_as_desired_eol = static_cast<QsciScintilla::EolMode> |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2752 (settings.value (ed_default_eol_mode).toInt ()); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2753 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2754 if (settings.value (ed_show_line_numbers).toBool ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2755 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2756 m_edit_area->setMarginLineNumbers (2, true); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2757 auto_margin_width (); |
29707
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
2758 connect (m_edit_area, SIGNAL (linesChanged ()), |
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
2759 this, SLOT (auto_margin_width ())); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2760 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2761 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2762 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2763 m_edit_area->setMarginLineNumbers (2, false); |
29707
81be7e4ddb0f
revert connection of qscintilla signals back to old syntax (bug #60469)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29698
diff
changeset
|
2764 disconnect (m_edit_area, SIGNAL (linesChanged ()), nullptr, nullptr); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2765 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2766 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2767 m_smart_indent = settings.value (ed_auto_indent).toBool (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2768 m_edit_area->setAutoIndent (m_smart_indent); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2769 m_edit_area->setTabIndents |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2770 (settings.value (ed_tab_indents_line).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2771 m_edit_area->setBackspaceUnindents |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2772 (settings.value (ed_backspace_unindents_line).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2773 m_edit_area->setIndentationGuides |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2774 (settings.value (ed_show_indent_guides).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2775 m_edit_area->setIndentationsUseTabs |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2776 (settings.value (ed_indent_uses_tabs).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2777 m_edit_area->setIndentationWidth |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2778 (settings.value (ed_indent_width).toInt ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2779 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2780 m_edit_area->setTabWidth |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2781 (settings.value (ed_tab_width).toInt ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2782 |
27198
dffdabfd0213
fix cursor position for editor smart indent after keyword (bug #56533)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27160
diff
changeset
|
2783 m_ind_char_width = 1; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2784 if (m_edit_area->indentationsUseTabs ()) |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2785 m_ind_char_width = m_edit_area->tabWidth (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2786 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2787 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR, |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2788 settings.value (ed_show_hscroll_bar).toBool ()); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2789 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2790 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,true); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2791 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2792 update_window_title (m_edit_area->isModified ()); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2793 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2794 m_auto_endif = settings.value (ed_auto_endif).toInt (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2795 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2796 // long line marker |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2797 int line_length = settings.value (ed_long_line_column).toInt (); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2798 m_edit_area->setEdgeColumn (line_length); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2799 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2800 if (settings.value (ed_long_line_marker).toBool ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2801 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2802 if (settings.value (ed_long_line_marker_line).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2803 m_edit_area->setEdgeMode (QsciScintilla::EdgeLine); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2804 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2805 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2806 if (settings.value (ed_long_line_marker_background) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2807 .toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2808 m_edit_area->setEdgeMode (QsciScintilla::EdgeBackground); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2809 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2810 m_edit_area->setEdgeMode (QsciScintilla::EdgeLine); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2811 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2812 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2813 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2814 m_edit_area->setEdgeMode (QsciScintilla::EdgeNone); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2815 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2816 // line wrapping and breaking |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2817 m_edit_area->setWrapVisualFlags (QsciScintilla::WrapFlagByBorder); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2818 m_edit_area->setWrapIndentMode (QsciScintilla::WrapIndentSame); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2819 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2820 if (settings.value (ed_wrap_lines).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2821 m_edit_area->setWrapMode (QsciScintilla::WrapWord); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2822 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2823 m_edit_area->setWrapMode (QsciScintilla::WrapNone); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2824 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2825 if (settings.value (ed_break_lines).toBool ()) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2826 m_line_break = line_length; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2827 else |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2828 m_line_break = 0; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2829 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2830 m_line_break_comments = |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2831 settings.value (ed_break_lines_comments).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2832 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2833 // highlight all occurrences of a word selected by a double click |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2834 m_highlight_all_occurrences = |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2835 settings.value (ed_highlight_all_occurrences).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2836 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2837 // reload changed files |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2838 m_always_reload_changed_files = |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2839 settings.value (ed_always_reload_changed_files).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2840 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2841 // Set cursor blinking depending on the settings. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2842 // QScintilla ignores the application global settings, so some special |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2843 // handling is required |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2844 bool cursor_blinking; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2845 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2846 if (settings.contains (global_cursor_blinking.key)) |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2847 cursor_blinking = settings.value (global_cursor_blinking).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2848 else |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
2849 cursor_blinking = settings.value (cs_cursor_blinking).toBool (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2850 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2851 if (cursor_blinking) |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
2852 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD, 500); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2853 else |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
2854 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD, 0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2855 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2856 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2857 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2858 void file_editor_tab::auto_margin_width (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2859 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2860 m_edit_area->setMarginWidth (2, "1" + QString::number (m_edit_area->lines ())); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2861 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2862 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2863 // the following close request was changed from a signal slot into a |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2864 // normal function because we need the return value from close whether |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2865 // the tab really was closed (for canceling exiting octave). |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2866 // When emitting a signal, only the return value from the last slot |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2867 // goes back to the sender |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2868 bool file_editor_tab::conditional_close (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2869 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2870 return close (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2871 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2872 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2873 void file_editor_tab::change_editor_state (const QWidget *ID) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2874 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2875 if (ID != 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
|
2876 return; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2877 |
29698
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
2878 emit editor_state_changed (m_copy_available, m_is_octave_file, |
bbf5d4ea616c
fix enabled state of editor save action depending on modification state
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29657
diff
changeset
|
2879 m_edit_area->isModified ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2880 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2881 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2882 void file_editor_tab::handle_file_reload_answer (int decision) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2883 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2884 if (decision == QMessageBox::Yes) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2885 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2886 // reload: file is readded to the file watcher in set_file_name () |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2887 load_file (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2888 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2889 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2890 { |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
2891 // do not reload: readd to the file watcher |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2892 m_file_system_watcher.addPath (m_file_name); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2893 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2894 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2895 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2896 void file_editor_tab::handle_file_resave_answer (int decision) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2897 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2898 // check decision of user in dialog |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2899 if (decision == QMessageBox::Save) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2900 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2901 save_file (m_file_name); // readds file to watcher in set_file_name () |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2902 m_edit_area->setReadOnly (false); // delete read only flag |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2903 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2904 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2905 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2906 // Definitely close the file. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2907 // Set modified to false to prevent the dialog box when the close event |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
2908 // is posted. If the user cancels the close in this dialog the tab is |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2909 // left open with a non-existing file. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2910 m_edit_area->setModified (false); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2911 close (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2912 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2913 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2914 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2915 void file_editor_tab::insert_debugger_pointer (const QWidget *ID, int line) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2916 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2917 if (ID != this || ID == nullptr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2918 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2919 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2920 emit remove_all_positions (); // debugger_position, unsure_debugger_position |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2921 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2922 if (line > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2923 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2924 marker *dp; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2925 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2926 if (m_edit_area->isModified ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2927 { |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
2928 // The best that can be done if the editor contents have been |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2929 // modified is to see if there is a match with the original |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2930 // line number of any existing breakpoints. We can put a normal |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2931 // debugger pointer at that breakpoint position. Otherwise, it |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2932 // isn't certain whether the original line number and current line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2933 // number match. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2934 int editor_linenr = -1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2935 marker *dummy; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2936 emit find_translated_line_number (line, editor_linenr, dummy); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2937 if (editor_linenr != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2938 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2939 // Match with an existing breakpoint. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2940 dp = new marker (m_edit_area, line, |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2941 marker::debugger_position, editor_linenr); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2942 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2943 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2944 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2945 int original_linenr = -1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2946 editor_linenr = -1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2947 emit find_linenr_just_before (line, original_linenr, editor_linenr); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2948 if (original_linenr >= 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2949 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2950 // Make a guess by using an offset from the breakpoint. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2951 int linenr_guess = editor_linenr + line - original_linenr; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2952 dp = new marker (m_edit_area, line, |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2953 marker::unsure_debugger_position, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2954 linenr_guess); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2955 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2956 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2957 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2958 // Can't make a very good guess, so just use the debugger |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2959 // line number. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2960 dp = new marker (m_edit_area, line, |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2961 marker::unsure_debugger_position); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2962 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2963 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2964 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2965 else |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2966 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
2967 dp = new marker (m_edit_area, line, marker::debugger_position); |
27008
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2968 |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2969 // In case of a not modified file we might have to remove |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2970 // a breakpoint here if we have stepped into the file |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2971 if (line == m_breakpoint_info.remove_line) |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2972 { |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2973 m_breakpoint_info.remove_line = -1; |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2974 if (line != m_breakpoint_info.do_not_remove_line) |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2975 handle_request_remove_breakpoint (line); |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2976 } |
e93b8887fedf
remove additionally added breakpoint when stepping into a file (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26975
diff
changeset
|
2977 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2978 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2979 connect (this, &file_editor_tab::remove_position_via_debugger_linenr, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2980 dp, &marker::handle_remove_via_original_linenr); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2981 |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2982 connect (this, &file_editor_tab::remove_all_positions, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
2983 dp, &marker::handle_remove); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2984 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2985 center_current_line (false); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2986 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2987 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2988 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2989 void file_editor_tab::delete_debugger_pointer (const QWidget *ID, int line) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2990 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2991 if (ID != this || ID == nullptr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2992 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2993 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2994 if (line > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2995 emit remove_position_via_debugger_linenr (line); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2996 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2997 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2998 void file_editor_tab::do_breakpoint_marker (bool insert, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
2999 const QWidget *ID, int line, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3000 const QString& cond) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3001 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3002 if (ID != this || ID == nullptr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3003 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3004 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3005 if (line > 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3006 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3007 if (insert) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3008 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3009 int editor_linenr = -1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3010 marker *bp = nullptr; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3011 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3012 // If comes back indicating a non-zero breakpoint marker, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3013 // reuse it if possible |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3014 emit find_translated_line_number (line, editor_linenr, bp); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3015 if (bp != nullptr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3016 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3017 if ((cond == "") != (bp->get_cond () == "")) |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
3018 { |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25070
diff
changeset
|
3019 // can only reuse conditional bp as conditional |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3020 emit remove_breakpoint_via_debugger_linenr (line); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3021 bp = nullptr; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3022 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3023 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3024 bp->set_cond (cond); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3025 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3026 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3027 if (bp == nullptr) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3028 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3029 bp = new marker (m_edit_area, line, |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3030 cond == "" ? marker::breakpoint |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3031 : marker::cond_break, cond); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3032 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3033 connect (this, &file_editor_tab::remove_breakpoint_via_debugger_linenr, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3034 bp, &marker::handle_remove_via_original_linenr); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3035 connect (this, &file_editor_tab::request_remove_breakpoint_via_editor_linenr, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3036 bp, &marker::handle_request_remove_via_editor_linenr); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3037 connect (this, &file_editor_tab::remove_all_breakpoints_signal, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3038 bp, &marker::handle_remove); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3039 connect (this, &file_editor_tab::find_translated_line_number, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3040 bp, &marker::handle_find_translation); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3041 connect (this, &file_editor_tab::find_linenr_just_before, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3042 bp, &marker::handle_find_just_before); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3043 connect (this, &file_editor_tab::report_marker_linenr, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3044 bp, &marker::handle_report_editor_linenr); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3045 connect (bp, &marker::request_remove, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29498
diff
changeset
|
3046 this, &file_editor_tab::handle_request_remove_breakpoint); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3047 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3048 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3049 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3050 emit remove_breakpoint_via_debugger_linenr (line); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3051 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3052 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3053 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3054 void file_editor_tab::center_current_line (bool always) |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
3055 { |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3056 long int visible_lines |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3057 = m_edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3058 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3059 if (visible_lines > 2) |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
3060 { |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3061 int line, index; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3062 m_edit_area->getCursorPosition (&line, &index); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3063 // compensate for "folding": |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3064 // step 1: expand the current line, if it was folded |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3065 m_edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3066 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3067 // step 2: map file line num to "visible" one // SCI_VISIBLEFROMDOCLINE |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3068 int vis_line = m_edit_area->SendScintilla (2220, line); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3069 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3070 int first_line = m_edit_area->firstVisibleLine (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3071 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3072 if (always || vis_line == first_line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3073 || vis_line > first_line + visible_lines - 2) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3074 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3075 first_line += (vis_line - first_line - (visible_lines - 1) / 2); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3076 m_edit_area->SendScintilla (2613, first_line); // SCI_SETFIRSTVISIBLELINE |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3077 } |
23237
904c8a356e76
provide the possibility for breaking lines only in comments (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23236
diff
changeset
|
3078 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3079 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3080 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3081 void file_editor_tab::handle_lines_changed (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3082 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3083 // the related signal is emitted before cursor-move-signal! |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3084 m_lines_changed = true; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3085 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3086 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3087 void file_editor_tab::handle_cursor_moved (int line, int col) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3088 { |
28382
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3089 // Cursor has moved, first check wether an autocompletion list |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3090 // is active or if it was closed. Scintilla provides signals for |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3091 // completed or cancelled lists, but not for list that where hidden |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3092 // due to a new character not matching anymore with the list entries |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3093 if (m_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE)) |
28382
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3094 m_autoc_active = true; |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3095 else if (m_autoc_active) |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3096 { |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3097 m_autoc_active = false; |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3098 emit autoc_closed (); // Tell editor about closed list |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3099 } |
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3100 |
29716
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3101 // Lines changed? Take care of indentation! |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3102 bool do_smart_indent = m_lines_changed && m_is_octave_file |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3103 && (line == m_line+1) && (col < m_col) |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3104 && (m_smart_indent || m_auto_endif); |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3105 m_lines_changed = false; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3106 |
28382
2b52e473b6ef
fix focus issues in editor due to qt bug with focus proxy chains (bug #57635)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28297
diff
changeset
|
3107 // Update line and column indicator in the status bar |
29716
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3108 int o_line = m_line; |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3109 update_rowcol_indicator (line, col); |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3110 |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3111 // Do smart indent after update of line indicator for having |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3112 // consistent indicator data |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3113 if (do_smart_indent) |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3114 m_edit_area->smart_indent (m_smart_indent, m_auto_endif, |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3115 o_line, m_ind_char_width); |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3116 } |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3117 |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3118 void file_editor_tab::update_rowcol_indicator (int line, int col) |
da9c55b3e9fa
fix wring row/col indicator in GUI editor when auto intending (bug #60690)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29707
diff
changeset
|
3119 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3120 m_line = line; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3121 m_col = col; |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3122 m_row_indicator->setNum (line+1); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3123 m_col_indicator->setNum (col+1); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3124 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3125 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3126 // Slot that is entered each time a new character was typed. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3127 // It is used for handling line breaking if this is desired. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3128 // The related signal is emitted after the signal for a moved cursor |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3129 // such that m_col and m_line can not be used for current position. |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3130 void file_editor_tab::handle_char_added (int) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3131 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3132 if (m_line_break) |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
3133 { |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3134 // If line breaking is desired, get the current line and column. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3135 // For taking the tab width into consideration, use own function |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3136 int line, col, pos; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3137 m_edit_area->get_current_position (&pos, &line, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3138 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3139 // immediately return if line has not reached the max. line length |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3140 if (col <= m_line_break) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3141 return; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3142 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3143 // If line breaking is only desired in comments, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3144 // return if not in a comment |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3145 int style_comment = octave_qscintilla::ST_NONE; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3146 if (m_line_break_comments) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3147 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3148 // line breaking only in comments, check for comment style |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3149 style_comment = m_edit_area->is_style_comment (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3150 if (! style_comment) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3151 return; // no comment, return |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3152 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3153 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3154 // Here we go for breaking the current line by inserting a newline. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3155 // For determining the position of a specific column, we have to get |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
3156 // the column from the QScintilla function without taking tab lengths |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
3157 // into account, since the calculation from line/col to position |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27861
diff
changeset
|
3158 // ignores this, too. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3159 m_edit_area->getCursorPosition (&line, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3160 int c = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3161 int col_space = col; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3162 int indentation = m_edit_area->indentation (line); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3163 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27455
diff
changeset
|
3164 // Search the first occurrence of space or tab backwards starting from |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3165 // the current column (col_space). |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3166 while (c != ' ' && c != '\t' && col_space > indentation) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3167 { |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3168 pos = m_edit_area->positionFromLineIndex (line, col_space--); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3169 c = m_edit_area->SendScintilla (QsciScintillaBase::SCI_GETCHARAT, pos); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3170 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3171 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3172 // If a space or tab was found, break at this char, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3173 // otherwise break at cursor position |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3174 int col_newline = col - 1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3175 if (c == ' ' || c == '\t') |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3176 col_newline = col_space + 1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3177 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3178 // Insert a newline char for breaking the line possibly followed |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3179 // by a line comment string |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3180 QString newline = QString ("\n"); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3181 style_comment = m_edit_area->is_style_comment (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3182 if (style_comment == octave_qscintilla::ST_LINE_COMMENT) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3183 newline = newline + m_edit_area->comment_string ().at (0); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3184 m_edit_area->insertAt (newline, line, col_newline); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3185 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3186 // Automatically indent the new line to the indentation of previous line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3187 // and set the cursor position to the end of the indentation. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3188 m_edit_area->setIndentation (line + 1, indentation); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3189 m_edit_area->SendScintilla (QsciScintillaBase::SCI_LINEEND); |
23181
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
3190 } |
78f04a9dfeee
allow line breaking in the editor (bug #41555)
Torsten <mttl@mailbox.org>
parents:
23179
diff
changeset
|
3191 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3192 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3193 // Slot handling a double click into the text area |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3194 void file_editor_tab::handle_double_click (int, int, int modifier) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3195 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3196 if (! modifier) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3197 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3198 // double clicks without modifier |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3199 // clear any existing indicators of this type |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3200 m_edit_area->clear_selection_markers (); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3201 |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3202 if (m_highlight_all_occurrences) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3203 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3204 // Clear any previous selection. |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3205 m_edit_area->set_word_selection (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3206 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3207 // highlighting of all occurrences of the clicked word is enabled |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3208 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3209 // get the resulting cursor position |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3210 // (required if click was beyond a line ending) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3211 int line, col; |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3212 m_edit_area->getCursorPosition (&line, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3213 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3214 // get the word at the cursor (if any) |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3215 QString word = m_edit_area->wordAtLineIndex (line, col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3216 word = word.trimmed (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3217 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3218 if (! word.isEmpty ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3219 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3220 // word is not empty, so find all occurrences of the word |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3221 |
28297
1127bcb30e61
Restore editor x-offset after highlight-all-occurrences double-click (bug #58372)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
28118
diff
changeset
|
3222 // remember first visible line and x-offset for restoring the view afterwards |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3223 int first_line = m_edit_area->firstVisibleLine (); |
28301 | 3224 int x_offset = m_edit_area->SendScintilla (QsciScintillaBase::SCI_GETXOFFSET); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3225 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3226 // search for first occurrence of the detected word |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3227 bool find_result_available |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3228 = m_edit_area->findFirst (word, |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3229 false, // no regexp |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3230 true, // case sensitive |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3231 true, // whole words only |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3232 false, // do not wrap |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3233 true, // forward |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29716
diff
changeset
|
3234 0, 0, // from the beginning |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3235 false |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
3236 #if defined (HAVE_QSCI_VERSION_2_6_0) |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3237 , true |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23186
diff
changeset
|
3238 #endif |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
3239 ); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3240 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3241 // loop over all occurrences and set the related indicator |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3242 int oline, ocol; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3243 int wlen = word.length (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3244 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3245 while (find_result_available) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3246 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3247 // get cursor position after having found an occurrence |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3248 m_edit_area->getCursorPosition (&oline, &ocol); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3249 // mark the selection |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3250 m_edit_area->show_selection_markers (oline, ocol-wlen, oline, ocol); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3251 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3252 // find next occurrence |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3253 find_result_available = m_edit_area->findNext (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3254 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3255 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3256 // restore the visible area of the file, the cursor position, |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3257 // and the selection |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3258 m_edit_area->setFirstVisibleLine (first_line); |
28301 | 3259 m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETXOFFSET, x_offset); |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3260 m_edit_area->setCursorPosition (line, col); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3261 m_edit_area->setSelection (line, col - wlen, line, col); |
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3262 m_edit_area->set_word_selection (word); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3263 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3264 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3265 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3266 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3267 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3268 QString file_editor_tab::get_function_name (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3269 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3270 QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3271 QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3272 QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$"); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3273 QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\\s]+)[\t ]*$"); |
26624
7994f91cbdb8
Provide correct guess at filename when saving classdef file from GUI (bug #55497).
Rik <rik@octave.org>
parents:
26561
diff
changeset
|
3274 QRegExp rxfun5 ("^[\t ]*classdef[\t ]+([^\\s]+)[\t ]*$"); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3275 |
27378
6d0585c8ee11
use m_ prefix for data members in file_editor_tab class
John W. Eaton <jwe@octave.org>
parents:
27375
diff
changeset
|
3276 QStringList lines = m_edit_area->text ().split ("\n"); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3277 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3278 for (int i = 0; i < lines.count (); i++) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3279 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3280 if (rxfun1.indexIn (lines.at (i)) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3281 return rxfun1.cap (1).remove (QRegExp ("[ \t]*")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3282 else if (rxfun2.indexIn (lines.at (i)) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3283 return rxfun2.cap (1).remove (QRegExp ("[ \t]*")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3284 else if (rxfun3.indexIn (lines.at (i)) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3285 return rxfun3.cap (1).remove (QRegExp ("[ \t]*")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3286 else if (rxfun4.indexIn (lines.at (i)) != -1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3287 return rxfun4.cap (1).remove (QRegExp ("[ \t]*")); |
26624
7994f91cbdb8
Provide correct guess at filename when saving classdef file from GUI (bug #55497).
Rik <rik@octave.org>
parents:
26561
diff
changeset
|
3288 else if (rxfun5.indexIn (lines.at (i)) != -1) |
7994f91cbdb8
Provide correct guess at filename when saving classdef file from GUI (bug #55497).
Rik <rik@octave.org>
parents:
26561
diff
changeset
|
3289 return rxfun5.cap (1).remove (QRegExp ("[ \t]*")); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3290 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3291 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3292 return QString (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24666
diff
changeset
|
3293 } |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
3294 |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31361
diff
changeset
|
3295 OCTAVE_END_NAMESPACE(octave) |
18834
0e6f7b5f6556
propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents:
18833
diff
changeset
|
3296 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15860
diff
changeset
|
3297 #endif |