Skip to content

Commit

Permalink
Mark some functions as externally used
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPl292 committed Oct 15, 2019
1 parent 2520855 commit 10fdada
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/kotlin/org/acejump/control/Handler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ object Handler : TypedActionHandler, Resettable {
override fun doExecute(e: Editor, c: Caret?, dc: DataContext?) = handle()
}

@ExternalUsage
fun regexSearch(regex: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) =
Canvas.reset().also { Finder.search(regex, bounds) }

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

Expand Down Expand Up @@ -123,10 +125,12 @@ object Handler : TypedActionHandler, Resettable {
editor.restoreSettings()
}

@ExternalUsage
fun addAceJumpListener(listener: AceJumpListener) {
listeners += listener
}

@ExternalUsage
fun removeAceJumpListener(listener: AceJumpListener) {
listeners -= listener
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/org/acejump/search/AceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,13 @@ fun Editor.normalizeLine(line: Int) = max(0, min(line, getLineCount() - 1))

fun Editor.normalizeOffset(line: Int, offset: Int, allowEnd: Boolean) =
if (getFileSize(allowEnd) == 0) 0 else
max(min(offset, getLineEndOffset(line, allowEnd)), getLineStartOffset(line))
max(min(offset, getLineEndOffset(line, allowEnd)), getLineStartOffset(line))

/**
* This annotation is a marker which means that the annotated function is
* used in external plugins.
*/

@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class ExternalUsage
1 change: 1 addition & 0 deletions src/main/kotlin/org/acejump/search/Finder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ object Finder : Resettable {
* AceFindModel should be empty. Additionally, if
* AceFindModes.isRegex == true, only one symbol is highlighted in document.
*/
@ExternalUsage
fun markResults(
results: SortedSet<Int>,
model: AceFindModel = AceFindModel("", true)
Expand Down

0 comments on commit 10fdada

Please sign in to comment.