简体   繁体   English

在java语言中,为了使文本编辑器像textmate一样,我应该使用哪个小部件

[英]in java language, in order to make a text editor like textmate, what widget should i use

i want to write a text editor in java. 我想在java中编写一个文本编辑器。 i want it have a snippet feature similar to textmate. 我希望它有一个类似于textmate的片段功能。 now i have no idea what to use as the main editor area. 现在我不知道该用什么作为主编辑区。 should i use some widget in swing? 我应该在秋千中使用一些小部件吗?

great thanks. 万分谢意。

I think you are going to want to use JTextArea , and probably wrap it in a JScrollPane. 我想你会想要使用JTextArea ,并且可能将它包装在JScrollPane中。 You may want to look at JEdit , it is a text editor written in java, you can view the source and get some ideas from how they are doing things. 你可能想看看JEdi​​t ,它是一个用java编写的文本编辑器,你可以查看源代码并从他们的工作方式中获得一些想法。 The tricky part is going to be handling the formatting of snippet you are trying to create. 棘手的部分是处理您尝试创建的代码段的格式。 JEdit has plugins for different languages, so I would definitely check that out for some ideas on how they handle things. JEdi​​t有不同语言的插件,所以我肯定会检查一下它们如何处理事情的一些想法。

Since a large part of the core added value of an editor such as textmate is the text editing view, if you were making a text editor you probably should implement the view from scratch ( JComponent and override drawing and event handling ). 由于textmate等编辑器的核心附加值的很大一部分是文本编辑视图,如果您正在创建文本编辑器,您可能应该从头开始实现视图(JComponent并覆盖绘图和事件处理)。

If instead you want a feature rich text editing component for another project, then there's a Java binding http://sourceforge.net/projects/jintilla/ for the Scintilla editor, which is quite nice ( SciTE or Notepad++ use Scintilla ). 如果你想要一个功能丰富的文本编辑组件用于另一个项目,那么Scintilla编辑器就有一个Java绑定http://sourceforge.net/projects/jintilla/ ,这非常好(SciTE或Notepad ++使用Scintilla)。

If I understand what you're wanting to do, you could use a JTextArea to accomplish this. 如果我理解你想要做什么,你可以使用JTextArea来完成这个。 I have a multithreaded text editor application I made that uses a JTextArea as the main editing area. 我有一个多线程文本编辑器应用程序,我使用JTextArea作为主编辑区域。 It's nothing fancy but it was fun to make. 它没什么特别的,但制作很有趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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