From 93617ec29679fd61721868dfac504adc7f77c9ba Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Mon, 26 Feb 2018 12:01:56 -0800 Subject: [PATCH] Rename EditorLayer -> BufferLayer --- package.json | 2 +- src/index.ts | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 71bb525..dc5d26a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oni-api", - "version": "0.0.32", + "version": "0.0.34", "description": "Oni's API layer", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/index.ts b/src/index.ts index f055647..7132f2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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. @@ -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 } @@ -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 getLines(start?: number, end?: number): Promise getTokenAt(line: number, column: number): Promise