Page 1 of 1
Determine current highlighter
Posted: 26 Aug 2016 17:32
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.
Re: Determine current highlighter
Posted: 20 Sep 2016 15:34
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 + "*/";
}