How does setCharacterAttributes take account of '\n' and '\t'?

半城伤御伤魂 提交于 2019-12-02 07:55:46

问题


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:

  1. Does setCharacterAttributes interpret \t as one char or multiple spaces? Will it interpret end of line (\n ) as one position?
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!