Skip to content

Commit

Permalink
Custom regex search support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPl292 committed Oct 15, 2019
1 parent 622ba42 commit c10b4c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/kotlin/org/acejump/control/Handler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ object Handler : TypedActionHandler, Resettable {
fun regexSearch(regex: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) =
Canvas.reset().also { Finder.search(regex, bounds) }

fun customRegexSearch(regex: String, bounds: Boundary = FULL_FILE_BOUNDARY) =
Canvas.reset().also { Finder.search(regex, bounds) }

fun activate() = if (!enabled) configureEditor() else { }

private fun clear() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/org/acejump/search/Finder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ object Finder : Resettable {

fun search(pattern: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) {
logger.info("Searching for regular expression: ${pattern.name} in $bounds")
search(pattern.string, bounds)
}

fun search(pattern: String, bounds: Boundary = FULL_FILE_BOUNDARY) {
boundaries = bounds
// TODO: Fix this broken reset
reset()
Tagger.reset()
search(AceFindModel(pattern.string, true))
search(AceFindModel(pattern, true))
}

fun search(model: AceFindModel = AceFindModel(query)) {
Expand Down

0 comments on commit c10b4c3

Please sign in to comment.