UNPKG

jupyterlab-emrys

Version:

A computational environment for Jupyter. Powered by Emrys

141 lines (140 loc) 3.62 kB
import * as CodeMirror from 'codemirror'; import { CodeMirrorWidget } from '../../codemirror/widget'; import { IChangedArgs } from 'phosphor-properties'; import { ISignal } from 'phosphor-signaling'; import { ICellModel } from './model'; import { JSONObject } from '../common/json'; /** * The location of requested edges. */ export declare type EdgeLocation = 'top' | 'bottom'; /** * An interface describing editor state coordinates. */ export interface ICoords extends JSONObject { /** * The left coordinate value. */ left: number; /** * The right coordinate value. */ right: number; /** * The top coordinate value. */ top: number; /** * The bottom coordinate value. */ bottom: number; } /** * An interface describing the state of the editor in an event. */ export interface IEditorState extends JSONObject { /** * The character number of the editor cursor within a line. */ ch: number; /** * The height of a character in the editor. */ chHeight: number; /** * The width of a character in the editor. */ chWidth: number; /** * The line number of the editor cursor. */ line: number; /** * The coordinate position of the cursor. */ coords: ICoords; /** * The cursor position of the request, including line breaks. */ position: number; } /** * An interface describing editor text changes. */ export interface ITextChange extends IEditorState { /** * The old value of the editor text. */ oldValue: string; /** * The new value of the editor text. */ newValue: string; } /** * An interface describing completion requests. */ export interface ICompletionRequest extends IEditorState { /** * The current value of the editor text. */ currentValue: string; } /** * A widget for a cell editor. */ export declare class CellEditorWidget extends CodeMirrorWidget { /** * Construct a new cell editor widget. */ constructor(options?: CodeMirror.EditorConfiguration); /** * A signal emitted when either the top or bottom edge is requested. */ edgeRequested: ISignal<CellEditorWidget, EdgeLocation>; /** * A signal emitted when a text change is completed. */ textChanged: ISignal<CellEditorWidget, ITextChange>; /** * A signal emitted when a tab (text) completion is requested. */ completionRequested: ISignal<CellEditorWidget, ICompletionRequest>; /** * The cell model used by the editor. */ model: ICellModel; /** * The line numbers state of the editor. */ lineNumbers: boolean; /** * Dispose of the resources held by the editor. */ dispose(): void; /** * Get the current cursor position of the editor. */ getCursorPosition(): number; /** * Set the current cursor position of the editor. */ setCursorPosition(position: number): void; /** * Handle changes in the model state. */ protected onModelStateChanged(model: ICellModel, args: IChangedArgs<any>): void; /** * Handle change events from the document. */ protected onDocChange(doc: CodeMirror.Doc, change: CodeMirror.EditorChange): void; /** * Handle keydown events from the editor. */ protected onEditorKeydown(editor: CodeMirror.Editor, event: KeyboardEvent): void; /** * Handle a tab key press. */ protected onTabEvent(event: KeyboardEvent, ch: number, line: number): void; private _model; }