Determine current highlighter

Ask questions about how to create a script or swap scripts with other users.
Post Reply
kbieb86
Posts: 41
Joined: 26 Aug 2016 13:49

Determine current highlighter

Post by kbieb86 »

Is it possible to determine the current highlighter affecting the text at the current cursor position. For example if I wanted to take one action if in the HTML section of an HTML document and another if in the JS section?

Thank you.

kbieb86
Posts: 41
Joined: 26 Aug 2016 13:49

Re: Determine current highlighter

Post by kbieb86 »

For posterity:

This is now possible in versions 11.20+.
Scripts
Added a new property to the document object to get the current highlighter at the cursor position. The name is returned as a string in lower case.
For example:

Code: Select all

var currentHighlighter = Document.HighlighterAtCursor;
if ((currentHighlighter == "html") || (currentHighlighter == "xml")) {
   Document.SelText = "<!--" + Document.SelText + "-->";
} else {
   Document.SelText = "/*" + Document.SelText + "*/";
}

Post Reply