Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace window

用于处理编辑器当前窗口(window)的命名空间。就是可见和活动的编辑器以及显示信息、选择和要求用户输入的 UI 元素。

maintainer

@youngjuning

索引

Variables(6)

Let activeTextEditor

activeTextEditor: TextEditor | undefined

当前活动的编辑器或 undefined。活动的编辑器是当前聚焦的编辑器,或者当没有聚焦时,是最近改变输入的编辑器。

Let visibleTextEditors

visibleTextEditors: TextEditor[]

当前可见的编辑器或者一个空数组。

Const terminals

terminals: readonly Terminal[]

The currently opened terminals or an empty array.

Const activeTerminal

activeTerminal: Terminal | undefined

The currently active terminal or undefined. The active terminal is the one that currently has focus or most recently had focus.

Const state

Represents the current window's state.

Let activeColorTheme

activeColorTheme: ColorTheme

The currently active color theme as configured in the settings. The active theme can be changed via the workbench.colorTheme setting.

Functions(39)

Const onDidChangeActiveTextEditor

Const onDidChangeVisibleTextEditors

Const onDidChangeTextEditorSelection

Const onDidChangeTextEditorVisibleRanges

Const onDidChangeTextEditorOptions

Const onDidChangeTextEditorViewColumn

Const onDidChangeActiveTerminal

Const onDidOpenTerminal

Const onDidCloseTerminal

Const onDidChangeWindowState

showTextDocument

createTextEditorDecorationType

showInformationMessage

  • showInformationMessage(message: string, ...items: string[]): Thenable<string | undefined>
  • showInformationMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>
  • showInformationMessage<T>(message: string, ...items: T[]): Thenable<T | undefined>
  • showInformationMessage<T>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>
  • Show an information message to users. Optionally provide an array of items which will be presented as clickable buttons.

    Parameters

    • message: string

      The message to show.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an information message to users. Optionally provide an array of items which will be presented as clickable buttons.

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an information message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an information message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

showWarningMessage

  • showWarningMessage(message: string, ...items: string[]): Thenable<string | undefined>
  • showWarningMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>
  • showWarningMessage<T>(message: string, ...items: T[]): Thenable<T | undefined>
  • showWarningMessage<T>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>
  • Show a warning message.

    see

    showInformationMessage

    Parameters

    • message: string

      The message to show.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show a warning message.

    see

    showInformationMessage

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show a warning message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show a warning message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

showErrorMessage

  • showErrorMessage(message: string, ...items: string[]): Thenable<string | undefined>
  • showErrorMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>
  • showErrorMessage<T>(message: string, ...items: T[]): Thenable<T | undefined>
  • showErrorMessage<T>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>
  • Show an error message.

    see

    showInformationMessage

    Parameters

    • message: string

      The message to show.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an error message.

    see

    showInformationMessage

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: string[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<string | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an error message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

  • Show an error message.

    see

    showInformationMessage

    Type parameters

    Parameters

    • message: string

      The message to show.

    • options: MessageOptions

      Configures the behaviour of the message.

    • Rest ...items: T[]

      A set of items that will be rendered as actions in the message.

    Returns Thenable<T | undefined>

    A thenable that resolves to the selected item or undefined when being dismissed.

showQuickPick

  • Shows a selection list allowing multiple selections.

    Parameters

    • items: readonly string[] | Thenable<readonly string[]>

      An array of strings, or a promise that resolves to an array of strings.

    • options: QuickPickOptions & { canPickMany: true }

      Configures the behavior of the selection list.

    • Optional token: CancellationToken

      A token that can be used to signal cancellation.

    Returns Thenable<string[] | undefined>

    A promise that resolves to the selected items or undefined.

  • Shows a selection list.

    Parameters

    • items: readonly string[] | Thenable<readonly string[]>

      An array of strings, or a promise that resolves to an array of strings.

    • Optional options: QuickPickOptions

      Configures the behavior of the selection list.

    • Optional token: CancellationToken

      A token that can be used to signal cancellation.

    Returns Thenable<string | undefined>

    A promise that resolves to the selection or undefined.

  • Shows a selection list allowing multiple selections.

    Type parameters

    Parameters

    • items: readonly T[] | Thenable<readonly T[]>

      An array of items, or a promise that resolves to an array of items.

    • options: QuickPickOptions & { canPickMany: true }

      Configures the behavior of the selection list.

    • Optional token: CancellationToken

      A token that can be used to signal cancellation.

    Returns Thenable<T[] | undefined>

    A promise that resolves to the selected items or undefined.

  • Shows a selection list.

    Type parameters

    Parameters

    • items: readonly T[] | Thenable<readonly T[]>

      An array of items, or a promise that resolves to an array of items.

    • Optional options: QuickPickOptions

      Configures the behavior of the selection list.

    • Optional token: CancellationToken

      A token that can be used to signal cancellation.

    Returns Thenable<T | undefined>

    A promise that resolves to the selected item or undefined.

showWorkspaceFolderPick

showOpenDialog

  • Shows a file open dialog to the user which allows to select a file for opening-purposes.

    Parameters

    Returns Thenable<Uri[] | undefined>

    A promise that resolves to the selected resources or undefined.

showSaveDialog

  • Shows a file save dialog to the user which allows to select a file for saving-purposes.

    Parameters

    Returns Thenable<Uri | undefined>

    A promise that resolves to the selected resource or undefined.

showInputBox

  • Opens an input box to ask the user for input.

    The returned value will be undefined if the input box was canceled (e.g. pressing ESC). Otherwise the returned value will be the string typed by the user or an empty string if the user did not type anything but dismissed the input box with OK.

    Parameters

    • Optional options: InputBoxOptions

      Configures the behavior of the input box.

    • Optional token: CancellationToken

      A token that can be used to signal cancellation.

    Returns Thenable<string | undefined>

    A promise that resolves to a string the user provided or to undefined in case of dismissal.

createQuickPick

createInputBox

createOutputChannel

createWebviewPanel

  • Create and show a new webview panel.

    Parameters

    • viewType: string

      Identifies the type of the webview panel.

    • title: string

      Title of the panel.

    • showOptions: ViewColumn | { viewColumn: ViewColumn; preserveFocus?: boolean }

      Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.

    • Optional options: WebviewPanelOptions & WebviewOptions

      Settings for the new panel.

    Returns WebviewPanel

    New webview panel.

setStatusBarMessage

  • setStatusBarMessage(text: string, hideAfterTimeout: number): Disposable
  • setStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable
  • setStatusBarMessage(text: string): Disposable
  • Set a message to the status bar. This is a short hand for the more powerful status bar items.

    Parameters

    • text: string

      The message to show, supports icon substitution as in status bar items.

    • hideAfterTimeout: number

      Timeout in milliseconds after which the message will be disposed.

    Returns Disposable

    A disposable which hides the status bar message.

  • Set a message to the status bar. This is a short hand for the more powerful status bar items.

    Parameters

    • text: string

      The message to show, supports icon substitution as in status bar items.

    • hideWhenDone: Thenable<any>

      Thenable on which completion (resolve or reject) the message will be disposed.

    Returns Disposable

    A disposable which hides the status bar message.

  • Set a message to the status bar. This is a short hand for the more powerful status bar items.

    Note that status bar messages stack and that they must be disposed when no longer used.

    Parameters

    • text: string

      The message to show, supports icon substitution as in status bar items.

    Returns Disposable

    A disposable which hides the status bar message.

withScmProgress

  • Show progress in the Source Control viewlet while running the given callback and while its returned promise isn't resolve or rejected.

    deprecated

    Use withProgress instead.

    Type parameters

    • R

    Parameters

    Returns Thenable<R>

    The thenable the task did return.

withProgress

  • Show progress in the editor. Progress is shown while running the given callback and while the promise it returned isn't resolved nor rejected. The location at which progress should show (and other details) is defined via the passed ProgressOptions.

    Type parameters

    • R

    Parameters

    • options: ProgressOptions
    • task: (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => Thenable<R>

      A callback returning a promise. Progress state can be reported with the provided Progress-object.

      To report discrete progress, use increment to indicate how much work has been completed. Each call with a increment value will be summed up and reflected as overall progress until 100% is reached (a value of e.g. 10 accounts for 10% of work done). Note that currently only ProgressLocation.Notification is capable of showing discrete progress.

      To monitor if the operation has been cancelled by the user, use the provided CancellationToken. Note that currently only ProgressLocation.Notification is supporting to show a cancel button to cancel the long running operation.

    Returns Thenable<R>

    The thenable the task-callback returned.

createStatusBarItem

  • Creates a status bar item.

    Parameters

    • Optional alignment: StatusBarAlignment

      The alignment of the item.

    • Optional priority: number

      The priority of the item. Higher values mean the item should be shown more to the left.

    Returns StatusBarItem

    A new status bar item.

  • Creates a status bar item.

    Parameters

    • id: string

      The unique identifier of the item.

    • Optional alignment: StatusBarAlignment

      The alignment of the item.

    • Optional priority: number

      The priority of the item. Higher values mean the item should be shown more to the left.

    Returns StatusBarItem

    A new status bar item.

createTerminal

  • Creates a Terminal with a backing shell process. The cwd of the terminal will be the workspace directory if it exists.

    throws

    When running in an environment where a new process cannot be started.

    Parameters

    • Optional name: string

      Optional human-readable string which will be used to represent the terminal in the UI.

    • Optional shellPath: string

      Optional path to a custom shell executable to be used in the terminal.

    • Optional shellArgs: string[] | string

      Optional args for the custom shell executable. A string can be used on Windows only which allows specifying shell args in command-line format.

    Returns Terminal

    A new Terminal.

  • Creates a Terminal with a backing shell process.

    throws

    When running in an environment where a new process cannot be started.

    Parameters

    • options: TerminalOptions

      A TerminalOptions object describing the characteristics of the new terminal.

    Returns Terminal

    A new Terminal.

  • Creates a Terminal where an extension controls its input and output.

    Parameters

    Returns Terminal

    A new Terminal.

registerTreeDataProvider

createTreeView

registerUriHandler

  • Registers a uri handler capable of handling system-wide uris. In case there are multiple windows open, the topmost window will handle the uri. A uri handler is scoped to the extension it is contributed from; it will only be able to handle uris which are directed to the extension itself. A uri must respect the following rules:

    • The uri-scheme must be vscode.env.uriScheme;
    • The uri-authority must be the extension id (e.g. my.extension);
    • The uri-path, -query and -fragment parts are arbitrary.

    For example, if the my.extension extension registers a uri handler, it will only be allowed to handle uris with the prefix product-name://my.extension.

    An extension can only register a single uri handler in its entire activation lifetime.

    • Note: There is an activation event onUri that fires when a uri directed for the current extension is about to be handled.

    Parameters

    • handler: UriHandler

      The uri handler to register for this extension.

    Returns Disposable

registerWebviewPanelSerializer

  • Registers a webview panel serializer.

    Extensions that support reviving should have an "onWebviewPanel:viewType" activation event and make sure that registerWebviewPanelSerializer is called during activation.

    Only a single serializer may be registered at a time for a given viewType.

    Parameters

    • viewType: string

      Type of the webview panel that can be serialized.

    • serializer: WebviewPanelSerializer

      Webview serializer.

    Returns Disposable

registerWebviewViewProvider

  • registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: { webviewOptions?: { retainContextWhenHidden?: boolean } }): Disposable
  • Register a new provider for webview views.

    Parameters

    • viewId: string

      Unique id of the view. This should match the id from the views contribution in the package.json.

    • provider: WebviewViewProvider

      Provider for the webview views.

    • Optional options: { webviewOptions?: { retainContextWhenHidden?: boolean } }
      • Optional Readonly webviewOptions?: { retainContextWhenHidden?: boolean }

        Content settings for the webview created for this view.

        • Optional Readonly retainContextWhenHidden?: boolean

          Controls if the webview element itself (iframe) is kept around even when the view is no longer visible.

          Normally the webview's html context is created when the view becomes visible and destroyed when it is hidden. Extensions that have complex state or UI can set the retainContextWhenHidden to make the editor keep the webview context around, even when the webview moves to a background tab. When a webview using retainContextWhenHidden becomes hidden, its scripts and other dynamic content are suspended. When the view becomes visible again, the context is automatically restored in the exact same state it was in originally. You cannot send messages to a hidden webview, even with retainContextWhenHidden enabled.

          retainContextWhenHidden has a high memory overhead and should only be used if your view's context cannot be quickly saved and restored.

    Returns Disposable

    Disposable that unregisters the provider.

registerCustomEditorProvider

  • customEditors 扩展功能点贡献的 viewType 注册一个自定义编辑器的 Provider。

    当打开一个自定义编辑器被时,会触发一个 onCustomEditor:viewType 活动事件。 你的扩展必须为 viewType 注册一个 CustomTextEditorProviderCustomReadonlyEditorProviderCustomEditorProvider 作为激活的一部分。

    Parameters

    • viewType: string

      自定义编辑器 provider 的唯一标识符。这应该与 contribution.customEditors 配置的 viewType 匹配。

    • provider: CustomTextEditorProvider | CustomReadonlyEditorProvider | CustomEditorProvider

      解析自定义编辑器的 Provider。

    • Optional options: { webviewOptions?: WebviewPanelOptions; supportsMultipleEditorsPerDocument?: boolean }

      的配置选项。

      • Optional Readonly webviewOptions?: WebviewPanelOptions

        Content settings for the webview panels created for this custom editor.

      • Optional Readonly supportsMultipleEditorsPerDocument?: boolean

        Only applies to CustomReadonlyEditorProvider | CustomEditorProvider.

        Indicates that the provider allows multiple editor instances to be open at the same time for the same resource.

        By default, the editor only allows one editor instance to be open at a time for each resource. If the user tries to open a second editor instance for the resource, the first one is instead moved to where the second one was to be opened.

        When supportsMultipleEditorsPerDocument is enabled, users can split and create copies of the custom editor. In this case, the custom editor must make sure it can properly synchronize the states of all editor instances for a resource so that they are consistent.

    Returns Disposable

    一次性的,取消注册的 provider

registerTerminalLinkProvider

  • Register provider that enables the detection and handling of links within the terminal.

    Parameters

    Returns Disposable

    Disposable that unregisters the provider.

registerTerminalProfileProvider

registerFileDecorationProvider

Const onDidChangeActiveColorTheme

VS Code 插件开发中文文档 | VS Code 中文文档 | VS Code 官网文档 | VS Code 扩展市场

Generated by TypeDoc | 站长统计