Created
January 31, 2014 11:45
-
-
Save chriseidhof/8730611 to your computer and use it in GitHub Desktop.
Deckset Sublime 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
# Go to Tools > New Plugin, type deckset.py and press 'Save' | |
# Then paste in the code below. | |
# | |
# It currently only works when you have a single file open, but it could easily be improved (pull requests very welcome) | |
import sublime, sublime_plugin, subprocess, os | |
class GoToSlideCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
pos = self.view.sel()[0].begin() | |
cmd = """tell application "Deckset" to tell document 1 to set position to %d""" % pos | |
subprocess.call(["osascript", "-e", cmd]) | |
class CursorRulerListener(sublime_plugin.EventListener): | |
def on_selection_modified(self, view): | |
active_window = sublime.active_window() | |
if active_window is not None: | |
# The view parameter doesn't always match the active view | |
# the cursor is in. This happens when there are multiple | |
# views of the same file. | |
active_view = active_window.active_view() | |
syntaxPath = active_view.settings().get('syntax') | |
if(syntaxPath != None): | |
syntax = os.path.splitext(syntaxPath)[0].split('/')[-1].lower() | |
if("markdown" in syntax): | |
active_view.run_command('go_to_slide') |
also, when I install this script, then my sublime gets very slow (every keypress seems to trigger something, and the cursor movement is slowed down/delayed)
I found a workaround via a build system:
{
"cmd": ["open","-a","/Applications/Deckset.app","$file"],
"selector": "text.html.markdown"
}
add this build system via Tools -> Build System -> New build system...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is this still supposed to work? I am on Sublime 3, added a plugin via "Tools > New Plugin" and saved the script above as
deckset.py
. But in Command Palette (Cmd-Shift-P) there's no Command "Deckset", right click also doesn't show Deckset, how is this supposed to be used?