Mercurial > octave
comparison libgui/src/main-window.cc @ 31068:0b402f523f09
allow executing a command in the new terminal widget
* command-widget.cc (console::new_command_line): Allow a new command
line with preset text;
(console::execute_command): Slot for executing a command
* command-widget.h, class console: new_command_line with optional
string argument, new functions execute_command and get_console
* main-window.cc (adopt_terminal_widget): connect execute command
signal with related signal in terminal widget;
(execute_command_in_terminal): in case of exp. terminal widget,
emit new signal execute_command_signal
* main-window.h: new signal execute_command_signal
* terminal-dock-widget.cc (terminal_dock_widget): connect own
execute signal to the slot in the console
* terminal-dock-widget.h: new signal execute_command_signal
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 04 Jun 2022 22:17:58 +0200 |
parents | 5261a81765b0 |
children | a44009224387 |
comparison
equal
deleted
inserted
replaced
31067:5261a81765b0 | 31068:0b402f523f09 |
---|---|
280 this, &main_window::set_screen_size); | 280 this, &main_window::set_screen_size); |
281 | 281 |
282 connect (cmd_widget, &QTerminal::clear_command_window_request, | 282 connect (cmd_widget, &QTerminal::clear_command_window_request, |
283 this, &main_window::handle_clear_command_window_request); | 283 this, &main_window::handle_clear_command_window_request); |
284 } | 284 } |
285 else | |
286 { | |
287 connect (this, &main_window::execute_command_signal, | |
288 m_command_window, &terminal_dock_widget::execute_command_signal); | |
289 } | |
285 } | 290 } |
286 | 291 |
287 void main_window::adopt_documentation_widget (void) | 292 void main_window::adopt_documentation_widget (void) |
288 { | 293 { |
289 m_doc_browser_window = m_octave_qobj.documentation_widget (this); | 294 m_doc_browser_window = m_octave_qobj.documentation_widget (this); |
1139 set_current_working_directory (dir); | 1144 set_current_working_directory (dir); |
1140 } | 1145 } |
1141 | 1146 |
1142 void main_window::execute_command_in_terminal (const QString& command) | 1147 void main_window::execute_command_in_terminal (const QString& command) |
1143 { | 1148 { |
1144 emit interpreter_event | 1149 if (m_octave_qobj.experimental_terminal_widget ()) |
1145 ([=] (void) | 1150 { |
1146 { | 1151 emit execute_command_signal (command); |
1147 // INTERPRETER THREAD | 1152 } |
1148 | 1153 else |
1149 std::string pending_input = command_editor::get_current_line (); | 1154 { |
1150 | 1155 emit interpreter_event |
1151 command_editor::set_initial_input (pending_input); | 1156 ([=] (void) |
1152 command_editor::replace_line (command.toStdString ()); | 1157 { |
1153 command_editor::redisplay (); | 1158 // INTERPRETER THREAD |
1154 command_editor::interrupt_event_loop (); | 1159 |
1155 command_editor::accept_line (); | 1160 std::string pending_input = command_editor::get_current_line (); |
1156 }); | 1161 |
1162 command_editor::set_initial_input (pending_input); | |
1163 command_editor::replace_line (command.toStdString ()); | |
1164 command_editor::redisplay (); | |
1165 command_editor::interrupt_event_loop (); | |
1166 command_editor::accept_line (); | |
1167 }); | |
1168 } | |
1157 | 1169 |
1158 focus_console_after_command (); | 1170 focus_console_after_command (); |
1159 } | 1171 } |
1160 | 1172 |
1161 void main_window::run_file_in_terminal (const QFileInfo& info) | 1173 void main_window::run_file_in_terminal (const QFileInfo& info) |