Java开发编辑器语法高亮_RSyntaxTextArea 一个支持语法高亮,代码折叠编辑器Java Swing组件...

RSyntaxTextArea

68747470733a2f2f7472617669732d63692e6f72672f626f6262796c696768742f5253796e74617854657874417265612e7376673f6272616e63683d6d617374657268747470733a2f2f636f766572616c6c732e696f2f7265706f732f626f6262796c696768742f5253796e74617854657874417265612f62616467652e737667

RSyntaxTextArea is a customizable, syntax highlighting text component for Java Swing applications. Out of the box, it supports syntax highlighting for 40+ programming languages, code folding, search and replace, and has add-on libraries for code completion and spell checking. Syntax highlighting for additional languages can be added via tools such as JFlex.

RSyntaxTextArea is available under a BSD 3-Clause license. For more information, visit http://bobbylight.github.io/RSyntaxTextArea/.

Available in the Maven Central repository (com.fifesoft:rsyntaxtextarea:XXX). SNAPSHOT builds of the in-development, unreleased version are hosted on Sonatype.

Building

RSyntaxTextArea uses Gradle to build. To compile, run all unit tests, and create the jar, run:

./gradlew build --warning-mode all

RSTA 3.0 and newer requires Java 8 to compile and run. If you need Java 6 compatibility, you'll need to use a 2.6.x version.

Example Usage

RSyntaxTextArea is simply a subclass of JTextComponent, so it can be dropped into any Swing application with ease.

import javax.swing.*;

import java.awt.BorderLayout;

import org.fife.ui.rtextarea.*;

import org.fife.ui.rsyntaxtextarea.*;

public class TextEditorDemo extends JFrame {

public TextEditorDemo() {

JPanel cp = new JPanel(new BorderLayout());

RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);

textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);

textArea.setCodeFoldingEnabled(true);

RTextScrollPane sp = new RTextScrollPane(textArea);

cp.add(sp);

setContentPane(cp);

setTitle("Text Editor Demo");

setDefaultCloseOperation(EXIT_ON_CLOSE);

pack();

setLocationRelativeTo(null);

}

public static void main(String[] args) {

// Start all Swing applications on the EDT.

SwingUtilities.invokeLater(() -> {

new TextEditorDemo().setVisible(true);

});

}

}

Sister Projects

RSyntaxTextArea provides syntax highlighting, code folding, and many other features out-of-the-box, but when building a code editor you often want to go further. Below is a list of small add-on libraries that add more complex functionality:

AutoComplete - Adds code completion to RSyntaxTextArea (or any other JTextComponent).

RSTALanguageSupport - Code completion for RSTA for the following languages: Java, JavaScript, HTML, PHP, JSP, Perl, C, Unix Shell. Built on both RSTA and AutoComplete.

SpellChecker - Adds squiggle-underline spell checking to RSyntaxTextArea.

RSTAUI - Common dialogs needed by text editing applications: Find, Replace, Go to Line, File Properties.

Getting Help

Add an issue on GitHub

Check the project's home page

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值