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;