an Unusual highlighting need

Started by 999hippo, August 16, 2013, 03:44:39 AM

Previous topic - Next topic

999hippo

I have a simple plugin: a cursor change event in the active-view triggers a function.

I would like the function to now:

      change the highlighting of the 3 characters left and right of the current cursor to RED.

(I need to see quickly and clearly where things have been affected by the other aspect of the function)

I am too new to sort this out in any reasonable period of time, so am truly grateful for any help.

alex

Here is an example:
Code (javascript) Select
// create the highlighting style, remember, it is alive whole editor session
var styleHighlight = new Style("my_highlighting", "Highlighting", "My Highlighting Style");
styleHighlight.ForeColor = "#FF0000";
//styleHighlight.BackColor = "#FF0000";

// get current cursor position
var posAbs = ActiveDocument.TextToAbsolute(ActiveView.Position);

// create range including two characters before and two after
var posStart = ActiveDocument.AbsoluteToText(posAbs - 2);
var posEnd = ActiveDocument.AbsoluteToText(posAbs + 2);
var rangeHighlight = new Range(posStart.Line, posStart.Pos, posEnd.Line, posEnd.Pos);

// highlight range with our style
ActiveDocument.AddStyleRange(rangeHighlight, styleHighlight);

// remove our highlighting
sleep(3000);
ActiveDocument.RemoveStyleRanges(null, styleHighlight);


I have also uploaded new version of scripting.hejs test, which also contains some examples.

During preparation of example I have noticed some glitches (as style can not be updated any more after initial creation in session) which I will try to fix in new updates.
If you find something that from your point of view works not as designed, please inform me, and I will check, if it is really like this and can be fixed/optimized.

BR, Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

999hippo

BRILLIANT!

It is not a complex little block of code, but would have cost me a couple days to sort out, so I appreciate it.

I now have my first plugin working EXACTLY as I want it, doing something I couldn't discover any other existing program capable of doing. (I'd post the plugin, but its extremely specific for a wierd peculiar need, so shouln't be of much value to anyone else).

I first tried HippoEDIT back when v1.34 was offered on giveawayoftheday. I've alsways liked it, but, have also always had a whole arsenal of text editors, so didn't always turn to it. But when I saw the addition of this scripting hosting, I knew this COULD solve my problem. Thanks to your fast response, it's solved. I still have 28 days left on my trial install of v1.5, but I just happily BOUGHT IT!!!

Thanks again for the assistance.

alex

No problem.

And thanks for feedback and registration. The license key is on the way.

Publish your plugin on forum, and we will check if it can be turned to something useful for all. Nevertheless if I see the code, I can suggest something, knowing HE internals.

BR, Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]