Skip to content

Commit

Permalink
Merge pull request #1 from slemouton/label-navigation
Browse files Browse the repository at this point in the history
Label navigation
  • Loading branch information
slemouton committed Mar 13, 2016
2 parents 12ab6ce + 59ea0a1 commit b078dfc
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 5 deletions.
46 changes: 46 additions & 0 deletions Antescofo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def run(self, edit):
line = self.view.line(region)
# Extract the string for the line, and add a newline
Contents = self.view.substr(line) + '\n'

else :
# if region, then send the region
# Get the selected text
Expand Down Expand Up @@ -74,6 +75,51 @@ def run(self):
oscmsg = oscmsg.build()
client.send(oscmsg)

# ctrl+shift+s for STARTFROMLABEL via OSC
# The cursor must be on an EVENT containing a Label!
class StartfromlabelCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.settings = sublime.load_settings('Antescofo.sublime-settings')
address = self.settings.get('antescofoip', 'localhost')
port = self.settings.get('antescofoport', 5678)
# Walk through each region in the selection
for region in self.view.sel():
# If no region, then it is a LINE
if region.empty():
# Expand the region to the full line it resides on, excluding the newline
line = self.view.line(region)
scope_name = 'source.antescofo labeled.textslm label.antescofo '
label = None
for r in self.view.find_by_selector(scope_name):
if r.intersects(line):
label = self.view.substr(r)
print(label)
break
if label is None :
print('Antescofo: No label at current position!')
else:
print('Antescofo startfromlabel ', label)
if pyosc:
## Use pyosc
client = OSC.OSCClient()
client.connect((address, port))
oscmsg = OSC.OSCMessage("/antescofo/cmd")
oscmsg.append('startfromlabel')
oscmsg.append(label)
client.send(oscmsg)
else:
## use pythonosc
client = udp_client.UDPClient(address, port)
oscmsg = osc_message_builder.OscMessageBuilder(address = "/antescofo/cmd")
oscmsg.add_arg("startfromlabel")
oscmsg.add_arg(label)
oscmsg = oscmsg.build()
client.send(oscmsg)
else :
print('Antescofo Startfromlabel Command does not work on Regions!')



# ctrl+s to START Antescofo via OSC
class StopantescofoCommand(sublime_plugin.WindowCommand):
def run(self):
Expand Down
38 changes: 38 additions & 0 deletions Antescofo.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,44 @@
<string>Antescofo</string>
<key>patterns</key>
<array>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>constant.language.antescofo</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>label.antescofo</string>
</dict>
</dict>
<key>match</key>
<string>^\s*(NOTE)\s+(\b.+?\b)\s+(\b.+?\b)\s+(("[^"]*")|(\b[^\s]*\b))</string>
<key>name</key>
<string>labeled.textslm</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>constant.language.antescofo</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>label.antescofo</string>
</dict>
</dict>
<key>match</key>
<string>^\s*(CHORD|TRILL|MULTI)\s+(\(.+?\))\s+(\b.+?\b)\s+(("[^"]*")|(\b[^\s]*\b))</string>
<key>name</key>
<string>labeled.textslm</string>
</dict>
<dict>
<key>captures</key>
<dict>
Expand Down
5 changes: 4 additions & 1 deletion Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
{
"keys": ["alt+l"], "command": "loadantescofo"
}
},
{
"keys": ["alt+shift+s"], "command": "startfromlabel"
}
]
5 changes: 4 additions & 1 deletion Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
{
"keys": ["alt+l"], "command": "loadantescofo"
}
},
{
"keys": ["alt+shift+s"], "command": "startfromlabel"
}
]
5 changes: 4 additions & 1 deletion Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
{
"keys": ["alt+l"], "command": "loadantescofo"
}
},
{
"keys": ["alt+shift+s"], "command": "startfromlabel"
}
]
14 changes: 14 additions & 0 deletions JBLO-light.tmTheme
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
<string>#919191</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>keywords</string>
<key>scope</key>
<string>label.antescofo</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0000F0</string>
<key>fontStyle</key>
<string>bold</string>

</dict>
</dict>
<dict>
<key>name</key>
<string>String</string>
Expand Down
14 changes: 14 additions & 0 deletions JBLO1.tmTheme
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
<string>#2AA198</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>keywords</string>
<key>scope</key>
<string>label.antescofo</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0000F0</string>
<key>fontStyle</key>
<string>bold</string>

</dict>
</dict>
<dict>
<key>name</key>
<string>StringNumber</string>
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ The following short cuts are currently available on all platforms. You can easil

- <kbd>alt+p</kbd> without text selection will evaluate the line in Antescofo (will send OSC message to Antescofo with 'playstring' prepend)
- <kbd>alt+p</kbd> with text selection will do the above on the entire selected text.
- <kbd>alt+s</kbd> : to 'start' Antescofo
- <kbd>alt+c</kbd> : to 'stop' Antescofo
- <kbd>alt+s</kbd> : to remotely 'start' Antescofo score
- <kbd>alt+shift+s</kbd> : 'startfromlabel' if cursor is on an event with a given label
- <kbd>alt+c</kbd> : to remotely 'stop' Antescofo
- <kbd>alt+l</kbd> : Loads the current file remotely in Antescofo object (Max/Pd) and Ascograph

#### Event navigation
To jump directly to an event in your score :
- <kbd>cmd+r</kbd> opens a menu with all the events in the score.

## Problems or Suggestions?

Create an [Issue](https://github.com/arshiacont/antescofo-sublime-package/issues) and we will get back to you swiftly!
15 changes: 15 additions & 0 deletions Symbol list antescofo.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Asco Symbol List</string>
<key>scope</key>
<string>source.antescofo labeled.textslm label.antescofo</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
</dict>
</dict>
</plist>

0 comments on commit b078dfc

Please sign in to comment.