annotate libgui/src/m-editor/file-editor-tab.cc @ 18684:86eca5d178a6 gui-release

disable some global shortcuts when editor gets focus to prevent conflicts * file-editor-tab.cc (constructor): connect signal from the qscintilla edit area about focus with the related new slot; (edit_area_has_focus): new slot for the focus signal from qscintilla edit area emitting a signal for enabling/disabling the common edit shortcuts * file-editor-tab.h: new slot edit_area_has_focus, new signal set_global_edit_shortcuts_signal * file-editor.cc (add_file_editor_tab ): connect new tab signal set_global_edit_shortcuts_signal with the related slot in main_window; (copyClipboard, pasteClipboard, selectAll): removed these functions because the related actions are triggered editor shortcuts * file-editor.h: remove copyClipboard, pasteClipboard, selectAll * octave-qscintilla.cc (focusInEvent, focusOutEvent): handlers emitting the signal about the focus state of the edit area * octave-qscintilla.h: new focus signal qsci_has_focus_signal, focus event handlers * main-window.cc (set_global_edit_shortcuts): new slot dis-/enabling the common edit shortcuts depending on focus of edit area * main-window.h: new slot set_global_edit_shortcuts
author Torsten <ttl@justmail.de>
date Sun, 27 Apr 2014 13:03:08 +0200
parents 1b289f45187f
children 74ef7fed8b9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18315
6e8188effddf file-editor-tab.cc: Fix a typo.
Julien Bect <julien.bect@supelec.fr>
parents: 18303
diff changeset
1
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
3
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17737
diff changeset
4 Copyright (C) 2011-2013 Jacob Dawid
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
22 */
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
24 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
25 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
26 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
27
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
28 #ifdef HAVE_QSCINTILLA
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
29
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
30 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H)
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
31 #define HAVE_LEXER_OCTAVE
16646
025bc6b5080e use QScintilla's lexer for highlighting Octave programs
John W. Eaton <jwe@octave.org>
parents: 16638
diff changeset
32 #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
33 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H)
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
34 #define HAVE_LEXER_MATLAB
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
35 #include <Qsci/qscilexermatlab.h>
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
36 #endif
14873
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
37 #include <Qsci/qscilexercpp.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
38 #include <Qsci/qscilexerbash.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
39 #include <Qsci/qscilexerperl.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
40 #include <Qsci/qscilexerbatch.h>
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
41 #include <Qsci/qscilexerdiff.h>
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
42 #include <Qsci/qsciprinter.h>
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
43 #include "resource-manager.h"
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
44 #include <QApplication>
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
45 #include <QFileDialog>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
46 #include <QMessageBox>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
47 #include <QTextStream>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
48 #include <QVBoxLayout>
16375
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
49 #include <QInputDialog>
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
50 #include <QPrintDialog>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
51
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
52 #include "file-editor-tab.h"
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
53 #include "file-editor.h"
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
54
18237
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
55 #include "file-ops.h"
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
56
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
57 #include "debug.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
58 #include "octave-qt-link.h"
16715
96ed7ab44e2e save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents: 16704
diff changeset
59 #include "version.h"
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
60 #include "utils.h"
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
61
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
62 // Make parent null for the file editor tab so that warning
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
63 // WindowModal messages don't affect grandparents.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
64 file_editor_tab::file_editor_tab (const QString& directory_arg)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
65 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
66 QString directory = directory_arg;
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
67 _lexer_apis = 0;
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
68 _app_closing = false;
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
69
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
70 // Make sure there is a slash at the end of the directory name
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
71 // for identification when saved later.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
72 if (directory.count () && directory.at (directory.count () - 1) != '/')
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
73 directory.append ("/");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
74
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
75 _file_name = directory;
17737
d3bb7f1e3971 prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents: 17706
diff changeset
76 _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
77
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
78 _edit_area = new octave_qscintilla (this);
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
79 // Connect signal for command execution to a slot of this tab which in turn
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
80 // emits a signal connected to the main window.
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
81 // Direct connection is not possible because tab's parent is null.
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
82 connect (_edit_area,
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
83 SIGNAL (execute_command_in_terminal_signal (const QString&)),
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
84 this,
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
85 SLOT (execute_command_in_terminal (const QString&)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
86
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
87 connect (_edit_area,
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
88 SIGNAL (cursorPositionChanged (int, int)),
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
89 this,
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
90 SLOT (handle_cursor_moved (int,int)));
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
91
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
92 // create statusbar for row/col indicator
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
93 _status_bar = new QStatusBar (this);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
94
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
95 _row_indicator = new QLabel ("", this);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
96 _row_indicator->setMinimumSize (30,0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
97 QLabel *row_label = new QLabel (tr ("Line:"), this);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
98 _col_indicator = new QLabel ("", this);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
99 _col_indicator->setMinimumSize (25,0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
100 QLabel *col_label = new QLabel (tr ("Col:"), this);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
101 _status_bar->addPermanentWidget (row_label, 0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
102 _status_bar->addPermanentWidget (_row_indicator, 0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
103 _status_bar->addPermanentWidget (col_label, 0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
104 _status_bar->addPermanentWidget (_col_indicator, 0);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
105
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
106 // Leave the find dialog box out of memory until requested.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
107 _find_dialog = 0;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
108 _find_dialog_is_visible = false;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
109
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
110 // symbols
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
111 _edit_area->setMarginType (1, QsciScintilla::SymbolMargin);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
112 _edit_area->setMarginSensitivity (1, true);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
113 _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark);
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
114 _edit_area->markerDefine (QPixmap (":/actions/icons/redled.png"),
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
115 breakpoint);
17699
1be2993d3656 improve appearance of gui's dcoumentation browser
Torsten <ttl@justmail.de>
parents: 17636
diff changeset
116 _edit_area->markerDefine (QPixmap (":/actions/icons/bookmark.png"),
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
117 debugger_position);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
118
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
119 connect (_edit_area, SIGNAL (marginClicked (int, int,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
120 Qt::KeyboardModifiers)),
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
121 this, SLOT (handle_margin_clicked (int, int,
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
122 Qt::KeyboardModifiers)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
123
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
124 // line numbers
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
125 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
126 _edit_area->setMarginsBackgroundColor (QColor (232, 232, 220));
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
127 _edit_area->setMarginType (2, QsciScintilla::TextMargin);
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
128
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
129 // code folding
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
130 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
131 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
132
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
133 // other features
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
134 _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
135 _edit_area->setAutoIndent (true);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
136 _edit_area->setIndentationWidth (2);
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
137 _edit_area->setIndentationsUseTabs (false);
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
138
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
139 _edit_area->setUtf8 (true);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
140
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
141 // auto completion
18483
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18482
diff changeset
142 _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART, false);
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
143
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
144 QVBoxLayout *edit_area_layout = new QVBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
145 edit_area_layout->addWidget (_edit_area);
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
146 edit_area_layout->addWidget (_status_bar);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
147 edit_area_layout->setMargin (0);
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
148 setLayout (edit_area_layout);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
149
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
150 // connect modified signal
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
151 connect (_edit_area, SIGNAL (modificationChanged (bool)),
14788
85daba52b2d4 Fixed bug with editor complaining that a file has been modified by another application when saving.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14715
diff changeset
152 this, SLOT (update_window_title (bool)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
153
14715
b4db843b1f26 Done some extra method renaming to fit the overall octave coding style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
154 connect (_edit_area, SIGNAL (copyAvailable (bool)),
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
155 this, SLOT (handle_copy_available (bool)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
156
18684
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
157 connect (_edit_area, SIGNAL (qsci_has_focus_signal (bool)),
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
158 this, SLOT (edit_area_has_focus (bool)));
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
159
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
160 connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
161 this, SLOT (file_has_changed (const QString&)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
162
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
163 QSettings *settings = resource_manager::get_settings ();
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
164 if (settings)
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
165 notice_settings (settings);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
166 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
167
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
168 file_editor_tab::~file_editor_tab (void)
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
169 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
170 // Destroy items attached to _edit_area.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
171 QsciLexer *lexer = _edit_area->lexer ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
172 if (lexer)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
173 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
174 delete lexer;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
175 _edit_area->setLexer (0);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
176 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
177 if (_find_dialog)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
178 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
179 delete _find_dialog;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
180 _find_dialog = 0;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
181 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
182
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
183 // Destroy _edit_area.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
184 delete _edit_area;
14680
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
185 }
628eeaf879f7 Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14676
diff changeset
186
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
187 void
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
188 file_editor_tab::closeEvent (QCloseEvent *e)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
189 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
190 // ignore close event if file is not saved and user cancels
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
191 // closing this window
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
192 if (check_file_modified () == QMessageBox::Cancel)
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
193 e->ignore ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
194 else
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
195 e->accept ();
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
196 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
197
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
198 void
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
199 file_editor_tab::execute_command_in_terminal (const QString& command)
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
200 {
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
201 emit execute_command_in_terminal_signal (command); // connected to main window
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
202 }
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
203
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
204 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
205 file_editor_tab::set_file_name (const QString& fileName)
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
206 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
207 // update tracked file if we really have a file on disk
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
208 QStringList trackedFiles = _file_system_watcher.files ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
209 if (!trackedFiles.isEmpty ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
210 _file_system_watcher.removePath (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
211 if (!fileName.isEmpty ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
212 _file_system_watcher.addPath (fileName);
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
213 _file_name = fileName;
15425
8ae34ffe5c1b Retain QsciAPIs lexer_api as part of lexer_octave_gui object (bug #37359)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15402
diff changeset
214
8ae34ffe5c1b Retain QsciAPIs lexer_api as part of lexer_octave_gui object (bug #37359)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15402
diff changeset
215 // update lexer after _file_name change
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
216 update_lexer ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
217
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
218 // update the file editor with current editing directory
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
219 emit editor_state_changed (_copy_available, _file_name);
15860
feba9ff6e6a8 editor: add list of recently used files to the file menu
Torsten <ttl@justmail.de>
parents: 15849
diff changeset
220 // add the new file to the mru list
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
221
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
222 emit mru_add_file (_file_name);
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
223 }
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
224
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
225 // valid_file_name (file): checks whether "file" names a file
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
226 // by default, "file" is empty, then _file_name is checked
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
227 bool
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
228 file_editor_tab::valid_file_name (const QString& file)
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
229 {
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
230 QString file_name;
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
231 if (file.isEmpty ())
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
232 file_name = _file_name;
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
233 else
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
234 file_name = file;
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
235 return (! file_name.isEmpty ()
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
236 && file_name.at (file_name.count () - 1) != '/');
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
237 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
238
14690
ca733a66be7a Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14680
diff changeset
239 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
240 file_editor_tab::handle_margin_clicked (int margin, int line,
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
241 Qt::KeyboardModifiers state)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
242 {
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
243 if (margin == 1)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
244 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
245 unsigned int markers_mask = _edit_area->markersAtLine (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
246
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
247 if (state & Qt::ControlModifier)
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
248 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
249 if (markers_mask && (1 << bookmark))
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
250 _edit_area->markerDelete (line, bookmark);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
251 else
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
252 _edit_area->markerAdd (line, bookmark);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
253 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
254 else
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
255 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
256 if (markers_mask && (1 << breakpoint))
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
257 request_remove_breakpoint (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
258 else
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
259 request_add_breakpoint (line);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
260 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
261 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
262 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
263
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
264 void
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
265 file_editor_tab::update_lexer ()
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
266 {
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
267 if (_lexer_apis)
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
268 _lexer_apis->cancelPreparation (); // stop preparing if apis exists
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
269
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
270 QsciLexer *lexer = _edit_area->lexer ();
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
271 delete lexer;
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
272 lexer = 0;
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
273
16559
78765ae325fd gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents: 16558
diff changeset
274 if (_file_name.endsWith (".m")
78765ae325fd gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents: 16558
diff changeset
275 || _file_name.endsWith ("octaverc"))
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
276 {
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
277 #if defined (HAVE_LEXER_OCTAVE)
16646
025bc6b5080e use QScintilla's lexer for highlighting Octave programs
John W. Eaton <jwe@octave.org>
parents: 16638
diff changeset
278 lexer = new QsciLexerOctave ();
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
279 #elif defined (HAVE_LEXER_MATLAB)
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
280 lexer = new QsciLexerMatlab ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
281 #endif
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
282 }
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
283
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
284 if (! lexer)
14873
355d6c165df0 Added syntax highlighting support for .sh/.bat/.pl and .diff-files.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14869
diff changeset
285 {
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
286 if (_file_name.endsWith (".c")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
287 || _file_name.endsWith (".cc")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
288 || _file_name.endsWith (".cpp")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
289 || _file_name.endsWith (".cxx")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
290 || _file_name.endsWith (".c++")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
291 || _file_name.endsWith (".h")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
292 || _file_name.endsWith (".hh")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
293 || _file_name.endsWith (".hpp")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
294 || _file_name.endsWith (".h++"))
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
295 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
296 lexer = new QsciLexerCPP ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
297 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
298 else if (_file_name.endsWith (".pl"))
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
299 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
300 lexer = new QsciLexerPerl ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
301 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
302 else if (_file_name.endsWith (".bat"))
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
303 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
304 lexer = new QsciLexerBatch ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
305 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
306 else if (_file_name.endsWith (".diff"))
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
307 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
308 lexer = new QsciLexerDiff ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
309 }
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
310 else if (! valid_file_name ())
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
311 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
312 // new, no yet named file: let us assume it is octave
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
313 #if defined (HAVE_LEXER_OCTAVE)
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
314 lexer = new QsciLexerOctave ();
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
315 #elif defined (HAVE_LEXER_MATLAB)
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
316 lexer = new QsciLexerMatlab ();
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
317 #else
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
318 lexer = new QsciLexerBash ();
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
319 #endif
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
320 }
16720
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
321 else
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
322 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
323 // other or no extension
16720
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
324 lexer = new QsciLexerBash ();
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
325 }
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14873
diff changeset
326 }
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
327
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
328 _lexer_apis = new QsciAPIs(lexer);
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
329 if (_lexer_apis)
16678
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
330 {
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
331 // get path to prepared api info
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
332 QDesktopServices desktopServices;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
333 QString prep_apis_path
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
334 = desktopServices.storageLocation (QDesktopServices::HomeLocation)
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
335 + "/.config/octave/" + QString(OCTAVE_VERSION) + "/qsci/";
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
336 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap";
16715
96ed7ab44e2e save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents: 16704
diff changeset
337
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
338 if (!_lexer_apis->loadPrepared (_prep_apis_file))
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
339 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
340 // no prepared info loaded, prepare and save if possible
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
341
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
342 // create raw apis info
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
343 QString keyword;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
344 QStringList keyword_list;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
345 int i,j;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
346 for (i=1; i<=3; i++) // test the first 5 keyword sets
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
347 {
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
348 keyword = QString(lexer->keywords (i)); // get list
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
349 keyword_list = keyword.split (QRegExp ("\\s+")); // split
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
350 for (j = 0; j < keyword_list.size (); j++) // add to API
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
351 _lexer_apis->add (keyword_list.at (j));
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
352 }
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
353
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
354 // dsiconnect slot for saving prepared info if already connected
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
355 disconnect (_lexer_apis, SIGNAL (apiPreparationFinished ()), 0, 0);
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
356 // check whether path for prepared info exists or can be created
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
357 if (QDir("/").mkpath (prep_apis_path))
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
358 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
359 // path exists, apis info can be saved there
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
360 connect (_lexer_apis, SIGNAL (apiPreparationFinished ()),
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
361 this, SLOT (save_apis_info ()));
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
362 }
16721
a71a784c7611 * file-editor-tab.cc(update_lexer): redundant code removed
Torsten <ttl@justmail.de>
parents: 16720
diff changeset
363 _lexer_apis->prepare (); // prepare apis info
16678
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
364 }
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
365 }
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
366
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15080
diff changeset
367 QSettings *settings = resource_manager::get_settings ();
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
368 if (settings)
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
369 lexer->readSettings (*settings);
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
370
16402
7fa90eb41240 gui: individually configurable styles of the editor lexers
Torsten <ttl@justmail.de>
parents: 16395
diff changeset
371 _edit_area->setLexer (lexer);
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
372
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
373 // fix line number width with respect to the font size of the lexer
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
374 if (settings->value ("editor/showLineNumbers", true).toBool ())
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
375 auto_margin_width ();
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
376 else
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
377 _edit_area->setMarginWidth (2,0);
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
378
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
379 }
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
380
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
381 void
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
382 file_editor_tab::save_apis_info ()
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
383 {
16715
96ed7ab44e2e save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents: 16704
diff changeset
384 _lexer_apis->savePrepared (_prep_apis_file);
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
385 }
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
386
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
387 QString
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
388 file_editor_tab::comment_string (const QString& lexer)
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
389 {
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
390 if (lexer == "octave" || lexer == "matlab")
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
391 return QString("%");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
392 else if (lexer == "perl" || lexer == "bash" || lexer == "diff")
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
393 return QString("#");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
394 else if (lexer == "cpp")
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
395 return ("//");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
396 else if (lexer == "batch")
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
397 return ("REM ");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
398 else
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
399 return ("%"); // should never happen
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
400 }
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
401
15980
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
402 // slot for fetab_set_focus: sets the focus to the current edit area
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
403 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
404 file_editor_tab::set_focus (const QWidget *ID)
15980
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
405 {
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
406 if (ID != this)
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
407 return;
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
408 _edit_area->setFocus ();
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
409 }
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
410
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
411 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
412 file_editor_tab::undo (const QWidget *ID)
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
413 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
414 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
415 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
416
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
417 _edit_area->undo ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
418 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
419
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
420 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
421 file_editor_tab::redo (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
422 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
423 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
424 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
425
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
426 _edit_area->redo ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
427 }
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
428
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
429 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
430 file_editor_tab::copy (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
431 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
432 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
433 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
434
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
435 _edit_area->copy ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
436 }
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
437
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
438 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
439 file_editor_tab::cut (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
440 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
441 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
442 return;
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
443
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
444 _edit_area->cut ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
445 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
446
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
447 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
448 file_editor_tab::paste (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
449 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
450 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
451 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
452
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
453 _edit_area->paste ();
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
454 }
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
455
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
456 void
18555
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
457 file_editor_tab::select_all (const QWidget *ID)
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
458 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
459 if (ID != this)
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
460 return;
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
461
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
462 _edit_area->selectAll ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
463 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
464
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
465
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18489
diff changeset
466 void
17627
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
467 file_editor_tab::context_help (const QWidget *ID, bool doc)
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
468 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
469 if (ID != this)
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
470 return;
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
471
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
472 _edit_area->context_help_doc (doc);
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
473 }
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
474
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
475 void
17628
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
476 file_editor_tab::context_edit (const QWidget *ID)
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
477 {
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
478 if (ID != this)
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
479 return;
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
480
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
481 _edit_area->context_edit ();
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
482 }
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
483
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
484 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
485 file_editor_tab::save_file (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
486 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
487 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
488 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
489
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
490 save_file (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
491 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
492 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
493
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
494 file_editor_tab::save_file (const QWidget *ID, const QString& fileName,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
495 bool remove_on_success)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
496 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
497 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
498 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
499
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
500 save_file (fileName, remove_on_success);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
501 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
502
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
503 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
504 file_editor_tab::save_file_as (const QWidget *ID)
14827
6b90737f69cc Very basic breakpoint setting and removing in the editor works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14826
diff changeset
505 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
506 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
507 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
508
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
509 save_file_as ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
510 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
511
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
512 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
513 file_editor_tab::print_file (const QWidget *ID)
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
514 {
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
515 if (ID != this)
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
516 return;
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
517
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
518 QsciPrinter *printer = new QsciPrinter (QPrinter::HighResolution);
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
519
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
520 QPrintDialog printDlg (printer, this);
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
521
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
522 if (printDlg.exec () == QDialog::Accepted)
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
523 printer->printRange (_edit_area);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
524
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
525 delete printer;
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
526 }
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
527
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
528 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
529 file_editor_tab::run_file (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
530 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
531 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
532 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
533
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
534 if (_edit_area->isModified ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
535 save_file (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
536
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
537 QFileInfo info (_file_name);
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
538 emit run_file_signal (info);
15080
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
539 }
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
540
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
541 void
17635
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
542 file_editor_tab::context_run (const QWidget *ID)
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
543 {
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
544 if (ID != this)
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
545 return;
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
546
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
547 _edit_area->context_run ();
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
548 }
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
549
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
550 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
551 file_editor_tab::toggle_bookmark (const QWidget *ID)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
552 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
553 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
554 return;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
555
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
556 int line, cur;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
557 _edit_area->getCursorPosition (&line, &cur);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
559 if (_edit_area->markersAtLine (line) && (1 << bookmark))
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
560 _edit_area->markerDelete (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
561 else
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
562 _edit_area->markerAdd (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
563 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
564
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
565 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
566 file_editor_tab::next_bookmark (const QWidget *ID)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
567 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
568 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
569 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
570
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
571 int line, cur;
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
572 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
573
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
574 if (_edit_area->markersAtLine (line) && (1 << bookmark))
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
575 line++; // we have a breakpoint here, so start search from next line
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
576
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
577 int nextline = _edit_area->markerFindNext (line, (1 << bookmark));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
578
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
579 _edit_area->setCursorPosition (nextline, 0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
580 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
581
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
582 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
583 file_editor_tab::previous_bookmark (const QWidget *ID)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
584 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
585 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
586 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
587
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
588 int line, cur;
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
589 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
590
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
591 if (_edit_area->markersAtLine (line) && (1 << bookmark))
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
592 line--; // we have a breakpoint here, so start search from prev line
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
593
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
594 int prevline = _edit_area->markerFindPrevious (line, (1 << bookmark));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
595
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
596 _edit_area->setCursorPosition (prevline, 0);
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
597 }
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
598
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
599 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
600 file_editor_tab::remove_bookmark (const QWidget *ID)
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
601 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
602 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
603 return;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
604
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
605 _edit_area->markerDeleteAll (bookmark);
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
606 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
607
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
608 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
609 file_editor_tab::add_breakpoint_callback (const bp_info& info)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
610 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
611 bp_table::intmap line_info;
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
612 line_info[0] = info.line;
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
613
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
614 if (octave_qt_link::file_in_path (info.file, info.dir))
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
615 bp_table::add_breakpoint (info.function_name, line_info);
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
616 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
617
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
618 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
619 file_editor_tab::remove_breakpoint_callback (const bp_info& info)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
620 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
621 bp_table::intmap line_info;
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
622 line_info[0] = info.line;
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
623
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
624 if (octave_qt_link::file_in_path (info.file, info.dir))
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
625 bp_table::remove_breakpoint (info.function_name, line_info);
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
626 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
627
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
628 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
629 file_editor_tab::remove_all_breakpoints_callback (const bp_info& info)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
630 {
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
631 if (octave_qt_link::file_in_path (info.file, info.dir))
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
632 bp_table::remove_all_breakpoints_in_file (info.function_name, true);
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
633 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
634
18237
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
635 file_editor_tab::bp_info::bp_info (const QString& fname, int l)
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
636 : line (l), file (fname.toStdString ())
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
637 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
638 QFileInfo file_info (fname);
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
639
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
640 QString q_dir = file_info.absolutePath ();
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
641 QString q_function_name = file_info.fileName ();
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
642
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
643 // We have to cut off the suffix, because octave appends it.
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
644 q_function_name.chop (file_info.suffix ().length () + 1);
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
645
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
646 dir = q_dir.toStdString ();
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
647 function_name = q_function_name.toStdString ();
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
648
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
649 // Is the last component of DIR @foo? If so, strip it and prepend it
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
650 // to the name of the function.
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
651
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
652 size_t pos = dir.rfind (file_ops::dir_sep_chars ());
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
653
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
654 if (pos != std::string::npos && pos < dir.length () - 1)
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
655 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
656 if (dir[pos+1] == '@')
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
657 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
658 function_name = file_ops::concat (dir.substr (pos+1), function_name);
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
659
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
660 dir = dir.substr (0, pos);
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
661 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
662 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
663 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
664
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
665 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
666 file_editor_tab::request_add_breakpoint (int line)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
667 {
18237
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
668 bp_info info (_file_name, line+1);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
669
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
670 octave_link::post_event
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
671 (this, &file_editor_tab::add_breakpoint_callback, info);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
672 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
673
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
674 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
675 file_editor_tab::request_remove_breakpoint (int line)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
676 {
18237
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
677 bp_info info (_file_name, line+1);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
678
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
679 octave_link::post_event
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
680 (this, &file_editor_tab::remove_breakpoint_callback, info);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
681 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
682
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
683 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
684 file_editor_tab::toggle_breakpoint (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
685 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
686 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
687 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
688
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
689 int line, cur;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
690 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
691
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
692 if (_edit_area->markersAtLine (line) && (1 << breakpoint))
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
693 request_remove_breakpoint (line);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
694 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
695 request_add_breakpoint (line);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
696 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
697
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
698 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
699 file_editor_tab::next_breakpoint (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
700 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
701 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
702 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
703
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
704 int line, cur;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
705 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
706
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
707 if (_edit_area->markersAtLine (line) && (1 << breakpoint))
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
708 line++; // we have a breakpoint here, so start search from next line
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
709
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
710 int nextline = _edit_area->markerFindNext (line, (1 << breakpoint));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
711
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
712 _edit_area->setCursorPosition (nextline, 0);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
713 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
714
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
715 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
716 file_editor_tab::previous_breakpoint (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
717 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
718 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
719 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
720
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
721 int line, cur, prevline;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
722 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
723
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
724 if (_edit_area->markersAtLine (line) && (1 << breakpoint))
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
725 line--; // we have a breakpoint here, so start search from prev line
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
726
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
727 prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
728
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
729 _edit_area->setCursorPosition (prevline, 0);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
730 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
731
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
732 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
733 file_editor_tab::remove_all_breakpoints (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
734 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
735 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
736 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
737
18237
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
738 bp_info info (_file_name);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
739
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
740 octave_link::post_event
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
741 (this, &file_editor_tab::remove_all_breakpoints_callback, info);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
742 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
743
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
744 void
18656
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
745 file_editor_tab::scintilla_command (const QWidget *ID, unsigned int sci_msg)
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
746 {
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
747 if (ID != this)
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
748 return;
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
749
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
750 _edit_area->SendScintilla (sci_msg);
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
751 }
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
752
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18560
diff changeset
753 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
754 file_editor_tab::comment_selected_text (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
755 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
756 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
757 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
758
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
759 do_comment_selected_text (true);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
760 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
761
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
762 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
763 file_editor_tab::uncomment_selected_text (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
764 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
765 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
766 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
767
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
768 do_comment_selected_text (false);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
769 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
770
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
771 void
18303
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
772 file_editor_tab::indent_selected_text (const QWidget *ID)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
773 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
774 if (ID != this)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
775 return;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
776
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
777 do_indent_selected_text (true);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
778 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
779
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
780 void
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
781 file_editor_tab::unindent_selected_text (const QWidget *ID)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
782 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
783 if (ID != this)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
784 return;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
785
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
786 do_indent_selected_text (false);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
787 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
788
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
789
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
790 void
18560
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
791 file_editor_tab::zoom_in (const QWidget *ID)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
792 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
793 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
794 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
795
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
796 _edit_area->zoomIn (1);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
797 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
798 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
799
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
800 void
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
801 file_editor_tab::zoom_out (const QWidget *ID)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
802 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
803 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
804 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
805
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
806 _edit_area->zoomOut (1);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
807 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
808 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
809
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
810 void
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
811 file_editor_tab::zoom_normal (const QWidget *ID)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
812 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
813 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
814 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
815
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
816 _edit_area->zoomTo (0);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
817 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
818 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
819
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
820
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
821 void
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
822 file_editor_tab::handle_find_dialog_finished (int)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
823 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
824 // Find dialog is going to hide. Save location of window for
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
825 // when it is reshown.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
826 _find_dialog_geometry = _find_dialog->geometry ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
827 _find_dialog_is_visible = false;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
828 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
829
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
830 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
831 file_editor_tab::find (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
832 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
833 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
834 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
835
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
836 // The find_dialog feature doesn't need a slot for return info.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
837 // Rather than Qt::DeleteOnClose, let the find feature hang about
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
838 // in case it contains useful information like previous searches
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
839 // and so on. Perhaps one find dialog for the whole editor is
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
840 // better, but individual find dialogs has the nice feature of
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
841 // retaining position per file editor tabs, which can be undocked.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
842
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
843 if (!_find_dialog)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
844 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
845 _find_dialog = new find_dialog (_edit_area,
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
846 qobject_cast<QWidget *> (sender ()));
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
847 connect (_find_dialog, SIGNAL (finished (int)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
848 this, SLOT (handle_find_dialog_finished (int)));
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
849 _find_dialog->setWindowModality (Qt::NonModal);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
850 _find_dialog_geometry = _find_dialog->geometry ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
851 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
852
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
853 if (!_find_dialog->isVisible ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
854 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
855 _find_dialog->setGeometry (_find_dialog_geometry);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
856 _find_dialog->show ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
857 _find_dialog_is_visible = true;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
858 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
859
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
860 _find_dialog->activateWindow ();
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15984
diff changeset
861 _find_dialog->init_search_text ();
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15984
diff changeset
862
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
863 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
864
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
865 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
866 file_editor_tab::goto_line (const QWidget *ID, int line)
16375
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
867 {
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
868 if (ID != this)
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
869 return;
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
870
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
871 if (line <= 0) // ask for desired line
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
872 {
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
873 bool ok = false;
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
874 int index;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
875 _edit_area->getCursorPosition (&line, &index);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
876 line = QInputDialog::getInt (_edit_area, tr ("Goto line"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
877 tr ("Line number"), line+1, 1,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
878 _edit_area->lines (), 1, &ok);
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
879 if (ok)
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
880 {
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
881 _edit_area->setCursorPosition (line-1, 0);
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
882 center_current_line ();
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
883 }
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
884 }
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
885 else // go to given line without dialog
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
886 _edit_area->setCursorPosition (line-1, 0);
16375
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
887 }
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
888
18303
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
889 void
18482
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
890 file_editor_tab::show_auto_completion (const QWidget *ID)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
891 {
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
892 if (ID != this)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
893 return;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
894
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
895 QsciScintilla::AutoCompletionSource s = _edit_area->autoCompletionSource ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
896 switch (s)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
897 {
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
898 case QsciScintilla::AcsAll:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
899 _edit_area->autoCompleteFromAll ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
900 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
901
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
902 case QsciScintilla::AcsAPIs:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
903 _edit_area->autoCompleteFromAPIs ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
904 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
905
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
906 case QsciScintilla::AcsDocument:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
907 _edit_area->autoCompleteFromDocument ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
908 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
909
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
910 case QsciScintilla::AcsNone:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
911 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
912 }
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
913 }
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
914
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
915 void
18303
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
916 file_editor_tab::do_indent_selected_text (bool indent)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
917 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
918 // TODO
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
919 _edit_area->beginUndoAction ();
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
920
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
921 if (_edit_area->hasSelectedText ())
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
922 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
923 int lineFrom, lineTo, colFrom, colTo;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
924 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
925
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
926 if (colTo == 0) // the beginning of last line is not selected
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
927 lineTo--; // stop at line above
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
928
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
929 for (int i = lineFrom; i <= lineTo; i++)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
930 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
931 if (indent)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
932 _edit_area->indent (i);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
933 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
934 _edit_area->unindent (i);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
935 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
936 //set selection on (un)indented section
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
937 _edit_area->setSelection (lineFrom, 0, lineTo,
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
938 _edit_area->text (lineTo).length ());
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
939 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
940 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
941 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
942 int cpline, col;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
943 _edit_area->getCursorPosition (&cpline, &col);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
944 if (indent)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
945 _edit_area->indent (cpline);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
946 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
947 _edit_area->unindent (cpline);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
948 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
949
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
950 _edit_area->endUndoAction ();
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18299
diff changeset
951 }
16375
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
952
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
953 void
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
954 file_editor_tab::do_comment_selected_text (bool comment)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
955 {
16737
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
956 QString comment_str = comment_string (_edit_area->lexer ()->lexer ());
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
957 _edit_area->beginUndoAction ();
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
958
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
959 if (_edit_area->hasSelectedText ())
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
960 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
961 int lineFrom, lineTo, colFrom, colTo;
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
962 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
963
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
964 if (colTo == 0) // the beginning of last line is not selected
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
965 lineTo--; // stop at line above
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
966
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
967 for (int i = lineFrom; i <= lineTo; i++)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
968 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
969 if (comment)
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
970 _edit_area->insertAt (comment_str, i, 0);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
971 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
972 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
973 QString line (_edit_area->text (i));
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
974 if (line.startsWith (comment_str))
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
975 {
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
976 _edit_area->setSelection (i, 0, i, comment_str.length ());
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
977 _edit_area->removeSelectedText ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
978 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
979 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
980 }
16737
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
981 //set selection on (un)commented section
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
982 _edit_area->setSelection (lineFrom, 0, lineTo,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
983 _edit_area->text (lineTo).length ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
984 }
16737
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
985 else
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
986 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
987 int cpline, col;
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
988 _edit_area->getCursorPosition (&cpline, &col);
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
989 if (comment)
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
990 _edit_area->insertAt (comment_str, cpline, 0);
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
991 else
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
992 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
993 QString line (_edit_area->text (cpline));
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
994 if (line.startsWith (comment_str))
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
995 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
996 _edit_area->setSelection (cpline, 0, cpline, comment_str.length ());
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
997 _edit_area->removeSelectedText ();
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
998 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
999 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1000 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1001 _edit_area->endUndoAction ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1002 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1003
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1004 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1005 file_editor_tab::update_window_title (bool modified)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1006 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1007 QString title ("");
15984
1eb3c67139f6 Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15982
diff changeset
1008 QString tooltip ("");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1009
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1010 if (! valid_file_name ())
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1011 title = tr ("<unnamed>");
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1012 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1013 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1014 if (_long_title)
15981
e3873531dd7c gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents: 15980
diff changeset
1015 title = _file_name;
e3873531dd7c gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents: 15980
diff changeset
1016 else
e3873531dd7c gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents: 15980
diff changeset
1017 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1018 QFileInfo file (_file_name);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1019 title = file.fileName ();
15984
1eb3c67139f6 Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15982
diff changeset
1020 tooltip = _file_name;
15981
e3873531dd7c gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents: 15980
diff changeset
1021 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1022 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1023
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1024 if (modified)
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1025 emit file_name_changed (title.prepend ("* "), tooltip);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1026 else
15984
1eb3c67139f6 Add full-length-name tool tip to editor file tab when name is not full length.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15982
diff changeset
1027 emit file_name_changed (title, tooltip);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1028 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1029
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1030 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1031 file_editor_tab::handle_copy_available (bool enableCopy)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1032 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1033 _copy_available = enableCopy;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1034 emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name));
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1035 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1036
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1037 // show_dialog: shows a modal or non modal dialog depeding on the closing
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1038 // of the app
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1039 void
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1040 file_editor_tab::show_dialog (QDialog *dlg)
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1041 {
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1042 dlg->setAttribute (Qt::WA_DeleteOnClose);
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1043 if (_app_closing)
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1044 dlg->exec ();
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1045 else
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1046 {
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1047 dlg->setWindowModality (Qt::WindowModal);
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1048 dlg->show ();
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1049 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1050 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1051
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1052 int
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1053 file_editor_tab::check_file_modified ()
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1054 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1055 int decision = QMessageBox::Yes;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1056 if (_edit_area->isModified ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1057 {
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1058 activateWindow ();
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1059 raise ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1060 // File is modified but not saved, ask user what to do. The file
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1061 // editor tab can't be made parent because it may be deleted depending
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1062 // upon the response. Instead, change the _edit_area to read only.
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1063 QMessageBox::StandardButtons buttons = QMessageBox::Save |
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1064 QMessageBox::Discard;
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1065 QString available_actions;
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1066
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1067 if (_app_closing)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1068 available_actions = tr ("Do you want to 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
1069 else
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1070 {
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1071 buttons = buttons | QMessageBox::Cancel; // cancel is allowed
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1072 available_actions
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1073 = tr ("Do you want to cancel closing, save or discard the changes?");
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1074 }
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1075
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1076 QString file;
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1077 if (valid_file_name ())
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1078 file = _file_name;
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1079 else
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1080 file = tr ("<unnamed>");
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1081
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1082 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1083 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1084 tr ("The file\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1085 "%1\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1086 "is about to be closed but has been modified.\n"
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1087 "%2").
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1088 arg (file). arg (available_actions),
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1089 buttons, qobject_cast<QWidget *> (parent ()));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1090
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1091 msgBox->setDefaultButton (QMessageBox::Save);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1092 _edit_area->setReadOnly (true);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1093 connect (msgBox, SIGNAL (finished (int)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1094 this, SLOT (handle_file_modified_answer (int)));
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1095
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1096 show_dialog (msgBox);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1097
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1098 return QMessageBox::Cancel;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1099 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1100 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1101 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1102 // Nothing was modified, just remove from editor.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1103 emit tab_remove_request ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1104 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1105
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1106 return decision;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1107 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1108
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1109 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1110 file_editor_tab::handle_file_modified_answer (int decision)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1111 {
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1112 if (decision == QMessageBox::Save)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1113 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1114 // Save file, then remove from editor.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1115 save_file (_file_name, true);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1116 }
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1117 else if (decision == QMessageBox::Discard)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1118 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1119 // User doesn't want to save, just remove from editor.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1120 emit tab_remove_request ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1121 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1122 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1123 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1124 // User canceled, allow editing again.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1125 _edit_area->setReadOnly (false);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1126 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1127 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1128
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1129 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1130 file_editor_tab::set_modified (bool modified)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1131 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1132 _edit_area->setModified (modified);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1133 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1134
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1135 QString
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1136 file_editor_tab::load_file (const QString& fileName)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1137 {
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1138 // get the absolute path
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1139 QFileInfo file_info = QFileInfo (fileName);
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1140 QString file_to_load;
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1141 if (file_info.exists ())
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1142 file_to_load = file_info.canonicalFilePath ();
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1143 else
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1144 file_to_load = fileName;
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1145 QFile file (file_to_load);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1146 if (!file.open (QFile::ReadOnly))
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1147 return file.errorString ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1148
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1149 QTextStream in (&file);
18299
6736fc9bce24 Set codec when loading/saving files in editor (Bug #41226)
John Donoghue <john.donoghue@ieee.org>
parents: 18275
diff changeset
1150 in.setCodec("UTF-8");
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1151 QApplication::setOverrideCursor (Qt::WaitCursor);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1152 _edit_area->setText (in.readAll ());
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1153 QApplication::restoreOverrideCursor ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1154
17636
230ffaf80ac9 fix enabling copy, cut and run selection actions depending on selected text
Torsten <ttl@justmail.de>
parents: 17635
diff changeset
1155 _copy_available = false; // no selection yet available
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1156 set_file_name (file_to_load);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1157 update_window_title (false); // window title (no modification)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1158 _edit_area->setModified (false); // loaded file is not modified yet
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1159
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1160 return QString ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1161 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1162
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1163 void
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16443
diff changeset
1164 file_editor_tab::new_file (const QString &commands)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1165 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1166 update_window_title (false); // window title (no modification)
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16443
diff changeset
1167 _edit_area->setText (commands);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1168 _edit_area->setModified (false); // new file is not modified yet
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1169 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1170
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1171 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1172 file_editor_tab::save_file (const QString& saveFileName, bool remove_on_success)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1173 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1174 // If it is a new file with no name, signal that saveFileAs
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1175 // should be performed.
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1176 if (! valid_file_name (saveFileName))
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1177 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1178 save_file_as (remove_on_success);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1179 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1180 }
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1181 // get the absolute path (if existing)
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1182 QFileInfo file_info = QFileInfo (saveFileName);
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1183 QString file_to_save;
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1184 if (file_info.exists ())
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1185 file_to_save = file_info.canonicalFilePath ();
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1186 else
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1187 file_to_save = saveFileName;
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1188 QFile file (file_to_save);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1189
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1190 // stop watching file
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1191 QStringList trackedFiles = _file_system_watcher.files ();
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1192 if (trackedFiles.contains (file_to_save))
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1193 _file_system_watcher.removePath (file_to_save);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1194
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1195 // open the file for writing
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1196 if (!file.open (QIODevice::WriteOnly))
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1197 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1198 // Unsuccessful, begin watching file again if it was being
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1199 // watched previously.
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1200 if (trackedFiles.contains (file_to_save))
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1201 _file_system_watcher.addPath (file_to_save);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1202
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1203 // Create a NonModal message about error.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1204 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1205 = new QMessageBox (QMessageBox::Critical,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1206 tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1207 tr ("Could not open file %1 for write:\n%2.").
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1208 arg (file_to_save).arg (file.errorString ()),
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1209 QMessageBox::Ok, 0);
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1210 show_dialog (msgBox);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1211
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1212 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1213 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1214
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1215 // save the contents into the file
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1216 QTextStream out (&file);
18299
6736fc9bce24 Set codec when loading/saving files in editor (Bug #41226)
John Donoghue <john.donoghue@ieee.org>
parents: 18275
diff changeset
1217 out.setCodec("UTF-8");
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1218 QApplication::setOverrideCursor (Qt::WaitCursor);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1219 out << _edit_area->text ();
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1220 out.flush ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1221 QApplication::restoreOverrideCursor ();
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1222 file.flush ();
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1223 file.close ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1224
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1225 // file exists now
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1226 file_info = QFileInfo (file);
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1227 file_to_save = file_info.canonicalFilePath ();
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1228
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1229 // save file name after closing file as set_file_name starts watching again
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1230 set_file_name (file_to_save); // make absolute
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1231
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1232 // set the window title to actual file name (not modified)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1233 update_window_title (false);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1234
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1235 // files is save -> not modified
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1236 _edit_area->setModified (false);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1237
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1238 if (remove_on_success)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1239 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1240 emit tab_remove_request ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1241 return; // Don't touch member variables after removal
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1242 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1243 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1244
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1245 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1246 file_editor_tab::save_file_as (bool remove_on_success)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1247 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1248 // Simply put up the file chooser dialog box with a slot connection
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1249 // then return control to the system waiting for a file selection.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1250
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1251 // If the tab is removed in response to a QFileDialog signal, the tab
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1252 // can't be a parent.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1253 QFileDialog* fileDialog;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1254 if (remove_on_success)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1255 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1256 // If tab is closed, "this" cannot be parent in which case modality
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1257 // has no effect. Disable editing instead.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1258 _edit_area->setReadOnly (true);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1259 fileDialog = new QFileDialog ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1260 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1261 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1262 fileDialog = new QFileDialog (this);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1263
16912
6bd74153c3ae no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents: 16757
diff changeset
1264 // Giving trouble under KDE (problem is related to Qt signal handling on unix,
6bd74153c3ae no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents: 16757
diff changeset
1265 // see https://bugs.kde.org/show_bug.cgi?id=260719 ,
6bd74153c3ae no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents: 16757
diff changeset
1266 // it had/has no effect on Windows, though)
6bd74153c3ae no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents: 16757
diff changeset
1267 fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
6bd74153c3ae no native dialogs to prevent hangs in KDE (patch #7948 by Andre da Costa Barros)
Torsten <ttl@justmail.de>
parents: 16757
diff changeset
1268
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1269 if (valid_file_name ())
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1270 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1271 fileDialog->selectFile (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1272 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1273 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1274 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1275 fileDialog->selectFile ("");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1276
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1277 if (_file_name.isEmpty ())
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1278 fileDialog->setDirectory (QDir::currentPath ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1279 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1280 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1281 // The file name is actually the directory name from the
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1282 // constructor argument.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1283 fileDialog->setDirectory (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1284 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1285 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1286
16560
ebec000cbfc5 gui: fix editor file name filters to allow all files
Mike Miller <mtmiller@ieee.org>
parents: 16559
diff changeset
1287 fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1288 fileDialog->setDefaultSuffix ("m");
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1289 fileDialog->setAcceptMode (QFileDialog::AcceptSave);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1290 fileDialog->setViewMode (QFileDialog::Detail);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1291
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1292 if (remove_on_success)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1293 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1294 connect (fileDialog, SIGNAL (fileSelected (const QString&)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1295 this, SLOT (handle_save_file_as_answer_close (const QString&)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1296
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1297 connect (fileDialog, SIGNAL (rejected ()),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1298 this, SLOT (handle_save_file_as_answer_cancel ()));
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1299 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1300 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1301 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1302 connect (fileDialog, SIGNAL (fileSelected (const QString&)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1303 this, SLOT (handle_save_file_as_answer (const QString&)));
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1304 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1305
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1306 show_dialog (fileDialog);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1307 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1308
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1309 bool
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1310 file_editor_tab::check_valid_identifier (QString file_name)
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1311 {
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1312 QFileInfo file = QFileInfo (file_name);
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1313 QString base_name = file.baseName ();
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1314
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1315 if ((file.suffix () == "m")
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1316 && (! valid_identifier (base_name.toStdString ())))
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1317 {
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1318 int ans = QMessageBox::question (0, tr ("Octave Editor"),
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1319 tr ("\"%1\"\n"
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1320 "is not a valid identifier.\n\n"
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1321 "If you keep this file name, you will not be able to\n"
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1322 "call your script using its name as an Octave command.\n\n"
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1323 "Do you want to choose another name?").arg (base_name),
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1324 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1325
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1326 if (ans == QMessageBox::Yes)
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1327 return true;
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1328 }
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1329
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1330 return false;
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1331 }
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1332
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1333 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1334 file_editor_tab::handle_save_file_as_answer (const QString& saveFileName)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1335 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1336 if (saveFileName == _file_name)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1337 {
18082
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1338 // same name as actual file, save it as "save" would do
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1339 save_file (saveFileName);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1340 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1341 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1342 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1343 // Have editor check for conflict, do not delete tab after save.
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1344 if (check_valid_identifier (saveFileName))
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1345 save_file_as (false);
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1346 else
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1347 emit editor_check_conflict_save (saveFileName, false);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1348 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1349 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1350
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1351 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1352 file_editor_tab::handle_save_file_as_answer_close (const QString& saveFileName)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1353 {
18082
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1354 // saveFileName == _file_name can not happen, because we only can get here
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1355 // when we close a tab and _file_name is not a valid file name yet
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1356
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1357 // Have editor check for conflict, delete tab after save.
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18315
diff changeset
1358 if (check_valid_identifier (saveFileName))
18275
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1359 save_file_as (true);
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1360 else
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18237
diff changeset
1361 emit editor_check_conflict_save (saveFileName, true);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1362 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1363
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1364 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1365 file_editor_tab::handle_save_file_as_answer_cancel ()
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1366 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1367 // User canceled, allow editing again.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1368 _edit_area->setReadOnly (false);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1369 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1370
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1371 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1372 file_editor_tab::file_has_changed (const QString&)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1373 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1374 // Prevent popping up multiple message boxes when the file has
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1375 // been changed multiple times by temporarily removing from the
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1376 // file watcher.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1377 QStringList trackedFiles = _file_system_watcher.files ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1378 if (!trackedFiles.isEmpty ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1379 _file_system_watcher.removePath (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1380
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1381 if (QFile::exists (_file_name))
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1382 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1383 // Create a WindowModal message that blocks the edit area
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1384 // by making _edit_area parent.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1385 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1386 = new QMessageBox (QMessageBox::Warning,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1387 tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1388 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?").
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1389 arg (_file_name),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1390 QMessageBox::Yes | QMessageBox::No, this);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1391
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1392 connect (msgBox, SIGNAL (finished (int)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1393 this, SLOT (handle_file_reload_answer (int)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1394
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1395 msgBox->setWindowModality (Qt::WindowModal);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1396 msgBox->setAttribute (Qt::WA_DeleteOnClose);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1397 msgBox->show ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1398 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1399 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1400 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1401 QString modified = "";
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1402 if (_edit_area->isModified ())
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1403 modified = tr ("\n\nWarning: The contents in the editor is modified!");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1404
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1405 // Create a WindowModal message. The file editor tab can't be made
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1406 // parent because it may be deleted depending upon the response.
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1407 // Instead, change the _edit_area to read only.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1408 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1409 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1410 tr ("It seems that the file\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1411 "%1\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1412 "has been deleted or renamed. Do you want to save it now?%2").
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1413 arg (_file_name).arg (modified),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1414 QMessageBox::Save | QMessageBox::Close, 0);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1415
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1416 _edit_area->setReadOnly (true);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1417
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1418 connect (msgBox, SIGNAL (finished (int)),
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1419 this, SLOT (handle_file_resave_answer (int)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1420
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1421 msgBox->setWindowModality (Qt::WindowModal);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1422 msgBox->setAttribute (Qt::WA_DeleteOnClose);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1423 msgBox->show ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1424 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1425 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1426
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1427 void
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
1428 file_editor_tab::notice_settings (const QSettings *settings)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1429 {
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
1430 // QSettings pointer is checked before emitting.
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16402
diff changeset
1431
16720
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
1432 update_lexer ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1433
16693
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1434 //highlight current line color
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1435 QVariant default_var = QColor (240, 240, 240);
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1436 QColor setting_color = settings->value ("editor/highlight_current_line_color",
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1437 default_var).value<QColor> ();
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1438 _edit_area->setCaretLineBackgroundColor (setting_color);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1439 _edit_area->setCaretLineVisible
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1440 (settings->value ("editor/highlightCurrentLine", true).toBool ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1441
18482
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1442 bool match_keywords = settings->value
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1443 ("editor/codeCompletion_keywords",true).toBool ();
18482
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1444 bool match_document = settings->value
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1445 ("editor/codeCompletion_document",true).toBool ();
16679
cf939872811c options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents: 16678
diff changeset
1446
18482
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1447 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1448 if (match_keywords)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1449 if (match_document)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1450 source = QsciScintilla::AcsAll;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1451 else
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1452 source = QsciScintilla::AcsAPIs;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1453 else if (match_document)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1454 source = QsciScintilla::AcsDocument;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1455 _edit_area->setAutoCompletionSource (source);
16679
cf939872811c options for auto completion threshold, source and word replacement in settings
Torsten <ttl@justmail.de>
parents: 16678
diff changeset
1456
18482
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1457 _edit_area->setAutoCompletionReplaceWord
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1458 (settings->value ("editor/codeCompletion_replace",false).toBool ());
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1459 _edit_area->setAutoCompletionCaseSensitivity
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1460 (settings->value ("editor/codeCompletion_case",true).toBool ());
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1461
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1462 if (settings->value ("editor/codeCompletion", true).toBool ())
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1463 _edit_area->setAutoCompletionThreshold
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18460
diff changeset
1464 (settings->value ("editor/codeCompletion_threshold",2).toInt ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1465 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1466 _edit_area->setAutoCompletionThreshold (-1);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1467
16702
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1468 if (settings->value ("editor/show_white_space",false).toBool ())
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1469 if (settings->value ("editor/show_white_space_indent",false).toBool ())
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1470 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1471 else
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1472 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1473 else
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1474 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1475
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1476 if (settings->value ("editor/showLineNumbers", true).toBool ())
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1477 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1478 _edit_area->setMarginLineNumbers (2, true);
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1479 auto_margin_width ();
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1480 connect (_edit_area, SIGNAL (linesChanged ()),
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1481 this, SLOT (auto_margin_width ()));
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1482 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1483 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1484 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1485 _edit_area->setMarginLineNumbers (2, false);
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1486 disconnect (_edit_area, SIGNAL (linesChanged ()), 0, 0);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1487 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1488
16703
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1489 _edit_area->setAutoIndent
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1490 (settings->value ("editor/auto_indent",true).toBool ());
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1491 _edit_area->setTabIndents
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1492 (settings->value ("editor/tab_indents_line",false).toBool ());
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1493 _edit_area->setBackspaceUnindents
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1494 (settings->value ("editor/backspace_unindents_line",false).toBool ());
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1495 _edit_area->setIndentationGuides
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1496 (settings->value ("editor/show_indent_guides",false).toBool ());
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1497
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1498 _edit_area->setTabWidth
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1499 (settings->value ("editor/tab_width",2).toInt ());
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1500
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1501 _long_title = settings->value ("editor/longWindowTitle", false).toBool ();
16757
35d9f1f79f06 update editor tab titles due to changed settings regarding the modifed state
Torsten <ttl@justmail.de>
parents: 16737
diff changeset
1502 update_window_title (_edit_area->isModified ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1503
18489
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1504 _edit_area->setEdgeColumn (
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1505 settings->value ("editor/long_line_column",80).toInt ());
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1506 if (settings->value ("editor/long_line_marker",true).toBool ())
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1507 _edit_area->setEdgeMode (QsciScintilla::EdgeLine);
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1508 else
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1509 _edit_area->setEdgeMode (QsciScintilla::EdgeNone);
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18483
diff changeset
1510
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1511 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1512
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1513 void
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1514 file_editor_tab::auto_margin_width ()
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1515 {
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1516 _edit_area->setMarginWidth (2, "1"+QString::number (_edit_area->lines ()));
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1517 }
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1518
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1519 void
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1520 file_editor_tab::conditional_close (const QWidget *ID, bool app_closing)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1521 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1522 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1523 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1524
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1525 _app_closing = app_closing;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1526 close ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1527 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1528
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1529 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1530 file_editor_tab::change_editor_state (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1531 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1532 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1533 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1534 // Widget may be going out of focus. If so, record location.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1535 if (_find_dialog)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1536 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1537 if (_find_dialog->isVisible ())
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1538 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1539 _find_dialog_geometry = _find_dialog->geometry ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1540 _find_dialog->hide ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1541 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1542 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1543 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1544 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1545
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1546 if (_find_dialog && _find_dialog_is_visible)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1547 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1548 _find_dialog->setGeometry (_find_dialog_geometry);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1549 _find_dialog->show ();
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1550 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1551
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1552 emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name));
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1553 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1554
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1555 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1556 file_editor_tab::file_name_query (const QWidget *ID)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1557 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1558 // A zero (null pointer) means that all file editor tabs
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1559 // should respond, otherwise just the desired file editor tab.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1560 if (ID != this && ID != 0)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1561 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1562
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1563 // Unnamed files shouldn't be transmitted.
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1564 if (!_file_name.isEmpty ())
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
1565 emit add_filename_to_list (_file_name, this);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1566 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1567
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1568 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1569 file_editor_tab::handle_file_reload_answer (int decision)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1570 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1571 if (decision == QMessageBox::Yes)
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1572 {
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1573 // reload: file is readded to the file watcher in set_file_name ()
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1574 load_file (_file_name);
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1575 }
15849
e55a64f49346 editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents: 15848
diff changeset
1576 else
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1577 {
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1578 // do not reload: readd to the file watche
15849
e55a64f49346 editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents: 15848
diff changeset
1579 _file_system_watcher.addPath (_file_name);
e55a64f49346 editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents: 15848
diff changeset
1580 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1581 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1582
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1583 void
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1584 file_editor_tab::handle_file_resave_answer (int decision)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1585 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1586 // check decision of user in dialog
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1587 if (decision == QMessageBox::Save)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1588 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1589 save_file (_file_name); // readds file to watcher in set_file_name ()
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1590 _edit_area->setReadOnly (false); // delete read only flag
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1591 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1592 else
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1593 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1594 // Definitely close the file.
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1595 // Set modified to false to prevent the dialog box when the close event
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1596 // is posted. If the user cancels the close in this dialog the tab is
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1597 // left open with a non-existing file.
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1598 _edit_area->setModified (false);
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1599 close ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1600 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1601 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1602
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1603 void
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1604 file_editor_tab::insert_debugger_pointer (const QWidget *ID, int line)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1605 {
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
1606 if (ID != this || ID == 0)
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
1607 return;
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
1608
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1609 if (line > 0)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1610 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
1611 _edit_area->markerAdd (line-1, debugger_position);
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1612 center_current_line ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1613 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1614 }
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
1615
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1616 void
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1617 file_editor_tab::delete_debugger_pointer (const QWidget *ID, int line)
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1618 {
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1619 if (ID != this || ID == 0)
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1620 return;
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1621
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1622 if (line > 0)
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
1623 _edit_area->markerDelete (line-1, debugger_position);
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1624 }
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1625
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
1626 void
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16440
diff changeset
1627 file_editor_tab::do_breakpoint_marker (bool insert, const QWidget *ID, int line)
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1628 {
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1629 if (ID != this || ID == 0)
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1630 return;
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1631
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1632 if (line > 0)
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1633 {
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1634 if (insert)
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
1635 _edit_area->markerAdd (line-1, breakpoint);
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1636 else
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
1637 _edit_area->markerDelete (line-1, breakpoint);
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1638 }
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1639 }
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
1640
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1641
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1642 void
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1643 file_editor_tab::center_current_line ()
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1644 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1645 long int visible_lines
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1646 = _edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1647
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1648 if (visible_lines > 2)
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1649 {
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1650 int line, index;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1651 _edit_area->getCursorPosition (&line, &index);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1652
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1653 int first_line = _edit_area->firstVisibleLine ();
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1654 first_line = first_line + (line - first_line - (visible_lines-1)/2);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1655
16591
2931e9282190 * file-editor-tab.cc: replace setFirstVisibleLine for older Qscintilla-versions
Torsten <ttl@justmail.de>
parents: 16570
diff changeset
1656 _edit_area->SendScintilla (2613,first_line); // SCI_SETFIRSTVISIBLELINE
16389
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1657 }
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1658 }
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1659
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1660 void
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1661 file_editor_tab::handle_cursor_moved (int line, int col)
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1662 {
18483
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18482
diff changeset
1663 if (_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18482
diff changeset
1664 show_auto_completion (this);
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18482
diff changeset
1665
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1666 _row_indicator->setNum (line+1);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1667 _col_indicator->setNum (col+1);
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1668 }
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
1669
18684
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1670 void
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1671 file_editor_tab::edit_area_has_focus (bool focus)
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1672 {
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1673 emit set_global_edit_shortcuts_signal (! focus);
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1674 }
86eca5d178a6 disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
1675
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
1676 #endif