[PYTHON] Added achievement function to Sublime Text

I put it on

Installation

  1. Select Install Package from Package Control
  2. Select Achievement

How to use

Cancellation of achievements

If you use it properly, the achievement will be canceled and a dialog will be displayed to that effect. スクリーンショット 2013-12-21 3.46.29.png

Display of unlocked achievements

Menu bar Sublime Text> Preferences> Package Settings> Achievement> View Achievements Or ⌘+⇧+,

At the moment, I can only check the achievement name that was canceled, so I want to be able to see the explanation (I'm worried about how to display it)

reset

I will implement the reset command soon Now delete the following files in __ / Users / USERNAME / Library / Application Support / Sublime Text 3 / Packages / User / __

Waiting for a pull request

Since the number of achievements is still small, please send a pull request. airtoxin / Achievement !! I don't think it's not very interesting to implement achievements yourself! Or if you just contact me on Twitter for ideas, I will do my best to implement them.

The implemented results are [here](https://dl.dropboxusercontent.com/u/1990306/%E5%AE%9F%E8%A3%85%E6%B8%88%E3%81%BF%E5%AE % 9F% E7% B8% BE% E4% B8% 80% E8% A6% A7.txt) (because it's completely spoiled)

Around the settings

It ’s just advertising, so even how to make it

Create a new directory in the sublime packages directory and place the created package files under it. Settings related files have sublime-settings as an extension Commands that can be executed from the command palette etc. are in Default.sublime-commands, Shortcut key settings are in Default.sublime-keymap, Menu bar settings in Main.sublime-menu I wrote each. The contents are json. For details on how to write, Summary of Sublime Text 2 Plugin Tutorial was helpful. After that, I think you should refer to the ones in other packages. For some reason, the ones other than the settings could not be read unless the file name was the same.

Also, these configuration files seem to be used as templates, and when I actually made changes with commands and saved them, they seemed to be saved in the User directory inside the packages directory.

EventListener

By default, there are some Prepared, so if you inherit this class and override each method, it will be event driven. Command can be created. If you use async, sublime will not be locked even during command execution, so you should basically use this one.

About EventListener that is not prepared

For those who are not provided in the EventListener class above (such as shortcut key events), it was okay if you created the command yourself and then overridden the shortcut key to sublime-keymap.

For example, for the copy shortcut event, create a class called OverrideCopyCommand by inheriting the TextCommand class of sublime_plugin, and first execute self.view.run_command ("copy") in the run method there (the run method is that command). Is executed when is called). This will execute the copy safely, and you can add the event to your favorite shortcut key by applying the behavior you want to execute after that. The default shortcut keys are in Sublime's Preferences> Key Bindings --Default, so you can search for them here.

If you want to process asynchronously, import threading

thread = threading.Thread(target=self._command_thread)
thread.setDaemon(True)
thread.start()

If you write like this and process the _command_thread method, it will be asynchronous.

Now that the command has been created, it will be in the Default.sublime-keymap file.

[
	{ "keys": ["super+c"], "command": "override_copy" }
]

You can override the shortcut key by adding it like this.

api The sublime api was staring at here.

Register with Package Control

Fork Package Control Channel and edit the json file in the repository directory to send a pull request. After a while, the automated test will run and the result will be displayed on the pull request screen. If there is no problem, a green bar will appear and it will be waiting for merging (in my case it was merged in a few hours) The json file is separated by name, so add it to your package name. The contents of json will also be played by automatic test if the package names are not arranged in order of name.

The contents are like this,

{
	"name": "Achievement",
	"details": "https://github.com/airtoxin/Achievement",
	"releases": 
	[
		{
			"sublime_text": ">2999",
			"details": "https://github.com/airtoxin/Achievement/tags"
		}
	]
}

sublime_text supports sublime version The details of releases is the version of the package. This version seems to be managed by git tags.

If it is successfully merged into the master, you can check it in Package Control.

Recommended Posts

Added achievement function to Sublime Text
I added a function to CPython (ternary operator)
Plugin to add variable symbols (Sublime Text) Description
Customize Jupyter notebook shortcuts to look like sublime text
Links to do what you want with Sublime Text
[Django] Added new question creation function to polls app
Pythonbrew with Sublime Text
I added a function to CPython (build & structure grasp)
Covector to think in function
Convert HTML to text file
How to call a function
Speech to speech in python [text to speech]
Pass text to Django genericview
Added Theme to Pelican Blog