Tabs¶
Tab and tab group management.
Tab
¶
Represents a tab within a tab group.
Initialize a Tab from VS Code data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Tab data from VS Code |
required |
Source code in vscode_sockpuppet/tabs.py
__repr__
¶
String representation of the tab.
Source code in vscode_sockpuppet/tabs.py
TabGroup¶
TabGroup
¶
Represents a group of tabs.
Initialize a TabGroup from VS Code data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Tab group data from VS Code |
required |
Source code in vscode_sockpuppet/tabs.py
__repr__
¶
TabGroups¶
TabGroups
¶
Manages tab groups in VS Code.
Initialize TabGroups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
VSCodeClient
|
The VSCodeClient instance |
required |
Source code in vscode_sockpuppet/tabs.py
get_all
¶
Get all tab groups.
Returns:
| Type | Description |
|---|---|
list[TabGroup]
|
List of all TabGroup instances |
Example
tab_groups = window.tab_groups.get_all() for group in tab_groups: print(f"Group {group.view_column}: {len(group.tabs)} tabs")
Source code in vscode_sockpuppet/tabs.py
get_active_tab_group
¶
Get the currently active tab group.
Returns:
| Type | Description |
|---|---|
Optional[TabGroup]
|
The active TabGroup or None |
Example
active_group = window.tab_groups.get_active_tab_group() if active_group: print(f"Active group has {len(active_group.tabs)} tabs")
Source code in vscode_sockpuppet/tabs.py
close_tab
¶
Close a specific tab.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tab
|
Tab
|
The tab to close |
required |
preserve_focus
|
bool
|
Whether to preserve focus |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Example
groups = window.tab_groups.get_all() for group in groups: for tab in group.tabs: if "test" in tab.label.lower(): window.tab_groups.close_tab(tab)
Source code in vscode_sockpuppet/tabs.py
close_group
¶
Close all tabs in a tab group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
TabGroup
|
The tab group to close |
required |
preserve_focus
|
bool
|
Whether to preserve focus |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Example
groups = window.tab_groups.get_all()
Close all groups except the active one¶
for group in groups: if not group.is_active: window.tab_groups.close_group(group)
Source code in vscode_sockpuppet/tabs.py
on_did_change_tab_groups
¶
Subscribe to tab group changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Callable[[TabGroupsChangeEvent], None]
|
Callback function for tab group changes |
required |
Returns:
| Type | Description |
|---|---|
Callable[[], None]
|
Dispose function to unsubscribe |
Example
def on_groups_changed(data): print("Tab groups changed!") groups = window.tab_groups.get_all() print(f"Now have {len(groups)} groups")
dispose = window.tab_groups.on_did_change_tab_groups( on_groups_changed )
Later: dispose()¶
Source code in vscode_sockpuppet/tabs.py
on_did_change_tabs
¶
Subscribe to tab changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Callable[[TabsChangeEvent], None]
|
Callback function for tab changes |
required |
Returns:
| Type | Description |
|---|---|
Callable[[], None]
|
Dispose function to unsubscribe |
Example
def on_tabs_changed(data): print("Tabs changed!") active = window.tab_groups.get_active_tab_group() if active and active.active_tab: print(f"Active tab: {active.active_tab.label}")
dispose = window.tab_groups.on_did_change_tabs(on_tabs_changed)