Created
July 23, 2017 20:44
-
-
Save pykong/0975977505da02bbdf29b41e35e85a78 to your computer and use it in GitHub Desktop.
Example how to communicate between plugins of Sublime Text 3 via in-memory settings files. Put both python files into plugin directory, include the keybinding (maybe change different key combination if required.) Watch the console and trigger the command. See what happens. Also, see following thread: https://forum.sublimetext.com/t/inter-plugin-…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
s = sublime.load_settings('var_share.sublime-settings') | |
def consume(): | |
num = s.get("test_var") | |
print("Consumer received: ", num) | |
def plugin_loaded(): | |
print("consumer loaded") | |
s.add_on_change('test_var', consume) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": ["ctrl+alt+shift+t"], "command": "send_test"} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
from random import randint | |
class SendTestCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
rnd = randint(0, 9) | |
print("Producer sends: ", rnd) | |
s = sublime.load_settings('var_share.sublime-settings') | |
s.set('test_var', rnd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment