comparison libgui/src/m-editor/marker.cc @ 21009:ea50940c362f

added missing files for cset 0a09c3cae800 (bug #46779) * marker.cc, marker.h
author Torsten <ttl@justmail.de>
date Tue, 29 Dec 2015 22:58:56 +0100
parents
children 65827e9cccb8
comparison
equal deleted inserted replaced
21008:9c41a7ee5e14 21009:ea50940c362f
1 /*
2
3 Copyright (C) 2015 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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #ifdef HAVE_QSCINTILLA
28
29 #include <stdio.h>
30
31 #include "marker.h"
32
33
34 marker::marker (QsciScintilla *area, int original_linenr, editor_markers type,
35 int editor_linenr) : QObject ()
36 {
37 construct (area, original_linenr, type, editor_linenr);
38 }
39
40
41 marker::marker (QsciScintilla *area, int original_linenr,
42 editor_markers type) : QObject ()
43 {
44 construct (area, original_linenr, type, original_linenr - 1);
45 }
46
47
48 marker::~marker (void)
49 {
50 }
51
52
53 void
54 marker::construct (QsciScintilla *area, int original_linenr,
55 editor_markers type, int editor_linenr)
56 {
57 _edit_area = area;
58 _original_linenr = original_linenr;
59 _marker_type = type;
60 _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
61 }
62
63
64 void
65 marker::handle_remove_via_original_linenr (int linenr)
66 {
67 if (_original_linenr == linenr)
68 {
69 _edit_area->markerDeleteHandle(_mhandle);
70 delete this;
71 }
72 }
73
74
75 void
76 marker::handle_request_remove_via_editor_linenr (int linenr)
77 {
78 // Get line number from the edit area and if it matches
79 // the requested line number, remove.
80 if (_edit_area->markerLine (_mhandle) == linenr)
81 {
82 // Rather than delete editor marker directly, issue command
83 // to Octave core. Octave core should signal back to remove
84 // this breakpoint via debugger line number.
85 emit request_remove (_original_linenr);
86 }
87 }
88
89
90 void
91 marker::handle_remove (void)
92 {
93 _edit_area->markerDeleteHandle (_mhandle);
94 delete this;
95 }
96
97
98 void
99 marker::handle_find_translation (int linenr, int& translation_linenr)
100 {
101 if (_original_linenr == linenr)
102 translation_linenr = _edit_area->markerLine (_mhandle);
103 }
104
105
106 void
107 marker::handle_find_just_before (int linenr, int& original_linenr, int& editor_linenr)
108 {
109 if (_original_linenr < linenr && _original_linenr >= original_linenr)
110 {
111 original_linenr = _original_linenr;
112 editor_linenr = _edit_area->markerLine (_mhandle);
113 }
114 }
115
116
117 void
118 marker::handle_find_just_after (int linenr, int& original_linenr, int& editor_linenr)
119 {
120 if (_original_linenr > linenr && _original_linenr <= original_linenr)
121 {
122 original_linenr = _original_linenr;
123 editor_linenr = _edit_area->markerLine (_mhandle);
124 }
125 }
126
127
128 void
129 marker::handle_report_editor_linenr (QIntList& list)
130 {
131 list << _edit_area->markerLine (_mhandle);
132 }
133
134
135 void
136 marker::handle_marker_line_deleted (int mhandle)
137 {
138 // FUTURE SUPPORT: There really should be a signal in QsciScintilla
139 // called markerLineDeleted (int mhandle) because there is no way
140 // of knowing this. QsciScintilla will place the marker at a
141 // different line rather than remove it from the margin. I (DJS) will
142 // lobby for such a signal.
143 if (_mhandle == mhandle)
144 {
145 if (_marker_type == breakpoint || _marker_type == debugger_position)
146 {
147 int editor_linenr = _edit_area->markerLine (_mhandle);
148 _edit_area->markerDeleteHandle(_mhandle);
149 _marker_type = _marker_type == breakpoint ? unsure_breakpoint
150 : unsure_debugger_position;
151 _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
152 }
153 }
154 }
155
156
157 void
158 marker::handle_marker_line_undeleted (int mhandle)
159 {
160 // FUTURE SUPPORT: There really should be a signal in QsciScintilla
161 // called markerLineUndeleted (int mhandle) because there is no way
162 // of knowing this. QsciScintilla will place the marker at a
163 // different line rather than remove it from the margin. I (DJS) will
164 // lobby for such a signal.
165 if (_mhandle == mhandle)
166 {
167 if (_marker_type == unsure_breakpoint || _marker_type == unsure_debugger_position)
168 {
169 int editor_linenr = _edit_area->markerLine (_mhandle);
170 _edit_area->markerDeleteHandle(_mhandle);
171 _marker_type = _marker_type == unsure_breakpoint ? breakpoint
172 : debugger_position;
173 _mhandle = _edit_area->markerAdd (editor_linenr, _marker_type);
174 }
175 }
176 }
177
178 #endif