Class: Cosmos::ScriptRunnerFrame
- Inherits:
-
Qt::Widget
- Object
- Qt::Base
- Qt::Widget
- Cosmos::ScriptRunnerFrame
- Defined in:
- lib/cosmos/tools/script_runner/script_runner_frame.rb
Overview
class ScriptRunnerDialog
Constant Summary collapse
- CMD_KEYWORDS =
%w(cmd cmd_no_range_check cmd_no_hazardous_check cmd_no_checks)
- TLM_KEYWORDS =
%w(tlm tlm_raw tlm_formatted tlm_with_units limits_enabled? \ enable_limits disable_limits wait_tolerance wait_tolerance_raw \ check_tolerance check_tolerance_raw wait_check_tolerance \ wait_check_tolerance_raw)
- SET_TLM_KEYWORDS =
%w(set_tlm set_tlm_raw)
- CHECK_KEYWORDS =
%w(check check_raw wait wait_raw wait_check wait_check_raw)
- @@instance =
nil
- @@run_thread =
nil
- @@breakpoints =
{}
- @@step_mode =
false
- @@line_delay =
0.1
- @@instrumented_cache =
{}
- @@file_cache =
{}
- @@output_thread =
nil
- @@limits_monitor_thread =
nil
- @@pause_on_error =
true
- @@monitor_limits =
false
- @@pause_on_red =
false
- @@show_backtrace =
false
- @@error =
nil
- @@output_sleeper =
Sleeper.new
- @@limits_sleeper =
Sleeper.new
- @@cancel_output =
false
- @@cancel_limits =
false
Instance Attribute Summary collapse
-
#change_callback ⇒ Object
Returns the value of attribute change_callback.
-
#continue_after_error ⇒ Object
Returns the value of attribute continue_after_error.
-
#error_callback ⇒ Object
Returns the value of attribute error_callback.
-
#exceptions ⇒ Object
Returns the value of attribute exceptions.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#inline_return ⇒ Object
Returns the value of attribute inline_return.
-
#inline_return_params ⇒ Object
Returns the value of attribute inline_return_params.
-
#message_log ⇒ Object
readonly
Returns the value of attribute message_log.
-
#pause_callback ⇒ Object
Returns the value of attribute pause_callback.
-
#run_callback ⇒ Object
Returns the value of attribute run_callback.
-
#script_binding ⇒ Object
Returns the value of attribute script_binding.
-
#script_class ⇒ Object
readonly
Returns the value of attribute script_class.
-
#stop_callback ⇒ Object
Returns the value of attribute stop_callback.
-
#top_level_instrumented_cache ⇒ Object
readonly
Returns the value of attribute top_level_instrumented_cache.
-
#use_instrumentation ⇒ Object
Returns the value of attribute use_instrumentation.
Class Method Summary collapse
- .breakpoint(filename, line_number) ⇒ Object
- .clear_breakpoint(filename, line_number) ⇒ Object
- .clear_breakpoints(filename = nil) ⇒ Object
- .instance ⇒ Object
- .instance=(value) ⇒ Object
- .instrument_script(text, filename, mark_private = false) ⇒ Object
- .instrument_script_implementation(ruby_lex_utils, comments_removed_text, num_lines, progress_dialog, filename, mark_private = false) ⇒ Object
- .instrumented_cache ⇒ Object
- .instrumented_cache=(value) ⇒ Object
- .line_delay ⇒ Object
- .line_delay=(value) ⇒ Object
- .monitor_limits ⇒ Object
- .monitor_limits=(value) ⇒ Object
- .pause_on_error ⇒ Object
- .pause_on_error=(value) ⇒ Object
- .pause_on_red ⇒ Object
- .pause_on_red=(value) ⇒ Object
- .running? ⇒ Boolean
- .show_backtrace ⇒ Object
- .show_backtrace=(value) ⇒ Object
- .step_mode ⇒ Object
- .step_mode=(value) ⇒ Object
- .stop! ⇒ Object
Instance Method Summary collapse
- #allow_start=(value) ⇒ Object
- #breakpoint_cleared(line) ⇒ Object
-
#breakpoint_set(line) ⇒ Object
Implement the breakpoint callbacks from the RubyEditor.
- #breakpoints_cleared ⇒ Object
- #clear ⇒ Object
- #comment_or_uncomment_lines ⇒ Object
- #copy ⇒ Object
- #create_ruby_editor ⇒ Object
- #current_backtrace ⇒ Object
- #current_tab_filename ⇒ Object
- #cut ⇒ Object
- #dialog_find(dialog) ⇒ Object
- #dialog_replace(dialog) ⇒ Object
- #dialog_replace_all(dialog) ⇒ Object
- #disable_retry ⇒ Object
- #enable_retry ⇒ Object
- #exception_instrumentation(error, filename, line_number) ⇒ Object
-
#find ⇒ Object
Implement Search functionality in the frame (find, replace, etc).
- #find_next ⇒ Object
- #find_previous ⇒ Object
- #go ⇒ Object
- #go? ⇒ Boolean
- #graceful_kill ⇒ Object
- #handle_output_io(filename = @current_filename, line_number = @current_line_number) ⇒ Object
- #hide_debug ⇒ Object
-
#initialize(parent, default_tab_text = 'Untitled') ⇒ ScriptRunnerFrame
constructor
A new instance of ScriptRunnerFrame.
- #key_press_callback=(callback) ⇒ Object
- #mnemonic_check_selection ⇒ Object
- #mnemonic_check_text(text, start_line_number = 1) ⇒ Object
- #modified ⇒ Object
- #modified=(bool) ⇒ Object
- #paste ⇒ Object
- #pause ⇒ Object
- #pause? ⇒ Boolean
- #perform_breakpoint(filename, line_number) ⇒ Object
- #perform_pause ⇒ Object
- #post_line_instrumentation(filename, line_number) ⇒ Object
- #pre_line_instrumentation(filename, line_number) ⇒ Object
-
#prompt_if_running_on_close ⇒ Object
Prompts the user that a script is running before they close the app.
- #redo ⇒ Object
- #replace ⇒ Object
- #retry_needed ⇒ Object
- #retry_needed? ⇒ Boolean
- #ruby_syntax_check_selection ⇒ Object
- #ruby_syntax_check_text(text) ⇒ Object
- #run ⇒ Object
- #run_and_close_on_complete(text_binding = nil) ⇒ Object
- #run_from_cursor ⇒ Object
-
#run_selection ⇒ Object
Implement Script functionality in the frame (run selection, run from cursor, etc.
- #run_selection_while_paused ⇒ Object
- #running? ⇒ Boolean
- #scriptrunner_puts(string) ⇒ Object
- #select_all ⇒ Object
- #select_tab_and_destroy_tabs_after_index(index) ⇒ Object
- #set_text(text, filename = '') ⇒ Object
- #set_text_from_file(filename) ⇒ Object
- #setFocus ⇒ Object
- #show_debug ⇒ Object
- #stop? ⇒ Boolean
- #stop_message_log ⇒ Object
- #text ⇒ Object
-
#toggle_debug(debug = nil) ⇒ Object
Implement the debug capability.
- #toggle_disconnect(config_file) ⇒ Object
-
#undo ⇒ Object
Implement edit functionality in the frame (cut, copy, paste, etc).
- #undo_available(bool) ⇒ Object
Constructor Details
#initialize(parent, default_tab_text = 'Untitled') ⇒ ScriptRunnerFrame
Returns a new instance of ScriptRunnerFrame.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 115 def initialize(parent, default_tab_text = 'Untitled') super(parent) @default_tab_text = ' ' + default_tab_text + ' ' # Keep track of whether this frame has been fully initialized @initialized = false @debug_frame = nil @layout = Qt::VBoxLayout.new @layout.setContentsMargins(0,0,0,0) # Add Realtime Button Bar @realtime_button_bar = RealtimeButtonBar.new(self) @realtime_button_bar.state = 'Stopped' @realtime_button_bar.start_callback = method(:handle_start_go_button) @realtime_button_bar.pause_callback = method(:handle_pause_retry_button) @realtime_button_bar.stop_callback = method(:handle_stop_button) @layout.addWidget(@realtime_button_bar) # Create a splitter to hold the script text area and the script output text area. @splitter = Qt::Splitter.new(Qt::Vertical, self) @layout.addWidget(@splitter) @top_widget = Qt::Widget.new(@splitter) @top_widget.setContentsMargins(0,0,0,0) @top_frame = Qt::VBoxLayout.new(@top_widget) @top_frame.setContentsMargins(0,0,0,0) # Add Initial Text Window @script = create_ruby_editor() @script.connect(SIGNAL('modificationChanged(bool)')) do |changed| emit modificationChanged(changed) end @top_frame.addWidget(@script) # Set self as the gui window to allow prompts and other popups to appear set_cmd_tlm_gui_window(self) # Add change handlers connect(@script, SIGNAL('undoAvailable(bool)'), self, SLOT('undo_available(bool)')) # Add Output Text @bottom_frame = Qt::Widget.new @bottom_layout = Qt::VBoxLayout.new @bottom_layout.setContentsMargins(0,0,0,0) @bottom_layout_label = Qt::Label.new("Script Output:") @bottom_layout.addWidget(@bottom_layout_label) @output = Qt::PlainTextEdit.new @output.setReadOnly(true) @output.setMaximumBlockCount(10000) # 10000 lines of history will be displayed @bottom_layout.addWidget(@output) @bottom_frame.setLayout(@bottom_layout) @splitter.addWidget(@bottom_frame) @splitter.setStretchFactor(0,10) @splitter.setStretchFactor(1,1) setLayout(@layout) # Configure Variables @line_offset = 0 @filename = '' @output_io = StringIO.new('', 'r+') @output_io_mutex = Mutex.new @change_callback = nil @run_callback = nil @stop_callback = nil @error_callback = nil @pause_callback = nil @key_press_callback = nil @allow_start = true @continue_after_error = true @debug_text = nil @debug_history = [] @debug_code_completion = nil @top_level_instrumented_cache = nil @output_time = Time.now initialize_variables() # Redirect $stdout and $stderr redirect_io() # Create Tabbook @tab_book = Qt::TabWidget.new @tab_book_shown = false @find_dialog = nil @replace_dialog = nil mark_breakpoints('') end |
Instance Attribute Details
#change_callback ⇒ Object
Returns the value of attribute change_callback.
81 82 83 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 81 def change_callback @change_callback end |
#continue_after_error ⇒ Object
Returns the value of attribute continue_after_error.
87 88 89 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 87 def continue_after_error @continue_after_error end |
#error_callback ⇒ Object
Returns the value of attribute error_callback.
84 85 86 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 84 def error_callback @error_callback end |
#exceptions ⇒ Object
Returns the value of attribute exceptions.
88 89 90 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 88 def exceptions @exceptions end |
#filename ⇒ Object
Returns the value of attribute filename.
86 87 88 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 86 def filename @filename end |
#inline_return ⇒ Object
Returns the value of attribute inline_return.
90 91 92 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 90 def inline_return @inline_return end |
#inline_return_params ⇒ Object
Returns the value of attribute inline_return_params.
91 92 93 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 91 def inline_return_params @inline_return_params end |
#message_log ⇒ Object (readonly)
Returns the value of attribute message_log.
92 93 94 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 92 def @message_log end |
#pause_callback ⇒ Object
Returns the value of attribute pause_callback.
85 86 87 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 85 def pause_callback @pause_callback end |
#run_callback ⇒ Object
Returns the value of attribute run_callback.
82 83 84 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 82 def run_callback @run_callback end |
#script_binding ⇒ Object
Returns the value of attribute script_binding.
89 90 91 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 89 def script_binding @script_binding end |
#script_class ⇒ Object (readonly)
Returns the value of attribute script_class.
93 94 95 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 93 def script_class @script_class end |
#stop_callback ⇒ Object
Returns the value of attribute stop_callback.
83 84 85 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 83 def stop_callback @stop_callback end |
#top_level_instrumented_cache ⇒ Object (readonly)
Returns the value of attribute top_level_instrumented_cache.
94 95 96 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 94 def top_level_instrumented_cache @top_level_instrumented_cache end |
#use_instrumentation ⇒ Object
Returns the value of attribute use_instrumentation.
80 81 82 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 80 def use_instrumentation @use_instrumentation end |
Class Method Details
.breakpoint(filename, line_number) ⇒ Object
1057 1058 1059 1060 1061 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1057 def self.breakpoint(filename, line_number) filename = File.basename(filename) @@breakpoints[filename] ||= {} @@breakpoints[filename][line_number] = true end |
.clear_breakpoint(filename, line_number) ⇒ Object
1063 1064 1065 1066 1067 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1063 def self.clear_breakpoint(filename, line_number) filename = File.basename(filename) @@breakpoints[filename] ||= {} @@breakpoints[filename].delete(line_number) if @@breakpoints[filename][line_number] end |
.clear_breakpoints(filename = nil) ⇒ Object
1069 1070 1071 1072 1073 1074 1075 1076 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1069 def self.clear_breakpoints(filename = nil) filename = File.basename(filename) unless filename.nil? if filename == nil or filename.empty? @@breakpoints = {} else @@breakpoints[filename] = {} end end |
.instance ⇒ Object
295 296 297 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 295 def self.instance @@instance end |
.instance=(value) ⇒ Object
299 300 301 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 299 def self.instance=(value) @@instance = value end |
.instrument_script(text, filename, mark_private = false) ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 457 def self.instrument_script(text, filename, mark_private = false) if filename and !filename.empty? @@file_cache[filename] = text.clone end ruby_lex_utils = RubyLexUtils.new instrumented_text = '' # Add an extra newline because the Ruby 1.9.1 lexer RubyLex has a bug # where it loops unless the file ends in a newline. If there is already # a newline then so what, we add an extra. text += "\n" Qt.execute_in_main_thread(true) do window = Qt::CoreApplication.instance.activeWindow @cancel_instrumentation = false ProgressDialog.execute(window, # parent "Instrumenting: #{File.basename(filename.to_s)}", 500, # width 100, # height true, # show overall progress false, # don't show step progress false, # don't show text false, # don't show done true) do |progress_dialog| # show cancel progress_dialog.cancel_callback = lambda {|dialog| @cancel_instrumentation = true; [true, false]} progress_dialog. comments_removed_text = ruby_lex_utils.remove_comments(text) num_lines = comments_removed_text.num_lines.to_f num_lines = 1 if num_lines < 1 instrumented_text = instrument_script_implementation(ruby_lex_utils, comments_removed_text, num_lines, progress_dialog, filename, mark_private) progress_dialog.close_done end end Kernel.raise StopScript if @cancel_instrumentation or ProgressDialog.canceled? instrumented_text end |
.instrument_script_implementation(ruby_lex_utils, comments_removed_text, num_lines, progress_dialog, filename, mark_private = false) ⇒ Object
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 501 def self.instrument_script_implementation(ruby_lex_utils, comments_removed_text, num_lines, progress_dialog, filename, mark_private = false) if mark_private instrumented_text = 'private; ' else instrumented_text = '' end ruby_lex_utils.each_lexed_segment(comments_removed_text) do |segment, instrumentable, inside_begin, line_no| return nil if @cancel_instrumentation instrumented_line = '' if instrumentable # If not inside a begin block then create one to catch exceptions unless inside_begin instrumented_line << 'begin; ' end # Add preline instrumentation instrumented_line << "ScriptRunnerFrame.instance.script_binding = binding(); if ScriptRunnerFrame.instance.inline_return then ScriptRunnerFrame.instance.inline_return = nil; return ScriptRunnerFrame.instance.inline_return_params; end; ScriptRunnerFrame.instance.pre_line_instrumentation('#{filename}', #{line_no}); " # Add the actual line instrumented_line << segment instrumented_line.chomp! # Add postline instrumentation instrumented_line << "; ScriptRunnerFrame.instance.post_line_instrumentation('#{filename}', #{line_no})" # Complete begin block to catch exceptions unless inside_begin instrumented_line << "; rescue Exception => eval_error; retry if ScriptRunnerFrame.instance.exception_instrumentation(eval_error, '#{filename}', #{line_no}); end" end instrumented_line << "\n" else unless segment =~ /^\s*end\s*$/ or segment =~ /^\s*when .*$/ num_left_brackets = segment.count('{') num_right_brackets = segment.count('}') num_left_square_brackets = segment.count('[') num_right_square_brackets = segment.count(']') if (num_right_brackets > num_left_brackets) || (num_right_square_brackets > num_left_square_brackets) instrumented_line = segment else instrumented_line = "ScriptRunnerFrame.instance.pre_line_instrumentation('#{filename}', #{line_no}); " + segment end else instrumented_line = segment end end instrumented_text << instrumented_line progress_dialog.set_overall_progress(line_no / num_lines) if progress_dialog and line_no end instrumented_text end |
.instrumented_cache ⇒ Object
326 327 328 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 326 def self.instrumented_cache @@instrumented_cache end |
.instrumented_cache=(value) ⇒ Object
330 331 332 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 330 def self.instrumented_cache=(value) @@instrumented_cache = value end |
.line_delay ⇒ Object
318 319 320 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 318 def self.line_delay @@line_delay end |
.line_delay=(value) ⇒ Object
322 323 324 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 322 def self.line_delay=(value) @@line_delay = value end |
.monitor_limits ⇒ Object
342 343 344 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 342 def self.monitor_limits @@monitor_limits end |
.monitor_limits=(value) ⇒ Object
346 347 348 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 346 def self.monitor_limits=(value) @@monitor_limits = value end |
.pause_on_error ⇒ Object
334 335 336 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 334 def self.pause_on_error @@pause_on_error end |
.pause_on_error=(value) ⇒ Object
338 339 340 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 338 def self.pause_on_error=(value) @@pause_on_error = value end |
.pause_on_red ⇒ Object
350 351 352 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 350 def self.pause_on_red @@pause_on_red end |
.pause_on_red=(value) ⇒ Object
354 355 356 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 354 def self.pause_on_red=(value) @@pause_on_red = value end |
.running? ⇒ Boolean
390 391 392 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 390 def self.running? if @@run_thread then true else false end end |
.show_backtrace ⇒ Object
358 359 360 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 358 def self.show_backtrace @@show_backtrace end |
.show_backtrace=(value) ⇒ Object
362 363 364 365 366 367 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 362 def self.show_backtrace=(value) @@show_backtrace = value if @@show_backtrace and @@error puts Time.now.formatted + " (SCRIPTRUNNER): " + "Most recent exception:\n" + @@error.formatted end end |
.step_mode ⇒ Object
303 304 305 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 303 def self.step_mode @@step_mode end |
.step_mode=(value) ⇒ Object
307 308 309 310 311 312 313 314 315 316 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 307 def self.step_mode=(value) @@step_mode = value if self.instance if value self.instance.pause else self.instance.go end end end |
.stop! ⇒ Object
418 419 420 421 422 423 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 418 def self.stop! if @@run_thread Cosmos.kill_thread(nil, @@run_thread) @@run_thread = nil end end |
Instance Method Details
#allow_start=(value) ⇒ Object
279 280 281 282 283 284 285 286 287 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 279 def allow_start=(value) @allow_start = value if @allow_start @realtime_button_bar..setEnabled(true) elsif not running? @realtime_button_bar..setEnabled(false) @script.setReadOnly(true) end end |
#breakpoint_cleared(line) ⇒ Object
650 651 652 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 650 def breakpoint_cleared(line) ScriptRunnerFrame.clear_breakpoint(current_tab_filename(), line) end |
#breakpoint_set(line) ⇒ Object
Implement the breakpoint callbacks from the RubyEditor
646 647 648 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 646 def breakpoint_set(line) ScriptRunnerFrame.breakpoint(current_tab_filename(), line) end |
#breakpoints_cleared ⇒ Object
654 655 656 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 654 def breakpoints_cleared ScriptRunnerFrame.clear_breakpoints(current_tab_filename()) end |
#clear ⇒ Object
289 290 291 292 293 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 289 def clear self.set_text('') self.filename = '' self.modified = false end |
#comment_or_uncomment_lines ⇒ Object
685 686 687 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 685 def comment_or_uncomment_lines @script.comment_or_uncomment_lines unless running?() end |
#copy ⇒ Object
673 674 675 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 673 def copy @script.copy unless running?() end |
#create_ruby_editor ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 220 def create_ruby_editor # Add Initial Text Window script = RubyEditor.new(self) script.enable_breakpoints = true if @debug_frame connect(script, SIGNAL('breakpoint_set(int)'), self, SLOT('breakpoint_set(int)')) connect(script, SIGNAL('breakpoint_cleared(int)'), self, SLOT('breakpoint_cleared(int)')) connect(script, SIGNAL('breakpoints_cleared()'), self, SLOT('breakpoints_cleared()')) # Add right click menu script.setContextMenuPolicy(Qt::CustomContextMenu) connect(script, SIGNAL('customContextMenuRequested(const QPoint&)'), self, SLOT('context_menu(const QPoint&)')) return script end |
#current_backtrace ⇒ Object
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1145 def current_backtrace trace = [] Qt.execute_in_main_thread(true) do if @@run_thread temp_trace = @@run_thread.backtrace cosmos_lib = Regexp.new(File.join(Cosmos::PATH, 'lib')) temp_trace.each do |line| next if line =~ cosmos_lib trace << line end end end trace end |
#current_tab_filename ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 207 def current_tab_filename if @tab_book_shown filename = @tab_book.tabText(@tab_book.currentIndex) if filename == @default_tab_text return '' else return filename.strip end else return @filename end end |
#cut ⇒ Object
669 670 671 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 669 def cut @script.cut unless running?() end |
#dialog_find(dialog) ⇒ Object
738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 738 def dialog_find(dialog) found = @script.find(dialog.find_text, dialog.find_flags) if not found and dialog.wrap_around? cursor = @script.textCursor if dialog.find_up? cursor.movePosition(Qt::TextCursor::End) else cursor.movePosition(Qt::TextCursor::Start) end @script.setTextCursor(cursor) @script.find(dialog.find_text, dialog.find_flags) end end |
#dialog_replace(dialog) ⇒ Object
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 752 def dialog_replace(dialog) if @script.textCursor.hasSelection && @script.textCursor.selectedText == dialog.find_text found = true else found = @script.find(dialog.find_text, dialog.find_flags) if not found and dialog.wrap_around? cursor = @script.textCursor if dialog.find_up? cursor.movePosition(Qt::TextCursor::End) else cursor.movePosition(Qt::TextCursor::Start) end @script.setTextCursor(cursor) found = @script.find(dialog.find_text, dialog.find_flags) end end if found @script.textCursor.removeSelectedText @script.textCursor.insertText(dialog.replace_text) cursor = @script.textCursor cursor.setPosition(cursor.position-1) cursor.select(Qt::TextCursor::WordUnderCursor) @script.setTextCursor(cursor) end end |
#dialog_replace_all(dialog) ⇒ Object
779 780 781 782 783 784 785 786 787 788 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 779 def dialog_replace_all(dialog) cursor = @script.textCursor cursor.movePosition(Qt::TextCursor::Start) @script.setTextCursor(cursor) while (@script.find(dialog.find_text, dialog.find_flags) == true) @script.textCursor.removeSelectedText @script.textCursor.insertText(dialog.replace_text) end end |
#disable_retry ⇒ Object
437 438 439 440 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 437 def disable_retry @realtime_button_bar..setText('Skip') @realtime_button_bar..setDisabled(true) end |
#enable_retry ⇒ Object
442 443 444 445 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 442 def enable_retry @realtime_button_bar..setText('Go') @realtime_button_bar..setDisabled(false) end |
#exception_instrumentation(error, filename, line_number) ⇒ Object
602 603 604 605 606 607 608 609 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 602 def exception_instrumentation(error, filename, line_number) if error.class == StopScript || error.class == SkipTestCase || !@use_instrumentation Kernel.raise error else line_number = line_number + @line_offset if @active_script.object_id == @script.object_id handle_exception(error, false, filename, line_number) end end |
#find ⇒ Object
Implement Search functionality in the frame (find, replace, etc)
692 693 694 695 696 697 698 699 700 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 692 def find unless @find_dialog @find_dialog = FindReplaceDialog.new(@script) @find_dialog.connect(SIGNAL('find_next()')) { dialog_find(@find_dialog) } end @find_dialog.show @find_dialog.raise @find_dialog.activateWindow end |
#find_next ⇒ Object
702 703 704 705 706 707 708 709 710 711 712 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 702 def find_next flags = FindReplaceDialog.find_flags flags &= ~Qt::TextDocument::FindBackward.to_i found = @script.find(FindReplaceDialog.find_text, flags) if not found and FindReplaceDialog.wrap_around? cursor = @script.textCursor cursor.movePosition(Qt::TextCursor::Start) @script.setTextCursor(cursor) @script.find(FindReplaceDialog.find_text, flags) end end |
#find_previous ⇒ Object
714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 714 def find_previous flags = FindReplaceDialog.find_flags flags |= Qt::TextDocument::FindBackward.to_i found = @script.find(FindReplaceDialog.find_text, flags) if not found and FindReplaceDialog.wrap_around? cursor = @script.textCursor cursor.movePosition(Qt::TextCursor::End) @script.setTextCursor(cursor) @script.find(FindReplaceDialog.find_text, flags) end end |
#go ⇒ Object
398 399 400 401 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 398 def go @go = true @pause = false unless @@step_mode end |
#go? ⇒ Boolean
403 404 405 406 407 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 403 def go? temp = @go @go = false temp end |
#graceful_kill ⇒ Object
1220 1221 1222 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1220 def graceful_kill # Just to avoid warning end |
#handle_output_io(filename = @current_filename, line_number = @current_line_number) ⇒ Object
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1164 def handle_output_io(filename = @current_filename, line_number = @current_line_number) @output_time = Time.now Qt.execute_in_main_thread(true) do if @output_io.string[-1..-1] == "\n" time_formatted = Time.now.formatted lines_to_write = '' out_line_number = line_number.to_s out_filename = File.basename(filename) if filename # Build each line to write string = @output_io.string.clone @output_io.string = @output_io.string[string.length..-1] line_count = 0 string.each_line do |out_line| color = nil if out_line[0..1] == '20' and out_line[10] == ' ' and out_line[23..24] == ' (' line_to_write = out_line else if filename line_to_write = time_formatted + " (#{out_filename}:#{out_line_number}): " + out_line else line_to_write = time_formatted + " (SCRIPTRUNNER): " + out_line color = Cosmos::BLUE end end @output.add_formatted_text(line_to_write, color) lines_to_write += line_to_write line_count += 1 if line_count > 1000 out_line = "ERROR: Too much written to stdout. Truncating output to 1000 lines.\n" if filename line_to_write = time_formatted + " (#{out_filename}:#{out_line_number}): " + out_line else line_to_write = time_formatted + " (SCRIPTRUNNER): " + out_line end @output.addText(line_to_write, Cosmos::RED) lines_to_write += line_to_write break end end # string.each_line # Actually add to the GUI @output.flush # Add to the message log if @filename.empty? @message_log ||= MessageLog.new("sr_untitled") else @message_log ||= MessageLog.new("sr_#{File.basename(@filename).split('.')[0]}") end @message_log.write(lines_to_write) end end end |
#hide_debug ⇒ Object
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1038 def hide_debug # Since we're disabling debug, clear the breakpoints and disable them ScriptRunnerFrame.clear_breakpoints() @script.clear_breakpoints @script.enable_breakpoints = false if @tab_book_shown if @tab_book.count > 0 (0..(@tab_book.count - 1)).each do |index| @tab_book.tab(index).enable_breakpoints = false end end end # Remove the debug frame @bottom_frame.layout.takeAt(@bottom_frame.layout.count - 1) if @debug_frame @debug_frame.removeAll @debug_frame.dispose @debug_frame = nil end |
#key_press_callback=(callback) ⇒ Object
271 272 273 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 271 def key_press_callback=(callback) @script.keyPressCallback = callback end |
#mnemonic_check_selection ⇒ Object
864 865 866 867 868 869 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 864 def mnemonic_check_selection unless self.class.running?() selection = @script.selected_lines mnemonic_check_text(selection, @script.selection_start_line+1) if selection end end |
#mnemonic_check_text(text, start_line_number = 1) ⇒ Object
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 871 def mnemonic_check_text(text, start_line_number = 1) results = [] line_number = start_line_number text.each_line do |line| if line =~ /\(/ result = nil keyword = line.split('(')[0].split[-1] if CMD_KEYWORDS.include? keyword result = mnemonic_check_cmd_line(keyword, line_number, line) elsif TLM_KEYWORDS.include? keyword result = mnemonic_check_tlm_line(keyword, line_number, line) elsif SET_TLM_KEYWORDS.include? keyword result = mnemonic_check_set_tlm_line(keyword, line_number, line) elsif CHECK_KEYWORDS.include? keyword result = mnemonic_check_check_line(keyword, line_number, line) end results << result if result end line_number += 1 end if results.empty? Qt::MessageBox.information(self, 'Mnemonic Check Successful', 'Mnemonic Check Found No Errors') else dialog = Qt::Dialog.new(self) do |box| box.setWindowTitle('Mnemonic Check Failed') text = Qt::PlainTextEdit.new text.setReadOnly(true) text.setPlainText(results.join("\n")) frame = Qt::VBoxLayout.new(box) ok = Qt::PushButton.new('Ok') ok.setDefault(true) ok.connect(SIGNAL('clicked(bool)')) { box.accept } frame.addWidget(text) frame.addWidget(ok) end dialog.exec dialog.dispose end end |
#modified ⇒ Object
259 260 261 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 259 def modified @script.document.isModified() end |
#modified=(bool) ⇒ Object
263 264 265 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 263 def modified=(bool) @script.document.setModified(bool) end |
#paste ⇒ Object
677 678 679 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 677 def paste @script.paste unless running?() end |
#pause ⇒ Object
409 410 411 412 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 409 def pause @pause = true @go = false end |
#pause? ⇒ Boolean
414 415 416 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 414 def pause? @pause end |
#perform_breakpoint(filename, line_number) ⇒ Object
616 617 618 619 620 621 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 616 def perform_breakpoint(filename, line_number) mark_breakpoint() scriptrunner_puts "Hit Breakpoint at #{filename}:#{line_number}" handle_output_io(filename, line_number) wait_for_go_or_stop() end |
#perform_pause ⇒ Object
611 612 613 614 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 611 def perform_pause mark_paused() wait_for_go_or_stop() end |
#post_line_instrumentation(filename, line_number) ⇒ Object
595 596 597 598 599 600 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 595 def post_line_instrumentation(filename, line_number) if @use_instrumentation line_number = line_number + @line_offset if @active_script.object_id == @script.object_id handle_output_io(filename, line_number) end end |
#pre_line_instrumentation(filename, line_number) ⇒ Object
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 563 def pre_line_instrumentation(filename, line_number) @current_filename = filename @current_line_number = line_number if @use_instrumentation # Clear go @go = false # Handle stopping mid-script if necessary Kernel.raise StopScript if @stop # Handle needing to change tabs handle_potential_tab_change(filename) # Adjust line number for offset in main script line_number = line_number + @line_offset if @active_script.object_id == @script.object_id detail_string = nil if filename detail_string = File.basename(filename) << ':' << line_number.to_s end Logger.detail_string = detail_string # Highlight the line that is about to run Qt.execute_in_main_thread(true) {@active_script.highlight_line(line_number)} # Handle pausing the script handle_pause(filename, line_number) # Handle delay between lines handle_line_delay() end end |
#prompt_if_running_on_close ⇒ Object
Prompts the user that a script is running before they close the app
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 624 def prompt_if_running_on_close safe_to_continue = true if running? case Qt::MessageBox.warning( self, # parent 'Warning', # title 'A Script is Running! Close Anyways?', # text Qt::MessageBox::Yes | Qt::MessageBox::No, # buttons Qt::MessageBox::No) # default button when Qt::MessageBox::Yes safe_to_continue = true ScriptRunnerFrame.stop! else safe_to_continue = false end end return safe_to_continue end |
#redo ⇒ Object
665 666 667 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 665 def redo @script.redo unless running?() end |
#replace ⇒ Object
726 727 728 729 730 731 732 733 734 735 736 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 726 def replace unless @replace_dialog @replace_dialog = FindReplaceDialog.new(@script, true) @replace_dialog.connect(SIGNAL('find_next()')) { dialog_find(@replace_dialog) } @replace_dialog.connect(SIGNAL('replace()')) { dialog_replace(@replace_dialog) } @replace_dialog.connect(SIGNAL('replace_all()')) { dialog_replace_all(@replace_dialog) } end @replace_dialog.show @replace_dialog.raise @replace_dialog.activateWindow end |
#retry_needed ⇒ Object
433 434 435 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 433 def retry_needed @retry_needed = true end |
#retry_needed? ⇒ Boolean
429 430 431 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 429 def retry_needed? @retry_needed end |
#ruby_syntax_check_selection ⇒ Object
830 831 832 833 834 835 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 830 def ruby_syntax_check_selection unless self.class.running?() selection = @script.selected_lines ruby_syntax_check_text(selection) if selection end end |
#ruby_syntax_check_text(text) ⇒ Object
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 837 def ruby_syntax_check_text(text) unless self.class.running?() check_process = IO.popen("ruby -c -rubygems 2>&1", 'r+') check_process.write("require 'cosmos'; require 'cosmos/script'; " + text) check_process.close_write results = check_process.gets check_process.close if results if results =~ /Syntax OK/ Qt::MessageBox.information(self, 'Syntax Check Successful', results) else # Results is a string like this: ":2: syntax error ..." # Normally the procedure comes before the first colon but since we # are writing to the process this is blank so we throw it away _, line_no, error = results.split(':') Qt::MessageBox.warning(self, 'Syntax Check Failed', "Error on line #{line_no}: #{error.strip}") end else Qt::MessageBox.critical(self, 'Syntax Check Exception', 'Ruby syntax check unexpectedly returned nil') end end end |
#run ⇒ Object
447 448 449 450 451 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 447 def run unless self.class.running?() run_text(@script.toPlainText) end end |
#run_and_close_on_complete(text_binding = nil) ⇒ Object
453 454 455 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 453 def run_and_close_on_complete(text_binding = nil) run_text(@script.toPlainText, 0, text_binding, true) end |
#run_from_cursor ⇒ Object
820 821 822 823 824 825 826 827 828 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 820 def run_from_cursor unless self.class.running?() line_number = @script.selection_start_line text = @script.toPlainText.split("\n")[line_number..-1].join("\n") scriptrunner_puts "Running script from line #{line_number}: #{File.basename(@filename)}" handle_output_io() run_text(text, line_number) end end |
#run_selection ⇒ Object
Implement Script functionality in the frame (run selection, run from cursor, etc
793 794 795 796 797 798 799 800 801 802 803 804 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 793 def run_selection unless self.class.running?() selection = @script.selected_lines if selection start_line_number = @script.selection_start_line end_line_number = @script.selection_end_line scriptrunner_puts "Running script lines #{start_line_number+1}-#{end_line_number+1}: #{File.basename(@filename)}" handle_output_io() run_text(selection, start_line_number) end end end |
#run_selection_while_paused ⇒ Object
806 807 808 809 810 811 812 813 814 815 816 817 818 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 806 def run_selection_while_paused current_script = @tab_book.tab(@tab_book.currentIndex) selection = current_script.selected_lines if selection start_line_number = current_script.selection_start_line end_line_number = current_script.selection_end_line scriptrunner_puts "Debug: Running selected lines #{start_line_number+1}-#{end_line_number+1}: #{@tab_book.tabText(@tab_book.currentIndex)}" handle_output_io() dialog = ScriptRunnerDialog.new(self, 'Executing Selected Lines While Paused') dialog.execute_text_and_close_on_complete(selection, @script_binding) handle_output_io() end end |
#running? ⇒ Boolean
394 395 396 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 394 def running? if @@instance == self and ScriptRunnerFrame.running?() then true else false end end |
#scriptrunner_puts(string) ⇒ Object
1160 1161 1162 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1160 def scriptrunner_puts(string) puts Time.now.formatted + " (SCRIPTRUNNER): " + string end |
#select_all ⇒ Object
681 682 683 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 681 def select_all @script.select_all unless running?() end |
#select_tab_and_destroy_tabs_after_index(index) ⇒ Object
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1078 def select_tab_and_destroy_tabs_after_index(index) Qt.execute_in_main_thread(true) do if @tab_book_shown @tab_book.setCurrentIndex(index) @active_script = @tab_book.tab(@tab_book.currentIndex) first_to_remove = index + 1 last_to_remove = @call_stack.length - 1 last_to_remove.downto(first_to_remove) do |tab_index| tab = @tab_book.tab(tab_index) @tab_book.removeTab(tab_index) tab.dispose end @call_stack = @call_stack[0..index] @current_file = @call_stack[index] end end end |
#set_text(text, filename = '') ⇒ Object
373 374 375 376 377 378 379 380 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 373 def set_text(text, filename = '') unless running?() @script.setPlainText(text) @script.stop_highlight @filename = filename mark_breakpoints(filename) end end |
#set_text_from_file(filename) ⇒ Object
382 383 384 385 386 387 388 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 382 def set_text_from_file(filename) unless running?() @@file_cache[filename] = nil load_file_into_script(filename) @filename = filename end end |
#setFocus ⇒ Object
275 276 277 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 275 def setFocus @script.setFocus end |
#show_debug ⇒ Object
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 937 def show_debug unless @debug_frame @script.enable_breakpoints = true if @tab_book_shown if @tab_book.count > 0 (0..(@tab_book.count - 1)).each do |index| @tab_book.tab(index).enable_breakpoints = true end end end @debug_frame = Qt::HBoxLayout.new @debug_frame.setContentsMargins(0,0,0,0) @debug_frame_label = Qt::Label.new("Debug:") @debug_frame.addWidget(@debug_frame_label) @debug_text = CompletionLineEdit.new(self) @debug_text.setFocus(Qt::OtherFocusReason) @debug_text.keyPressCallback = lambda { |event| case event.key when Qt::Key_Return, Qt::Key_Enter begin debug_text = @debug_text.toPlainText @debug_history.unshift(debug_text) @debug_history_index = 0 @debug_text.setPlainText('') scriptrunner_puts "Debug: #{debug_text}" handle_output_io() if not running? # Capture STDOUT and STDERR $stdout.add_stream(@output_io) $stderr.add_stream(@output_io) end if @script_binding eval(debug_text, @script_binding, 'debug', 1) else Object.class_eval(debug_text, 'debug', 1) end handle_output_io() rescue Exception => error if error.class == DRb::DRbConnError Logger.error("Error Connecting to Command and Telemetry Server") else Logger.error(error.class.to_s.split('::')[-1] + ' : ' + error.) end handle_output_io() ensure if not running? # Capture STDOUT and STDERR $stdout.remove_stream(@output_io) $stderr.remove_stream(@output_io) end end when Qt::Key_Up if @debug_history.length > 0 @debug_text.setPlainText(@debug_history[@debug_history_index]) @debug_history_index += 1 if @debug_history_index == @debug_history.length @debug_history_index = @debug_history.length-1 end end when Qt::Key_Down if @debug_history.length > 0 @debug_text.setPlainText(@debug_history[@debug_history_index]) @debug_history_index -= 1 @debug_history_index = 0 if @debug_history_index < 0 end when Qt::Key_Escape @debug_text.setPlainText("") end } @debug_frame.addWidget(@debug_text) @toggle_button = Qt::PushButton.new('Toggle Run/Step') @debug_frame.addWidget(@toggle_button) @toggle_button.connect(SIGNAL('clicked(bool)')) do if @@step_mode scriptrunner_puts "Debug: run_mode" handle_output_io() self.class.step_mode = false else scriptrunner_puts "Debug: step_mode" handle_output_io() self.class.step_mode = true end end @return_button = Qt::PushButton.new('Insert Return') @debug_frame.addWidget(@return_button) @return_button.connect(SIGNAL('clicked(bool)')) do scriptrunner_puts "Debug: insert_return(); ScriptRunnerFrame.instance.go()" handle_output_io() insert_return() go() end @bottom_frame.layout.addLayout(@debug_frame) end end |
#stop? ⇒ Boolean
425 426 427 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 425 def stop? @stop end |
#stop_message_log ⇒ Object
247 248 249 250 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 247 def @message_log.stop if @message_log @message_log = nil end |
#text ⇒ Object
369 370 371 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 369 def text @script.toPlainText.gsub("\r", '') end |
#toggle_debug(debug = nil) ⇒ Object
Implement the debug capability
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 917 def toggle_debug(debug = nil) if debug.nil? if @debug_frame hide_debug() else show_debug() end else if debug if !@debug_frame show_debug() end else if @debug_frame hide_debug() end end end end |
#toggle_disconnect(config_file) ⇒ Object
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 1099 def toggle_disconnect(config_file) if get_cmd_tlm_disconnect set_cmd_tlm_disconnect(false) self.parent.setPalette(Cosmos::DEFAULT_PALETTE) else dialog = Qt::Dialog.new(self, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) dialog.setWindowTitle(tr("Server Config File")) dialog_layout = Qt::VBoxLayout.new chooser = FileChooser.new(self, "Config File", config_file, 'Select', File.join('config', 'tools', 'cmd_tlm_server', config_file)) chooser.callback = lambda do |filename| chooser.filename = File.basename(filename) end dialog_layout.addWidget(chooser) = Qt::HBoxLayout.new ok = Qt::PushButton.new("Ok") ok.setDefault(true) ok.connect(SIGNAL('clicked()')) do dialog.accept() end .addWidget(ok) cancel = Qt::PushButton.new("Cancel") cancel.connect(SIGNAL('clicked()')) do dialog.reject() end .addWidget(cancel) dialog_layout.addLayout() dialog.setLayout(dialog_layout) if dialog.exec == Qt::Dialog::Accepted config_file = chooser.filename self.parent.setPalette(Cosmos::RED_PALETTE) Splash.execute(self) do |splash| ConfigParser.splash = splash splash. = "Initializing Command and Telemetry Server" set_cmd_tlm_disconnect(true, config_file) ConfigParser.splash = nil end end dialog.dispose end config_file end |
#undo ⇒ Object
Implement edit functionality in the frame (cut, copy, paste, etc)
661 662 663 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 661 def undo @script.undo unless running?() end |
#undo_available(bool) ⇒ Object
267 268 269 |
# File 'lib/cosmos/tools/script_runner/script_runner_frame.rb', line 267 def undo_available(bool) emit undoAvailable(bool) end |