From db03811bc59500c3976222413cc0474ce9f59c79 Mon Sep 17 00:00:00 2001 From: Kay <21156929@qq.com> Date: Wed, 11 Jan 2023 19:25:18 +0800 Subject: [PATCH] Add plugin --- Main.sublime-menu | 22 ++++++++++++++++++++++ SublimeMate.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 Main.sublime-menu create mode 100644 SublimeMate.py diff --git a/Main.sublime-menu b/Main.sublime-menu new file mode 100644 index 0000000..fbf4373 --- /dev/null +++ b/Main.sublime-menu @@ -0,0 +1,22 @@ +[{ + "id": "preferences", + "children": [{ + "id": "package-settings", + "children": [{ + "caption": "SublimeMate", + "children": [{ + "caption": "Main", + "command": "sublime_mate" + }, { + "caption": "Help", + "command": "sublime_mate_open_help" + }, { + "caption": "File a bug", + "command": "sublime_mate_open_bug_file" + }, { + "caption": "What's new in v2.0?", + "command": "sublime_mate_open_release_notes" + }] + }] + }] +}] diff --git a/SublimeMate.py b/SublimeMate.py new file mode 100644 index 0000000..887df4f --- /dev/null +++ b/SublimeMate.py @@ -0,0 +1,45 @@ +import sys +import sublime +import sublime_plugin +from os.path import dirname +from sublime_plugin import TextCommand +from webbrowser import open_new_tab + +sys.path.insert(0, dirname(__file__)) + + +class SublimeMateCommand(TextCommand): + def run(self, edit): + self.view.insert(edit, 0, "Hello, World!") + + +class SublimeMateOpenHelpCommand(TextCommand): + def run(self, _): + view_readme() + + +class SublimeMateOpenBugFile(TextCommand): + def run(self, _): + file_bug() + + +class SublimeMateOpenReleaseNotes(TextCommand): + def run(self, _): + view_release_notes() + +def file_bug(): + """Opens a new tab in the default browser at this plugin's repo""" + url = "https://github.com/liushoukai/SublimeMate/issues/new" + open_new_tab(url) + + +def view_readme(): + """Opens a new tab in the default browser at this plugin's repo""" + url = "https://github.com/liushoukai/SublimeMate/blob/master/README.md" + open_new_tab(url) + + +def view_release_notes(): + """Opens a new tab in the default browser at this plugin's repo""" + url = "https://github.com/liushoukai/SublimeMate/releases" + open_new_tab(url)