GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
marker.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://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 namespace octave
32 {
33  marker::marker (QsciScintilla *area, int original_linenr,
34  editor_markers type, int editor_linenr,
35  const QString& condition)
36  : QObject ()
37  {
38  construct (area, original_linenr, type, editor_linenr, condition);
39  }
40 
41  marker::marker (QsciScintilla *area, int original_linenr,
42  editor_markers type, const QString& condition)
43  : QObject ()
44  {
45  construct (area, original_linenr, type, original_linenr - 1, condition);
46  }
47 
48  void marker::construct (QsciScintilla *area, int original_linenr,
49  editor_markers type, int editor_linenr,
50  const QString& condition)
51  {
52  m_edit_area = area;
53  m_original_linenr = original_linenr;
55  m_mhandle = m_edit_area->markerAdd (editor_linenr, m_marker_type);
56  m_condition = condition;
57  }
58 
60  {
61  if (m_original_linenr == linenr)
62  {
63  m_edit_area->markerDeleteHandle (m_mhandle);
64  delete this;
65  }
66  }
67 
69  {
70  // Get line number from the edit area and if it matches
71  // the requested line number, remove.
72  if (m_edit_area->markerLine (m_mhandle) == linenr)
73  {
74  // Rather than delete editor marker directly, issue command
75  // to Octave core. Octave core should signal back to remove
76  // this breakpoint via debugger line number.
78  }
79  }
80 
82  {
83  m_edit_area->markerDeleteHandle (m_mhandle);
84  delete this;
85  }
86 
87  void marker::handle_find_translation (int linenr, int& translation_linenr,
88  marker *& bp)
89  {
90  if (m_original_linenr == linenr)
91  {
92  translation_linenr = m_edit_area->markerLine (m_mhandle);
93  bp = this;
94  }
95  }
96 
97  void marker::handle_find_just_before (int linenr, int& original_linenr,
98  int& editor_linenr)
99  {
100  if (m_original_linenr < linenr && m_original_linenr >= original_linenr)
101  {
102  original_linenr = m_original_linenr;
103  editor_linenr = m_edit_area->markerLine (m_mhandle);
104  }
105  }
106 
107  void marker::handle_find_just_after (int linenr, int& original_linenr,
108  int& editor_linenr)
109  {
110  if (m_original_linenr > linenr && m_original_linenr <= original_linenr)
111  {
112  original_linenr = m_original_linenr;
113  editor_linenr = m_edit_area->markerLine (m_mhandle);
114  }
115  }
116 
118  QStringList& conditions)
119  {
120  lines << m_edit_area->markerLine (m_mhandle);
121  conditions << m_condition;
122  }
123 
125  {
126  // FUTURE SUPPORT: There really should be a signal in QsciScintilla
127  // called markerLineDeleted (int mhandle) because there is no way
128  // of knowing this. QsciScintilla will place the marker at a
129  // different line rather than remove it from the margin. I (DJS) will
130  // lobby for such a signal.
131  if (m_mhandle == mhandle)
132  {
134  {
135  int editor_linenr = m_edit_area->markerLine (m_mhandle);
136  m_edit_area->markerDeleteHandle (m_mhandle);
139  m_mhandle = m_edit_area->markerAdd (editor_linenr, m_marker_type);
140  }
141  }
142  }
143 
145  {
146  // FUTURE SUPPORT: There really should be a signal in QsciScintilla
147  // called markerLineUndeleted (int mhandle) because there is no way
148  // of knowing this. QsciScintilla will place the marker at a
149  // different line rather than remove it from the margin. I (DJS) will
150  // lobby for such a signal.
151  if (m_mhandle == mhandle)
152  {
155  {
156  int editor_linenr = m_edit_area->markerLine (m_mhandle);
157  m_edit_area->markerDeleteHandle (m_mhandle);
160  m_mhandle = m_edit_area->markerAdd (editor_linenr, m_marker_type);
161  }
162  }
163  }
164 }
165 #endif
void request_remove(int original_linenr)
void handle_marker_line_undeleted(int mhandle)
Definition: marker.cc:144
void construct(QsciScintilla *edit_area, int original_linenr, editor_markers marker_type, int editor_linenr, const QString &condition)
Definition: marker.cc:48
void handle_report_editor_linenr(QIntList &lines, QStringList &conditions)
Definition: marker.cc:117
void handle_remove_via_original_linenr(int original_linenr)
Definition: marker.cc:59
int m_original_linenr
Definition: marker.h:100
void handle_find_just_before(int linenr, int &original_linenr, int &editor_linenr)
Definition: marker.cc:97
marker(QsciScintilla *edit_area, int original_linenr, editor_markers marker_type, const QString &condition="")
Definition: marker.cc:41
editor_markers m_marker_type
Definition: marker.h:101
QString m_condition
Definition: marker.h:103
idx type
Definition: ov.cc:3114
void handle_marker_line_deleted(int mhandle)
Definition: marker.cc:124
void handle_find_translation(int original_linenr, int &editor_linenr, marker *&bp)
Definition: marker.cc:87
void handle_remove(void)
Definition: marker.cc:81
QsciScintilla * m_edit_area
Definition: marker.h:99
int m_mhandle
Definition: marker.h:102
QList< int > QIntList
Definition: dialog.h:38
void handle_find_just_after(int linenr, int &original_linenr, int &editor_linenr)
Definition: marker.cc:107
void handle_request_remove_via_editor_linenr(int editor_linenr)
Definition: marker.cc:68