sieukrem / jn-npp-plugin

Plugin for Notepad++ allowing you to automate some tasks using JavaScript
https://github.com/sieukrem/jn-npp-plugin/wiki
109 stars 24 forks source link

Smart Highlighter: 5th color style doesn't work #82

Open text-dev opened 4 years ago

text-dev commented 4 years ago

With Smart Highlighter enabled the 5th color style doesn't work. The styles 1th to 4th work as expected, but the color of the 5th style doesn't show in the document and the navigation bar.

Edit: Really strange behavior. I have a short CSV file with 11 lines. When I mark the comma separator with the 5th style, no color shows up. If I mark a word with 17 characters that occurs two times, the 5th style color shows up, when I put the cursor exactly at the end of the word. When I select a new line, the color disappears. The same works with styles 1th to 4th with no errors.

Notepad++ v7.8.4 (32-bit) jN Plugin v2.2.185.5

sieukrem commented 4 years ago

You are right the 5th color does not work, but it is by "design".

Smart Highlighter uses 5th color to highlight the double click selection. The "double click" selection disappeares as soon the cursor is moved.

Due to avoid strange behavior, you describe, it would be necessary to implement double click selection in native code.

text-dev commented 4 years ago

Now I understand. I found the corresponding code in the file SmartHighlighter.js and removed it. The 5th color style now works again like the others.

But now highlight by double click only shows up for the current scroll position in the navigation bar. I guess that the 5th color style was a workaround for that. It would be great if you have the time to implement double click highlighting natively. I often need all five color style to analyze log files.

Skrell commented 1 year ago

I'm in the same boat and would love to be able to use both 5th color AND double click highlighting. Thank you!

Skrell commented 1 year ago

I wonder if there's anyway to modify the GlobalListener.addListener to receive the list of currently highlighted words and their colors.
If so, it wouldn't be hard to modify this function to make the DOUBLECLICK function create a unique color by mixing 2 of the existing smart highlighter colors such as: MenuCmds.SEARCH_MARKALLEXT4() MenuCmds.SEARCH_MARKALLEXT5()

Then after UNMARKING both styles upon another double click, restoring BACK the styles highlighted for previous words. So I guess this means this function would also need a way to instruct notepad to "smart highlight" the following saved term.

Just an idea...

Skrell commented 1 year ago

So I was able to fix this problem by altering the notepad++ source code directly and recompiling. Now the smart-highlighting feature uses the same logic as the style-token highlighting and hence this plugin correctly picks up on the colors throughout the ENTIRE document rather than just the visible portion (this was the reason the author of this plugin used style-token#5 originally bc of this strange limitation of smart-highlighting) I plan to propose this source code change to the author of notepad++

Now as a result of my notepad++ code change you no longer need the following code: image

However, the inactive tab (which correctly smart-highlights) does not update it's indicator panel on the side. I THINK this might be a limitation of the jN.dll plugin itself.
@sieukrem My question is can you update this plugin so that both indicator panels graphics update? Or am I wrong in my understanding of how the graphics are updated?: image