Komodo Edit macro to replace a specific word in current document with clipboard content; is it possible?

StackOverflow https://stackoverflow.com/questions/11421229

Frage

I created this macro to replace a specific word with another word in the current document, but ideally, I want to replace it with clipboard content. My current code is as follows:

// Macro recorded on: Wed Jul 11 2012 01:29:42 GMT+0530 (India Standard Time)
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
ko.find.replaceAllInMacro(window, 0, 'Itemlink', 'target', true, 0, 2, false, false);

The above code replaces the word 'Itemlink' with the word 'target', but how to use clipboard content instead ? So far, I found this Komodo command to paste data from the clipboard, but I don't know how to use it. The command is:

komodo.doCommand('cmd_paste');

Please help, thanks...

War es hilfreich?

Lösung

Use a reference to the scimoz object, which uses a subset of the Scintilla API and includes both the copyText() method to add to the clipboard and the paste() method to output the current data:

komodo.assertMacroVersion(2);
var editor = ko.views.manager.currentView.scimoz;
editor.copyText(1,"("); //add left parentheses to clipboard buffer

Find_ReplaceAllInMacro(window, 0, 'Itemlink', editor.paste(), true, 0, 2, false, false);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top