33 GeneralizedRange ,
44 Range ,
55 ScopeType ,
6+ SpokenForm ,
67 TextEditor ,
7- } from "@cursorless/common " ;
8+ } from ".. " ;
89
910export interface ScopeProvider {
1011 /**
@@ -17,6 +18,7 @@ export interface ScopeProvider {
1718 editor : TextEditor ,
1819 config : ScopeRangeConfig ,
1920 ) => ScopeRanges [ ] ;
21+
2022 /**
2123 * Get the iteration scope ranges for the given editor.
2224 * @param editor The editor
@@ -75,6 +77,41 @@ export interface ScopeProvider {
7577 editor : TextEditor ,
7678 scopeType : ScopeType ,
7779 ) => ScopeSupport ;
80+
81+ /**
82+ * Registers a callback to be run when the scope support changes for the active
83+ * editor. The callback will be run immediately once with the current support
84+ * levels for the active editor.
85+ *
86+ * Note that this watcher could be expensive, because it runs all the scope
87+ * handlers for the active editor every time the content of the active editor
88+ * changes. If you only need info about the available scopes, including their
89+ * spoken forms, you should use {@link onDidChangeScopeInfo} instead.
90+ * @param callback The callback to run when the scope support changes
91+ * @returns A {@link Disposable} which will stop the callback from running
92+ */
93+ onDidChangeScopeSupport : ( callback : ScopeSupportEventCallback ) => Disposable ;
94+
95+ /**
96+ * Registers a callback to be run when the scope info changes. The callback
97+ * will be run immediately once with the current scope info.
98+ *
99+ * Includes information about the available scopes, including their custom
100+ * spoken forms, if available. Note that even custom regex scopes will be
101+ * available, as reported to the engine by Talon.
102+ * @param callback The callback to run when the scope support changes
103+ * @returns A {@link Disposable} which will stop the callback from running
104+ */
105+ onDidChangeScopeInfo ( callback : ScopeTypeInfoEventCallback ) : Disposable ;
106+
107+ /**
108+ * Get info about {@link scopeType}, including its custom spoken form, if
109+ * available.
110+ * @param editor The editor to check
111+ * @param scopeType The scope type to check
112+ * @returns Info about {@link scopeType}
113+ */
114+ getScopeInfo : ( scopeType : ScopeType ) => ScopeTypeInfo ;
78115}
79116
80117interface ScopeRangeConfigBase {
@@ -108,6 +145,24 @@ export type IterationScopeChangeEventCallback = (
108145 scopeRanges : IterationScopeRanges [ ] ,
109146) => void ;
110147
148+ export interface ScopeSupportInfo extends ScopeTypeInfo {
149+ support : ScopeSupport ;
150+ iterationScopeSupport : ScopeSupport ;
151+ }
152+
153+ export type ScopeSupportEventCallback = (
154+ scopeSupportInfos : ScopeSupportInfo [ ] ,
155+ ) => void ;
156+
157+ export interface ScopeTypeInfo {
158+ scopeType : ScopeType ;
159+ spokenForm : SpokenForm ;
160+ humanReadableName : string ;
161+ isLanguageSpecific : boolean ;
162+ }
163+
164+ export type ScopeTypeInfoEventCallback = ( scopeInfos : ScopeTypeInfo [ ] ) => void ;
165+
111166/**
112167 * Contains the ranges that define a given scope, eg its {@link domain} and the
113168 * ranges for its {@link targets}.
0 commit comments