Skip to content

事件

用类型化助手或 EventBus 订阅。

kotlin
val unsub = controller.onTextChanged { event ->
    // event.changes, event.kind, event.source
}
unsub()

controller.events.subscribe<CursorChangedEvent> { }

dispose() 会清空 bus。Composable detach 时不会自动清 events(除非你调用 dispose)。

EditorEvent 类型

类型字段
TextChangedEventchanges: List<TextChange>kindsource
CursorChangedEventcursorPosition
SelectionChangedEventhasSelectionselectioncursorPosition
ScrollChangedEventscrollXscrollY
ScaleChangedEventscale
DocumentLoadedEventlineCount
FoldToggleEventline
GutterIconClickEventlinecolumniconIdlocationInEditor
InlayHintClickEventlinecolumnlocationInEditor
CodeLensClickEventlinecolumnlocationInEditor
LongPressEventcursorPositionlocationInEditor
DoubleTapEventcursorPositionlocationInEditor
ContextMenuEventcursorPositionlocationInEditor
ContextMenuItemClickEventitemrequest
SelectionMenuItemClickEventitemId
LinkClickEventlinecolumntargetlocationInEditor

TextChangerange + newText

来源与种类

EditorActionSourceNONESETUPPROGRAMMATICKEYBOARDIMEGESTUREANIMATIONDECORATIONFOLDINGSEARCHLINKED_EDITINGDIFF

TextChangeKindNONEINSERTIONREPLACEMENTDELETIONMOVEUNDOREDOMIXED

查询 API 不返回动作结果。变更走 session 唯一派发,再变成这些事件。