Skip to content

Commit ebc2b6c

Browse files
committed
feat: add missing Atom types
1 parent c410851 commit ebc2b6c

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

src-commons-ui/float-pane/FloatPane.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { DisplayMarker, Decoration, TextEditor, Disposable, DisposableLike, CompositeDisposable } from "atom"
1+
import { DisplayMarker, Decoration, TextEditor, Disposable, DisposableLike, CompositeDisposable, TextEditorElement } from "atom"
2+
import "../../types-packages/atom"
23
import { Observable, fromEvent } from "rxjs"
34
import type {Subscription} from "rxjs"
45
import { disposableFromSubscription } from "../../src-commons-atom/disposable"

types-packages/atom.d.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// TODO add to @types/Atom
2+
3+
export {}
4+
5+
// An {Object} with the following fields:
6+
interface BufferChangeEvent {
7+
// The deleted text
8+
oldText: string
9+
10+
// The {Range} of the deleted text before the change took place.
11+
oldRange: Range
12+
13+
// The inserted text
14+
newText: string
15+
16+
// The {Range} of the inserted text after the change took place.
17+
newRange: Range
18+
}
19+
20+
type HighlightingChangeEvent = (range: Range) => void
21+
22+
declare module "atom" {
23+
interface TextEditor {
24+
// Get the Element for the editor.
25+
getElement(): TextEditorElement
26+
27+
// Controls visibility based on the given {Boolean}.
28+
setVisible(visible: boolean): void
29+
30+
// Experimental: Get a notification when async tokenization is completed.
31+
onDidTokenize(callback: () => any): Disposable
32+
33+
component: {
34+
getNextUpdatePromise(): Promise<unknown>
35+
}
36+
37+
isDestroyed(): boolean
38+
}
39+
40+
interface LanguageMode {
41+
// A {Function} that returns a {String} identifying the language.
42+
getLanguageId(): string
43+
44+
// A {Function} that is called whenever the buffer changes.
45+
bufferDidChange(change: BufferChangeEvent): void
46+
47+
// 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.
48+
onDidChangeHighlighting(callback: HighlightingChangeEvent): void
49+
50+
// A function that returns an iterator object with the following methods:
51+
buildHighlightIterator(): {
52+
// A {Function} that takes a {Point} and resets the iterator to that position.
53+
seek(point: Point): any
54+
55+
// A {Function} that advances the iterator to the next token
56+
moveToSuccessor(): void
57+
58+
// A {Function} that returns a {Point} representing the iterator's current position in the buffer.
59+
getPosition(): Point
60+
61+
// A {Function} that returns an {Array} of {Number}s representing tokens that end at the current position.
62+
getCloseTags(): Array<number>
63+
64+
// A {Function} that returns an {Array} of {Number}s representing tokens that begin at the current position.
65+
getOpenTags(): Array<number>
66+
}
67+
}
68+
69+
interface TextMateLanguageMode {
70+
fullyTokenized: boolean
71+
72+
// Get the suggested indentation level for an existing line in the buffer.
73+
//
74+
// * bufferRow - A {Number} indicating the buffer row
75+
//
76+
// Returns a {Number}.
77+
suggestedIndentForBufferRow(bufferRow: number, tabLength: number, options: object): number
78+
79+
// Get the suggested indentation level for a given line of text, if it were inserted at the given
80+
// row in the buffer.
81+
//
82+
// * bufferRow - A {Number} indicating the buffer row
83+
//
84+
// Returns a {Number}.
85+
suggestedIndentForLineAtBufferRow(bufferRow: number, line: number, tabLength: number): number
86+
87+
// Get the suggested indentation level for a line in the buffer on which the user is currently
88+
// typing. This may return a different result from {::suggestedIndentForBufferRow} in order
89+
// to avoid unexpected changes in indentation. It may also return undefined if no change should
90+
// be made.
91+
//
92+
// * bufferRow - The row {Number}
93+
//
94+
// Returns a {Number}.
95+
suggestedIndentForEditedBufferRow(bufferRow: number, tabLength: number): number
96+
}
97+
98+
interface TextBuffer {
99+
// Experimental: Get the language mode associated with this buffer.
100+
//
101+
// Returns a language mode {Object} (See {TextBuffer::setLanguageMode} for its interface).
102+
getLanguageMode(): LanguageMode | TextMateLanguageMode
103+
104+
// Experimental: Set the LanguageMode for this buffer.
105+
//
106+
// * `languageMode` - an {Object} with the following methods:
107+
setLanguageMode(languageMode: LanguageMode | TextMateLanguageMode): void
108+
}
109+
110+
interface TextEditorElement {
111+
setUpdatedSynchronously(val: boolean): void
112+
}
113+
}

0 commit comments

Comments
 (0)