Created
January 31, 2014 11:45
-
-
Save chriseidhof/8730611 to your computer and use it in GitHub Desktop.
Deckset Sublime Plugin
This file contains 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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a workaround via a build system:
add this build system via Tools -> Build System -> New build system...