eteran / nedit-ng

a Qt5 port of the NEdit using modern C++14
GNU General Public License v2.0
95 stars 26 forks source link

Highlight current line, highlight all words matching currently selected word #84

Open pbazarnik opened 5 years ago

pbazarnik commented 5 years ago

I'm interested in adding these two features (pretty common in other editors)

I have successfully built nedit_ng from sources and I think I can code it myself. I'm an absolute Qt newb but I have worked with C++ (mostly OpenCV, CImg stuff etc)

I hope someone can point me in the right direction so perhaps it will be clean enough for inclusion in nedit-ng codebase (or perhaps someone can just code it)

1) highlight current line: this should change Bg color of line where cursor is currently located (edge to edge)

It looks like TextArea::drawCursor could be a candidate to add that. (?)

2) highlight other matching words: once user double clicks a word it gets selected (already existing feature) and other instances of this word are highlighted (different color - similar to show matching)

eteran commented 5 years ago

Cool! so for highlighting matching words, we probably want to do either:

  1. create an auto-magic rangeset entry which already is capable of highlighting arbitrary text
  2. update the style buffer as this is where the color information comes from for syntax highlighting.

I'm not sure what the best option would be given that the style buffer doesn't exist for plain text modes

For the highlight current line stuff, I think the easiest place to do it would be manually in drawString (controlled by a preference). This is code already exists to highlight to the end of lines for selections. It should be a fairly easy extension to have a parameter or something that says "the cursor is on this line, override how we draw the BG of the line".

That being said, I'm not prescribing a solution, only brain storming.

I look forward to seeing what you come up with!