Package-level declarations

Find & replace for the Compose Text Editor: the FindBar UI, the FindState holder and its rememberFindState factory, the findShortcut modifier, localizable FindBarStrings, and the match highlight styles.

Types

Link copied to clipboard
data class FindBarStrings(val placeholder: String, val clearSearch: String, val noMatches: String, val previousMatch: String, val nextMatch: String, val close: String, val matchCount: (current: Int, total: Int) -> String, val replacePlaceholder: String, val replace: String, val replaceAll: String, val showReplace: String, val hideReplace: String, val matchCase: String = "Match case", val wholeWord: String = "Whole word", val regex: String = "Regular expression", val inSelection: String = "Find in selection", val invalidPattern: String = "Invalid pattern")

Localizable strings for the FindBar component. Provide a custom implementation to localize the Find UI.

Link copied to clipboard

Highlight style for the current/active find match, drawn on layer. A FindState draws its own on a layer of its own.

Link copied to clipboard

Highlight style for all find matches (non-current), drawn on layer. A FindState draws its own on a layer of its own.

Link copied to clipboard
class FindState(val textState: TextEditorState, scope: CoroutineScope)

State management for the Find feature.

Functions

Link copied to clipboard
fun TextEditorState.findAll(query: String, caseSensitive: Boolean = false, wholeWord: Boolean = false, regex: Boolean = false): List<TextEditorRange>

Find all occurrences of a query in the text editor. Matches never span a line break.

Link copied to clipboard
fun FindBar(state: FindState, onClose: () -> Unit, modifier: Modifier = Modifier, strings: FindBarStrings = FindBarStrings.Default, requestFocus: Boolean = true, prefillFromSelection: Boolean = true)

A find bar UI component that provides search and replace functionality.

Link copied to clipboard

Returns the index into matches of the match nearest the cursor.

Link copied to clipboard
fun Modifier.findShortcut(onToggle: () -> Unit): Modifier

Intercepts the standard find shortcut (Ctrl+F on Windows, Linux, and Android; Cmd+F on macOS and iOS) and invokes onToggle when triggered. Repeated presses toggle the find bar: onToggle is expected to flip the host's own visibility state.

fun Modifier.findShortcut(state: FindState, onToggle: () -> Unit): Modifier

findShortcut plus find next and previous while state has a query: F3 and Shift+F3, and Ctrl+G and Ctrl+Shift+G (Cmd on macOS and iOS). Without a query those keys pass through.

Link copied to clipboard

Whether query compiles as a regular expression for findAll.

Link copied to clipboard

Creates and remembers a FindState for the given TextEditorState.