Commands
Commands in Intype are the most different from TextMate. The reason is once again: LUA. In actual implementation they do not use special UI fields (see Shell Commands in TextMate) for setting save options, input / output options. Everything is done in command itself. LUA engine has full access to Intype API. You can control everything directly and in real time. Let’s have a look at this simple command which inserts a snippet into a new document:
local snippet = '<img src="${1:Input.selection()}" />'
Editor.newDocument(”HTML”)
Editor.insertSnippet(snippet)
Editor.saveDocumentAs(”my_document.html”)
Editor.closeDocument()
LUA has also access to a parser in Intype. So you don’t have to write your own parser for language-sensitive commands (such as Reformat text, Lowercase/Uppercase tags, Conversion or transformation to other language (HTML to Textile) and so. You also can use parser access to fire an auto-completition popup with explicit lexemes. So for example if you want to fire a list of variables, you just ask parser for it:
local list = Parser.getListByScope ("variable", 0, Editor.caretPosition());
Editor.popup(list);
Shell code, external scripts or executables are also available. LUA can execute them by OS.exec(command, params) function and capture output in a string which you can transform to a snippet (using regular expressions) and insert to a document, or just do whatever you need.
June 30th, 2006
Comments are locked
We are sorry, but comments for this post are locked. This post is outdated.
Original post can be found at intype development blog.