Last active
December 22, 2015 13:49
-
-
Save bamboo/6481736 to your computer and use it in GitHub Desktop.
Custom Livity keyboard mode provider.
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
import Livity.Collections | |
import Livity.Composition | |
import Livity.Text.Data | |
import Livity.Text.UI.Commands | |
import Livity.Text.UI.Editor | |
import UnityEngine | |
[Export(IKeyboardModeProvider)] | |
class CustomKeyboardModeProvider(IKeyboardModeProvider): | |
Name: | |
get: "Mine" | |
def KeyboardModeFor(editor as ITextEditor): | |
return KeyBindings() { | |
"&up": editor.Operations.TransposeLineUp, | |
"&down": editor.Operations.TransposeLineDown, | |
"^s": { editor.Operations.ExecuteCommand("Livity:Save") }, | |
"^r": { editor.Operations.ExecuteCommand("Livity:Save:Refresh") }, | |
"f1": { Help(editor) } | |
} | |
def Help(editor as ITextEditor): | |
word = editor.DocumentNavigator.CurrentWord.Text.Trim() | |
if string.IsNullOrEmpty(word): return | |
Application.OpenURL("http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=$word") | |
[Export(ICommand)] | |
class Duplicate(DocumentCommand, INamed): | |
Name: | |
get: "Duplicate" | |
override def ExecuteCommandOn(doc as ITextDocument): | |
line as ITextSnapshotLine = doc.CurrentLine() | |
newText = (line.Text if line.IsTerminated else "\n" + line.Text) | |
doc.Insert(line.End, newText + "\n") | |
doc.Caret.MoveDown(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment