scoop:scoop.ui:0.1.0
src/text/editor/drop_edit.scoop
Selected production source · src/text/editor/drop_edit.scoop
1
package scoop.ui.text3
import scoop.window.*5
/** A rejected destination must not publish the composition fallback used by native input. */6
internal fun prepareEditorDrop(7
editor: TextEditorState,8
position: Long,9
text: String,10
policy: TextEditPolicy,11
singleLine: Boolean = false,12
complete: Boolean = false13
): EditorPreparedEdit? {14
val operations = ArrayList<TextInputOperation>()15
if (editor.isComposing)16
operations.add(TextInputOperation.ClearPreedit)17
operations.add(18
TextInputOperation.Commit(text, TextReplacement.Range(Utf8Range(position, position)))19
)20
val raw =21
prepareEditorInput(editor, TextInputBatch(Some(editor.revision), operations.toArray()))!!22
val result =23
finishEditorInput(raw, policy, TextEditSource.DragDrop, singleLine, EditorEditKind.Separate)24
if (complete)25
return completeEditorTransfer(raw, result)26
return if (result.accepted)27
Some(result)28
else29
None30
}