mirror of
https://github.com/java-decompiler/jd-gui.git
synced 2025-02-20 12:31:25 +00:00
Fixes links on Log pages
This commit is contained in:
parent
a2bf0c6387
commit
6683252152
@ -252,7 +252,9 @@ class ClassFilePage
|
||||
void goToLineNumber(int lineNumber) {
|
||||
int textAreaLineNumber = getTextAreaLineNumber(lineNumber)
|
||||
if (textAreaLineNumber > 0) {
|
||||
textArea.caretPosition = textArea.getLineStartOffset(textAreaLineNumber-1)
|
||||
int start = textArea.getLineStartOffset(textAreaLineNumber-1)
|
||||
int end = textArea.getLineEndOffset(textAreaLineNumber-1)
|
||||
setCaretPositionAndCenter(new DocumentRange(start, end))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ abstract class SourcePage extends HyperlinkPage {
|
||||
return max
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
int getTextAreaLineNumber(int sourceLineNumber) {
|
||||
int textAreaLineNumber = 1
|
||||
int greatestLowerSourceLineNumber = 0
|
||||
@ -91,7 +92,7 @@ abstract class SourcePage extends HyperlinkPage {
|
||||
if (sln <= sourceLineNumber) {
|
||||
if (greatestLowerSourceLineNumber < sln) {
|
||||
greatestLowerSourceLineNumber = sln
|
||||
textAreaLineNumber = lineNumberMap[i]
|
||||
textAreaLineNumber = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,44 +119,59 @@ class TextPage extends JPanel implements ContentCopyable, ContentSelectable, Lin
|
||||
try {
|
||||
Rectangle r = textArea.modelToView(start)
|
||||
|
||||
if (r) { // Visible
|
||||
if (end != start) {
|
||||
r = r.union(textArea.modelToView(end))
|
||||
}
|
||||
|
||||
Rectangle visible = textArea.visibleRect
|
||||
|
||||
visible.@x = r.@x - (visible.@width - r.@width) / 2 as int
|
||||
visible.@y = r.@y - (visible.@height - r.@height) / 2 as int
|
||||
|
||||
Rectangle bounds = textArea.bounds
|
||||
Insets i = textArea.insets
|
||||
bounds.@x = i.left
|
||||
bounds.@y = i.top
|
||||
bounds.@width -= i.left + i.right
|
||||
bounds.@height -= i.top + i.bottom
|
||||
|
||||
if (visible.@x < bounds.@x) {
|
||||
visible.@x = bounds.@x
|
||||
}
|
||||
if (visible.@x + visible.@width > bounds.@x + bounds.@width) {
|
||||
visible.@x = bounds.@x + bounds.@width - visible.@width
|
||||
}
|
||||
if (visible.@y < bounds.@y) {
|
||||
visible.@y = bounds.@y
|
||||
}
|
||||
if (visible.@y + visible.@height > bounds.@y + bounds.@height) {
|
||||
visible.@y = bounds.@y + bounds.@height - visible.@height
|
||||
}
|
||||
|
||||
textArea.scrollRectToVisible(visible)
|
||||
textArea.caretPosition = start
|
||||
if (r) {
|
||||
// Visible
|
||||
setCaretPositionAndCenter(start, end, r)
|
||||
} else {
|
||||
// Not visible yet
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
void run() {
|
||||
r = textArea.modelToView(start)
|
||||
if (r) {
|
||||
setCaretPositionAndCenter(start, end, r)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (BadLocationException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setCaretPositionAndCenter(int start, int end, Rectangle r) {
|
||||
if (end != start) {
|
||||
r = r.union(textArea.modelToView(end))
|
||||
}
|
||||
|
||||
Rectangle visible = textArea.visibleRect
|
||||
|
||||
visible.@x = r.@x - (visible.@width - r.@width) / 2 as int
|
||||
visible.@y = r.@y - (visible.@height - r.@height) / 2 as int
|
||||
|
||||
Rectangle bounds = textArea.bounds
|
||||
Insets i = textArea.insets
|
||||
bounds.@x = i.left
|
||||
bounds.@y = i.top
|
||||
bounds.@width -= i.left + i.right
|
||||
bounds.@height -= i.top + i.bottom
|
||||
|
||||
if (visible.@x < bounds.@x) {
|
||||
visible.@x = bounds.@x
|
||||
}
|
||||
if (visible.@x + visible.@width > bounds.@x + bounds.@width) {
|
||||
visible.@x = bounds.@x + bounds.@width - visible.@width
|
||||
}
|
||||
if (visible.@y < bounds.@y) {
|
||||
visible.@y = bounds.@y
|
||||
}
|
||||
if (visible.@y + visible.@height > bounds.@y + bounds.@height) {
|
||||
visible.@y = bounds.@y + bounds.@height - visible.@height
|
||||
}
|
||||
|
||||
textArea.scrollRectToVisible(visible)
|
||||
textArea.caretPosition = start
|
||||
}
|
||||
|
||||
// --- ContentCopyable --- //
|
||||
void copy() {
|
||||
if (textArea.selectionStart == textArea.selectionEnd) {
|
||||
|
@ -2,4 +2,5 @@ jd.gui.service.indexer.DirectoryIndexerProvider
|
||||
jd.gui.service.indexer.ClassFileIndexerProvider
|
||||
jd.gui.service.indexer.MetainfServiceFileIndexerProvider
|
||||
jd.gui.service.indexer.TextFileIndexerProvider
|
||||
jd.gui.service.indexer.XmlFileIndexerProvider
|
||||
jd.gui.service.indexer.ZipFileIndexerProvider
|
||||
|
Loading…
x
Reference in New Issue
Block a user