From 0209ab171331010907acceabe6d4505dd7f3493c Mon Sep 17 00:00:00 2001 From: Glen Harmon Date: Thu, 23 Jan 2020 10:19:51 +0100 Subject: [PATCH] 2.34.0 --- Network Tech.py | 1 + Network Tech.sublime-commands | 5 +++++ Network Tech.sublime-settings | 1 + cisco-ios-xr.sublime-syntax | 1 - lib/format_/network.py | 2 ++ lib/search/network/listener.py | 6 +++++ lib/settings/__init__.py | 4 ++++ lib/settings/listener.py | 32 +++++++++++++++++++++++++++ messages.json | 5 +++-- messages/2.34.0.md | 9 ++++++++ tests/syntax_test_cisco_ios.cisco-ios | 1 - 11 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 lib/format_/network.py create mode 100644 lib/settings/__init__.py create mode 100644 lib/settings/listener.py create mode 100644 messages/2.34.0.md diff --git a/Network Tech.py b/Network Tech.py index 710ac8e..3600cf3 100644 --- a/Network Tech.py +++ b/Network Tech.py @@ -9,6 +9,7 @@ from .lib.detect_syntax import AutoSyntaxDetection # noqa from .lib.search.network import FindSubnetCommand, NetworkInfoListener # noqa from .lib.format_ import FormatMacCommand, DashFormatMacCommand, ColonFormatMacCommand, DotFormatMacCommand # noqa +from .lib.settings import ToggleNetworkInfoOnHoverCommand # noqa logger = logging.getLogger('network_tech') diff --git a/Network Tech.sublime-commands b/Network Tech.sublime-commands index 12330c7..8f392ce 100644 --- a/Network Tech.sublime-commands +++ b/Network Tech.sublime-commands @@ -1,4 +1,9 @@ [ + { + "caption": "Network Tech: Toggle Network Info Popup on Hover", + "command": "toggle_network_info_on_hover", + "args": {} + }, { "caption": "Network Tech: Format MAC Address", "command": "format_mac", diff --git a/Network Tech.sublime-settings b/Network Tech.sublime-settings index 7f0ea8e..c1c8778 100644 --- a/Network Tech.sublime-settings +++ b/Network Tech.sublime-settings @@ -1,3 +1,4 @@ { + "network_info_on_hover": false, "log_level": "debug" } \ No newline at end of file diff --git a/cisco-ios-xr.sublime-syntax b/cisco-ios-xr.sublime-syntax index 6e4500e..3f804f9 100644 --- a/cisco-ios-xr.sublime-syntax +++ b/cisco-ios-xr.sublime-syntax @@ -2255,7 +2255,6 @@ contexts: - include: router_bgp_neighbor_address_family_ipv6_multicast - include: router_bgp_neighbor_address_family_ipv6_flowspec - include: router_bgp_neighbor_address_family_ipv6_mvpn - - include: router_bgp_neighbor_address_family_vpnv6 router_bgp_neighbor_group_address_family: - include: router_bgp_neighbor_group_address_family_ipv4_unicast diff --git a/lib/format_/network.py b/lib/format_/network.py new file mode 100644 index 0000000..139597f --- /dev/null +++ b/lib/format_/network.py @@ -0,0 +1,2 @@ + + diff --git a/lib/search/network/listener.py b/lib/search/network/listener.py index c64f834..392f51a 100644 --- a/lib/search/network/listener.py +++ b/lib/search/network/listener.py @@ -19,6 +19,12 @@ class NetworkInfoListener(sublime_plugin.ViewEventListener): def on_hover(self, point, hover_zone): + settings = sublime.load_settings('Network Tech.sublime-settings') + network_info_on_hover = settings.get('network_info_on_hover', True) + + if not network_info_on_hover: + return + if not self.view.scope_name(point).startswith(SCOPE_PREFIX): return if hover_zone == sublime.HOVER_TEXT: diff --git a/lib/settings/__init__.py b/lib/settings/__init__.py new file mode 100644 index 0000000..c54cbba --- /dev/null +++ b/lib/settings/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2017 Glen Harmon + + +from .listener import ToggleNetworkInfoOnHoverCommand \ No newline at end of file diff --git a/lib/settings/listener.py b/lib/settings/listener.py new file mode 100644 index 0000000..9f58434 --- /dev/null +++ b/lib/settings/listener.py @@ -0,0 +1,32 @@ +# Copyright 2017 Glen Harmon + +import logging + +import sublime +import sublime_plugin + +logger = logging.getLogger('network_tech.settings.listener') + + +STATUS_KEY = 'Network Tech' +SETTINGS_FILE_NAME = 'Network Tech.sublime-settings' +NETWORK_INFO_ON_HOVER_SETTING_NAME = 'network_info_on_hover' + +class ToggleNetworkInfoOnHoverCommand(sublime_plugin.TextCommand): + + def run(self, edit): + settings = sublime.load_settings(SETTINGS_FILE_NAME) + network_info_on_hover = settings.get(NETWORK_INFO_ON_HOVER_SETTING_NAME, True) + settings.set(NETWORK_INFO_ON_HOVER_SETTING_NAME, not network_info_on_hover) + sublime.save_settings(SETTINGS_FILE_NAME) + + setting_status = 'ON' if not network_info_on_hover else 'OFF' + set_status = 'Network Info Popup: {}'.format(setting_status) + + def clear_status(): + current_status = self.view.get_status(STATUS_KEY) + if set_status == current_status: + self.view.erase_status(STATUS_KEY) + + self.view.set_status(STATUS_KEY, set_status) + sublime.set_timeout_async(clear_status, 4000) \ No newline at end of file diff --git a/messages.json b/messages.json index 84754a0..1a7a9ba 100644 --- a/messages.json +++ b/messages.json @@ -33,6 +33,7 @@ "2.29.0": "messages/2.29.0.md", "2.30.0": "messages/2.30.0.md", "2.31.0": "messages/2.31.0.md", - "2.32.0": "messages/2.32.0.md" - "2.33.0": "messages/2.33.0.md" + "2.32.0": "messages/2.32.0.md", + "2.33.0": "messages/2.33.0.md", + "2.34.0": "messages/2.34.0.md" } diff --git a/messages/2.34.0.md b/messages/2.34.0.md new file mode 100644 index 0000000..fda8959 --- /dev/null +++ b/messages/2.34.0.md @@ -0,0 +1,9 @@ +# [2.34.0] - 2020.01.23 + +## Added + +* Command: "Network Tech: Toggle Network Info Popup on Hover" + +The popup window with network information that appears when you mouse over a network can be turned on and off with this command. + +Tools → Command Pallet → Network Tech: Toggle Network Info Popup on Hover diff --git a/tests/syntax_test_cisco_ios.cisco-ios b/tests/syntax_test_cisco_ios.cisco-ios index 11c5ccf..bbc6a01 100644 --- a/tests/syntax_test_cisco_ios.cisco-ios +++ b/tests/syntax_test_cisco_ios.cisco-ios @@ -32,7 +32,6 @@ username [ACCOUNT] privilege 15 secret [ACCOUNT_PASSWORD] # device router02 - ip classless copy tftp://1.2.3.4/path startup-config ! Inline comment