Window¶
Window operations including messages, dialogs, editors, and UI components.
Window
¶
VS Code window operations.
Source code in vscode_sockpuppet/window.py
on_did_change_active_text_editor
property
¶
Event fired when the active text editor changes.
on_did_change_text_editor_selection
property
¶
Event fired when the selection in an editor changes.
on_did_change_visible_text_editors
property
¶
Event fired when the visible text editors change.
on_did_open_terminal
property
¶
Event fired when a terminal is opened.
on_did_close_terminal
property
¶
Event fired when a terminal is closed.
on_did_change_terminal_state
property
¶
Event fired when a terminal's state changes.
on_did_change_text_editor_visible_ranges
property
¶
Event fired when visible ranges in an editor change.
on_did_change_text_editor_options
property
¶
Event fired when text editor options change.
on_did_change_text_editor_view_column
property
¶
Event fired when an editor's view column changes.
on_did_change_window_state
property
¶
Event fired when the window state changes (focus).
show_information_message
¶
Show an information message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to show |
required |
*items
|
str
|
Optional items to show as buttons |
()
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The selected item or None if dismissed |
Source code in vscode_sockpuppet/window.py
show_warning_message
¶
Show a warning message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to show |
required |
*items
|
str
|
Optional items to show as buttons |
()
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The selected item or None if dismissed |
Source code in vscode_sockpuppet/window.py
show_error_message
¶
Show an error message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to show |
required |
*items
|
str
|
Optional items to show as buttons |
()
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The selected item or None if dismissed |
Source code in vscode_sockpuppet/window.py
show_quick_pick
¶
Show a quick pick menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items
|
list[str]
|
The items to pick from |
required |
options
|
Optional[QuickPickOptions]
|
Quick pick options (QuickPickOptions TypedDict) |
None
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The selected item(s) or None if dismissed |
Source code in vscode_sockpuppet/window.py
show_input_box
¶
Show an input box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Optional[InputBoxOptions]
|
Input box options (InputBoxOptions TypedDict) |
None
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The entered text or None if dismissed |
Source code in vscode_sockpuppet/window.py
show_open_dialog
¶
Show a file open dialog to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Optional[OpenDialogOptions]
|
Dialog options (OpenDialogOptions TypedDict) |
None
|
Returns:
Type | Description |
---|---|
Optional[list[str]]
|
List of selected file/folder URIs, or None if canceled |
Example
Select a single Python file¶
uris = client.window.show_open_dialog({ 'canSelectFiles': True, 'canSelectFolders': False, 'canSelectMany': False, 'filters': {'Python': ['py']}, 'title': 'Select a Python file' })
Select multiple files or folders¶
uris = client.window.show_open_dialog({ 'canSelectFiles': True, 'canSelectFolders': True, 'canSelectMany': True, 'title': 'Select files or folders' })
Source code in vscode_sockpuppet/window.py
show_save_dialog
¶
Show a file save dialog to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Optional[SaveDialogOptions]
|
Dialog options (SaveDialogOptions TypedDict) |
None
|
Returns:
Type | Description |
---|---|
Optional[str]
|
Selected save location URI, or None if canceled |
Example
Save a Python file¶
uri = client.window.show_save_dialog({ 'filters': {'Python': ['py']}, 'title': 'Save Python file', 'saveLabel': 'Save' })
if uri: # Write to the selected location client.fs.write_text(uri, 'print("Hello")')
Source code in vscode_sockpuppet/window.py
show_workspace_folder_pick
¶
Show a workspace folder picker to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Optional[dict]
|
Optional picker options (placeHolder, ignoreFocusOut) |
None
|
Returns:
Type | Description |
---|---|
Optional[dict]
|
A dict with |
Optional[dict]
|
or None if canceled. |
Source code in vscode_sockpuppet/window.py
show_text_document
¶
Show a text document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
str
|
The URI of the document to show |
required |
options
|
Optional[TextDocumentShowOptions]
|
View options (TextDocumentShowOptions TypedDict) |
None
|
Returns:
Type | Description |
---|---|
dict
|
Success status |
Source code in vscode_sockpuppet/window.py
visible_text_editors
¶
Get a list of currently visible text editors.
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dicts with |
Source code in vscode_sockpuppet/window.py
get_state
¶
Get the current window state (focused flag).
Returns:
Type | Description |
---|---|
WindowState
|
A dict with |
create_output_channel
¶
create_output_channel(name: str, text: Optional[str] = None, show: bool = False, preserve_focus: bool = True) -> dict
Create an output channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the output channel |
required |
text
|
Optional[str]
|
Optional text to append |
None
|
show
|
bool
|
Whether to show the channel |
False
|
preserve_focus
|
bool
|
Whether to preserve focus when showing |
True
|
Returns:
Type | Description |
---|---|
dict
|
Success status |
Source code in vscode_sockpuppet/window.py
create_terminal
¶
create_terminal(name: Optional[str] = None, shell_path: Optional[str] = None, shell_args: Optional[list] = None) -> Terminal
Create a terminal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the terminal |
None
|
shell_path
|
Optional[str]
|
Path to the shell executable |
None
|
shell_args
|
Optional[list]
|
Arguments for the shell |
None
|
Returns:
Type | Description |
---|---|
Terminal
|
Terminal instance for interacting with the terminal |
Example
Create a simple terminal¶
terminal = window.create_terminal(name="My Terminal")
Create with custom shell¶
terminal = window.create_terminal( name="Bash", shell_path="/bin/bash" )
Use the terminal¶
terminal.send_text("echo 'Hello!'") terminal.show()
Source code in vscode_sockpuppet/window.py
set_status_bar_message
¶
Set a status bar message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The message to show |
required |
hide_after_timeout
|
Optional[int]
|
Optional timeout in milliseconds |
None
|
Returns:
Type | Description |
---|---|
dict
|
Success status |
Source code in vscode_sockpuppet/window.py
create_webview_panel
¶
create_webview_panel(title: str, html: str, view_type: Optional[str] = None, panel_id: Optional[str] = None, show_options: int = 1, options: Optional[WebviewOptions] = None) -> WebviewPanel
Create a webview panel with custom HTML content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
The title of the webview panel |
required |
html
|
str
|
The HTML content to display |
required |
view_type
|
Optional[str]
|
Identifier for the webview type (auto-generated if None) |
None
|
panel_id
|
Optional[str]
|
Unique identifier for the panel (auto-generated if None) |
None
|
show_options
|
int
|
ViewColumn where to show (1=One, 2=Two, 3=Three) |
1
|
options
|
Optional[WebviewOptions]
|
Webview configuration options |
None
|
Returns:
Type | Description |
---|---|
WebviewPanel
|
The created WebviewPanel instance |
Example
with window.create_webview_panel( "My Panel", "
Hello from Python!
" ) as panel: # Panel will automatically dispose when exiting context panel.update_html("Updated content
")Source code in vscode_sockpuppet/window.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|