martinrotter / textosaurus

Cross-platform text editor based on Qt and Scintilla.
GNU General Public License v3.0
284 stars 44 forks source link

Keyword highlighting improvement and new functionality #38

Closed severach closed 6 years ago

severach commented 6 years ago

Keyword highlighting: mark a word and all words like it are highlighted.

Notepad++ has two different methods of keyword highlighting, marking a word with mouse or keyboard, and Style Token from the right click menu.

tape
tapestry
tapered
tape recorder

Mark tape on the first line with the mouse and we should only see highlights on lines 1,4 because mouse marking must be word based. This is necessary because many languages have single letter variables and we need to see where they all are without the false positives from any word that contains the letter. The Notepadqq crew disallowed highlights from single letter marking because is it so utterly useless to see every occurrence of a single letter all over the screen.

Mark tape on the second line with Style Token and we should see highlights on all 4 lines because Style Token is text based, not word based. This allows word prefixes to be highlighted without having to be words.

Another distinction is that mouse marking is case insensitive. Style token is case sensitive.

Style Token is additive. A token can be styled with all 5 colors and the color is some sort of sum of the selected colors.

Requests: Change mouse marking to be word based. Add non word based Style Token.

martinrotter commented 6 years ago

Hello, brother.

I see, I have actually never really used context-aware keyword highlighting. Maybe I could add some key to modify the behavior of current feature implementation.

For example pressing ALT and selecting some text could triggier CONTEXT-AWARE highlighting, while current usage (without ALT being pressed, just selections) would be kept.

What you think?

severach commented 6 years ago

Cinnamon hijacks Alt-Mouse for move window. Alt-Mouse Alt-Shift-Arrow is usually used for column marking. Having to use a key would make it hard to discover and would make the functionality different than Notepad++. A config option would be better. Non whole word styling will be provided by "Style Token."

I like the live styling while dragging across text. One option is to live style non word based text while drag/shift and when the drag/shift is released the non whole words are unstyled and only the whole words remain styled. Marking part of a word only to have it unstyled when the mouse is released may cause bug reports.

Another option is to do both based on what has been marked. If the marked text is not a whole word then style non whole word text. If the marked text is a whole word then only style whole words. To let the user know that what is marked changes the style method you should distinguish the two styling methods in some way, maybe with a different color.

martinrotter commented 6 years ago

What if I add checkable switch into editor context menu and into "View" menu? Something like "Use context-aware occurrences highlighting". This switch could be assigned to keyboard shortcut (for example CTRL+L) and its changes would apply immediately, so you can use it like this:

  1. You highlight some text with your mouse (for example ca) and (with THE switch being disabled) now all occurrences are highlighted (including cat or california).
  2. You hit CTRL+L and highlighting is switched to context-aware mode, now highlighted words are auto-updated and only ca is two-letter word is thus highligted.

Does this makes sense? Would it be good enough solution for you?

severach commented 6 years ago

That sounds good.

martinrotter commented 6 years ago

https://streamable.com/4bngv

martinrotter commented 6 years ago

Can you test the feature in latest development release for commit 081ae54?

martinrotter commented 6 years ago

@severach ping