我正在使用RSyntaxTextArea进行代码编辑,并且我需要知道在行中有一个断点。
使用以下代码,我可以将文本区域的偏移量移至找到断点的位置,但是我不能仅计算每个的行断点。
版本:rsyntaxtextarea-3.0.0
输出:
GUTTERS
断点标记偏移:15
断点标记偏移:41
文字区域属性
当前行的端点偏移:15
当前行的末端偏移:18
行数:11
有什么想法吗?
public class Tab extends javax.swing.JPanel {
RSyntaxTextArea textArea;
RTextScrollPane sp;
Gutter gutter;
public Tab(){
initComponents();
this.setLayout(new BorderLayout());
AtextArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
textArea.setCodeFoldingEnabled(true);
textArea.setCurrentLineHighlightColor(new Color(227, 242, 253, 200));
textArea.setFadeCurrentLineHighlight(true);
textArea.setBorder(BorderFactory.createEmptyBorder());
sp = new RTextScrollPane(textArea);
gutter = sp.getGutter();
ImageIcon breakPoint = new ImageIcon(System.getProperty("user.dir") + "/src/olc2/dew/sources/icons/024-break-point.png");
gutter.setBookmarkIcon(breakPoint);
gutter.setFoldIndicatorEnabled(true);
gutter.setBookmarkingEnabled(true);
this.add(sp);
}
public void showGutters() {
GutterIconInfo[] breakPoints = gutter.getBookmarks();
System.out.println("GUTTERS");
for (GutterIconInfo breakPoint : breakPoints) {
System.out.println("Break Point Marked Offset: " + breakPoint.getMarkedOffset());//Show the offset until to find a break point
}
//I need only the break point number line, don't the offset
System.out.println("TEXT AREA PROPERTIES");
System.out.println("End Offset of Current Line: " + textArea.getLineStartOffsetOfCurrentLine());
System.out.println("End Offset of Current Line: " + textArea.getLineEndOffsetOfCurrentLine());
System.out.println("Line Count: " + textArea.getLineCount());
System.out.println("Line Height: " + textArea.getLineHeight());
}
}