diff --git a/openc3-cmd-tlm-api/app/controllers/script_autocomplete_controller.rb b/openc3-cmd-tlm-api/app/controllers/script_autocomplete_controller.rb index 6212f46c5..082923da9 100644 --- a/openc3-cmd-tlm-api/app/controllers/script_autocomplete_controller.rb +++ b/openc3-cmd-tlm-api/app/controllers/script_autocomplete_controller.rb @@ -17,6 +17,8 @@ # All changes Copyright 2022, OpenC3, Inc. # All Rights Reserved +require 'openc3/config/meta_config_parser' + class ScriptAutocompleteController < ApplicationController CMD_KEYWORDS = %w(cmd cmd_no_range_check cmd_no_hazardous_check cmd_no_checks cmd_raw cmd_raw_no_range_check cmd_raw_no_hazardous_check cmd_raw_no_checks) @@ -33,7 +35,14 @@ def get_reserved_item_names end def get_keywords - keywords = params[:type].upcase == 'TLM' ? TLM_KEYWORDS : CMD_KEYWORDS + keywords = case params[:type].upcase + when 'CMD' + CMD_KEYWORDS + when 'TLM' + TLM_KEYWORDS + when 'SCREEN' + get_screen_keywords() + end render :json => keywords, :status => 200 end @@ -45,13 +54,38 @@ def get_ace_autocomplete_data end # private + + def get_screen_keywords + OpenC3::MetaConfigParser.load(File.join(OpenC3::PATH, 'data', 'config', 'screen.yaml')).keys.sort + end + def build_autocomplete_data(type, scope) - autocomplete_data = OpenC3::TargetModel.all(scope: scope).flat_map do |target_name, target_info| - OpenC3::TargetModel.packets(target_name, type: type.upcase.intern, scope: scope).flat_map do |packet| - packet_to_autocomplete_hashes(packet, target_info, type) + if type.upcase == 'SCREEN' + yaml = OpenC3::MetaConfigParser.load(File.join(OpenC3::PATH, 'data', 'config', 'screen.yaml')) + yaml.sort.map.each do |keyword, data| + params = [] + if data['parameters'] + params = data['parameters'].collect { |param| param['name'] } + end + # The snippet is what gets put in the file when you autocomplete + # Thus we put the keyword with all the parameters surround by <> + # e.g. SCREEN + snippet = keyword.dup + snippet << " <#{params.join('> <')}>" unless params.empty? + { + :caption => keyword, + :snippet => snippet, + :meta => 'widget', + } + end + else + autocomplete_data = OpenC3::TargetModel.all(scope: scope).flat_map do |target_name, target_info| + OpenC3::TargetModel.packets(target_name, type: type.upcase.intern, scope: scope).flat_map do |packet| + packet_to_autocomplete_hashes(packet, target_info, type) + end end + autocomplete_data.sort_by { |packet| packet[:caption] } end - autocomplete_data.sort_by { |packet| packet[:caption] } end def target_packet_name(packet) diff --git a/openc3-init/plugins/packages/openc3-tool-tlmviewer/package.json b/openc3-init/plugins/packages/openc3-tool-tlmviewer/package.json index 5842c1363..0491086c4 100644 --- a/openc3-init/plugins/packages/openc3-tool-tlmviewer/package.json +++ b/openc3-init/plugins/packages/openc3-tool-tlmviewer/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@openc3/tool-common": "5.0.9-beta0", + "ace-builds": "1.8.1", "date-fns": "2.29.1", "lodash": "4.17.21", "axios": "0.26.1", diff --git a/openc3-init/plugins/packages/openc3-tool-tlmviewer/src/tools/TlmViewer/EditScreenDialog.vue b/openc3-init/plugins/packages/openc3-tool-tlmviewer/src/tools/TlmViewer/EditScreenDialog.vue index 61de807b2..88a4f9c45 100644 --- a/openc3-init/plugins/packages/openc3-tool-tlmviewer/src/tools/TlmViewer/EditScreenDialog.vue +++ b/openc3-init/plugins/packages/openc3-tool-tlmviewer/src/tools/TlmViewer/EditScreenDialog.vue @@ -15,7 +15,7 @@