Skip to content

Commit

Permalink
feat: add LanguageMode and TextBuffer types
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 8, 2020
1 parent b91633a commit f6bbb42
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/atom.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
export {}

// An {Object} with the following fields:
interface BufferChangeEvent {

// The deleted text
oldText: string

// The {Range} of the deleted text before the change took place.
oldRange: Range

// The inserted text
newText: string

// The {Range} of the inserted text after the change took place.
newRange: Range
}

type HighlightingChangeEvent = (range: Range) => void

declare module "atom" {


interface TextEditor {

// Get the Element for the editor.
Expand All @@ -9,6 +30,50 @@ declare module "atom" {
setVisible(visible: boolean): void
}

interface LanguageMode {
// A {Function} that returns a {String} identifying the language.
getLanguageId(): string

// A {Function} that is called whenever the buffer changes.
bufferDidChange(change: BufferChangeEvent): void

// A {Function} that takes a callback {Function} and calls it with a {Range} argument whenever the syntax of a given part of the buffer is updated.
onDidChangeHighlighting(callback: HighlightingChangeEvent): void

// A function that returns an iterator object with the following methods:
buildHighlightIterator(): {
// A {Function} that takes a {Point} and resets the iterator to that position.
seek(point: Point): any

// A {Function} that advances the iterator to the next token
moveToSuccessor(): void

// A {Function} that returns a {Point} representing the iterator's current position in the buffer.
getPosition(): Point

// A {Function} that returns an {Array} of {Number}s representing tokens that end at the current position.
getCloseTags(): Array<number>

// A {Function} that returns an {Array} of {Number}s representing tokens that begin at the current position.
getOpenTags(): Array<number>
}

}

interface TextBuffer {

// Experimental: Get the language mode associated with this buffer.
//
// Returns a language mode {Object} (See {TextBuffer::setLanguageMode} for its interface).
getLanguageMode(): string


// Experimental: Set the LanguageMode for this buffer.
//
// * `languageMode` - an {Object} with the following methods:
setLanguageMode (languageMode: LanguageMode): void
}

interface TextEditorElement {
setUpdatedSynchronously(val: boolean): void
}
Expand Down

0 comments on commit f6bbb42

Please sign in to comment.