scripting:examples:text-highlight

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scripting:examples:text-highlight [2017/04/03 01:26] – created adminscripting:examples:text-highlight [2018/01/10 20:36] (current) – external edit 127.0.0.1
Line 5: Line 5:
  
 <file javascript highlighting.hejs> <file javascript highlighting.hejs>
 +var doc = ActiveDocument;
 +var sel = new Range(0, 0, doc.LineCount - 1, doc.GetLineLength(doc.LineCount - 1));
 +var output = Application.Output("Test Output");
 +var results = doc.FindAll("test", 0, sel);
 +var styleHigligh = new Style("my_highlighting", "Highlighting", "My Highlighting Style");
 +styleHigligh.BoxColor = "Error";
 +styleHigligh.BoxStyle = eBoxStyleRoundRect;
 +output.writeln("Find all \"test\" matches in current document (" + results.length + "):");
 +for (var i = 1, len = results.length; i <= len; i++) {
 +    output.writeln("Line : " + results[i].Top + ", Pos : " + results[i].Left);
 +    doc.AddStyleRange(results[i], styleHigligh);
 +}
 +doc.RemoveStyleRanges(null, styleHigligh);
 +</file>
 +
 +<file javascript highlighting2.hejs>
 // create the highlighting style, remember, it is alive whole editor session // create the highlighting style, remember, it is alive whole editor session
 var styleHighlight = new Style("my_highlighting", "Highlighting", "My Highlighting Style"); var styleHighlight = new Style("my_highlighting", "Highlighting", "My Highlighting Style");