Added: #2404 Quick find in text/script editors - show number of occurences

Fixed: AS1/2 improper selection of search result
This commit is contained in:
Jindra Petřík
2025-05-23 01:06:55 +02:00
parent 31c8715fd3
commit 470f1411d9
9 changed files with 150 additions and 27 deletions
@@ -252,12 +252,18 @@ public class ScrollPosStorage {
return;
}
actionScriptCaret = mainPanel.getABCPanel().decompiledTextArea.getCaretPosition();
if (mainPanel.getABCPanel().decompiledTextArea.getSelectionStart() > 0) {
actionScriptCaret = mainPanel.getABCPanel().decompiledTextArea.getSelectionStart();
}
actionScriptScrollHorizontal = mainPanel.getABCPanel().decompiledScrollPane.getHorizontalScrollBar().getValue();
actionScriptScrollVertical = mainPanel.getABCPanel().decompiledScrollPane.getVerticalScrollBar().getValue();
pcodeScrollHorizontal = mainPanel.getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.getSourceScrollPane().getHorizontalScrollBar().getValue();
pcodeScrollVertical = mainPanel.getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.getSourceScrollPane().getVerticalScrollBar().getValue();
pcodeCaret = mainPanel.getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea().getCaretPosition();
if (mainPanel.getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea().getSelectionStart() > 0) {
pcodeCaret = mainPanel.getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea().getSelectionStart();
}
}
} else if (asmItem instanceof ASMSource) {
@@ -272,9 +278,15 @@ public class ScrollPosStorage {
actionScriptScrollHorizontal = ((JScrollPane) mainPanel.getActionPanel().decompiledEditor.getParent().getParent()).getHorizontalScrollBar().getValue();
actionScriptScrollVertical = ((JScrollPane) mainPanel.getActionPanel().decompiledEditor.getParent().getParent()).getVerticalScrollBar().getValue();
actionScriptCaret = mainPanel.getActionPanel().decompiledEditor.getCaretPosition();
if (mainPanel.getActionPanel().decompiledEditor.getSelectionStart() > 0) {
actionScriptCaret = mainPanel.getActionPanel().decompiledEditor.getSelectionStart();
}
pcodeScrollHorizontal = ((JScrollPane) mainPanel.getActionPanel().editor.getParent().getParent()).getHorizontalScrollBar().getValue();
pcodeScrollVertical = ((JScrollPane) mainPanel.getActionPanel().editor.getParent().getParent()).getVerticalScrollBar().getValue();
pcodeCaret = mainPanel.getActionPanel().editor.getCaretPosition();
if (mainPanel.getActionPanel().editor.getSelectionStart() > 0) {
pcodeCaret = mainPanel.getActionPanel().editor.getSelectionStart();
}
}
}
int folderPreviewScrollVertical = 0;
@@ -86,6 +86,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -1391,14 +1393,27 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
searchPanel.setSearchText(searchedText);
Runnable onScriptComplete = new Runnable() {
@Override
public void run() {
decompiledEditor.setCaretPosition(0);
public void run() {
Timer tim = new Timer();
tim.schedule(new TimerTask() {
@Override
public void run() {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
decompiledEditor.setSelectionStart(0);
decompiledEditor.setSelectionEnd(0);
decompiledEditor.setCaretPosition(0);
if (result.isPcode()) {
searchPanel.showQuickFindDialog(editor);
} else {
searchPanel.showQuickFindDialog(decompiledEditor);
}
}
});
}
}, 100);
if (result.isPcode()) {
searchPanel.showQuickFindDialog(editor);
} else {
searchPanel.showQuickFindDialog(decompiledEditor);
}
removeScriptListener(this);
}
};
@@ -1406,10 +1421,10 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
addScriptListener(onScriptComplete);
AbstractTagTreeModel ttm = mainPanel.getCurrentTree().getFullModel();
mainPanel.getCurrentTree().getSelectionModel().clearSelection();
TreePath tp = ttm.getTreePath(result.getSrc());
mainPanel.getCurrentTree().setSelectionPath(tp);
mainPanel.getCurrentTree().scrollPathToVisible(tp);
}
@Override