Macros: using getLine in Javascript API

I’m trying to use the scintilla function SCI_GETLINE in a Javscript macro.

If I use: line = scimoz.getLine(linenumber) I get: NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [ISciMozLite.getLine]

Fair enough. SCI_GETLINE has two arguments–the first for the line number and the second is a buffer to receive the text of the line. However, if I try: scimoz.getLine(linenumber, buffer), Komodo dies a big, fiery, where-do-you-want-to-send-the-ashes death. Interestingly, if buffer is an array Komodo does not die but buffer is empty.

SCI_GETLINE is supported as a python XPCOM function as komodo.editor.getLine(linenumber). It seems that there ought to be a way to call it with the Javascript API.

Anyone have any suggestions?
Thanks!

GetLine is one of the Komodo XPCOM APIs that use a different return value, see example here:

Basically, it requires a special out parameter:

var line = {};
scimoz.getLine(lineNo, line);
line = line.value;

Just to let you know - we’re in the process of moving to new APIs (for Komodo 9 and beyond) that will be easier to use, see progress in:


Cheers,
Todd

Thanks Todd. Works just fine.

v.9 API looks pretty nice. What do you plan on using the scintilla object for (vs. scimoz)?

I assume you’re referring to

The scimoz and scintilla methods are helpers, they are not exposed through the API. Only properties on the module.exports object are exposed. So you do not have to worry about scintilla or scimoz yourself.

The editor API is loosely based on the CodeMirror one, meaning that much of the CodeMirror API documentation will also apply to the Komodo editor API.

We intend to have documentation for this by the time Komodo 9 final releases.