问题
I am working in school project for creating a simple IDE.
In it I am processing the entire program as a single string like...
import java.io.*\npublic class A{\n...........\0
To trace all
/*comments*/
"strings"
'c'haracters
/**Documentation*/
I am maintaining an ArrayList<Pair>
to mark all positions. Say, if (23,34) is an entry in ArrayList<Pair> comments
, this means the characters between 23 and 34 are in a comment.
And I acheived that using setCharacterAttributes defined in StyledDocument.
My Questions are:
- Does setCharacterAttributes interpret
\t
as one char or multiple spaces? Will it interpret end of line (\n
) as one position? - How is the replace argument used? (Though I saw the java documentation, I cannot make out the meaning of overrides).
来源:https://stackoverflow.com/questions/7667150/how-does-setcharacterattributes-take-account-of-n-and-t