annotate libgui/src/m-editor/file-editor-tab.cc @ 20815:a260a6acb70f

fix test failures introduced by a22d8a2eb0e5 * scripts/ode/private/integrate_adaptive.m: fix stepping backwards, fix invocation of OutputFcn, fix text of some error messages * scripts/ode/private/integrate_const.m: remove use of option OutputSave * scripts/ode/private/integrate_n_steps.m: remove use of option OutputSave
author Carlo de Falco <carlo.defalco@polimi.it>
date Sun, 11 Oct 2015 23:09:01 +0200
parents 046904b54dc4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18357
6e8188effddf file-editor-tab.cc: Fix a typo.
Julien Bect <julien.bect@supelec.fr>
parents: 18345
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
19898
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19826
diff changeset
4 Copyright (C) 2011-2015 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>
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
51 #include <QDateTime>
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
52
15402
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-tab.h"
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
54 #include "file-editor.h"
19543
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
55 #include "octave-txt-lexer.h"
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
56
18236
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
57 #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
58
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
59 #include "debug.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
60 #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
61 #include "version.h"
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
62 #include "utils.h"
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
63 #include "defaults.h"
19196
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
64 #include <oct-map.h>
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
65
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
66 bool file_editor_tab::_cancelled = false;
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
67
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
68 // 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
69 // WindowModal messages don't affect grandparents.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
70 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
71 {
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
72 _lexer_apis = 0;
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
73 _is_octave_file = true;
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
74 _lines_changed = false;
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
75
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
76 _ced = directory_arg;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
77
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
78 _file_name = "";
17737
d3bb7f1e3971 prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents: 17706
diff changeset
79 _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
80
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents: 16721
diff changeset
81 _edit_area = new octave_qscintilla (this);
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
82 _line = 0;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
83 _col = 0;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
84
19805
4b980842edba clean up some signal-slot combinations in the editor
Torsten <ttl@justmail.de>
parents: 19802
diff changeset
85 connect (_edit_area, SIGNAL (cursorPositionChanged (int, int)),
4b980842edba clean up some signal-slot combinations in the editor
Torsten <ttl@justmail.de>
parents: 19802
diff changeset
86 this, SLOT (handle_cursor_moved (int,int)));
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
87
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
88 connect (_edit_area, SIGNAL (linesChanged ()),
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
89 this, SLOT (handle_lines_changed ()));
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
90
19196
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
91 connect (_edit_area, SIGNAL (context_menu_edit_signal (const QString&)),
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
92 this, SLOT (handle_context_menu_edit (const QString&)));
18842
99e26cb0f87f use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents: 18841
diff changeset
93
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
94 // create statusbar for row/col indicator and eol mode
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
95 _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
96
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
97 // eol mode
19436
05d8e71d20cb add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents: 19432
diff changeset
98 QLabel *eol_label = new QLabel (tr ("eol:"), this);
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
99 _eol_indicator = new QLabel ("",this);
20051
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 20049
diff changeset
100 QFontMetrics fm = eol_label->fontMetrics ();
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 20049
diff changeset
101 _eol_indicator->setMinimumSize (5*fm.averageCharWidth (),0);
19436
05d8e71d20cb add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents: 19432
diff changeset
102 _status_bar->addPermanentWidget (eol_label, 0);
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
103 _status_bar->addPermanentWidget (_eol_indicator, 0);
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
104
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
105 // row- and col-indicator
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
106 _row_indicator = new QLabel ("", this);
20051
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 20049
diff changeset
107 _row_indicator->setMinimumSize (5*fm.averageCharWidth (),0);
19436
05d8e71d20cb add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents: 19432
diff changeset
108 QLabel *row_label = new QLabel (tr ("line:"), this);
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
109 _col_indicator = new QLabel ("", this);
20051
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 20049
diff changeset
110 _col_indicator->setMinimumSize (4*fm.averageCharWidth (),0);
19436
05d8e71d20cb add a label to the eol indicator in the editors status bar
Torsten <ttl@justmail.de>
parents: 19432
diff changeset
111 QLabel *col_label = new QLabel (tr ("col:"), this);
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
112 _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
113 _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
114 _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
115 _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
116
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
117 // 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
118 _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
119 _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
120
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
121 // 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
122 _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
123 _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
124 _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark);
20109
ded81845c597 omit icons for breakpoint markers and in documentation viewer
Torsten <ttl@justmail.de>
parents: 20051
diff changeset
125 _edit_area->setMarkerBackgroundColor (QColor (0,0,232), bookmark);
ded81845c597 omit icons for breakpoint markers and in documentation viewer
Torsten <ttl@justmail.de>
parents: 20051
diff changeset
126 _edit_area->markerDefine (QsciScintilla::Circle, breakpoint);
ded81845c597 omit icons for breakpoint markers and in documentation viewer
Torsten <ttl@justmail.de>
parents: 20051
diff changeset
127 _edit_area->setMarkerBackgroundColor (QColor (192,0,0), breakpoint);
ded81845c597 omit icons for breakpoint markers and in documentation viewer
Torsten <ttl@justmail.de>
parents: 20051
diff changeset
128 _edit_area->markerDefine (QsciScintilla::RightTriangle, debugger_position);
ded81845c597 omit icons for breakpoint markers and in documentation viewer
Torsten <ttl@justmail.de>
parents: 20051
diff changeset
129 _edit_area->setMarkerBackgroundColor (QColor (255,255,0), debugger_position);
14825
eae0e9f2a8c6 Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14804
diff changeset
130
15045
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
131 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
132 Qt::KeyboardModifiers)),
1ffaad442161 Source code formatting (80-column lines, mostly whitespace changes)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14890
diff changeset
133 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
134 Qt::KeyboardModifiers)));
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
135
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
136 // line numbers
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
137 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
138 _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
139 _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
140
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
141 // 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
142 _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
143 _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
144 _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
145 _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
146
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
147 _edit_area->setUtf8 (true);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
148
15365
b4c32f245da7 GUI: Settings take immediate effect on the m-editor
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 15356
diff changeset
149 // auto completion
18551
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18550
diff changeset
150 _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
151
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
152 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
153 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
154 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
155 edit_area_layout->setMargin (0);
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
156 setLayout (edit_area_layout);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
157
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
158 // 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
159 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
160 this, SLOT (update_window_title (bool)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
161
14715
b4db843b1f26 Done some extra method renaming to fit the overall octave coding style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
162 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
163 this, SLOT (handle_copy_available (bool)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
164
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
165 connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
166 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
167
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
168 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
169 if (settings)
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
170 notice_settings (settings, true);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
171 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
172
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
173 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
174 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
175 // 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
176 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
177 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
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 lexer;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
180 _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
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 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
183 {
424edeca3c66 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 _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
185 _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
186 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
187
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
188 // 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
189 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
190 }
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
191
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
192 void
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
193 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
194 {
20049
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
195 _cancelled = false; // prevent unwanted interaction of previous
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
196 // exits of octave which were canceled by the user
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
197
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
198 if (check_file_modified () == QMessageBox::Cancel)
20049
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
199 { // ignore close event if file is not saved and user cancels
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
200 // closing this window
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
201 e->ignore ();
a09471d938a5 fix closing a tab with modification
Torsten <ttl@justmail.de>
parents: 20009
diff changeset
202 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
203 else
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
204 {
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
205 e->accept ();
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
206 emit tab_remove_request ();
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
207 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
208 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
209
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
210 void
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
211 file_editor_tab::set_current_directory (const QString& dir)
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
212 {
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
213 _ced = dir;
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
214 }
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
215
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
216 void
19196
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
217 file_editor_tab::handle_context_menu_edit (const QString& word_at_cursor)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
218 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
219 // search for a subfunction in actual file (this is done at first because
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
220 // octave finds this function before other with same name in the search path
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
221 QRegExp rxfun1 ("^[\t ]*function[^=]+=[\t ]*"
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
222 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
223 QRegExp rxfun2 ("^[\t ]*function[\t ]+"
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
224 + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
225 QRegExp rxfun3 ("^[\t ]*function[\t ]+"
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
226 + word_at_cursor + "[\t ]*$");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
227 QRegExp rxfun4 ("^[\t ]*function[^=]+=[\t ]*"
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
228 + word_at_cursor + "[\t ]*$");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
229
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
230 int pos_fct = -1;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
231 QStringList lines = _edit_area->text ().split ("\n");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
232
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
233 int line;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
234 for (line = 0; line < lines.count (); line++)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
235 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
236 if ((pos_fct = rxfun1.indexIn (lines.at (line))) != -1)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
237 break;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
238 if ((pos_fct = rxfun2.indexIn (lines.at (line))) != -1)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
239 break;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
240 if ((pos_fct = rxfun3.indexIn (lines.at (line))) != -1)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
241 break;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
242 if ((pos_fct = rxfun4.indexIn (lines.at (line))) != -1)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
243 break;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
244 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
245
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
246 if (pos_fct > -1)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
247 { // reg expr. found: it is an internal function
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
248 _edit_area->setCursorPosition (line, pos_fct);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
249 _edit_area->SendScintilla (2613, line); // SCI_SETFIRSTVISIBLELINE
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
250 return;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
251 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
252
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
253 // Is it a regular function within the search path? (Call __which__)
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
254 octave_value_list fct = F__which__ (ovl (word_at_cursor.toStdString ()),0);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
255 octave_map map = fct(0).map_value ();
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
256
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
257 QString type = QString::fromStdString (
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
258 map.contents ("type").data ()[0].string_value ());
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
259 QString name = QString::fromStdString (
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
260 map.contents ("name").data ()[0].string_value ());
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
261
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
262 QString message = QString ();
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
263 QString filename = QString ();
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
264
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
265 if (type == QString("built-in function"))
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
266 { // built in function: can't edit
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
267 message = tr ("%1 is a built-in function");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
268 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
269 else if (type.isEmpty ())
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
270 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
271 // function not known to octave -> try directory of edited file
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
272 // get directory
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
273 QDir dir;
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
274 if (_file_name.isEmpty ())
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
275 dir = _ced;
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
276 else
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
277 dir = QDir (QFileInfo (_file_name).canonicalPath ());
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
278
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
279 // function not known to octave -> try directory of edited file
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
280 QFileInfo file = QFileInfo (dir, word_at_cursor + ".m");
19196
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
281
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
282 if (file.exists ())
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
283 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
284 filename = file.canonicalFilePath (); // local file exists
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
285 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
286 else
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
287 { // local file does not exist -> try private directory
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
288 file = QFileInfo (_file_name);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
289 file = QFileInfo (QDir (file.canonicalPath () + "/private"),
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
290 word_at_cursor + ".m");
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
291
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
292 if (file.exists ())
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
293 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
294 filename = file.canonicalFilePath (); // private function exists
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
295 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
296 else
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
297 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
298 message = tr ("Can not find function %1"); // no file found
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
299 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
300 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
301 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
302
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
303 if (! message.isEmpty ())
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
304 {
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
305 QMessageBox *msgBox
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
306 = new QMessageBox (QMessageBox::Critical,
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
307 tr ("Octave Editor"),
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
308 message.arg (name),
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
309 QMessageBox::Ok, this);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
310
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
311 msgBox->setWindowModality (Qt::NonModal);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
312 msgBox->setAttribute (Qt::WA_DeleteOnClose);
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
313 msgBox->show ();
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
314 return;
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
315 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
316
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
317 if ( filename.isEmpty ())
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
318 filename = QString::fromStdString (
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
319 map.contents ("file").data ()[0].string_value ());
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
320
19802
d258070914ef open file directly without edit command when editing a function from editor
Torsten <ttl@justmail.de>
parents: 19792
diff changeset
321 if (! filename.endsWith (".m"))
d258070914ef open file directly without edit command when editing a function from editor
Torsten <ttl@justmail.de>
parents: 19792
diff changeset
322 filename.append (".m");
d258070914ef open file directly without edit command when editing a function from editor
Torsten <ttl@justmail.de>
parents: 19792
diff changeset
323
d258070914ef open file directly without edit command when editing a function from editor
Torsten <ttl@justmail.de>
parents: 19792
diff changeset
324 emit request_open_file (filename);
19196
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
325 }
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
326
e87e65bc71ae improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents: 19136
diff changeset
327 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
328 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
329 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
330 // 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
331 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
332 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
333 _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
334 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
335 _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
336 _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
337
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
338 // 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
339 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
340
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
341 // update the file editor with current editing directory
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
342 emit editor_state_changed (_copy_available, _is_octave_file);
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
343
15860
feba9ff6e6a8 editor: add list of recently used files to the file menu
Torsten <ttl@justmail.de>
parents: 15849
diff changeset
344 // 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
345 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
346 }
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
347
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
348 // 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
349 // 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
350 bool
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
351 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
352 {
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
353 if (file.isEmpty ())
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
354 {
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
355 if (_file_name.isEmpty ())
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
356 return false;
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
357 else
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
358 return true;
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
359 }
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
360
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
361 return true;
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
362 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
363
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
364 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
365 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
366 Qt::KeyboardModifiers state)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
367 {
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
368 if (margin == 1)
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
369 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
370 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
371
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
372 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
373 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
374 if (markers_mask && (1 << bookmark))
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
375 _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
376 else
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
377 _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
378 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
379 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
380 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
381 if (markers_mask && (1 << breakpoint))
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
382 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
383 else
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
384 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
385 }
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
386 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
387 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
388
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
389 void
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
390 file_editor_tab::update_lexer ()
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
391 {
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
392 if (_lexer_apis)
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
393 _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
394
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
395 QsciLexer *lexer = _edit_area->lexer ();
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
396 delete lexer;
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
397 lexer = 0;
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
398
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
399 _is_octave_file = false;
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
400
16559
78765ae325fd gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents: 16558
diff changeset
401 if (_file_name.endsWith (".m")
78765ae325fd gui: handle octaverc files with the octave lexer
Mike Miller <mtmiller@ieee.org>
parents: 16558
diff changeset
402 || _file_name.endsWith ("octaverc"))
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
403 {
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
404 #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
405 lexer = new QsciLexerOctave ();
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
406 #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
407 lexer = new QsciLexerMatlab ();
19543
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
408 #else
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
409 lexer = new octave_txt_lexer ();
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
410 #endif
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
411 _is_octave_file = true;
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
412 }
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
413
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
414 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
415 {
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
416 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
417 || _file_name.endsWith (".cc")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
418 || _file_name.endsWith (".cpp")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
419 || _file_name.endsWith (".cxx")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
420 || _file_name.endsWith (".c++")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
421 || _file_name.endsWith (".h")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
422 || _file_name.endsWith (".hh")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
423 || _file_name.endsWith (".hpp")
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
424 || _file_name.endsWith (".h++"))
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
425 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
426 lexer = new QsciLexerCPP ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
427 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
428 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
429 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
430 lexer = new QsciLexerPerl ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
431 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
432 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
433 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
434 lexer = new QsciLexerBatch ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
435 }
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
436 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
437 {
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
438 lexer = new QsciLexerDiff ();
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
439 }
19543
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
440 else if (_file_name.endsWith (".sh"))
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
441 {
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
442 lexer = new QsciLexerBash ();
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
443 }
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
444 else if (! valid_file_name ())
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
445 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
446 // 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
447 #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
448 lexer = new QsciLexerOctave ();
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
449 _is_octave_file = true;
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
450 #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
451 lexer = new QsciLexerMatlab ();
18949
095fdef3d67c use editors run selection action for the context menu
Torsten <ttl@justmail.de>
parents: 18898
diff changeset
452 _is_octave_file = true;
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
453 #else
19543
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
454 lexer = new octave_txt_lexer ();
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
455 #endif
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
456 }
16720
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
457 else
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
458 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
459 // other or no extension
19543
c364b9a44580 provide an editor lexer for text or unknown files (bug #43572)
Torsten <ttl@justmail.de>
parents: 19527
diff changeset
460 lexer = new octave_txt_lexer ();
16720
973fd2367d44 select octave lexer for unnamed files and bash lexer for files without extension
Torsten <ttl@justmail.de>
parents: 16719
diff changeset
461 }
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
462 }
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
463
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
464 QSettings *settings = resource_manager::get_settings ();
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
465
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
466 // build information for auto completion (APIs)
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
467 _lexer_apis = new QsciAPIs(lexer);
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
468
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
469 if (_lexer_apis)
16678
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
470 {
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
471 bool update_apis_file = false; // flag, whether update of apis files
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
472
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
473 // 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
474 QDesktopServices desktopServices;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
475 QString prep_apis_path
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
476 = desktopServices.storageLocation (QDesktopServices::HomeLocation)
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
477 + "/.config/octave/" + QString(OCTAVE_VERSION) + "/qsci/";
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
478
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
479 // get settings which infos are used for octave
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
480 bool octave_builtins = settings->value (
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
481 "editor/codeCompletion_octave_builtins", true).toBool ();
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
482 bool octave_functions = settings->value (
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
483 "editor/codeCompletion_octave_functions", true).toBool ();
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
484
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
485 if (_is_octave_file)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
486 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
487 // octave file: keywords are always used
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
488 _prep_apis_file = prep_apis_path + lexer->lexer () + "_k";
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
489
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
490 if (octave_builtins)
20440
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20119
diff changeset
491 _prep_apis_file += "b"; // use builtins, too
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
492
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
493 if (octave_functions)
20440
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20119
diff changeset
494 _prep_apis_file += "f"; // use keywords, too
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
495
20440
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20119
diff changeset
496 _prep_apis_file += ".pap"; // final name of apis file
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
497
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
498 // check whether the APIs info needs to be prepared and saved
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
499 QFileInfo apis_file = QFileInfo (_prep_apis_file);
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
500 update_apis_file = ! apis_file.exists (); // flag whether apis file needs update
16715
96ed7ab44e2e save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents: 16704
diff changeset
501
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
502 // function list depends on installed packages: check mod. date
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
503 if (! update_apis_file && octave_functions)
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
504 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
505 // check whether package file is newer than apis_file
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
506 QDateTime apis_date = apis_file.lastModified ();
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
507
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
508 // compare to local package list
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
509 // FIXME: How to get user chosen location?
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
510 QFileInfo local_pkg_list = QFileInfo (
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
511 desktopServices.storageLocation (QDesktopServices::HomeLocation)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
512 + "/.octave_packages");
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
513 if (local_pkg_list.exists ()
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
514 & (apis_date < local_pkg_list.lastModified ()) )
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
515 update_apis_file = true;
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
516
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
517 // compare to global package list
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
518 // FIXME: How to get user chosen location?
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
519 QFileInfo global_pkg_list = QFileInfo (
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
520 QString::fromStdString (Voctave_home)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
521 + "/share/octave/octave_packages");
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
522 if (global_pkg_list.exists ()
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
523 && (apis_date < global_pkg_list.lastModified ()) )
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
524 update_apis_file = true;
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
525 }
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
526 }
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
527 else // no octave file, just add extension
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
528 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
529 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap";
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
530 }
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
531
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
532 if (update_apis_file || !_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
533 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
534 // 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
535
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
536 // create raw apis info
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
537 QString keyword;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
538 QStringList keyword_list;
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
539 int i,j;
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
540
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
541 if (_is_octave_file)
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
542 {
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
543 // octave: get keywords from internal informations depending on
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
544 // user preferences
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
545
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
546 // keywords are always used
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
547 add_octave_apis (F__keywords__ ()); // add new entries
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
548
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
549 if (octave_builtins)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
550 add_octave_apis (F__builtins__ ()); // add new entries
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
551
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
552 if (octave_functions)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
553 add_octave_apis (F__list_functions__ ()); // add new entries
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
554
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
555 }
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
556 else
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
557 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
558
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
559 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap";
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
560
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
561 for (i=1; i<=3; i++) // test the first 5 keyword sets
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
562 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
563 keyword = QString(lexer->keywords (i)); // get list
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
564 keyword_list = keyword.split (QRegExp ("\\s+")); // split
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
565 for (j = 0; j < keyword_list.size (); j++) // add to API
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
566 _lexer_apis->add (keyword_list.at (j));
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
567 }
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
568 }
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
569
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
570 // 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
571 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
572 // 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
573 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
574 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
575 // 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
576 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
577 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
578 }
16721
a71a784c7611 * file-editor-tab.cc(update_lexer): redundant code removed
Torsten <ttl@justmail.de>
parents: 16720
diff changeset
579 _lexer_apis->prepare (); // prepare apis info
16678
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
580 }
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
581 }
518dbe0ae857 fix auto completion for octave files in editor
Torsten <ttl@justmail.de>
parents: 16662
diff changeset
582
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
583 lexer->readSettings (*settings);
16662
72665c4ae25b allow build to continue without QScintilla lexer for Octave
John W. Eaton <jwe@octave.org>
parents: 16646
diff changeset
584
16402
7fa90eb41240 gui: individually configurable styles of the editor lexers
Torsten <ttl@justmail.de>
parents: 16395
diff changeset
585 _edit_area->setLexer (lexer);
19373
e85203f41402 set cursor color of the editor to color of default text (bug #43314)
Torsten <ttl@justmail.de>
parents: 19235
diff changeset
586 _edit_area->setCaretForegroundColor (lexer->color (0));
e85203f41402 set cursor color of the editor to color of default text (bug #43314)
Torsten <ttl@justmail.de>
parents: 19235
diff changeset
587 _edit_area->setIndentationGuidesForegroundColor (lexer->color (0));
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
588
16717
9ad6e7d4fa42 fix bug concerning preparing the apis info for code completion
Torsten <ttl@justmail.de>
parents: 16716
diff changeset
589 // 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
590 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
591 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
592 else
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
593 _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
594
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
595 }
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
596
19023
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
597 // function for adding entries to the octave lexer's APIs
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
598 void
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
599 file_editor_tab::add_octave_apis (octave_value_list key_ovl)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
600 {
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
601 octave_value keys = key_ovl(0);
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
602 Cell key_list = keys.cell_value ();
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
603
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
604 for (int idx = 0; idx < key_list.numel (); idx++)
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
605 _lexer_apis->add (QString (key_list.elem (idx).string_value ().data ()));
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
606 }
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18949
diff changeset
607
16704
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
608 void
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
609 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
610 {
16715
96ed7ab44e2e save prepared apis info for qscintilla into a path depending on octave version
Torsten <ttl@justmail.de>
parents: 16704
diff changeset
611 _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
612 }
e38a0fa08368 fix restoring editor files from previous session and speedup lexer preparation
Torsten <ttl@justmail.de>
parents: 16703
diff changeset
613
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
614 QString
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
615 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
616 {
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
617 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
618 return QString("%");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
619 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
620 return QString("#");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
621 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
622 return ("//");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
623 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
624 return ("REM ");
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
625 else
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
626 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
627 }
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
628
15980
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
629 // 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
630 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
631 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
632 {
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
633 if (ID != this)
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
634 return;
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
635 _edit_area->setFocus ();
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
636 }
6c0fce0632a4 gui: set keyboard focus when switching between dock widgets (bug #36957)
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
637
14869
db3c84d38345 Now supporting c/cc/cpp syntax highlighting.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14833
diff changeset
638 void
17627
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
639 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
640 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
641 if (ID != this)
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
642 return;
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
643
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
644 _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
645 }
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
646
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16912
diff changeset
647 void
17628
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
648 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
649 {
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
650 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
651 return;
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
652
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
653 _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
654 }
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
655
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
656 void
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
657 file_editor_tab::check_modified_file (void)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
658 {
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
659 if (_cancelled)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
660 return;
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
661
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
662 if (check_file_modified () == QMessageBox::Cancel)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
663 _cancelled = true;
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
664 }
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
665
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
666 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
667 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
668 {
424edeca3c66 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 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
670 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
671
424edeca3c66 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 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
673 }
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
674
15848
424edeca3c66 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 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
676 file_editor_tab::save_file (const QWidget *ID, const QString& fileName,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
677 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
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 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
680 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
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 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
683 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
684
424edeca3c66 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 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
686 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
687 {
15848
424edeca3c66 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 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
689 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
690
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
691 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
692 }
424edeca3c66 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
424edeca3c66 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 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
695 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
696 {
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
697 if (ID != this)
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
698 return;
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
699
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
700 QsciPrinter *printer = new QsciPrinter (QPrinter::HighResolution);
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
701
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
702 QPrintDialog printDlg (printer, this);
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
703
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
704 if (printDlg.exec () == QDialog::Accepted)
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
705 printer->printRange (_edit_area);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
706
16440
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
707 delete printer;
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
708 }
aaf024ac8015 Add editor print menu/toolbutton implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16437
diff changeset
709
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
710 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
711 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
712 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
713 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
714 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
715
19028
b43157d085ba make sure a new and still unnamed file is saved when run from the editor
Torsten <ttl@justmail.de>
parents: 19027
diff changeset
716 if (_edit_area->isModified () | ! valid_file_name ())
20119
bb1629e15afe cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents: 20109
diff changeset
717 {
bb1629e15afe cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents: 20109
diff changeset
718 save_file (_file_name); // save file dialog
bb1629e15afe cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents: 20109
diff changeset
719 if (! valid_file_name ())
bb1629e15afe cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents: 20109
diff changeset
720 return; // still invalid file name: "save as" was cancelled
bb1629e15afe cancel run action when saving unnamed file was canceled (bug #44434)
Torsten <ttl@justmail.de>
parents: 20109
diff changeset
721 }
15848
424edeca3c66 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
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
723 QFileInfo info (_file_name);
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
724 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
725 }
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
726
4c4f2fb07a50 Added find functionality in editor by to.lil.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 15045
diff changeset
727 void
17635
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
728 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
729 {
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
730 if (ID != this)
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
731 return;
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
732
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
733 _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
734 }
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
735
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
736 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
737 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
738 {
15848
424edeca3c66 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 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
740 return;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
741
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
742 int line, cur;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
743 _edit_area->getCursorPosition (&line, &cur);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
744
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
745 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
746 _edit_area->markerDelete (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
747 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
748 _edit_area->markerAdd (line, bookmark);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
749 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
750
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
751 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
752 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
753 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
754 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
755 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
756
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
757 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
758 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
759
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
760 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
761 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
762
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
763 int nextline = _edit_area->markerFindNext (line, (1 << bookmark));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
764
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
765 _edit_area->setCursorPosition (nextline, 0);
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
766 }
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
767
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
768 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
769 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
770 {
15848
424edeca3c66 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 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
772 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
773
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
774 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
775 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
776
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
777 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
778 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
779
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
780 int prevline = _edit_area->markerFindPrevious (line, (1 << bookmark));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
781
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
782 _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
783 }
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
784
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
785 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
786 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
787 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
788 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
789 return;
14676
35512b788af2 Editor can now handle multiple files in tabs.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
790
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
791 _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
792 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
793
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
794 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
795 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
796 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
797 bp_table::intmap line_info;
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
798 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
799
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
800 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
801 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
802 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
803
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
804 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
805 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
806 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
807 bp_table::intmap line_info;
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
808 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
809
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
810 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
811 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
812 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
813
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
814 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15389
diff changeset
815 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
816 {
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16591
diff changeset
817 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
818 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
819 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
820
18236
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
821 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
822 : 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
823 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
824 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
825
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
826 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
827 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
828
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
829 // 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
830 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
831
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
832 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
833 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
834
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
835 // 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
836 // 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
837
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
838 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
839
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
840 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
841 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
842 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
843 {
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
844 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
845
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
846 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
847 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
848 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
849 }
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
850
15848
424edeca3c66 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 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
852 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
853 {
18236
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
854 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
855
424edeca3c66 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 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
857 (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
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 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
861 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
862 {
18236
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
863 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
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 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
866 (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
867 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
868
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
869 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
870 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
871 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
872 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
873 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
874
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
875 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
876 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
877
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
878 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
879 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
880 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
881 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
882 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
883
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
884 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
885 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
886 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
887 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
888 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
889
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
890 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
891 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
892
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
893 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
894 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
895
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
896 int nextline = _edit_area->markerFindNext (line, (1 << breakpoint));
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
897
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
898 _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
899 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
900
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
901 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
902 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
903 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
904 if (ID != this)
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
905 return;
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
906
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
907 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
908 _edit_area->getCursorPosition (&line, &cur);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
909
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
910 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
911 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
912
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
913 prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
914
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
915 _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
916 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
917
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
918 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
919 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
920 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
921 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
922 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
923
18236
f26d527c1a71 allow the gui editor to set breakpoints in class methods (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 18082
diff changeset
924 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
925
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
926 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
927 (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
928 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
929
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
930 void
18811
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
931 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: 18655
diff changeset
932 {
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
933 if (ID != this)
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
934 return;
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
935
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
936 _edit_area->SendScintilla (sci_msg);
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
937 }
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
938
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18655
diff changeset
939 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
940 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
941 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
942 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
943 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
944
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
945 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
946 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
947
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
948 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
949 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
950 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
951 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
952 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
953
424edeca3c66 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 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
955 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
956
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
957 void
18345
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
958 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: 18341
diff changeset
959 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
960 if (ID != this)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
961 return;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
962
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
963 do_indent_selected_text (true);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
964 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
965
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
966 void
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
967 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: 18341
diff changeset
968 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
969 if (ID != this)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
970 return;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
971
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
972 do_indent_selected_text (false);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
973 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
974
19439
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
975 void
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
976 file_editor_tab::convert_eol (const QWidget *ID, QsciScintilla::EolMode eol_mode)
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
977 {
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
978 if (ID != this)
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
979 return;
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
980
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
981 _edit_area->convertEols (eol_mode);
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
982 _edit_area->setEolMode (eol_mode);
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
983 update_eol_indicator ();
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
984 }
18345
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
985
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
986 void
18655
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
987 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: 18640
diff changeset
988 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
989 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
990 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
991
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
992 _edit_area->zoomIn (1);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
993 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
994 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
995
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
996 void
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
997 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: 18640
diff changeset
998 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
999 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1000 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1001
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1002 _edit_area->zoomOut (1);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1003 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1004 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1005
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1006 void
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1007 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: 18640
diff changeset
1008 {
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1009 if (ID != this)
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1010 return;
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1011
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1012 _edit_area->zoomTo (0);
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1013 auto_margin_width ();
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1014 }
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1015
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1016
26d15a57f45b add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents: 18640
diff changeset
1017 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
1018 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
1019 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1020 // 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
1021 // 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
1022 _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
1023 _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
1024 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1025
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1026 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1027 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
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 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
1030 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
1031
424edeca3c66 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 // 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
1033 // 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
1034 // 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
1035 // 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
1036 // 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
1037 // 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
1038
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1039 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
1040 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1041 _find_dialog = new find_dialog (_edit_area,
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1042 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
1043 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
1044 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
1045 _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
1046 _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
1047 }
19638
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1048 else if (!_find_dialog->isVisible ())
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1049 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1050 _find_dialog->setGeometry (_find_dialog_geometry);
19638
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1051 QPoint p = _find_dialog->pos ();
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1052 _find_dialog->move(p.x ()+10, p.y ()+10);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1053 }
424edeca3c66 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
19638
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1055 _find_dialog->show ();
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1056 _find_dialog_is_visible = true;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1057 _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
1058 _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
1059
15848
424edeca3c66 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 }
424edeca3c66 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
424edeca3c66 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 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1063 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
1064 {
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1065 if (ID != this)
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1066 return;
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1067
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
1068 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
1069 {
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
1070 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
1071 int index;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1072 _edit_area->getCursorPosition (&line, &index);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1073 line = QInputDialog::getInt (_edit_area, tr ("Goto line"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1074 tr ("Line number"), line+1, 1,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1075 _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
1076 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
1077 {
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
1078 _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
1079 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
1080 }
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
1081 }
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
1082 else // go to given line without dialog
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1083 _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
1084 }
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1085
18345
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1086 void
19826
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1087 file_editor_tab::move_match_brace (const QWidget *ID, bool select)
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1088 {
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1089 if (ID != this)
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1090 return;
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1091
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1092 if (select)
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1093 _edit_area->selectToMatchingBrace ();
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1094 else
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1095 _edit_area->moveToMatchingBrace ();
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1096 }
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1097
8ef79bc61d8a add actions for moving/selecting to matching brace
Torsten <ttl@justmail.de>
parents: 19805
diff changeset
1098 void
18550
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1099 file_editor_tab::show_auto_completion (const QWidget *ID)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1100 {
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1101 if (ID != this)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1102 return;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1103
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1104 QsciScintilla::AutoCompletionSource s = _edit_area->autoCompletionSource ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1105 switch (s)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1106 {
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1107 case QsciScintilla::AcsAll:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1108 _edit_area->autoCompleteFromAll ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1109 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1110
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1111 case QsciScintilla::AcsAPIs:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1112 _edit_area->autoCompleteFromAPIs ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1113 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1114
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1115 case QsciScintilla::AcsDocument:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1116 _edit_area->autoCompleteFromDocument ();
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1117 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1118
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1119 case QsciScintilla::AcsNone:
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1120 break;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1121 }
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1122 }
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1123
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1124 void
18345
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1125 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: 18341
diff changeset
1126 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1127 // TODO
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1128 _edit_area->beginUndoAction ();
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1129
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1130 if (_edit_area->hasSelectedText ())
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1131 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1132 int lineFrom, lineTo, colFrom, colTo;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1133 _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: 18341
diff changeset
1134
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1135 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: 18341
diff changeset
1136 lineTo--; // stop at line above
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1137
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1138 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: 18341
diff changeset
1139 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1140 if (indent)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1141 _edit_area->indent (i);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1142 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1143 _edit_area->unindent (i);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1144 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1145 //set selection on (un)indented section
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1146 _edit_area->setSelection (lineFrom, 0, lineTo,
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1147 _edit_area->text (lineTo).length ());
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1148 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1149 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1150 {
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1151 int cpline, col;
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1152 _edit_area->getCursorPosition (&cpline, &col);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1153 if (indent)
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1154 _edit_area->indent (cpline);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1155 else
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1156 _edit_area->unindent (cpline);
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1157 }
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1158
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1159 _edit_area->endUndoAction ();
106da7544504 gui: Add indent/unindent edit menu to editor (Bug #41223)
John Donoghue <john.donoghue@ieee.org>
parents: 18341
diff changeset
1160 }
16375
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1161
f482302d81c9 editor goto line menu item (bug #38590)
John Donoghue <john.donoghue@ieee.org>
parents: 16018
diff changeset
1162 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
1163 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
1164 {
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
1165 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
1166 _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
1167
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1168 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
1169 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1170 int lineFrom, lineTo, colFrom, colTo;
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1171 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1172
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1173 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
1174 lineTo--; // stop at line above
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1175
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1176 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
1177 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1178 if (comment)
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
1179 _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
1180 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
1181 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1182 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
1183 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
1184 {
16719
0f6f14e3ac6a commenting selected lines in the editor uses comment string depending on lexer
Torsten <ttl@justmail.de>
parents: 16717
diff changeset
1185 _edit_area->setSelection (i, 0, i, comment_str.length ());
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1186 _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
1187 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1188 }
424edeca3c66 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 }
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
1190 //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
1191 _edit_area->setSelection (lineFrom, 0, lineTo,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1192 _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
1193 }
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
1194 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
1195 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1196 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
1197 _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
1198 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
1199 _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
1200 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
1201 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1202 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
1203 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
1204 {
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1205 _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
1206 _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
1207 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1208 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1209 }
e81084a745a9 GUI: change (un)comment handling of selection, allow (un)comment of current line
Thorsten Liebig <thorsten.liebig@gmx.de>
parents: 16731
diff changeset
1210 _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
1211 }
424edeca3c66 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
424edeca3c66 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 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
1214 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
1215 {
424edeca3c66 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 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
1217 QString tooltip ("");
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1218
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1219 if (! valid_file_name ())
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1220 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
1221 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
1222 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1223 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
1224 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
1225 else
e3873531dd7c gui: correct tab title for new editor file if short title setting is selected
Torsten <ttl@justmail.de>
parents: 15980
diff changeset
1226 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1227 QFileInfo file (_file_name);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1228 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
1229 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
1230 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1231 }
424edeca3c66 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
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1233 if (modified)
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1234 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
1235 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
1236 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
1237 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1238
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1239 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1240 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
1241 {
424edeca3c66 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 _copy_available = enableCopy;
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
1243 emit editor_state_changed (_copy_available, _is_octave_file);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
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
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1246 // show_dialog: shows a modal or non modal dialog depending on input arg
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1247 void
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1248 file_editor_tab::show_dialog (QDialog *dlg, bool modal)
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1249 {
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1250 dlg->setAttribute (Qt::WA_DeleteOnClose);
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1251 if (modal)
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1252 dlg->exec ();
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1253 else
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1254 {
20009
dfa608a9c36e fix issue when saving a new modified file while closing
Torsten <ttl@justmail.de>
parents: 20008
diff changeset
1255 dlg->setWindowModality (Qt::NonModal);
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1256 dlg->show ();
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1257 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1258 }
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1259
15848
424edeca3c66 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 int
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1261 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
1262 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1263 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
1264 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
1265 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1266 // 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
1267 // 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
1268 // 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
1269 QMessageBox::StandardButtons buttons = QMessageBox::Save |
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1270 QMessageBox::Discard |
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1271 QMessageBox::Cancel;
19608
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1272
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1273 // For now, just a warning message about closing a tab that has been
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1274 // modified seems sufficient. Exit-condition-specific messages could
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1275 // be achieved by making 'available_actions' a function input string.
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1276 QString available_actions =
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1277 tr ("Do you want to cancel closing, save or discard the changes?");
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1278
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1279 QString file;
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1280 if (valid_file_name ())
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1281 file = _file_name;
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1282 else
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1283 file = tr ("<unnamed>");
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1284
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1285 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1286 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"),
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1287 tr ("The file\n\n"
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1288 " %1\n\n"
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1289 "is about to be closed but has been modified. "
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
1290 "%2").
17973
6925dca34807 fix saving unnamed editor files when closing octave (bug #40637)
Torsten <ttl@justmail.de>
parents: 17962
diff changeset
1291 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
1292 buttons, qobject_cast<QWidget *> (parent ()));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1293
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1294 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
1295 _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
1296 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
1297 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
1298
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1299 show_dialog (msgBox, true);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1300
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1301 if (_cancelled)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1302 return QMessageBox::Cancel;
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1303 else
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1304 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
1305 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1306 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
1307 {
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1308 // Nothing was modified. Leave tab present in case user
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1309 // decides to cancel some point further along.
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1310 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1311
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1312 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
1313 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1314
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1315 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
1316 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
1317 {
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1318 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
1319 {
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1320 // Save file, but do not remove from editor.
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1321 save_file (_file_name, 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
1322 }
16018
e0df71fbe39b gui: clearer message box with cancel button when closing an unsaved editor file
Torsten <ttl@justmail.de>
parents: 16017
diff changeset
1323 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
1324 {
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1325 // User doesn't want to save, leave tab and remove subsequently.
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1326 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1327 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
1328 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1329 // 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
1330 _edit_area->setReadOnly (false);
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1331 _cancelled = true;
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1332 }
424edeca3c66 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 }
424edeca3c66 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
424edeca3c66 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 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
1336 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
1337 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1338 _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
1339 }
424edeca3c66 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 QString
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1342 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
1343 {
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1344 // 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
1345 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
1346 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
1347 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
1348 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
1349 else
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1350 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
1351 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
1352 if (!file.open (QFile::ReadOnly))
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1353 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
1354
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1355 QTextStream in (&file);
18341
6736fc9bce24 Set codec when loading/saving files in editor (Bug #41226)
John Donoghue <john.donoghue@ieee.org>
parents: 18300
diff changeset
1356 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
1357 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
1358 _edit_area->setText (in.readAll ());
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1359 _edit_area->setEolMode (detect_eol_mode ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1360 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
1361
17636
230ffaf80ac9 fix enabling copy, cut and run selection actions depending on selected text
Torsten <ttl@justmail.de>
parents: 17635
diff changeset
1362 _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
1363 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
1364 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
1365 _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
1366
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1367 update_eol_indicator ();
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1368
15848
424edeca3c66 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 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
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
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1372 QsciScintilla::EolMode
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1373 file_editor_tab::detect_eol_mode ()
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1374 {
19973
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1375 QByteArray text = _edit_area->text ().toAscii ();
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1376
19973
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1377 QByteArray eol_lf = QByteArray (1,0x0a);
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1378 QByteArray eol_cr = QByteArray (1,0x0d);
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1379 QByteArray eol_crlf = eol_cr;
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1380 eol_crlf.append (eol_lf);
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1381
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1382 int count_crlf = text.count (eol_crlf);
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1383 int count_lf = text.count (eol_lf) - count_crlf; // isolated lf
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1384 int count_cr = text.count (eol_cr) - count_crlf; // isolated cr;
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1385
19440
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1386 // get default from OS or from settings
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1387 #if defined (Q_OS_WIN32)
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1388 int os_eol_mode = QsciScintilla::EolWindows;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1389 #elif defined (Q_OS_MAC)
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1390 int os_eol_mode = QsciScintilla::EolMac;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1391 #else
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1392 int os_eol_mode = QsciScintilla::EolUnix;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1393 #endif
19973
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1394 QSettings *settings = resource_manager::get_settings ();
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1395 QsciScintilla::EolMode eol_mode = static_cast<QsciScintilla::EolMode> (
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1396 settings->value("editor/default_eol_mode",os_eol_mode).toInt ());
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1397
19440
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1398 int count_max = 0;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1399
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1400 if (count_crlf > count_max)
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1401 {
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1402 eol_mode = QsciScintilla::EolWindows;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1403 count_max = count_crlf;
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1404 }
19973
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1405 if (count_lf > count_max)
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1406 {
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1407 eol_mode = QsciScintilla::EolUnix;
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1408 count_max = count_lf;
95a94c98c884 fix eol detection in editor which caused a crash for huge files
Torsten <ttl@justmail.de>
parents: 19917
diff changeset
1409 }
19429
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1410 if (count_cr > count_max)
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1411 {
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1412 eol_mode = QsciScintilla::EolMac;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1413 count_max = count_cr;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1414 }
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1415
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1416 return eol_mode;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1417 }
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1418
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1419 void
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1420 file_editor_tab::update_eol_indicator ()
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1421 {
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1422 switch (_edit_area->eolMode ())
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1423 {
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1424 case QsciScintilla::EolWindows:
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1425 _eol_indicator->setText ("CRLF");
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1426 break;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1427 case QsciScintilla::EolMac:
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1428 _eol_indicator->setText ("CR");
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1429 break;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1430 case QsciScintilla::EolUnix:
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1431 _eol_indicator->setText ("LF");
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1432 break;
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1433 }
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1434 }
c766a1f63c40 detect eol mode when opening a file in the editor of the gui (#bug 43334)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1435
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1436 void
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16443
diff changeset
1437 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
1438 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1439 update_window_title (false); // window title (no modification)
19437
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1440
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1441 QSettings *settings = resource_manager::get_settings ();
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1442
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1443 // set the eol mode from the settings or depending on the OS if the entry is
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1444 // missing in the settings
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1445 #if defined (Q_OS_WIN32)
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1446 int eol_mode = QsciScintilla::EolWindows;
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1447 #elif defined (Q_OS_MAC)
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1448 int eol_mode = QsciScintilla::EolMac;
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1449 #else
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1450 int eol_mode = QsciScintilla::EolUnix;
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1451 #endif
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1452 _edit_area->setEolMode (
19440
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1453 static_cast<QsciScintilla::EolMode> (
54943eb0ce37 reorder eol modes in the editor settings
Torsten <ttl@justmail.de>
parents: 19439
diff changeset
1454 settings->value("editor/default_eol_mode",eol_mode).toInt ()));
19437
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1455
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1456 update_eol_indicator ();
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1457
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
1458 update_lexer ();
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
1459
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16443
diff changeset
1460 _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
1461 _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
1462 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1463
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1464 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
1465 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
1466 {
424edeca3c66 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 // 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
1468 // should be performed.
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1469 if (! valid_file_name (saveFileName))
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1470 {
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1471 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
1472 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
1473 }
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1474 // 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
1475 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
1476 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
1477 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
1478 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
1479 else
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1480 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
1481 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
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 // 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
1484 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
1485 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
1486 _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
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 // 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
1489 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
1490 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1491 // 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
1492 // 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
1493 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
1494 _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
1495
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1496 // Create a NonModal message about error.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1497 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1498 = new QMessageBox (QMessageBox::Critical,
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1499 tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1500 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
1501 arg (file_to_save).arg (file.errorString ()),
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1502 QMessageBox::Ok, 0);
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1503 show_dialog (msgBox, false);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1504
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1505 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
1506 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1507
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1508 // 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
1509 QTextStream out (&file);
18341
6736fc9bce24 Set codec when loading/saving files in editor (Bug #41226)
John Donoghue <john.donoghue@ieee.org>
parents: 18300
diff changeset
1510 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
1511 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
1512 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
1513 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
1514 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
1515 file.flush ();
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1516 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
1517
17706
97ed9dd479ab make sure all entries in the editor's mru-menu have an absolute path
Torsten <ttl@justmail.de>
parents: 17699
diff changeset
1518 // 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
1519 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
1520 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
1521
15848
424edeca3c66 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 // 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
1523 set_file_name (file_to_save); // make absolute
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1524
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1525 // 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
1526 update_window_title (false);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1527
15848
424edeca3c66 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 // 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
1529 _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
1530
424edeca3c66 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 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
1532 {
424edeca3c66 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 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
1534 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
1535 }
424edeca3c66 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
424edeca3c66 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 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
1539 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
1540 {
424edeca3c66 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 // 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
1542 // 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
1543
424edeca3c66 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 // 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
1545 // 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
1546 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
1547 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
1548 {
424edeca3c66 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 // 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
1550 // 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
1551 _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
1552 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
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 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
1555 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
1556
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
1557 // 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
1558 // 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
1559 // 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
1560 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
1561
19441
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1562 // get the dialog's layout for adding extra elements
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1563 QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (fileDialog->layout ());
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1564 int rows = dialog_layout->rowCount ();
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1565
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1566 // define a new grid layout with the extra elements
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1567 QGridLayout *extra = new QGridLayout (fileDialog);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1568 QSpacerItem *spacer = new QSpacerItem (1,1,QSizePolicy::Expanding,
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1569 QSizePolicy::Fixed);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1570 QFrame *separator = new QFrame (fileDialog);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1571 separator->setFrameShape (QFrame::HLine); // horizontal line as separator
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1572 separator->setFrameStyle (QFrame::Sunken);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1573
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1574 // combo box for choosing new line ending chars
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1575 QLabel *label_eol = new QLabel (tr ("Line Endings:"));
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1576 QComboBox *combo_eol = new QComboBox ();
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1577 combo_eol->addItem ("Windows (CRLF)"); // ensure the same order as in
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1578 combo_eol->addItem ("Mac (CR)"); // the settings dialog
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1579 combo_eol->addItem ("Unix (LF)");
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1580 _save_as_desired_eol = _edit_area->eolMode (); // init with current eol
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1581 combo_eol->setCurrentIndex (_save_as_desired_eol);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1582
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1583 // track changes in the combo box
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1584 connect (combo_eol, SIGNAL (currentIndexChanged (int)),
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1585 this, SLOT (handle_combo_eol_current_index (int)));
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1586
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1587 // build the extra grid layout
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1588 extra->addWidget (separator,0,0,1,3);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1589 extra->addWidget (label_eol,1,0);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1590 extra->addWidget (combo_eol,1,1);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1591 extra->addItem (spacer, 1,2);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1592
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1593 // and add the extra grid layout to the dialog's layout
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1594 dialog_layout->addLayout (extra,rows,0,1,dialog_layout->columnCount ());
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1595
19448
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1596 // add the possible filters and the default suffix
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1597 QStringList filters;
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1598 filters << tr ("Octave Files (*.m)")
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1599 << tr ("All Files (*)");
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1600 fileDialog->setNameFilters (filters);
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1601 fileDialog->setDefaultSuffix ("m");
19441
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1602
17979
a761ba02a52f some code cleanup in file_editor_tab
Torsten <ttl@justmail.de>
parents: 17973
diff changeset
1603 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
1604 {
424edeca3c66 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 fileDialog->selectFile (_file_name);
19448
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1606 QFileInfo file_info (_file_name);
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1607 if (file_info.suffix () != "m")
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1608 { // it is not an octave file
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1609 fileDialog->selectNameFilter (filters.at (1)); // "All Files"
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1610 fileDialog->setDefaultSuffix (""); // no default suffix
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1611 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1612 }
424edeca3c66 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 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
1614 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1615 fileDialog->selectFile ("");
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
1616 fileDialog->setDirectory (_ced);
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
1617
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
1618 // propose a name corresponding to the function name
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
1619 QString fname = get_function_name ();
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
1620 if (! fname.isEmpty ())
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
1621 fileDialog->selectFile (fname + ".m");
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1622 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1623
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1624 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
1625 fileDialog->setViewMode (QFileDialog::Detail);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1626
19448
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1627 connect (fileDialog, SIGNAL (filterSelected (const QString&)),
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1628 this, SLOT (handle_save_as_filter_selected (const QString&)));
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1629
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1630 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
1631 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1632 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
1633 this, SLOT (handle_save_file_as_answer_close (const QString&)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1634
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1635 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
1636 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
1637 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1638 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
1639 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1640 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
1641 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
1642 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1643
20009
dfa608a9c36e fix issue when saving a new modified file while closing
Torsten <ttl@justmail.de>
parents: 20008
diff changeset
1644 show_dialog (fileDialog, ! valid_file_name ());
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1645 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1646
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1647 void
19441
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1648 file_editor_tab::handle_combo_eol_current_index (int index)
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1649 {
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1650 _save_as_desired_eol = static_cast<QsciScintilla::EolMode> (index);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1651 }
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1652
19448
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1653 void
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1654 file_editor_tab::handle_save_as_filter_selected (const QString& filter)
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1655 {
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1656 QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ());
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1657
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1658 QRegExp rx ("\\*\\.([^ ^\\)]*)[ \\)]"); // regexp for suffix in filter
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1659 int index = rx.indexIn (filter,0); // get first suffix in filter
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1660
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1661 if (index > -1)
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1662 file_dialog->setDefaultSuffix (rx.cap (1)); // found a suffix, set default
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1663 else
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1664 file_dialog->setDefaultSuffix (""); // not found, clear default
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1665 }
ce9bd5ed44d2 usage of default suffix depending on filter in save as dialog (bug #43335)
Torsten <ttl@justmail.de>
parents: 19441
diff changeset
1666
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1667 bool
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1668 file_editor_tab::check_valid_identifier (QString file_name)
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1669 {
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1670 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: 18357
diff changeset
1671 QString base_name = file.baseName ();
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1672
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1673 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: 18357
diff changeset
1674 && (! valid_identifier (base_name.toStdString ())))
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1675 {
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1676 int ans = QMessageBox::question (0, tr ("Octave Editor"),
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1677 tr ("\"%1\"\n"
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1678 "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: 18357
diff changeset
1679 "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: 18357
diff changeset
1680 "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: 18357
diff changeset
1681 "Do you want to choose another name?").arg (base_name),
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1682 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: 18236
diff changeset
1683
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1684 if (ans == QMessageBox::Yes)
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1685 return true;
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1686 }
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1687
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1688 return false;
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1689 }
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1690
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1691 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
1692 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
1693 {
19441
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1694 if (_save_as_desired_eol != _edit_area->eolMode ())
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1695 convert_eol (this,_save_as_desired_eol);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1696
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1697 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
1698 {
18082
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1699 // 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
1700 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
1701 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1702 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
1703 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1704 // Have editor check for conflict, do not delete tab after save.
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1705 if (check_valid_identifier (saveFileName))
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1706 save_file_as (false);
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1707 else
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1708 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
1709 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1710 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1711
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1712 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
1713 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
1714 {
19441
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1715 if (_save_as_desired_eol != _edit_area->eolMode ())
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1716 {
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1717 _edit_area->setReadOnly (false); // was set to read-only in save_file_as
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1718 convert_eol (this,_save_as_desired_eol);
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1719 _edit_area->setReadOnly (true); // restore read-only mode
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1720 }
d10c711a08d8 add a drop down menu with the eol mode in the save-file-as-dialog
Torsten <ttl@justmail.de>
parents: 19440
diff changeset
1721
18082
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1722 // 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
1723 // 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
1724
c3e7da9836bd allow saving an editor file as the current one (bug #40759)
Torsten <ttl@justmail.de>
parents: 17979
diff changeset
1725 // Have editor check for conflict, delete tab after save.
18360
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18357
diff changeset
1726 if (check_valid_identifier (saveFileName))
18300
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1727 save_file_as (true);
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1728 else
3a26bb54655e warn when saving or executing a file with spaces in its name (bug #41136)
Torsten <ttl@justmail.de>
parents: 18236
diff changeset
1729 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
1730 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1731
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1732 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
1733 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
1734 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1735 // 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
1736 _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
1737 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1738
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1739 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
1740 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
1741 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1742 // 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
1743 // 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
1744 // 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
1745 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
1746 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
1747 _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
1748
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1749 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
1750 {
19136
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1751 if (_always_reload_changed_files)
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1752
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1753 load_file (_file_name);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1754
19136
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1755 else
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1756 {
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1757 // Create a WindowModal message that blocks the edit area
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1758 // by making _edit_area parent.
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1759 QMessageBox* msgBox
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1760 = new QMessageBox (QMessageBox::Warning,
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1761 tr ("Octave Editor"),
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1762 tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?").
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1763 arg (_file_name),
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1764 QMessageBox::Yes | QMessageBox::No, this);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1765
19136
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1766 connect (msgBox, SIGNAL (finished (int)),
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1767 this, SLOT (handle_file_reload_answer (int)));
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1768
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1769 msgBox->setWindowModality (Qt::WindowModal);
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1770 msgBox->setAttribute (Qt::WA_DeleteOnClose);
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1771 msgBox->show ();
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1772 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1773 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1774 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
1775 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1776 QString modified = "";
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1777 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
1778 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
1779
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1780 // 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
1781 // 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
1782 // Instead, change the _edit_area to read only.
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1783 QMessageBox* msgBox
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1784 = new QMessageBox (QMessageBox::Warning, tr ("Octave Editor"),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1785 tr ("It seems that the file\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1786 "%1\n"
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1787 "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
1788 arg (_file_name).arg (modified),
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1789 QMessageBox::Save | QMessageBox::Close, 0);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1790
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1791 _edit_area->setReadOnly (true);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1792
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1793 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
1794 this, SLOT (handle_file_resave_answer (int)));
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1795
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1796 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
1797 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
1798 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
1799 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1800 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1801
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1802 void
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
1803 file_editor_tab::notice_settings (const QSettings *settings, bool init)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1804 {
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
1805 // 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
1806
19975
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
1807 if (! init)
35a8e1beac8d fix some oddities updating lexer and api-files for auto completion
Torsten <ttl@justmail.de>
parents: 19973
diff changeset
1808 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
1809
18898
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1810 // code folding
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1811 if (settings->value ("editor/code_folding",true).toBool ())
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1812 {
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1813 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1814 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1815 }
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1816 else
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1817 {
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1818 _edit_area->setFolding (QsciScintilla::NoFoldStyle, 3);
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1819 }
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1820
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1821 // status bar
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1822 if (settings->value ("editor/show_edit_status_bar",true).toBool ())
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1823 _status_bar->show ();
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1824 else
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1825 _status_bar->hide ();
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18842
diff changeset
1826
16693
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1827 //highlight current line color
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1828 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
1829 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
1830 default_var).value<QColor> ();
e9d0b8252a0a make color of current line marker in the editor configurable
Torsten <ttl@justmail.de>
parents: 16679
diff changeset
1831 _edit_area->setCaretLineBackgroundColor (setting_color);
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1832 _edit_area->setCaretLineVisible
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1833 (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
1834
18550
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1835 bool match_keywords = settings->value
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1836 ("editor/codeCompletion_keywords",true).toBool ();
18550
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1837 bool match_document = settings->value
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
1838 ("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
1839
18550
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1840 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1841 if (match_keywords)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1842 if (match_document)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1843 source = QsciScintilla::AcsAll;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1844 else
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1845 source = QsciScintilla::AcsAPIs;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1846 else if (match_document)
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1847 source = QsciScintilla::AcsDocument;
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1848 _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
1849
18550
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1850 _edit_area->setAutoCompletionReplaceWord
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1851 (settings->value ("editor/codeCompletion_replace",false).toBool ());
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1852 _edit_area->setAutoCompletionCaseSensitivity
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1853 (settings->value ("editor/codeCompletion_case",true).toBool ());
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1854
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1855 if (settings->value ("editor/codeCompletion", true).toBool ())
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1856 _edit_area->setAutoCompletionThreshold
3a509de8e791 automatic completion list as user preference (bug #41469)
Torsten <ttl@justmail.de>
parents: 18528
diff changeset
1857 (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
1858 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
1859 _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
1860
16702
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1861 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
1862 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
1863 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1864 else
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1865 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1866 else
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1867 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible);
553cfdd5d660 make white space visibility in the editor configurable
Torsten <ttl@justmail.de>
parents: 16701
diff changeset
1868
19437
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1869 _edit_area->setEolVisibility (
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1870 settings->value("editor/show_eol_chars",false).toBool ());
f3c4b48f3c53 add a preference for the default eol mode of new files (bug #43334)
Torsten <ttl@justmail.de>
parents: 19436
diff changeset
1871
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1872 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
1873 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1874 _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
1875 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
1876 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
1877 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
1878 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1879 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
1880 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1881 _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
1882 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
1883 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1884
16703
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1885 _edit_area->setAutoIndent
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1886 (settings->value ("editor/auto_indent",true).toBool ());
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
1887 _smart_indent = settings->value ("editor/auto_indent",true).toBool ();
16703
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1888 _edit_area->setTabIndents
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1889 (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
1890 _edit_area->setBackspaceUnindents
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1891 (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
1892 _edit_area->setIndentationGuides
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1893 (settings->value ("editor/show_indent_guides",false).toBool ());
19517
5fb4505b84ff provide option for using tabs for indentations in the editor
Torsten <ttl@justmail.de>
parents: 19448
diff changeset
1894 _edit_area->setIndentationsUseTabs
5fb4505b84ff provide option for using tabs for indentations in the editor
Torsten <ttl@justmail.de>
parents: 19448
diff changeset
1895 (settings->value ("editor/indent_uses_tabs",false).toBool ());
19527
cd2a75e5cd6e use indentation width for the editor from the settings (bug #43592)
Torsten <ttl@justmail.de>
parents: 19517
diff changeset
1896 _edit_area->setIndentationWidth
cd2a75e5cd6e use indentation width for the editor from the settings (bug #43592)
Torsten <ttl@justmail.de>
parents: 19517
diff changeset
1897 (settings->value ("editor/indent_width",2).toInt ());
16703
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1898
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1899 _edit_area->setTabWidth
5cf19370011d add more settings concerning tabs and indentation to the editor settings
Torsten <ttl@justmail.de>
parents: 16702
diff changeset
1900 (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
1901
19627
472a5572849c hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents: 19623
diff changeset
1902 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR,
472a5572849c hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents: 19623
diff changeset
1903 settings->value ("editor/show_hscroll_bar",true).toBool ());
472a5572849c hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents: 19623
diff changeset
1904 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1);
19787
6d75f1683ce8 fix scroll width of horizontal scroll bar (bug #44040)
Torsten <ttl@justmail.de>
parents: 19638
diff changeset
1905 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,true);
19627
472a5572849c hiding horizontal scroll bar in editor when not needed (bug #41592)
Torsten <ttl@justmail.de>
parents: 19623
diff changeset
1906
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1907 _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
1908 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
1909
18557
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1910 _edit_area->setEdgeColumn (
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1911 settings->value ("editor/long_line_column",80).toInt ());
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1912 if (settings->value ("editor/long_line_marker",true).toBool ())
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1913 _edit_area->setEdgeMode (QsciScintilla::EdgeLine);
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1914 else
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1915 _edit_area->setEdgeMode (QsciScintilla::EdgeNone);
6eae8ba32e62 provide a long line marker in the editor
Torsten <ttl@justmail.de>
parents: 18551
diff changeset
1916
19136
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1917 // reload changed files
19792
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19791
diff changeset
1918 _always_reload_changed_files =
19136
0be65bd7f369 add an user preference for loading changed files without a prompt (bug #42678)
Torsten <ttl@justmail.de>
parents: 19028
diff changeset
1919 settings->value ("editor/always_reload_changed_files",false).toBool ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1920 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1921
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1922 void
16716
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1923 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
1924 {
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1925 _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
1926 }
23b5dde25367 make octave lexer the default and dynamically set margin width for line numbers
Torsten <ttl@justmail.de>
parents: 16715
diff changeset
1927
19608
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1928 // the following close request was changed from a signal slot into a
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1929 // normal function because we need the return value from close whether
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1930 // the tab really was closed (for canceling exiting octave).
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1931 // When emitting a signal, only the return value from the last slot
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1932 // goes back to the sender
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1933 bool
19917
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19898
diff changeset
1934 file_editor_tab::conditional_close (void)
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1935 {
19608
ed0df431631b allow to cancel exiting if editor tabs are modified and exit is requested in gui
Torsten <ttl@justmail.de>
parents: 19543
diff changeset
1936 return close ();
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1937 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1938
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1939 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1940 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
1941 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1942 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
1943 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1944 // 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
1945 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
1946 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1947 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
1948 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1949 _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
1950 _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
1951 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1952 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1953 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
1954 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1955
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1956 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
1957 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1958 _find_dialog->setGeometry (_find_dialog_geometry);
19638
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1959 QPoint p = _find_dialog->pos ();
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 19627
diff changeset
1960 _find_dialog->move(p.x ()+10, p.y ()+10);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1961 _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
1962 }
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1963
20008
415864f5b85f communicating actual working directory to the editor (#44298)
Torsten <ttl@justmail.de>
parents: 19975
diff changeset
1964 emit editor_state_changed (_copy_available, _is_octave_file);
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1965 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1966
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1967 void
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1968 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
1969 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1970 // 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
1971 // 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
1972 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
1973 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
1974
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1975 // 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
1976 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
1977 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
1978 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1979
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1980 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
1981 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
1982 {
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1983 if (decision == QMessageBox::Yes)
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1984 {
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1985 // 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
1986 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
1987 }
15849
e55a64f49346 editor: prevent reloaded file from being added twice to the file watcher
Torsten <ttl@justmail.de>
parents: 15848
diff changeset
1988 else
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1989 {
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
1990 // 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
1991 _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
1992 }
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1993 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1994
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
1995 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
1996 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
1997 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
1998 // 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
1999 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
2000 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
2001 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
2002 _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
2003 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2004 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
2005 {
16017
06187a0b7a62 gui: new handling when an editor file is deleted or renamed (bug #38282)
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
2006 // 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
2007 // 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
2008 // 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
2009 // 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
2010 _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
2011 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
2012 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2013 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2014
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2015 void
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2016 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
2017 {
16377
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
2018 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
2019 return;
8430ea8c1594 open editor tab and insert marker for debugging with gui
John W. Eaton <jwe@octave.org>
parents: 16375
diff changeset
2020
15848
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2021 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
2022 {
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
2023 _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
2024 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
2025 }
424edeca3c66 Redo portions of file editor to use more signals/slots rather than casting.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15449
diff changeset
2026 }
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
2027
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2028 void
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2029 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
2030 {
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2031 if (ID != this || ID == 0)
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2032 return;
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2033
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2034 if (line > 0)
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
2035 _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
2036 }
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2037
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16389
diff changeset
2038 void
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16440
diff changeset
2039 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
2040 {
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2041 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
2042 return;
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2043
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2044 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
2045 {
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2046 if (insert)
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
2047 _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
2048 else
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16520
diff changeset
2049 _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
2050 }
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2051 }
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16379
diff changeset
2052
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
2053
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
2054 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
2055 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
2056 {
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
2057 long int visible_lines
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
2058 = _edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
2059
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
2060 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
2061 {
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
2062 int line, index;
16558
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
2063 _edit_area->getCursorPosition (&line, &index);
5fc1ce2947bd style fixes
John W. Eaton <jwe@octave.org>
parents: 16547
diff changeset
2064
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
2065 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
2066 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
2067
16591
2931e9282190 * file-editor-tab.cc: replace setFirstVisibleLine for older Qscintilla-versions
Torsten <ttl@justmail.de>
parents: 16570
diff changeset
2068 _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
2069 }
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
2070 }
f5204f486a29 gui: add shortcut for goto line action in the editor and center the target line
Torsten <ttl@justmail.de>
parents: 16388
diff changeset
2071
19790
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19429
diff changeset
2072 void
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2073 file_editor_tab::handle_lines_changed ()
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2074 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2075 // the related signal is emitted before cursor-move-signal!
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2076 _lines_changed = true;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2077 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2078
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2079 void
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
2080 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
2081 {
18551
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18550
diff changeset
2082 if (_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18550
diff changeset
2083 show_auto_completion (this);
0f3bc7ccb875 update the completion list of the editor while typing
Torsten <ttl@justmail.de>
parents: 18550
diff changeset
2084
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2085 if (_lines_changed) // check for smart indentation
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2086 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2087 _lines_changed = false;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2088 if (_is_octave_file && _smart_indent && line == _line+1 && col < _col)
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2089 do_smart_indent ();
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2090 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2091
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2092 _line = line;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2093 _col = col;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2094
17962
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
2095 _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
2096 _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
2097 }
4a53bcc1a4ae GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
John Donoghue <john.donoghue@ieee.org>
parents: 17790
diff changeset
2098
20624
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2099 void
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2100 file_editor_tab::do_smart_indent ()
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2101 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2102 QString prev_line = _edit_area->text (_line);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2103
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2104 QRegExp bkey = QRegExp ("^[\t ]*(if|for|while|switch|case|do|function"
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2105 "|unwind_protect|unwind_protect_cleanup|try)"
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2106 "[\n\t #%]");
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2107 if (prev_line.contains (bkey))
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2108 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2109 _edit_area->indent (_line+1);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2110 _edit_area->setCursorPosition (_line+1,
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2111 _edit_area->indentation (_line) +
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2112 _edit_area->indentationWidth ());
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2113 return;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2114 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2115
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2116 QRegExp mkey = QRegExp ("^[\t ]*(else|elseif|catch)[\t #%\n]");
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2117 if (prev_line.contains (mkey))
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2118 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2119 int prev_ind = _edit_area->indentation (_line-1);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2120 int act_ind = _edit_area->indentation (_line);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2121
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2122 if (prev_ind == act_ind)
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2123 _edit_area->unindent (_line);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2124 else if (prev_ind > act_ind)
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2125 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2126 _edit_area->setIndentation (_line+1, prev_ind);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2127 _edit_area->setCursorPosition (_line+1, prev_ind);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2128 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2129 return;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2130 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2131
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2132 QRegExp ekey = QRegExp ("^[\t ]*(end|endif|endfor|endwhile|until|endfunction"
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2133 "|end_try_catch|end_unwind_protext)[\t #%\n(;]");
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2134 if (prev_line.contains (ekey))
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2135 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2136 if (_edit_area->indentation (_line-1) <= _edit_area->indentation (_line))
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2137 {
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2138 _edit_area->unindent (_line+1);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2139 _edit_area->unindent (_line);
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2140 _edit_area->setCursorPosition (_line+1,
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2141 _edit_area->indentation (_line));
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2142 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2143 return;
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2144 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2145
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2146 }
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2147
046904b54dc4 editor with smart indentation for octave files (bug #41554)
Torsten <ttl@justmail.de>
parents: 20440
diff changeset
2148
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2149 QString
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2150 file_editor_tab::get_function_name ()
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2151 {
19197
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2152 QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$");
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2153 QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$");
19235
2e6b34324d50 fix compile warning in gui editor tab
Torsten <ttl@justmail.de>
parents: 19197
diff changeset
2154 QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$");
2e6b34324d50 fix compile warning in gui editor tab
Torsten <ttl@justmail.de>
parents: 19197
diff changeset
2155 QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\\s]+)[\t ]*$");
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2156
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2157 QStringList lines = _edit_area->text ().split ("\n");
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2158
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2159 for (int i = 0; i < lines.count (); i++)
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2160 {
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2161 if (rxfun1.indexIn (lines.at (i)) != -1)
19197
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2162 return rxfun1.cap (1).remove (QRegExp("[ \t]*"));
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2163 else if (rxfun2.indexIn (lines.at (i)) != -1)
19197
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2164 return rxfun2.cap (1).remove (QRegExp("[ \t]*"));
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2165 else if (rxfun3.indexIn (lines.at (i)) != -1)
19197
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2166 return rxfun3.cap (1).remove (QRegExp("[ \t]*"));
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2167 else if (rxfun4.indexIn (lines.at (i)) != -1)
bf7c5d96d1ff improved regexp for file name suggestion when saving a new editor file
Torsten <ttl@justmail.de>
parents: 19196
diff changeset
2168 return rxfun4.cap (1).remove (QRegExp("[ \t]*"));
19024
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2169 }
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2170
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2171 return QString ();
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2172 }
0e6f7b5f6556 propose function name as file name when saving a new file (bug #42568)
Torsten <ttl@justmail.de>
parents: 19023
diff changeset
2173
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15860
diff changeset
2174 #endif