mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 22:29:50 +00:00
Search bar now auto-opens on highlighted word
This commit is contained in:
1 parent
abd639438e
commit
8514b9f980
2 files changed
+20
-16
No files matched your search
@@ -99,6 +99,8 @@ public class SearchReplaceBar {
|
||||
*/
|
||||
public interface SearchCallback {
|
||||
String getText();
|
||||
|
||||
String getHighlightedWord();
|
||||
void setText(String text);
|
||||
void scrollToPosition(int position);
|
||||
void setSelection(int start, int end);
|
||||
@@ -134,11 +136,17 @@ public class SearchReplaceBar {
|
||||
showReplace = false;
|
||||
searchFieldFocused = true;
|
||||
replaceFieldFocused = false;
|
||||
if (callback != null) {
|
||||
callback.unfocusMainEditor();
|
||||
String highlight = callback.getHighlightedWord();
|
||||
if (highlight != null) {
|
||||
searchText = highlight;
|
||||
}
|
||||
}
|
||||
searchSelectionStart = 0;
|
||||
searchSelectionEnd = searchText.length();
|
||||
searchCursor = searchText.length();
|
||||
markActivity();
|
||||
if (callback != null) callback.unfocusMainEditor();
|
||||
updateMatches();
|
||||
}
|
||||
|
||||
@@ -146,16 +154,8 @@ public class SearchReplaceBar {
|
||||
* Open search+replace bar (Ctrl+Shift+R)
|
||||
*/
|
||||
public void openSearchReplace() {
|
||||
visible = true;
|
||||
showReplace = true;
|
||||
searchFieldFocused = true;
|
||||
replaceFieldFocused = false;
|
||||
searchSelectionStart = 0;
|
||||
searchSelectionEnd = searchText.length();
|
||||
searchCursor = searchText.length();
|
||||
markActivity();
|
||||
if (callback != null) callback.unfocusMainEditor();
|
||||
updateMatches();
|
||||
openSearch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user