comparison gui/src/octave-adapter/octave-event.h @ 14827:6b90737f69cc gui

Very basic breakpoint setting and removing in the editor works. * file-editor-tab: Instead of toggling breakpoints directly, now sends events. * octave-event: Created new events to add and remove breakpoints.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 02 Jul 2012 12:35:08 +0200
parents 61c80e9326a8
children e97be88fc478
comparison
equal deleted inserted replaced
14826:ed0f820c7ce0 14827:6b90737f69cc
248 } 248 }
249 return true; 249 return true;
250 } 250 }
251 }; 251 };
252 252
253 class octave_add_breakpoint_event : public octave_event
254 {
255 public:
256 octave_add_breakpoint_event (octave_event_observer& o,
257 std::string path,
258 std::string function_name,
259 int line)
260 : octave_event (o)
261 {
262 _path = path;
263 _function_name = function_name;
264 _line = line;
265 }
266
267 bool perform ()
268 {
269 bp_table::intmap intmap;
270 intmap[0] = _line;
271
272 // TODO: Check success.
273 std::string previous_directory = octave_env::get_current_directory ();
274 octave_env::chdir (_path);
275 bp_table::add_breakpoint (_function_name, intmap);
276 octave_env::chdir (previous_directory);
277 return true;
278 }
279
280 std::string get_path ()
281 {
282 return _path;
283 }
284
285 std::string get_function_name ()
286 {
287 return _function_name;
288 }
289
290 int get_line ()
291 {
292 return _line;
293 }
294
295 private:
296 std::string _path;
297 std::string _function_name;
298 int _line;
299 };
300
301 class octave_remove_breakpoint_event : public octave_event
302 {
303 public:
304 octave_remove_breakpoint_event (octave_event_observer& o,
305 std::string path,
306 std::string function_name,
307 int line)
308 : octave_event (o)
309 {
310 _path = path;
311 _function_name = function_name;
312 _line = line;
313 }
314
315 bool perform ()
316 {
317 bp_table::intmap intmap;
318 intmap[0] = _line;
319
320 // TODO: Check success.
321 std::string previous_directory = octave_env::get_current_directory ();
322 octave_env::chdir (_path);
323 bp_table::remove_breakpoint (_function_name, intmap);
324 octave_env::chdir (previous_directory);
325 return true;
326 }
327
328 std::string get_path ()
329 {
330 return _path;
331 }
332
333 std::string get_function_name ()
334 {
335 return _function_name;
336 }
337
338 int get_line ()
339 {
340 return _line;
341 }
342
343 private:
344 std::string _path;
345 std::string _function_name;
346 int _line;
347 };
348
349 class octave_remove_all_breakpoints_event : public octave_event
350 {
351 public:
352 octave_remove_all_breakpoints_event (octave_event_observer& o,
353 std::string file)
354 : octave_event (o)
355 {
356 _file = file;
357 }
358
359 bool perform ()
360 {
361 // TODO: Check success.
362 bp_table::remove_all_breakpoints_in_file (_file, true);
363 return true;
364 }
365
366 private:
367 std::string _file;
368 };
369
253 class octave_debug_step_into_event : public octave_event 370 class octave_debug_step_into_event : public octave_event
254 { 371 {
255 public: 372 public:
256 /** Creates a new octave_debug_step_into_event. */ 373 /** Creates a new octave_debug_step_into_event. */
257 octave_debug_step_into_event (octave_event_observer& o) 374 octave_debug_step_into_event (octave_event_observer& o)