Mercurial > octave
changeset 33533:e89b2f30867d bytecode-interpreter
maint: Merge default to bytecode-interpreter
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Sun, 05 May 2024 18:12:44 -0400 |
parents | 4aec1230dd8f (current diff) 5157dd5a6c9a (diff) |
children | e17dbda5f34f |
files | |
diffstat | 11 files changed, 101 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/files-dock-widget.cc Sun May 05 18:12:44 2024 -0400 @@ -872,7 +872,7 @@ QModelIndex index = rows[0]; QFileInfo info = m_file_system_model->fileInfo (index); - emit run_file_signal (info); + emit run_file_signal (info, ED_RUN_FILE); } }
--- a/libgui/src/files-dock-widget.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/files-dock-widget.h Sun May 05 18:12:44 2024 -0400 @@ -79,7 +79,7 @@ //! Emitted, whenever the user requested to run a file. - void run_file_signal (const QFileInfo& info); + void run_file_signal (const QFileInfo& info, int ops); //! Emitted, whenever wants to search for a file .
--- a/libgui/src/gui-preferences-global.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/gui-preferences-global.h Sun May 05 18:12:44 2024 -0400 @@ -134,6 +134,15 @@ "Fusion-Dark" }; +// Different modes for running a file from editor +enum +{ + ED_RUN_FILE = 0, + ED_STEP_INTO, + ED_RUN_TESTS, + ED_RUN_DEMOS +}; + #if defined (Q_OS_MAC) // prevent native file dialogs on MAC by setting the default "false" and // setting the flag for ignoring the pref to "true" (3rd argument)
--- a/libgui/src/gui-preferences-sc.cc Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/gui-preferences-sc.cc Sun May 05 18:12:44 2024 -0400 @@ -205,6 +205,8 @@ // run sc_pref sc_edit_run_run_file (QCoreApplication::translate ("shortcuts", "Run File"), sc_edit_run + ":run_file", OCTAVE_QT_KEYCOMBINATION (PRE, Qt::Key_F5)); sc_pref sc_edit_run_run_selection (QCoreApplication::translate ("shortcuts", "Run Selection"), sc_edit_run + ":run_selection", OCTAVE_QT_KEYCOMBINATION (PRE, Qt::Key_F9)); +sc_pref sc_edit_run_run_tests (QCoreApplication::translate ("shortcuts", "Run Tests"), sc_edit_run + ":run_file", OCTAVE_QT_KEYCOMBINATION (CTRL, Qt::Key_F5)); +sc_pref sc_edit_run_run_demos (QCoreApplication::translate ("shortcuts", "Run Demos"), sc_edit_run + ":run_file", OCTAVE_QT_KEYCOMBINATION (CTRL_SHIFT, Qt::Key_F5)); // help sc_pref sc_edit_help_help_keyword (QCoreApplication::translate ("shortcuts", "Help on Keyword"), sc_edit_help + ":help_keyword", QKeySequence::HelpContents);
--- a/libgui/src/gui-preferences-sc.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/gui-preferences-sc.h Sun May 05 18:12:44 2024 -0400 @@ -255,6 +255,8 @@ const QString sc_edit_run ("editor_run"); extern sc_pref sc_edit_run_run_file; extern sc_pref sc_edit_run_run_selection; +extern sc_pref sc_edit_run_run_tests; +extern sc_pref sc_edit_run_run_demos; // help const QString sc_edit_help ("editor_help");
--- a/libgui/src/m-editor/file-editor-tab.cc Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/m-editor/file-editor-tab.cc Sun May 05 18:12:44 2024 -0400 @@ -68,13 +68,14 @@ #include <Qsci/qscilexerperl.h> #include <Qsci/qsciprinter.h> -#include "file-editor-tab.h" -#include "file-editor.h" #include "gui-preferences-cs.h" #include "gui-preferences-ed.h" #include "gui-preferences-global.h" #include "gui-settings.h" #include "gui-utils.h" +#include "main-window.h" +#include "file-editor-tab.h" +#include "file-editor.h" #include "marker.h" #include "octave-txt-lexer.h" @@ -1091,7 +1092,7 @@ } void -file_editor_tab::run_file (const QWidget *ID, bool step_into) +file_editor_tab::run_file (const QWidget *ID, int opts) { if (ID != this) return; @@ -1107,7 +1108,9 @@ return; } - if (step_into) + int actual_opts = opts; + + if (opts == ED_STEP_INTO) { // Get current first breakpoint and set breakpoint waiting for // the returned line number. Store whether to remove this breakpoint @@ -1121,10 +1124,11 @@ // Add breakpoint, storing its line number handle_request_add_breakpoint (1, QString ()); + actual_opts = ED_RUN_FILE; } QFileInfo info (m_file_name); - emit run_file_signal (info); + emit run_file_signal (info, actual_opts); } void
--- a/libgui/src/m-editor/file-editor-tab.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/m-editor/file-editor-tab.h Sun May 05 18:12:44 2024 -0400 @@ -82,7 +82,7 @@ void mru_add_file (const QString& file_name, const QString& encoding); void editor_check_conflict_save (const QString& saveFileName, bool remove_on_success); - void run_file_signal (const QFileInfo& info); + void run_file_signal (const QFileInfo& info, int opts); void request_open_file (const QString&, const QString& = QString ()); void edit_mfile_request (const QString&, const QString&, const QString&, int); @@ -150,7 +150,7 @@ bool remove_on_success); void save_file_as (const QWidget *ID); void print_file (const QWidget *ID); - void run_file (const QWidget *ID, bool step_into = false); + void run_file (const QWidget *ID, int opts); void context_run (const QWidget *ID); void toggle_bookmark (const QWidget *ID); void next_bookmark (const QWidget *ID);
--- a/libgui/src/m-editor/file-editor.cc Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/m-editor/file-editor.cc Sun May 05 18:12:44 2024 -0400 @@ -46,10 +46,10 @@ #include <QVBoxLayout> #include <Qsci/qscicommandset.h> +#include "gui-preferences-global.h" #include "file-editor.h" #include "gui-preferences-ed.h" #include "gui-preferences-sc.h" -#include "gui-preferences-global.h" #include "gui-settings.h" #include "main-window.h" @@ -714,7 +714,7 @@ } void -file_editor::request_run_file (bool) +file_editor::run_file (bool, int opts) { // The interpreter_event callback function below emits a signal. // Because we don't control when that happens, use a guarded pointer @@ -723,7 +723,7 @@ QPointer<file_editor> this_fe (this); emit interpreter_event - ([this, this_fe] (interpreter& interp) + ([this, this_fe, opts] (interpreter& interp) { // INTERPRETER THREAD @@ -745,14 +745,32 @@ if (tw.in_debug_repl ()) emit request_dbcont_signal (); else - emit fetab_run_file (m_tab_widget->currentWidget ()); + emit fetab_run_file (m_tab_widget->currentWidget (), opts); }); } void +file_editor::request_run_file (bool) +{ + run_file (true, ED_RUN_FILE); +} + +void +file_editor::request_run_tests (bool) +{ + run_file (true, ED_RUN_TESTS); +} + +void +file_editor::request_run_demos (bool) +{ + run_file (true, ED_RUN_DEMOS); +} + +void file_editor::request_step_into_file () { - emit fetab_run_file (m_tab_widget->currentWidget (), true); + emit fetab_run_file (m_tab_widget->currentWidget (), ED_STEP_INTO); } void @@ -1559,6 +1577,8 @@ // Run menu settings.set_shortcut (m_run_action, sc_edit_run_run_file); settings.set_shortcut (m_run_selection_action, sc_edit_run_run_selection); + settings.set_shortcut (m_run_tests_action, sc_edit_run_run_tests); + settings.set_shortcut (m_run_demos_action, sc_edit_run_run_demos); // Help menu settings.set_shortcut (m_context_help_action, sc_edit_help_help_keyword); @@ -2430,6 +2450,16 @@ SLOT (request_context_run (bool))); m_run_selection_action->setEnabled (false); + m_run_tests_action + = add_action (_run_menu, + tr ("Save File and Run All &Tests"), + SLOT (request_run_tests (bool))); + + m_run_demos_action + = add_action (_run_menu, + tr ("Save File and Run All &Demos"), + SLOT (request_run_demos (bool))); + // help menu QMenu *_help_menu = add_menu (m_menu_bar, tr ("&Help"));
--- a/libgui/src/m-editor/file-editor.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/m-editor/file-editor.h Sun May 05 18:12:44 2024 -0400 @@ -140,7 +140,7 @@ void fetab_save_file (const QWidget *ID); void fetab_save_file_as (const QWidget *ID); void fetab_print_file (const QWidget *ID); - void fetab_run_file (const QWidget *ID, bool step_into = false); + void fetab_run_file (const QWidget *ID, int opts); void fetab_context_run (const QWidget *ID); void fetab_toggle_bookmark (const QWidget *ID); void fetab_next_bookmark (const QWidget *ID); @@ -188,7 +188,7 @@ void update_gui_lexer_signal (bool); void execute_command_in_terminal_signal (const QString&); void focus_console_after_command_signal (); - void run_file_signal (const QFileInfo&); + void run_file_signal (const QFileInfo&, int opts); void edit_mfile_request (const QString&, const QString&, const QString&, int); void debug_quit_signal (); @@ -222,6 +222,8 @@ void request_save_file (bool); void request_save_file_as (bool); void request_run_file (bool); + void request_run_tests (bool); + void request_run_demos (bool); void request_step_into_file (); void request_context_run (bool); void request_toggle_bookmark (bool); @@ -321,6 +323,8 @@ void request_preferences (bool); void request_styles_preferences (bool); + void run_file (bool, int opts); + void show_line_numbers (bool); void show_white_space (bool); void show_eol_chars (bool); @@ -441,6 +445,8 @@ QAction *m_print_action; QAction *m_run_action; QAction *m_run_selection_action; + QAction *m_run_tests_action; + QAction *m_run_demos_action; QAction *m_edit_function_action; QAction *m_popdown_mru_action;
--- a/libgui/src/main-window.cc Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/main-window.cc Sun May 05 18:12:44 2024 -0400 @@ -56,10 +56,6 @@ // QTerminal includes #include "QTerminal.h" -#if defined (HAVE_QSCINTILLA) -# include "file-editor.h" -# include "command-widget.h" -#endif #include "gui-preferences-cs.h" #include "gui-preferences-dw.h" #include "gui-preferences-ed.h" @@ -68,6 +64,10 @@ #include "gui-preferences-nr.h" #include "gui-preferences-sc.h" #include "gui-settings.h" +#if defined (HAVE_QSCINTILLA) +# include "file-editor.h" +# include "command-widget.h" +#endif #include "gui-utils.h" #include "interpreter-qobject.h" #include "main-window.h" @@ -1191,10 +1191,10 @@ } void -main_window::run_file_in_terminal (const QFileInfo& info) +main_window::run_file_in_terminal (const QFileInfo& info, int opts) { emit interpreter_event - ([info] (interpreter& interp) + ([this, opts, info] (interpreter& interp) { // INTERPRETER THREAD @@ -1221,22 +1221,39 @@ std::string path = info.absolutePath ().toStdString (); if (lp.contains_file_in_dir (file_path, path)) - command_editor::replace_line (function_name.toStdString ()); + { + QString cmd; + if (opts == ED_RUN_TESTS) + cmd = "test "; + else if (opts == ED_RUN_DEMOS) + cmd = "demo "; + cmd = cmd + function_name; + + if (m_octave_qobj.experimental_terminal_widget ()) + emit execute_command_signal (cmd); + else + command_editor::replace_line (cmd.toStdString ()); + } } else { // No valid identifier: use equivalent of Fsource (), no // debug possible. - interp.source_file (file_path); - - command_editor::replace_line (""); + if (opts == ED_RUN_FILE) + { + interp.source_file (file_path); + command_editor::replace_line (""); + } } - command_editor::set_initial_input (pending_input); - command_editor::redisplay (); - command_editor::interrupt_event_loop (); - command_editor::accept_line (); + if (! m_octave_qobj.experimental_terminal_widget ()) + { + command_editor::set_initial_input (pending_input); + command_editor::redisplay (); + command_editor::interrupt_event_loop (); + command_editor::accept_line (); + } }); focus_console_after_command ();
--- a/libgui/src/main-window.h Sat May 04 08:31:05 2024 -0400 +++ b/libgui/src/main-window.h Sun May 05 18:12:44 2024 -0400 @@ -173,7 +173,7 @@ void accept_directory_line_edit (); void execute_command_in_terminal (const QString& dir); - void run_file_in_terminal (const QFileInfo& info); + void run_file_in_terminal (const QFileInfo& info, int opts); void handle_new_figure_request ();