-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gui):improve search and usage dialog
- Loading branch information
Showing
27 changed files
with
937 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
jadx-gui/src/main/java/jadx/gui/search/MatchingPositions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package jadx.gui.search; | ||
|
||
public class MatchingPositions { | ||
private final String line; | ||
private int startMath; | ||
private int endMath; | ||
|
||
private int lineNumber; | ||
|
||
public MatchingPositions(String line) { | ||
this.line = line; | ||
} | ||
|
||
public MatchingPositions(String line, int lineNumber, int startMath, int endMath) { | ||
this.line = line; | ||
this.lineNumber = lineNumber; | ||
this.startMath = startMath; | ||
this.endMath = endMath; | ||
} | ||
|
||
public MatchingPositions(String line, int startMath, int endMath) { | ||
this.line = line; | ||
this.lineNumber = -1; | ||
this.startMath = startMath; | ||
this.endMath = endMath; | ||
} | ||
|
||
public MatchingPositions(int startMath, int endMath) { | ||
this.line = null; | ||
this.lineNumber = -1; | ||
this.startMath = startMath; | ||
this.endMath = endMath; | ||
} | ||
|
||
public int getLineNumber() { | ||
return lineNumber; | ||
} | ||
|
||
public String getLine() { | ||
return line; | ||
} | ||
|
||
public int getEndMath() { | ||
return endMath; | ||
} | ||
|
||
public int getStartMath() { | ||
return startMath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package jadx.gui.search; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class SearchManager { | ||
/** | ||
* Generate the good pattern according to the different boolean | ||
* | ||
* @param exp the searched expression | ||
* @param caseSensitive boolean | ||
* @param wholeWord boolean | ||
* @param useRegexp boolean | ||
* @return the pattern | ||
*/ | ||
public static Pattern generatePattern(String exp, boolean caseSensitive, boolean wholeWord, boolean useRegexp) { | ||
String word = exp; | ||
if (word != null && !word.isEmpty()) { | ||
if (!useRegexp) { | ||
word = word.replace("\\E", "\\E\\\\E\\Q"); | ||
word = "\\Q" + word + "\\E"; | ||
if (wholeWord && exp.matches("\\b.*\\b")) { | ||
word = "\\b" + word + "\\b"; | ||
} | ||
} | ||
|
||
if (!caseSensitive) { | ||
word = "(?i)" + word; | ||
} | ||
|
||
if (useRegexp) { | ||
word = "(?m)" + word; | ||
} | ||
|
||
return Pattern.compile(word); | ||
} else { | ||
return Pattern.compile(""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.