Skip to content

Commit

Permalink
Merge pull request #26 from onivim/bryphe/api/editor-api-updates
Browse files Browse the repository at this point in the history
Editor API updates
  • Loading branch information
bryphe authored Feb 26, 2018
2 parents db51bef + 77b80b5 commit 3e052d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oni-api",
"version": "0.0.34",
"version": "0.0.35",
"description": "Oni's API layer",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
19 changes: 18 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,36 @@ export interface BufferLayerRenderContext {
dimensions: Shapes.Rectangle
}

export type InputCallbackFunction = (input: string) => Promise<void>

export interface Editor {
mode: string
onModeChanged: IEvent<Vim.Mode>

activeBuffer: Buffer

/**
* Helper function to queue / block input while a long-running process
* is occurring.
*
* This is important for API calls that may require multiple steps while
* the user is typing, for example, auto-closing pairs or snippets.
*
* This takes a function that returns a promise, as well as an input
* argument so that input can be entered exclusively by the block.
*
* Use sparingly as this may cause a visible delay in typing.
*/
blockInput(atomicInputFunction: (inputCallback: InputCallbackFunction) => Promise<void>): void

openFile(file: string, method?: string): Promise<Buffer>

onBufferEnter: IEvent<EditorBufferEventArgs>
onBufferLeave: IEvent<EditorBufferEventArgs>
onBufferChanged: IEvent<EditorBufferChangedEventArgs>
onBufferScrolled: IEvent<EditorBufferScrolledEventArgs>
onBufferSaved: IEvent<EditorBufferEventArgs>
onCursorMoved: IEvent<Cursor>
onModeChanged: IEvent<Vim.Mode>

// Optional capabilities for the editor to implement
neovim?: NeovimEditorCapability
Expand Down

0 comments on commit 3e052d2

Please sign in to comment.