So I want to make an attempt at creating a very simple "Vim mode" for a text editor with some of the basic (primitive?) features of Vim. To go with that, I'd like to use a block caret for Normal and Visual mode because I find that it makes things much easier and I think it's available in gVim. Not sure because I use the terminal version, but still enabled the block cursor for Normal and Visual.
Anyways, is there a way to do this in JUCE already? If not, then how do you think I could do it? I saw the CaretComponent, but I'm not really sure how to use it with the text editors in JUCE.
One possible strategy:
In the LookAndFeel methods, there is a method called createCaretComponent which creates the caret obect. You could create your own LookAndFeel, override this method, and inside there you create your own BlockCaretComponent object with a custom paint method.
If you set that LookAndFeel on your CodeEditorComponent, it will use your custom caret.
Another possible strategy:
The default caret seems to be simply a Rectangle that is drawn within some bounds. The bounds of the caret are probably set by the Editor somewhere, so you could play around with that code as well and increase the bounds of that rectangle.
Thanks for the reply. I'll have to try those ideas out.
Now that I think about it, I would have to make the character that's under the block visible (in a different color) when the block is visible. Maybe I could just find out which character is under it and draw that character on the block.
Another idea is to just make the background of one character the color of the block and change the color of the character appropriately. I'm not sure how I could do that though. I imagine it would be similar to how highlighting is done.