From 10950a71da51201f6fc5122c9d44c4fc6f262881 Mon Sep 17 00:00:00 2001 From: Konloch Date: Sun, 27 Jun 2021 17:02:56 -0700 Subject: [PATCH] Added getLineText --- .../gui/components/SearchableRSyntaxTextArea.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java index 9bca1013..4c36aac9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java @@ -9,6 +9,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListe import the.bytecode.club.bytecodeviewer.util.JTextAreaUtils; import javax.swing.*; +import javax.swing.text.BadLocationException; import java.awt.*; import java.awt.event.KeyEvent; @@ -89,6 +90,17 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea JTextAreaUtils.highlight(this, pattern, caseSensitiveSearch); } + public String getLineText(int line) { + try { + if (line < getLineCount()) { + int start = getLineStartOffset(line); + int end = getLineEndOffset(line); + return getText(start, end - start).trim(); + } + } catch (BadLocationException ignored) { } + return ""; + } + public RTextScrollPane getScrollPane() { return scrollPane;