Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor offset for highlighted blocks in HighlightTextArea wrong #306

Open
Teekeks opened this issue May 4, 2019 · 3 comments
Open

Cursor offset for highlighted blocks in HighlightTextArea wrong #306

Teekeks opened this issue May 4, 2019 · 3 comments
Labels

Comments

@Teekeks
Copy link

Teekeks commented May 4, 2019

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

@kotcrab
Copy link
Owner

kotcrab commented May 4, 2019

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.

@Teekeks
Copy link
Author

Teekeks commented May 4, 2019

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.

@kotcrab
Copy link
Owner

kotcrab commented May 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants