简体   繁体   中英

RSyntaxTextArea numbers followed by letters are highlighted in a different way [Java]

I know my qustion is not that clear but I'll try to explain it here: In my java application I am using the RSyntaxTextArea library. When I try to write a string composed by some digits followed by letters (ie 2c, 7x, 12g) this string changes color, different from the usual numbers or ordinary strings. My question is: How can I make this type of 'numbers' to remain with black as foreground color?

在此输入图像描述

Thanks for your tips!

I found out what was going wrong. I used TokenMakerMaker to create my own language, and in the flex file it creates, an ErrorNumberFormat line :

{ErrorNumberFormat}         { addToken(Token.ERROR_NUMBER_FORMAT); }

So, probably, while using this as custom language in RSTA, whenever the user type something like "3tr" (string composed my digit(s) followed by letter(s)), the scheme recognized it like an error within the format of the number and colores it in a different way. To fix my problem I simply write this code in my application:

SyntaxScheme scheme = textArea.getSyntaxScheme();
scheme.getStyle(Token.ERROR_NUMBER_FORMAT).foreground = Color.BLACK;
textArea.repaint();
textArea.revalidate();

to set the color of this Token to Black!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM