cosmos 3.4.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Manifest.txt +69 -11
- data/autohotkey/config/targets/INST/cmd_tlm/inst_tlm.txt +23 -0
- data/autohotkey/tools/TestRunnerAHK5 +17 -0
- data/autohotkey/tools/TestRunnerAHK6 +17 -0
- data/autohotkey/tools/cmd_extractor.ahk +6 -0
- data/autohotkey/tools/data_viewer.ahk +6 -0
- data/autohotkey/tools/limits_monitor.ahk +67 -14
- data/autohotkey/tools/replay.ahk +6 -0
- data/autohotkey/tools/test_runner5.ahk +8 -0
- data/autohotkey/tools/test_runner6.ahk +5 -0
- data/autohotkey/tools/tlm_extractor.ahk +25 -1
- data/autohotkey/tools/tlm_grapher.ahk +6 -0
- data/cosmos.gemspec +19 -19
- data/data/crc.txt +46 -46
- data/data/critical.wav +0 -0
- data/data/information.wav +0 -0
- data/data/input.wav +0 -0
- data/data/message.wav +0 -0
- data/data/question.wav +0 -0
- data/data/warning.wav +0 -0
- data/demo/Gemfile +5 -1
- data/demo/Launcher +5 -4
- data/demo/Launcher.bat +6 -56
- data/demo/config/data/crc.txt +73 -55
- data/demo/config/system/system.txt +1 -0
- data/demo/config/targets/EXAMPLE/cmd_tlm/example_tlm.txt +2 -0
- data/demo/procedures/example_test.rb +17 -16
- data/demo/tools/CmdExtractor +6 -5
- data/demo/tools/CmdExtractor.bat +6 -56
- data/demo/tools/CmdSender +6 -5
- data/demo/tools/CmdSender.bat +6 -56
- data/demo/tools/CmdTlmServer +6 -5
- data/demo/tools/CmdTlmServer.bat +6 -56
- data/demo/tools/DataViewer +6 -5
- data/demo/tools/DataViewer.bat +6 -56
- data/demo/tools/ExampleTarget +6 -5
- data/demo/tools/ExampleTarget.bat +6 -56
- data/demo/tools/HandbookCreator +6 -5
- data/demo/tools/HandbookCreator.bat +6 -58
- data/demo/tools/Launcher +6 -5
- data/demo/tools/Launcher.bat +6 -56
- data/demo/tools/LimitsMonitor +6 -5
- data/demo/tools/LimitsMonitor.bat +6 -56
- data/demo/tools/OpenGLBuilder +6 -5
- data/demo/tools/OpenGLBuilder.bat +6 -56
- data/demo/tools/PacketViewer +6 -5
- data/demo/tools/PacketViewer.bat +6 -56
- data/demo/tools/Replay +6 -5
- data/demo/tools/Replay.bat +6 -56
- data/demo/tools/ScpiTarget +6 -5
- data/demo/tools/ScpiTarget.bat +6 -56
- data/demo/tools/ScriptRunner +6 -5
- data/demo/tools/ScriptRunner.bat +6 -56
- data/demo/tools/TableManager +6 -5
- data/demo/tools/TableManager.bat +6 -56
- data/demo/tools/TestRunner +6 -5
- data/demo/tools/TestRunner.bat +6 -56
- data/demo/tools/TlmExtractor +6 -5
- data/demo/tools/TlmExtractor.bat +6 -56
- data/demo/tools/TlmGrapher +6 -5
- data/demo/tools/TlmGrapher.bat +6 -56
- data/demo/tools/TlmViewer +6 -5
- data/demo/tools/TlmViewer.bat +6 -56
- data/demo/tools/ToolLaunch.bat +63 -0
- data/demo/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +6 -5
- data/demo/tools/mac/CmdExtractor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +6 -5
- data/demo/tools/mac/CmdSender.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +6 -5
- data/demo/tools/mac/CmdTlmServer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +6 -5
- data/demo/tools/mac/DataViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +6 -5
- data/demo/tools/mac/HandbookCreator.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +6 -5
- data/demo/tools/mac/Launcher.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +6 -5
- data/demo/tools/mac/LimitsMonitor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +6 -5
- data/demo/tools/mac/OpenGLBuilder.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +6 -5
- data/demo/tools/mac/PacketViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/Replay.app/Contents/MacOS/Replay.rb +6 -5
- data/demo/tools/mac/Replay.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +6 -5
- data/demo/tools/mac/ScriptRunner.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +6 -5
- data/demo/tools/mac/TableManager.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +6 -5
- data/demo/tools/mac/TestRunner.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +6 -5
- data/demo/tools/mac/TlmExtractor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +6 -5
- data/demo/tools/mac/TlmGrapher.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +6 -5
- data/demo/tools/mac/TlmViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/tool_launch.rb +38 -0
- data/install/Gemfile +5 -1
- data/install/Launcher +5 -3
- data/install/Launcher.bat +6 -56
- data/install/config/data/crc.txt +67 -49
- data/install/config/tools/launcher/launcher.txt +1 -0
- data/install/tools/CmdExtractor +6 -5
- data/install/tools/CmdExtractor.bat +6 -56
- data/install/tools/CmdSender +6 -5
- data/install/tools/CmdSender.bat +6 -56
- data/install/tools/CmdTlmServer +6 -5
- data/install/tools/CmdTlmServer.bat +6 -56
- data/install/tools/DataViewer +6 -5
- data/install/tools/DataViewer.bat +6 -56
- data/install/tools/HandbookCreator +6 -5
- data/install/tools/HandbookCreator.bat +6 -58
- data/install/tools/Launcher +6 -5
- data/install/tools/Launcher.bat +6 -56
- data/install/tools/LimitsMonitor +6 -5
- data/install/tools/LimitsMonitor.bat +6 -56
- data/install/tools/OpenGLBuilder +6 -5
- data/install/tools/OpenGLBuilder.bat +6 -56
- data/install/tools/PacketViewer +6 -5
- data/install/tools/PacketViewer.bat +6 -56
- data/install/tools/Replay +6 -5
- data/install/tools/Replay.bat +6 -56
- data/install/tools/ScriptRunner +6 -5
- data/install/tools/ScriptRunner.bat +6 -56
- data/install/tools/TableManager +6 -5
- data/install/tools/TableManager.bat +6 -56
- data/install/tools/TestRunner +6 -5
- data/install/tools/TestRunner.bat +6 -56
- data/install/tools/TlmExtractor +6 -5
- data/install/tools/TlmExtractor.bat +6 -56
- data/install/tools/TlmGrapher +6 -5
- data/install/tools/TlmGrapher.bat +6 -56
- data/install/tools/TlmViewer +6 -5
- data/install/tools/TlmViewer.bat +6 -56
- data/install/tools/ToolLaunch.bat +63 -0
- data/install/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +6 -5
- data/install/tools/mac/CmdExtractor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +6 -5
- data/install/tools/mac/CmdSender.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +6 -5
- data/install/tools/mac/CmdTlmServer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +6 -5
- data/install/tools/mac/DataViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +6 -5
- data/install/tools/mac/HandbookCreator.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +6 -5
- data/install/tools/mac/Launcher.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +6 -5
- data/install/tools/mac/LimitsMonitor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +6 -5
- data/install/tools/mac/OpenGLBuilder.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +6 -5
- data/install/tools/mac/PacketViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/Replay.app/Contents/MacOS/Replay.rb +6 -5
- data/install/tools/mac/Replay.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +6 -5
- data/install/tools/mac/ScriptRunner.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +6 -5
- data/install/tools/mac/TableManager.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +6 -5
- data/install/tools/mac/TestRunner.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +6 -5
- data/install/tools/mac/TlmExtractor.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +6 -5
- data/install/tools/mac/TlmGrapher.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +6 -5
- data/install/tools/mac/TlmViewer.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/tool_launch.rb +38 -0
- data/lib/cosmos/core_ext/string.rb +3 -2
- data/lib/cosmos/gui/dialogs/about_dialog.rb +3 -7
- data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +200 -136
- data/lib/cosmos/gui/opengl/gl_viewer.rb +8 -8
- data/lib/cosmos/gui/qt.rb +56 -27
- data/lib/cosmos/gui/qt_tool.rb +3 -1
- data/lib/cosmos/gui/text/ruby_editor.rb +130 -110
- data/lib/cosmos/gui/utilities/script_module_gui.rb +150 -4
- data/lib/cosmos/io/json_drb.rb +1 -1
- data/lib/cosmos/io/win32_serial_driver.rb +2 -4
- data/lib/cosmos/packet_logs/ccsds_log_reader.rb +1 -0
- data/lib/cosmos/packet_logs/packet_log_reader.rb +13 -4
- data/lib/cosmos/packets/limits.rb +6 -3
- data/lib/cosmos/packets/telemetry.rb +34 -3
- data/lib/cosmos/processors/new_packet_log_processor.rb +1 -1
- data/lib/cosmos/script/commands.rb +20 -2
- data/lib/cosmos/script/extract.rb +11 -3
- data/lib/cosmos/script/limits.rb +6 -0
- data/lib/cosmos/script/scripting.rb +17 -9
- data/lib/cosmos/system/system.rb +73 -17
- data/lib/cosmos/system/target.rb +10 -5
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +1 -0
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +95 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +8 -4
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +55 -0
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +5 -12
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +14 -48
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -5
- data/lib/cosmos/tools/launcher/launcher.rb +4 -0
- data/lib/cosmos/tools/launcher/launcher_config.rb +50 -0
- data/lib/cosmos/tools/launcher/launcher_tool.rb +21 -9
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +607 -566
- data/lib/cosmos/tools/replay/replay.rb +51 -45
- data/lib/cosmos/tools/script_runner/script_runner.rb +13 -5
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +8 -109
- data/lib/cosmos/tools/test_runner/test.rb +65 -6
- data/lib/cosmos/tools/test_runner/test_runner.rb +4 -4
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +5 -0
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_logfile_thread.rb +3 -0
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +3 -2
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +9 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb +1 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb +1 -5
- data/lib/cosmos/top_level.rb +86 -3
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/win32_main.rb +7 -1
- data/spec/packet_logs/packet_log_reader_spec.rb +67 -7
- data/spec/packets/limits_spec.rb +19 -1
- data/spec/packets/telemetry_spec.rb +44 -1
- data/spec/script/commands_spec.rb +14 -0
- data/spec/script/scripting_spec.rb +5 -1
- data/spec/script/telemetry_spec.rb +38 -3
- data/spec/system/system_spec.rb +24 -4
- data/spec/tools/cmd_tlm_server/api_spec.rb +30 -0
- data/test/benchmarks/gsub_benchmark.rb +42 -4
- data/test/benchmarks/is_a_benchmark.rb +34 -0
- data/test/performance/config/data/crc.txt +161 -171
- data/test/performance/config/system/system_packets.txt +10 -10
- data/test/performance/config/system/system_threads.txt +30 -30
- data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +7 -2
- data/test/performance/config/targets/PACKET/cmd_tlm/packet_cmds.txt +20 -0
- data/test/performance/config/targets/PACKET/cmd_tlm/packet_tlm.txt +98 -0
- data/test/performance/config/targets/{EXAMPLE → PACKET}/cmd_tlm_server.txt +2 -2
- data/test/performance/config/targets/PACKET/lib/packet_interface.rb +22 -0
- data/test/performance/config/targets/PACKET/lib/packet_limits_response.rb +24 -0
- data/test/performance/config/targets/PACKET/screens/status.txt +25 -0
- data/test/performance/config/targets/PACKET/target.txt +28 -0
- data/test/performance/config/targets/{EXAMPLE/cmd_tlm/example_cmds.txt → THREAD/cmd_tlm/thread_cmds.txt} +1 -1
- data/test/performance/config/targets/{EXAMPLE/cmd_tlm/example_tlm.txt → THREAD/cmd_tlm/thread_tlm.txt} +1 -1
- data/test/performance/config/targets/THREAD/cmd_tlm_server.txt +6 -0
- data/test/performance/config/targets/{EXAMPLE/lib/example_interface.rb → THREAD/lib/thread_interface.rb} +1 -1
- data/test/performance/config/targets/THREAD/screens/status.txt +25 -0
- data/test/performance/config/targets/{EXAMPLE → THREAD}/target.txt +0 -0
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_packets.txt +24 -30
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_threads.txt +31 -31
- data/test/performance/config/tools/launcher/launcher_packets.txt +16 -11
- data/test/performance/config/tools/launcher/launcher_threads.txt +41 -35
- data/test/performance/config/tools/tlm_grapher/tlm_grapher.txt +204 -0
- data/test/performance/config/tools/tlm_viewer/tlm_viewer.txt +10 -38
- data/test/performance/lib/packet_target.rb +126 -0
- data/test/performance/lib/{example_target.rb → thread_target.rb} +9 -9
- data/test/performance/tools/CmdTlmServerMemProf +1 -1
- data/test/performance/tools/{ExampleTarget → PacketTarget} +2 -2
- data/test/performance/tools/{ExampleTarget.bat → PacketTarget.bat} +0 -0
- data/test/performance/tools/ThreadTarget +14 -0
- data/test/performance/tools/ThreadTarget.bat +59 -0
- data/test/performance/tools/TlmGrapherMemProf +1 -1
- data/test/performance/tools/TlmViewerMemProf +19 -0
- data/{autohotkey/tools/Replay.bat → test/performance/tools/TlmViewerMemProf.bat} +1 -1
- metadata +107 -55
- data/test/performance/lib/example_background_task.rb +0 -57
- data/test/performance/lib/scpi_target.rb +0 -74
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# encoding: ascii-8bit
|
|
3
3
|
|
|
4
|
-
# Copyright
|
|
4
|
+
# Copyright 2015 Ball Aerospace & Technologies Corp.
|
|
5
5
|
# All Rights Reserved.
|
|
6
6
|
#
|
|
7
7
|
# This program is free software; you can modify and/or redistribute it
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
# as published by the Free Software Foundation; version 3 with
|
|
10
10
|
# attribution addendums as found in the LICENSE.txt
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require 'cosmos/tools/tlm_viewer/tlm_viewer'
|
|
15
|
-
Cosmos::TlmViewer.run
|
|
12
|
+
require_relative 'tool_launch'
|
|
13
|
+
tool_launch do
|
|
14
|
+
require 'cosmos/tools/tlm_viewer/tlm_viewer'
|
|
15
|
+
Cosmos::TlmViewer.run
|
|
16
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: ascii-8bit
|
|
3
|
+
|
|
4
|
+
# Copyright 2015 Ball Aerospace & Technologies Corp.
|
|
5
|
+
# All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# This program is free software; you can modify and/or redistribute it
|
|
8
|
+
# under the terms of the GNU General Public License
|
|
9
|
+
# as published by the Free Software Foundation; version 3 with
|
|
10
|
+
# attribution addendums as found in the LICENSE.txt
|
|
11
|
+
|
|
12
|
+
def tool_launch
|
|
13
|
+
begin
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
require 'cosmos'
|
|
16
|
+
yield
|
|
17
|
+
rescue Exception => error
|
|
18
|
+
popup_error = error; popup_error = $cosmos_fatal_exception if defined? $cosmos_fatal_exception
|
|
19
|
+
begin
|
|
20
|
+
raise error if STDIN.isatty # Have a console
|
|
21
|
+
raise error unless defined? $cosmos_fatal_exception or (error.class != SystemExit and error.class != Interrupt)
|
|
22
|
+
case RUBY_PLATFORM
|
|
23
|
+
when /mingw32/
|
|
24
|
+
require 'fiddle'
|
|
25
|
+
Fiddle::Function.new(Fiddle.dlopen('user32')['MessageBox'], [Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG], Fiddle::TYPE_LONG).call(0, "#{popup_error.class}:#{popup_error.message}\n\n#{popup_error.backtrace.join("\n")}\n\nNote: Ctrl-C will copy this information to the clipboard.", "Error Starting COSMOS Tool", 0x50030)
|
|
26
|
+
when /darwin/
|
|
27
|
+
system("osascript -e 'display notification \"#{popup_error.class}:#{popup_error.message}:#{popup_error.backtrace[0].tr("'\"`<>", '')}\" with title \"Error Starting COSMOS Tool\"'")
|
|
28
|
+
else
|
|
29
|
+
message = "#{popup_error.class}:#{popup_error.message}\\n\\n#{popup_error.backtrace.join("\\n").tr("'\"`<>", '')}"
|
|
30
|
+
command = "zenity --info --text=\"#{message}\" --title=\"Error Starting COSMOS Tool\""
|
|
31
|
+
success = system(command)
|
|
32
|
+
system("notify-send \"Error Starting COSMOS Tool\" \"#{message}\"") unless success
|
|
33
|
+
end
|
|
34
|
+
ensure
|
|
35
|
+
raise error
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: ascii-8bit
|
|
3
|
+
|
|
4
|
+
# Copyright 2015 Ball Aerospace & Technologies Corp.
|
|
5
|
+
# All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# This program is free software; you can modify and/or redistribute it
|
|
8
|
+
# under the terms of the GNU General Public License
|
|
9
|
+
# as published by the Free Software Foundation; version 3 with
|
|
10
|
+
# attribution addendums as found in the LICENSE.txt
|
|
11
|
+
|
|
12
|
+
def tool_launch
|
|
13
|
+
begin
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
require 'cosmos'
|
|
16
|
+
yield
|
|
17
|
+
rescue Exception => error
|
|
18
|
+
popup_error = error; popup_error = $cosmos_fatal_exception if defined? $cosmos_fatal_exception
|
|
19
|
+
begin
|
|
20
|
+
raise error if STDIN.isatty # Have a console
|
|
21
|
+
raise error unless defined? $cosmos_fatal_exception or (error.class != SystemExit and error.class != Interrupt)
|
|
22
|
+
case RUBY_PLATFORM
|
|
23
|
+
when /mingw32/
|
|
24
|
+
require 'fiddle'
|
|
25
|
+
Fiddle::Function.new(Fiddle.dlopen('user32')['MessageBox'], [Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG], Fiddle::TYPE_LONG).call(0, "#{popup_error.class}:#{popup_error.message}\n\n#{popup_error.backtrace.join("\n")}\n\nNote: Ctrl-C will copy this information to the clipboard.", "Error Starting COSMOS Tool", 0x50030)
|
|
26
|
+
when /darwin/
|
|
27
|
+
system("osascript -e 'display notification \"#{popup_error.class}:#{popup_error.message}:#{popup_error.backtrace[0].tr("'\"`<>", '')}\" with title \"Error Starting COSMOS Tool\"'")
|
|
28
|
+
else
|
|
29
|
+
message = "#{popup_error.class}:#{popup_error.message}\\n\\n#{popup_error.backtrace.join("\\n").tr("'\"`<>", '')}"
|
|
30
|
+
command = "zenity --info --text=\"#{message}\" --title=\"Error Starting COSMOS Tool\""
|
|
31
|
+
success = system(command)
|
|
32
|
+
system("notify-send \"Error Starting COSMOS Tool\" \"#{message}\"") unless success
|
|
33
|
+
end
|
|
34
|
+
ensure
|
|
35
|
+
raise error
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -244,15 +244,16 @@ class String
|
|
|
244
244
|
# Converts a String representing a class (i.e. "MyGreatClass") to a Ruby
|
|
245
245
|
# filename which implements the class (i.e. "my_great_class.rb").
|
|
246
246
|
#
|
|
247
|
+
# @param include_extension [Boolean] Whether to add '.rb' extension
|
|
247
248
|
# @return [String] Filename which implements the class name
|
|
248
|
-
def class_name_to_filename
|
|
249
|
+
def class_name_to_filename(include_extension = true)
|
|
249
250
|
filename = ''
|
|
250
251
|
length = self.length
|
|
251
252
|
length.times do |index|
|
|
252
253
|
filename << '_' if index != 0 and self[index..index] == self[index..index].upcase
|
|
253
254
|
filename << self[index..index].downcase
|
|
254
255
|
end
|
|
255
|
-
filename << '.rb'
|
|
256
|
+
filename << '.rb' if include_extension
|
|
256
257
|
filename
|
|
257
258
|
end
|
|
258
259
|
|
|
@@ -13,6 +13,7 @@ module Cosmos
|
|
|
13
13
|
class AboutDialog < Qt::Dialog
|
|
14
14
|
ABOUT_COSMOS = ''
|
|
15
15
|
ABOUT_COSMOS << "COSMOS application icons are courtesy of http://icons8.com.\n"
|
|
16
|
+
ABOUT_COSMOS << "COSMOS application sounds are courtesy of http://www.freesfx.co.uk.\n"
|
|
16
17
|
ABOUT_COSMOS << "\n"
|
|
17
18
|
ABOUT_COSMOS << "COSMOS utilizes the QtRuby (http://rubyforge.org/projects/korundum) library under "
|
|
18
19
|
ABOUT_COSMOS << "the GNU Lesser General Public License. QtRuby is a Ruby extension module that provides an "
|
|
@@ -97,17 +98,12 @@ module Cosmos
|
|
|
97
98
|
interior_layout.addLayout(icon_layout)
|
|
98
99
|
interior_layout.addWidget(about)
|
|
99
100
|
scroll_widget.setLayout(interior_layout)
|
|
100
|
-
|
|
101
|
-
scroll_area.setMinimumHeight(scroll_widget.minimumSizeHint.height + 80)
|
|
102
|
-
scroll_area.setMinimumWidth(scroll_widget.minimumSizeHint.width)
|
|
103
|
-
else
|
|
104
|
-
scroll_area.setMinimumWidth(scroll_widget.minimumSizeHint.width + 20)
|
|
105
|
-
end
|
|
101
|
+
scroll_area.setMinimumWidth(scroll_widget.minimumSizeHint.width + 20)
|
|
106
102
|
scroll_widget.adjustSize
|
|
107
103
|
addLayout(button_layout)
|
|
108
104
|
end
|
|
109
105
|
|
|
110
|
-
setMaximumWidth(
|
|
106
|
+
setMaximumWidth(800)
|
|
111
107
|
self.raise()
|
|
112
108
|
exec()
|
|
113
109
|
dispose()
|
|
@@ -8,189 +8,253 @@
|
|
|
8
8
|
# as published by the Free Software Foundation; version 3 with
|
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
|
10
10
|
|
|
11
|
-
# This file contains the implementation of the FindDialog class. This class
|
|
12
|
-
# provides a dialog box with options for finding text
|
|
13
|
-
|
|
14
11
|
require 'cosmos'
|
|
15
12
|
require 'cosmos/gui/qt'
|
|
13
|
+
require 'singleton'
|
|
16
14
|
|
|
17
15
|
module Cosmos
|
|
18
|
-
|
|
16
|
+
# Provides a Qt::Dialog which implements Find and optionally Replace
|
|
17
|
+
# functionality for a Qt::PlainTextEdit.
|
|
19
18
|
class FindReplaceDialog < Qt::Dialog
|
|
20
|
-
|
|
21
|
-
signals 'replace()'
|
|
22
|
-
signals 'replace_all()'
|
|
23
|
-
|
|
24
|
-
@@find_text = ""
|
|
25
|
-
@@replace_text = ""
|
|
26
|
-
@@match_whole_word = false
|
|
27
|
-
@@match_case = false
|
|
28
|
-
@@wrap_around = true
|
|
29
|
-
@@find_up = false
|
|
30
|
-
@@find_down = true
|
|
31
|
-
@@find_flags = 0
|
|
32
|
-
|
|
33
|
-
def initialize(parent, replace_dialog = false)
|
|
34
|
-
# Call base class constructor
|
|
35
|
-
super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
|
36
|
-
@replace_dialog = replace_dialog
|
|
37
|
-
setWindowTitle('Find') unless @replace_dialog
|
|
38
|
-
setWindowTitle('Replace') if @replace_dialog
|
|
39
|
-
|
|
40
|
-
@layout = Qt::HBoxLayout.new
|
|
41
|
-
|
|
42
|
-
@find_layout = Qt::FormLayout.new
|
|
43
|
-
@find_box = Qt::LineEdit.new(@@find_text)
|
|
44
|
-
@find_layout.addRow(tr("Fi&nd what:"), @find_box)
|
|
45
|
-
if @replace_dialog
|
|
46
|
-
@replace_box = Qt::LineEdit.new(@@replace_text)
|
|
47
|
-
@find_layout.addRow(tr("Re&place with:"), @replace_box)
|
|
48
|
-
end
|
|
19
|
+
include Singleton
|
|
49
20
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@checkbox_layout.addWidget(@wrap_around)
|
|
60
|
-
@checkbox_layout.addStretch
|
|
21
|
+
# Displays a Find dialog
|
|
22
|
+
# @param text [Qt::PlainTextEdit] Dialog parent
|
|
23
|
+
def self.show_find(text)
|
|
24
|
+
self.instance.show_find(text)
|
|
25
|
+
end
|
|
26
|
+
def show_find(text)
|
|
27
|
+
disable_replace
|
|
28
|
+
show_dialog(text)
|
|
29
|
+
end
|
|
61
30
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@cancel.connect(SIGNAL('clicked()')) { self.reject }
|
|
86
|
-
if @replace_dialog
|
|
87
|
-
@replace = Qt::PushButton.new("&Replace")
|
|
88
|
-
@replace.connect(SIGNAL('clicked()')) { emit replace() }
|
|
89
|
-
@replace_all = Qt::PushButton.new("Replace &All")
|
|
90
|
-
@replace_all.connect(SIGNAL('clicked()')) { emit replace_all() }
|
|
31
|
+
# Displays a Find/Replace dialog
|
|
32
|
+
# @param text [Qt::PlainTextEdit] Dialog parent
|
|
33
|
+
def self.show_replace(text)
|
|
34
|
+
self.instance.show_replace(text)
|
|
35
|
+
end
|
|
36
|
+
def show_replace(text)
|
|
37
|
+
enable_replace
|
|
38
|
+
show_dialog(text)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param text [Qt::PlainTextEdit] Text widget to search
|
|
42
|
+
def self.find_next(text)
|
|
43
|
+
self.instance.find_next(text)
|
|
44
|
+
end
|
|
45
|
+
def find_next(text)
|
|
46
|
+
flags = find_flags()
|
|
47
|
+
flags &= ~Qt::TextDocument::FindBackward.to_i
|
|
48
|
+
found = text.find(find_text(), flags)
|
|
49
|
+
if not found and wrap_around?
|
|
50
|
+
cursor = text.textCursor
|
|
51
|
+
cursor.movePosition(Qt::TextCursor::Start)
|
|
52
|
+
text.setTextCursor(cursor)
|
|
53
|
+
text.find(find_text(), flags)
|
|
91
54
|
end
|
|
55
|
+
end
|
|
92
56
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
57
|
+
# @param text [Qt::PlainTextEdit] Text widget to search
|
|
58
|
+
def self.find_previous(text)
|
|
59
|
+
self.instance.find_previous(text)
|
|
60
|
+
end
|
|
61
|
+
def find_previous(text)
|
|
62
|
+
flags = find_flags()
|
|
63
|
+
flags |= Qt::TextDocument::FindBackward.to_i
|
|
64
|
+
found = text.find(find_text(), flags)
|
|
65
|
+
if not found and wrap_around?
|
|
66
|
+
cursor = text.textCursor
|
|
67
|
+
cursor.movePosition(Qt::TextCursor::End)
|
|
68
|
+
text.setTextCursor(cursor)
|
|
69
|
+
text.find(find_text(), flags)
|
|
98
70
|
end
|
|
99
|
-
|
|
100
|
-
@button_layout.addStretch
|
|
71
|
+
end
|
|
101
72
|
|
|
102
|
-
|
|
103
|
-
@layout.addLayout(@button_layout)
|
|
73
|
+
private
|
|
104
74
|
|
|
105
|
-
|
|
75
|
+
def initialize
|
|
76
|
+
# The dialog will be re-parented when shown so pass nil
|
|
77
|
+
super(nil, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
|
78
|
+
# Items which are only valid in a Replace dialog
|
|
79
|
+
@replace_items = []
|
|
106
80
|
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
layout = Qt::HBoxLayout.new
|
|
82
|
+
left_side = Qt::VBoxLayout.new
|
|
83
|
+
left_side.addLayout(create_input_layout)
|
|
84
|
+
left_side.addLayout(create_options_layout)
|
|
85
|
+
layout.addLayout(left_side)
|
|
86
|
+
layout.addLayout(create_button_layout)
|
|
109
87
|
|
|
110
|
-
|
|
111
|
-
super
|
|
112
|
-
@find_box.selectAll
|
|
113
|
-
@find_box.setFocus(Qt::PopupFocusReason)
|
|
88
|
+
setLayout(layout)
|
|
114
89
|
end
|
|
115
90
|
|
|
116
|
-
def
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
def create_input_layout
|
|
92
|
+
input_layout = Qt::FormLayout.new
|
|
93
|
+
@find_box = Qt::LineEdit.new
|
|
94
|
+
input_layout.addRow(tr("Fi&nd what:"), @find_box)
|
|
95
|
+
@replace_box = Qt::LineEdit.new
|
|
96
|
+
replace_label = Qt::Label.new(tr("Re&place with:"))
|
|
97
|
+
replace_label.setBuddy(@replace_box)
|
|
98
|
+
@replace_items << replace_label
|
|
99
|
+
input_layout.addRow(replace_label, @replace_box)
|
|
100
|
+
@replace_items << @replace_box
|
|
101
|
+
input_layout
|
|
122
102
|
end
|
|
123
103
|
|
|
124
|
-
def
|
|
125
|
-
|
|
104
|
+
def create_options_layout
|
|
105
|
+
options_layout = Qt::HBoxLayout.new
|
|
106
|
+
options_layout.addLayout(create_checkbox_layout)
|
|
107
|
+
options_layout.addWidget(create_direction_widget)
|
|
108
|
+
options_layout
|
|
126
109
|
end
|
|
127
110
|
|
|
128
|
-
def
|
|
129
|
-
|
|
111
|
+
def create_checkbox_layout
|
|
112
|
+
checkbox_layout = Qt::VBoxLayout.new
|
|
113
|
+
@match_whole_word = Qt::CheckBox.new("Match &whole word only")
|
|
114
|
+
checkbox_layout.addWidget(@match_whole_word)
|
|
115
|
+
@match_case = Qt::CheckBox.new("Match &case")
|
|
116
|
+
checkbox_layout.addWidget(@match_case)
|
|
117
|
+
@wrap_around = Qt::CheckBox.new("Wrap ar&ound")
|
|
118
|
+
@wrap_around.setChecked(true)
|
|
119
|
+
checkbox_layout.addWidget(@wrap_around)
|
|
120
|
+
checkbox_layout.addStretch
|
|
121
|
+
checkbox_layout
|
|
130
122
|
end
|
|
131
123
|
|
|
132
|
-
def
|
|
133
|
-
@
|
|
124
|
+
def create_direction_widget
|
|
125
|
+
@up = Qt::RadioButton.new("&Up")
|
|
126
|
+
down = Qt::RadioButton.new("&Down")
|
|
127
|
+
down.setChecked(true)
|
|
128
|
+
direction_layout = Qt::VBoxLayout.new
|
|
129
|
+
direction_layout.addWidget(@up)
|
|
130
|
+
direction_layout.addWidget(down)
|
|
131
|
+
direction_layout.addStretch
|
|
132
|
+
direction = Qt::GroupBox.new(tr("Direction"))
|
|
133
|
+
direction.setLayout(direction_layout)
|
|
134
|
+
direction
|
|
134
135
|
end
|
|
135
136
|
|
|
136
|
-
def
|
|
137
|
-
|
|
137
|
+
def create_button_layout
|
|
138
|
+
find_next = Qt::PushButton.new("&Find Next")
|
|
139
|
+
find_next.setDefault(true)
|
|
140
|
+
find_next.connect(SIGNAL('clicked()')) { handle_find_next }
|
|
141
|
+
cancel = Qt::PushButton.new("Cancel")
|
|
142
|
+
cancel.connect(SIGNAL('clicked()')) { reject }
|
|
143
|
+
replace = Qt::PushButton.new("&Replace")
|
|
144
|
+
replace.connect(SIGNAL('clicked()')) { handle_replace }
|
|
145
|
+
@replace_items << replace
|
|
146
|
+
replace_all = Qt::PushButton.new("Replace &All")
|
|
147
|
+
replace_all.connect(SIGNAL('clicked()')) { handle_replace_all }
|
|
148
|
+
@replace_items << replace_all
|
|
149
|
+
|
|
150
|
+
button_layout = Qt::VBoxLayout.new
|
|
151
|
+
button_layout.addWidget(find_next)
|
|
152
|
+
button_layout.addWidget(replace)
|
|
153
|
+
button_layout.addWidget(replace_all)
|
|
154
|
+
button_layout.addWidget(cancel)
|
|
155
|
+
button_layout.addStretch
|
|
156
|
+
button_layout
|
|
138
157
|
end
|
|
139
158
|
|
|
140
|
-
def
|
|
141
|
-
@
|
|
159
|
+
def show_dialog(text)
|
|
160
|
+
@find_box.selectAll
|
|
161
|
+
@find_box.setFocus(Qt::PopupFocusReason)
|
|
162
|
+
setParent(text, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | 3)
|
|
163
|
+
show()
|
|
142
164
|
end
|
|
143
165
|
|
|
144
|
-
def
|
|
145
|
-
@
|
|
166
|
+
def enable_replace
|
|
167
|
+
@replace_items.each {|item| item.show }
|
|
168
|
+
setWindowTitle('Replace')
|
|
146
169
|
end
|
|
147
170
|
|
|
148
|
-
def
|
|
149
|
-
@
|
|
171
|
+
def disable_replace
|
|
172
|
+
@replace_items.each {|item| item.hide }
|
|
173
|
+
setWindowTitle('Find')
|
|
150
174
|
end
|
|
151
175
|
|
|
152
|
-
def
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
@@find_up = @up.isChecked
|
|
159
|
-
@@find_down = @down.isChecked
|
|
160
|
-
@@find_flags = find_flags
|
|
176
|
+
def find_flags
|
|
177
|
+
flags = 0
|
|
178
|
+
flags |= Qt::TextDocument::FindBackward.to_i if @up.isChecked
|
|
179
|
+
flags |= Qt::TextDocument::FindCaseSensitively.to_i if @match_case.isChecked
|
|
180
|
+
flags |= Qt::TextDocument::FindWholeWords.to_i if @match_whole_word.isChecked
|
|
181
|
+
flags
|
|
161
182
|
end
|
|
162
183
|
|
|
163
|
-
def
|
|
164
|
-
|
|
184
|
+
def wrap_around?
|
|
185
|
+
@wrap_around.isChecked
|
|
165
186
|
end
|
|
166
187
|
|
|
167
|
-
def
|
|
168
|
-
|
|
188
|
+
def find_up?
|
|
189
|
+
@up.isChecked
|
|
169
190
|
end
|
|
170
191
|
|
|
171
|
-
def
|
|
172
|
-
|
|
192
|
+
def find_text
|
|
193
|
+
@find_box.text
|
|
173
194
|
end
|
|
174
195
|
|
|
175
|
-
def
|
|
176
|
-
|
|
196
|
+
def replace_text
|
|
197
|
+
@replace_box.text
|
|
177
198
|
end
|
|
178
199
|
|
|
179
|
-
def
|
|
180
|
-
|
|
200
|
+
def handle_find_next
|
|
201
|
+
text = parentWidget
|
|
202
|
+
found = text.find(find_text, find_flags)
|
|
203
|
+
if not found and wrap_around?
|
|
204
|
+
cursor = text.textCursor
|
|
205
|
+
if find_up?
|
|
206
|
+
cursor.movePosition(Qt::TextCursor::End)
|
|
207
|
+
else
|
|
208
|
+
cursor.movePosition(Qt::TextCursor::Start)
|
|
209
|
+
end
|
|
210
|
+
text.setTextCursor(cursor)
|
|
211
|
+
text.find(find_text, find_flags)
|
|
212
|
+
end
|
|
181
213
|
end
|
|
182
214
|
|
|
183
|
-
def
|
|
184
|
-
|
|
215
|
+
def handle_replace
|
|
216
|
+
text = parentWidget
|
|
217
|
+
if text.textCursor.hasSelection &&
|
|
218
|
+
text.textCursor.selectedText == find_text
|
|
219
|
+
found = true
|
|
220
|
+
else
|
|
221
|
+
found = text.find(find_text, find_flags)
|
|
222
|
+
if not found and wrap_around?
|
|
223
|
+
cursor = text.textCursor
|
|
224
|
+
if find_up?
|
|
225
|
+
cursor.movePosition(Qt::TextCursor::End)
|
|
226
|
+
else
|
|
227
|
+
cursor.movePosition(Qt::TextCursor::Start)
|
|
228
|
+
end
|
|
229
|
+
text.setTextCursor(cursor)
|
|
230
|
+
found = text.find(find_text, find_flags)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
if found
|
|
234
|
+
text.textCursor.removeSelectedText
|
|
235
|
+
text.textCursor.insertText(replace_text)
|
|
236
|
+
cursor = text.textCursor
|
|
237
|
+
cursor.setPosition(cursor.position-1)
|
|
238
|
+
cursor.select(Qt::TextCursor::WordUnderCursor)
|
|
239
|
+
text.setTextCursor(cursor)
|
|
240
|
+
end
|
|
185
241
|
end
|
|
186
242
|
|
|
187
|
-
def
|
|
188
|
-
|
|
189
|
-
|
|
243
|
+
def handle_replace_all
|
|
244
|
+
text = parentWidget
|
|
245
|
+
cursor = text.textCursor
|
|
246
|
+
# Start the edit block so this can be all undone with a single undo step
|
|
247
|
+
cursor.beginEditBlock
|
|
248
|
+
|
|
249
|
+
cursor.movePosition(Qt::TextCursor::Start)
|
|
250
|
+
text.setTextCursor(cursor)
|
|
190
251
|
|
|
191
|
-
|
|
192
|
-
|
|
252
|
+
while (text.find(find_text, find_flags) == true)
|
|
253
|
+
text.textCursor.removeSelectedText
|
|
254
|
+
text.textCursor.insertText(replace_text)
|
|
255
|
+
end
|
|
256
|
+
cursor.endEditBlock
|
|
193
257
|
end
|
|
194
|
-
end # class FindReplaceDialog
|
|
195
258
|
|
|
259
|
+
end # class FindReplaceDialog
|
|
196
260
|
end # module Cosmos
|