# EditProcessor

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/input/EditProcessor.kt+class:androidx.compose.ui.text.input.EditProcessor) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class EditProcessor
  ```

*** ** * ** ***

Helper class to apply `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditCommand`s on an internal buffer. Used by TextField Composable to combine TextFieldValue lifecycle with the editing operations.

- When a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` is suggested by the developer, `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#reset(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextInputSession)` should be called.

- When `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService` provides `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditCommand`s, they should be applied to the internal buffer using `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#apply(kotlin.collections.List)`.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#EditProcessor()()` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#apply(kotlin.collections.List)(editCommands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditCommand>)` Applies a set of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#apply(kotlin.collections.List)` to the internal text editing buffer. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#reset(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextInputSession)(value: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue, textInputSession: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession?)` Must be called whenever new editor model arrives. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#toTextFieldValue()()` Returns the current state of the internal editing buffer as a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue`. | Cmn |

## Public constructors

### EditProcessor

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
EditProcessor()
```

## Public functions

### apply

Cmn

```
fun apply(editCommands: List<EditCommand>): TextFieldValue
```

Applies a set of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditProcessor#apply(kotlin.collections.List)` to the internal text editing buffer.

After applying the changes, returns the final state of the editing buffer as a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue`

| Parameters |
|---|---|
| `editCommands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditCommand>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/EditCommand`s to be applied to the editing buffer. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` | the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` representation of the final buffer state. |

### reset

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun reset(value: TextFieldValue, textInputSession: TextInputSession?): Unit
```

Must be called whenever new editor model arrives.

This method updates the internal editing buffer with the given editor model. This method may tell the IME about the selection offset changes or extracted text changes.

### toTextFieldValue

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun toTextFieldValue(): TextFieldValue
```

Returns the current state of the internal editing buffer as a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue`.