@unisnips/ultisnips
Version:
Utilities for converting ultisnips in unisnips project
47 lines (46 loc) • 1.42 kB
TypeScript
import { Point } from 'unist';
export interface TextPosition {
line: number;
column: number;
/**
* offset may be 'undefined' during operation
*/
offset?: number;
}
/**
* Represents a Position in a text file: (0 based line index, 0 based column
* index) and provides methods for moving them around.
*/
export declare class TextPosition implements TextPosition {
static fromUnistPoint(point: Point): TextPosition;
/**
* A function that compares positions, useful for sorting
*/
static compare(a: TextPosition, b: TextPosition): number;
constructor(line: number, col: number, offset?: number);
toString(): string;
clone(): TextPosition;
toUnistPosition(): {
line: number;
column: number;
offset: number;
};
/**
* Returns the difference that the cursor must move to come from 'pos' to us
*/
delta(pos: TextPosition): TextPosition;
/**
* Create a new position that, moved 'delta' from us.
* Slightly different than `add` method
*/
moveWith(delta: TextPosition): TextPosition;
add(pos: TextPosition): TextPosition;
substract(pos: TextPosition): TextPosition;
/**
* Create a new position from this position.
*
* @param newLineNumber new line number
* @param newColumn new column
*/
with(newLineNumber?: number, newColumn?: number): TextPosition;
}