vis-ui icon indicating copy to clipboard operation
vis-ui copied to clipboard

Cursor offset for highlighted blocks in HighlightTextArea wrong

Open Teekeks opened this issue 6 years ago • 3 comments
trafficstars

If I have multible Highlighted areas in a HighlightTextArea on the same line, the cursor position gets offset to the left a bit more per block.

Code Example for reproduction: https://pastebin.com/vnYv9qg2

Used Java version: JavaSE11 used libGDX version: 1.9.9 with lwjgl3 backend Used visUI version: 1.4.2

In the attached screenshot you can see that the cursor is offset way off to the right even tho the cursor position is at the end of the line which is right behind the word "false" (there are no spaces after that). 20190504160646_1

Teekeks avatar May 04 '19 14:05 Teekeks

Looks like this is an issue with kerning. X offset of highlight is calculated only on the highlighted text itself while cursor is using glyph positions calculated on the entire text. Unfortunately I'm not seeing an easy fix for this.

By the way, in your regex you can use ^ to match start of the line.

kotcrab avatar May 04 '19 20:05 kotcrab

Is there any way to work around this then? Maybe use a diffrent font or something?

Thanks for the tip with ^, I am already using that somewhere else and just didnt change it in this example.

Teekeks avatar May 04 '19 21:05 Teekeks

You can try using any monospaced font. They don't use kerning and it should work better in general for code-type stuff. Or you can drop the rule for |, highlighting entire words seems to work okay.

kotcrab avatar May 06 '19 17:05 kotcrab