GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
marker.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2017 Daniel J. Sebald
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #if defined (HAVE_QSCINTILLA)
28 
29 #include "marker.h"
30 
31 
32 marker::marker (QsciScintilla *area, int original_linenr, editor_markers type,
33  int editor_linenr, const QString& condition) : QObject ()
34 {
35  construct (area, original_linenr, type, editor_linenr, condition);
36 }
37 
38 
39 marker::marker (QsciScintilla *area, int original_linenr,
40  editor_markers type, const QString& condition) : QObject ()
41 {
42  construct (area, original_linenr, type, original_linenr - 1, condition);
43 }
44 
45 
47 { }
48 
49 
50 void
51 marker::construct (QsciScintilla *area, int original_linenr,
52  editor_markers type, int editor_linenr,
53  const QString& condition)
54 {
55  _edit_area = area;
56  _original_linenr = original_linenr;
58  _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
59  _condition = condition;
60 }
61 
62 
63 void
65 {
66  if (_original_linenr == linenr)
67  {
68  _edit_area->markerDeleteHandle(_mhandle);
69  delete this;
70  }
71 }
72 
73 
74 void
76 {
77  // Get line number from the edit area and if it matches
78  // the requested line number, remove.
79  if (_edit_area->markerLine (_mhandle) == linenr)
80  {
81  // Rather than delete editor marker directly, issue command
82  // to Octave core. Octave core should signal back to remove
83  // this breakpoint via debugger line number.
85  }
86 }
87 
88 
89 void
91 {
92  _edit_area->markerDeleteHandle (_mhandle);
93  delete this;
94 }
95 
96 
97 void
98 marker::handle_find_translation (int linenr, int& translation_linenr,
99  marker *& bp)
100 {
101  if (_original_linenr == linenr)
102  {
103  translation_linenr = _edit_area->markerLine (_mhandle);
104  bp = this;
105  }
106 }
107 
108 
109 void
110 marker::handle_find_just_before (int linenr, int& original_linenr,
111  int& editor_linenr)
112 {
113  if (_original_linenr < linenr && _original_linenr >= original_linenr)
114  {
115  original_linenr = _original_linenr;
116  editor_linenr = _edit_area->markerLine (_mhandle);
117  }
118 }
119 
120 
121 void
122 marker::handle_find_just_after (int linenr, int& original_linenr,
123  int& editor_linenr)
124 {
125  if (_original_linenr > linenr && _original_linenr <= original_linenr)
126  {
127  original_linenr = _original_linenr;
128  editor_linenr = _edit_area->markerLine (_mhandle);
129  }
130 }
131 
132 
133 void
134 marker::handle_report_editor_linenr (QIntList& lines, QStringList& conditions)
135 {
136  lines << _edit_area->markerLine (_mhandle);
137  conditions << _condition;
138 }
139 
140 
141 void
143 {
144  // FUTURE SUPPORT: There really should be a signal in QsciScintilla
145  // called markerLineDeleted (int mhandle) because there is no way
146  // of knowing this. QsciScintilla will place the marker at a
147  // different line rather than remove it from the margin. I (DJS) will
148  // lobby for such a signal.
149  if (_mhandle == mhandle)
150  {
152  {
153  int editor_linenr = _edit_area->markerLine (_mhandle);
154  _edit_area->markerDeleteHandle(_mhandle);
157  _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
158  }
159  }
160 }
161 
162 
163 void
165 {
166  // FUTURE SUPPORT: There really should be a signal in QsciScintilla
167  // called markerLineUndeleted (int mhandle) because there is no way
168  // of knowing this. QsciScintilla will place the marker at a
169  // different line rather than remove it from the margin. I (DJS) will
170  // lobby for such a signal.
171  if (_mhandle == mhandle)
172  {
175  {
176  int editor_linenr = _edit_area->markerLine (_mhandle);
177  _edit_area->markerDeleteHandle(_mhandle);
180  _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
181  }
182  }
183 }
184 
185 #endif
void request_remove(int original_linenr)
Definition: moc-marker.cc:129
QString _condition
Definition: marker.h:96
int _mhandle
Definition: marker.h:95
void construct(QsciScintilla *edit_area, int original_linenr, editor_markers marker_type, int editor_linenr, const QString &condition)
Definition: marker.cc:51
editor_markers
Definition: marker.h:48
QsciScintilla * _edit_area
Definition: marker.h:92
void handle_find_just_after(int linenr, int &original_linenr, int &editor_linenr)
Definition: marker.cc:122
editor_markers _marker_type
Definition: marker.h:94
void handle_find_translation(int original_linenr, int &editor_linenr, marker *&bp)
Definition: marker.cc:98
~marker(void)
Definition: marker.cc:46
void handle_report_editor_linenr(QIntList &lines, QStringList &conditions)
Definition: marker.cc:134
int _original_linenr
Definition: marker.h:93
void handle_request_remove_via_editor_linenr(int editor_linenr)
Definition: marker.cc:75
idx type
Definition: ov.cc:3129
void handle_marker_line_undeleted(int mhandle)
Definition: marker.cc:164
void handle_marker_line_deleted(int mhandle)
Definition: marker.cc:142
Definition: marker.h:39
void handle_remove_via_original_linenr(int original_linenr)
Definition: marker.cc:64
void handle_remove(void)
Definition: marker.cc:90
marker(QsciScintilla *edit_area, int original_linenr, editor_markers marker_type, const QString &condition="")
Definition: marker.cc:39
QList< int > QIntList
Definition: dialog.h:38
void handle_find_just_before(int linenr, int &original_linenr, int &editor_linenr)
Definition: marker.cc:110