We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
也许类似于
JSyntaxPane
?Something like
JSyntaxPane
, perhaps?RSyntaxTextArea 怎么样? 它使用修改后的 BSD 许可证。
What about RSyntaxTextArea? It uses a modified BSD license.
您首先应该考虑使用通用解析器从源创建 AST(抽象语法树)。 有一些工具,首先我发现谷歌搜索互联网是 javaparser。 看起来这个解析器还记录了行号和列,因此 javaparser 中的 AST 对于编辑器来说是一个很好的模型。
只需处理树,定义 AST 节点类型的颜色并打印它。
You first should think about using a common parser to create an AST (abstract syntax tree) from the sources. There are some tools around, first I find googling the internet was javaparser. It looks like this parser also records line numbers and columns, so the AST from javaparser can be a nice model for the editor.
Just process the tree, define colors for the AST node types and print it.
可能想查看现有的编辑器(例如 Notepad++ - http://notepad-plus .sourceforge.net/uk/site.htm)并查看用户定义的语法突出显示是如何完成的(要检查的插件之一 - Gmod 10 Lua 语法突出显示)。 我敢打赌 Java(和其他语言)也是类似的......
Might want to look at an existing editor (Notepad++ for example - http://notepad-plus.sourceforge.net/uk/site.htm) and see how user-defined syntax highlighting is done (oneo of the plugins to check - Gmod 10 Lua Syntax Highlighter). I'd wager that the Java (and other languages) are done similarly...
您应该查看 Google 的 prettify.js。 其中有一些非常巧妙的技巧,您可能会对语法突出显示有更强大的感觉。
You should check Google's prettify.js out. Some pretty neat tricks in there, and you might get a more robust feel for syntax highlighting.
http://www.neathighlighter.com/ 是一个很好的 JavaScript 荧光笔
http://www.neathighlighter.com/ is a good JavaScript highlighter