Created
November 20, 2013 20:48
-
-
Save Naatan/7570727 to your computer and use it in GitHub Desktop.
Komodo Macro - Execute (selection) as JavaScript Quick and dirty, will probably break in many use-cases
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
komodo.assertMacroVersion(3); | |
if (komodo.view) { komodo.view.setFocus() }; | |
// Get text to execute | |
var ke = komodo.editor; | |
if(!ke.selText) | |
{ | |
// Use all text in file | |
var text = ko.views.manager.currentView.scimoz.text.trim() | |
} | |
else | |
{ | |
// Use selected text | |
var text = komodo.interpolate('%s').trim(); | |
} | |
var _eval_pre = "var _logged = ''; var console = {log: function(val) { _logged += val + \"\\n\\n\"; return val; }}; " | |
var _eval_post = " if (_logged != '') _logged;"; | |
var result = eval(_eval_pre + text + _eval_post); | |
ko.run.runEncodedCommand(window, "printf \"" + result + "\\n\""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment