Mercurial > hg > octave-nkf
diff libgui/src/m-editor/file-editor-tab.cc @ 16635:25e418d23a4b
fix running files from file browser's context menu
* main-window.cc(run_file_in_terminal): new slot for run_file_signal
(run_file_callback): callback for running files after checking the path
* main-window.h: new functions run_file_in_terminal und run_file_callback)
* files-dock-widget.cc(constructor): connect signal to slot for running files
(contextmenu_run): emit run_file_signal with QFileInfo as parameter
* files-dock-widget.h: run_file_signal has QFileInfo as parameter
* file-editor-tab.cc: removed function run_file_callback
(run_file): get file info of current file and emit run_file_signal
(file_in_path): moved to octave_qt_link allowiung access from other widgets,
updated calls to this functions
* file-editor-tab.h: new run_file_signal with QFileInfo, removed functions
run_file_callback and file_in_path
* file-editor.cc(add_file_editor_tab): connect signal to slot for running files
* octave-qt-link.cc/h(file_in_path): moved from file-editor-tab and made static
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 10 May 2013 21:01:02 +0200 |
parents | 2931e9282190 |
children | 3c2e457eeb72 |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -48,14 +48,8 @@ #include "file-editor-tab.h" #include "file-editor.h" -#include "cmd-edit.h" - -#include "builtin-defun-decls.h" #include "debug.h" -#include "load-path.h" -#include "octave-link.h" -#include "oct-env.h" -#include "utils.h" +#include "octave-qt-link.h" // Make parent null for the file editor tab so that warning // WindowModal messages don't affect grandparents. @@ -355,25 +349,6 @@ delete printer; } - -void -file_editor_tab::run_file_callback (const bp_info& info) -{ - if (file_in_path (info.file, info.dir)) - { - std::string pending_input = command_editor::get_current_line (); - - command_editor::set_initial_input (pending_input); - - command_editor::replace_line (info.function_name); - command_editor::redisplay (); - - // We are executing inside the command editor event loop. Force - // the current line to be returned for processing. - command_editor::interrupt (); - } -} - void file_editor_tab::run_file (const QWidget *ID) { @@ -383,14 +358,8 @@ if (_edit_area->isModified ()) save_file (_file_name); - QFileInfo file_info (_file_name); - QString dir = file_info.absolutePath (); - QString function_name = file_info.fileName (); - function_name.chop (file_info.suffix ().length () + 1); - - bp_info info (_file_name, dir, function_name, 1); - - octave_link::post_event (this, &file_editor_tab::run_file_callback, info); + QFileInfo info (_file_name); + emit run_file_signal (info); } void @@ -451,77 +420,13 @@ _edit_area->markerDeleteAll (bookmark); } -bool -file_editor_tab::file_in_path (const std::string& file, const std::string& dir) -{ - bool ok = false; - bool addpath_option = true; - - std::string curr_dir = octave_env::get_current_directory (); - - if (same_file (curr_dir, dir)) - ok = true; - else - { - bool dir_in_load_path = load_path::contains_canonical (dir); - - std::string base_file = octave_env::base_pathname (file); - std::string lp_file = load_path::find_file (base_file); - - if (dir_in_load_path) - { - if (same_file (lp_file, file)) - ok = true; - } - else - { - // File directory is not in path. Is the file in the path in - // the current directory? If so, then changing the current - // directory will be needed. Adding directory to path is - // not enough because the file in the current directory would - // still be found. - - if (same_file (lp_file, base_file)) - { - if (same_file (curr_dir, dir)) - ok = true; - else - addpath_option = false; - } - } - } - - if (! ok) - { - int action - = octave_link::debug_cd_or_addpath_error (file, dir, addpath_option); - switch (action) - { - case 1: - Fcd (ovl (dir)); - ok = true; - break; - - case 2: - load_path::prepend (dir); - ok = true; - break; - - default: - break; - } - } - - return ok; -} - void file_editor_tab::add_breakpoint_callback (const bp_info& info) { bp_table::intmap line_info; line_info[0] = info.line; - if (file_in_path (info.file, info.dir)) + if (octave_qt_link::file_in_path (info.file, info.dir)) bp_table::add_breakpoint (info.function_name, line_info); } @@ -531,14 +436,14 @@ bp_table::intmap line_info; line_info[0] = info.line; - if (file_in_path (info.file, info.dir)) + if (octave_qt_link::file_in_path (info.file, info.dir)) bp_table::remove_breakpoint (info.function_name, line_info); } void file_editor_tab::remove_all_breakpoints_callback (const bp_info& info) { - if (file_in_path (info.file, info.dir)) + if (octave_qt_link::file_in_path (info.file, info.dir)) bp_table::remove_all_breakpoints_in_file (info.function_name, true); }