TextDiagnosticsState

class TextDiagnosticsState(val textState: TextEditorState, checker: TextDiagnosticsChecker?, color: Color = DefaultDiagnosticColor, suggestionColor: Color = DefaultSuggestionColor, scanContext: CoroutineContext = Dispatchers.Default, cacheLines: Int = DEFAULT_CACHE_LINES)(source)

Underlines what a TextDiagnosticsChecker finds in textState, line by line. Results are kept by line text, so after an edit only the lines that changed go to TextDiagnosticsChecker.check; TextDiagnosticsChecker.checkText sees the whole text every time. Pass it to com.darkrockstudios.texteditor.spellcheck.SpellCheckingTextEditor, which refreshes it as the text changes and opens a menu of the message and fixes on an underline. The underlines are on the diagnostics decoration layer, which it reads and replaces by line; a state made for the same editor later takes over the underlines an earlier one left.

Parameters

color
suggestionColor
scanContext

Where the checker runs. Spans change on the caller's dispatcher.

cacheLines

How many lines' results to keep.

Constructors

Link copied to clipboard
constructor(textState: TextEditorState, checker: TextDiagnosticsChecker?, color: Color = DefaultDiagnosticColor, suggestionColor: Color = DefaultSuggestionColor, scanContext: CoroutineContext = Dispatchers.Default, cacheLines: Int = DEFAULT_CACHE_LINES)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun applyFix(span: RichSpan, fix: String)

Replaces the text under span, a diagnostic's underline, with fix, unless a refresh has since replaced it. The underline goes once fix has landed as given, and stays when the input filter refuses it, as com.darkrockstudios.texteditor.spellcheck.SpellCheckState.correctSpelling keeps a flag.

Link copied to clipboard

Removes the underlines an edit touched, ahead of the refresh that checks the edited lines again, so none sits on text it no longer describes. Edits that have landed since operation must be passed with it, through the overload taking a list.

Removes the underlines operations touched, edits that landed one after another with no other since (TextEditorState.editOperationBursts): each is read in the text after it, as moved by those after it. See the overload for one edit.

Link copied to clipboard
suspend fun refresh()

Checks the lines not checked yet, then makes every line's underlines match its results. A line edited while the checker ran keeps its underlines until the next refresh.

Link copied to clipboard
suspend fun setChecker(value: TextDiagnosticsChecker?)

Replaces the checker, forgetting what the old one found, and checks the whole text again.

Link copied to clipboard
fun setColor(value: Color)

Redraws every DiagnosticSeverity.Error's underline in value.

Link copied to clipboard

Redraws every DiagnosticSeverity.Suggestion's underline in value.