mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
Merge pull request #2906 from hellochar/patch-2
Add StringStream definition for codemirror
This commit is contained in:
Vendored
+110
@@ -806,4 +806,114 @@ declare module CodeMirror {
|
||||
By default, a marker appears only in its target document. */
|
||||
shared?: boolean;
|
||||
}
|
||||
|
||||
interface StringStream {
|
||||
lastColumnPos: number;
|
||||
lastColumnValue: number;
|
||||
lineStart: number;
|
||||
|
||||
/**
|
||||
* Current position in the string.
|
||||
*/
|
||||
pos: number;
|
||||
|
||||
/**
|
||||
* Where the stream's position was when it was first passed to the token function.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* The current line's content.
|
||||
*/
|
||||
string: string;
|
||||
|
||||
/**
|
||||
* Number of spaces per tab character.
|
||||
*/
|
||||
tabSize: number;
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the end of the line.
|
||||
*/
|
||||
eol(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the start of the line.
|
||||
*/
|
||||
sol(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream without advancing it. Will return an null at the end of the line.
|
||||
*/
|
||||
peek(): string;
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream and advances it. Also returns null when no more characters are available.
|
||||
*/
|
||||
next(): string;
|
||||
|
||||
/**
|
||||
* match can be a character, a regular expression, or a function that takes a character and returns a boolean.
|
||||
* If the next character in the stream 'matches' the given argument, it is consumed and returned.
|
||||
* Otherwise, undefined is returned.
|
||||
*/
|
||||
eat(match: string): string;
|
||||
eat(match: RegExp): string;
|
||||
eat(match: (char: string) => boolean): string;
|
||||
|
||||
/**
|
||||
* Repeatedly calls eat with the given argument, until it fails. Returns true if any characters were eaten.
|
||||
*/
|
||||
eatWhile(match: string): boolean;
|
||||
eatWhile(match: RegExp): boolean;
|
||||
eatWhile(match: (char: string) => boolean): boolean;
|
||||
|
||||
/**
|
||||
* Shortcut for eatWhile when matching white-space.
|
||||
*/
|
||||
eatSpace(): boolean;
|
||||
|
||||
/**
|
||||
* Moves the position to the end of the line.
|
||||
*/
|
||||
skipToEnd(): void;
|
||||
|
||||
/**
|
||||
* Skips to the next occurrence of the given character, if found on the current line (doesn't advance the stream if
|
||||
* the character does not occur on the line).
|
||||
*
|
||||
* Returns true if the character was found.
|
||||
*/
|
||||
skipTo(ch: string): boolean;
|
||||
|
||||
/**
|
||||
* Act like a multi-character eat - if consume is true or not given - or a look-ahead that doesn't update the stream
|
||||
* position - if it is false. pattern can be either a string or a regular expression starting with ^. When it is a
|
||||
* string, caseFold can be set to true to make the match case-insensitive. When successfully matching a regular
|
||||
* expression, the returned value will be the array returned by match, in case you need to extract matched groups.
|
||||
*/
|
||||
match(pattern: string, consume?: boolean, caseFold?: boolean): boolean;
|
||||
match(pattern: RegExp, consume?: boolean): string[];
|
||||
|
||||
/**
|
||||
* Backs up the stream n characters. Backing it up further than the start of the current token will cause things to
|
||||
* break, so be careful.
|
||||
*/
|
||||
backUp(n: number): void;
|
||||
|
||||
/**
|
||||
* Returns the column (taking into account tabs) at which the current token starts.
|
||||
*/
|
||||
column(): number;
|
||||
|
||||
/**
|
||||
* Tells you how far the current line has been indented, in spaces. Corrects for tab characters.
|
||||
*/
|
||||
indentation(): number;
|
||||
|
||||
/**
|
||||
* Get the string between the start of the current token and the current stream position.
|
||||
*/
|
||||
current(): string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user