Skip to content

Commit

Permalink
Merge pull request #25 from onivim/bryphe/docs/editorlayer-to-bufferl…
Browse files Browse the repository at this point in the history
…ayer

API: Rename EditorLayer -> BufferLayer, and add 'removeLayer' API
  • Loading branch information
bryphe authored Feb 26, 2018
2 parents c4cc2a0 + 5dc406b commit db51bef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 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.33",
"version": "0.0.34",
"description": "Oni's API layer",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
26 changes: 20 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ export interface NeovimEditorCapability {
}

/**
* An EditorLayer is a UI overlay presented over a buffer.
* A BufferLayer is a UI overlay presented over a buffer.
*
* This allows for all manners of custom rendering - whether it is simply
* overlaying tokens or showing adorners, or completely overriding the
* rendering layer of the buffer.
*/
export interface EditorLayer {
export interface BufferLayer {

/**
* Unique id for the buffer layer. This must be globally unique and is used to reference the layer.
Expand All @@ -194,19 +194,31 @@ export interface EditorLayer {
* `render` returns a custom UI element. Note that this may be called multiple times per buffer,
* if there are multiple windows with the same buffer.
*/
render(context: EditorLayerRenderContext): JSX.Element
render(context: BufferLayerRenderContext): JSX.Element
}

/**
* EditorLayerRenderContext
* BufferLayerRenderContext
*/
export interface EditorLayerRenderContext {
export interface BufferLayerRenderContext {
isActive: boolean

windowId: number

/**
* Function that takes a _buffer_ position (line, character) and converts it to a
* _screen cell_ position.
*/
bufferToScreen: Coordinates.BufferToScreen

/**
* Function that takes a _screen cell_ position and converts it to a _pixel_ position.
*/
screenToPixel: Coordinates.ScreenToPixel

/**
* Dimensions of the buffer window, in cells.
*/
dimensions: Shapes.Rectangle
}

Expand Down Expand Up @@ -249,7 +261,9 @@ export interface Buffer {

lineCount: number

addLayer(layer: EditorLayer): void
addLayer(layer: BufferLayer): void
removeLayer(layer: BufferLayer): void

applyTextEdits(edit: types.TextEdit | types.TextEdit[]): Promise<void>
getLines(start?: number, end?: number): Promise<string[]>
getTokenAt(line: number, column: number): Promise<IToken>
Expand Down

0 comments on commit db51bef

Please sign in to comment.