M3.6: integrated terminal with PTY sessions and xterm.js sub-tabs
- crates/terminal: portable-pty sessions (ConPTY on Windows) with reader, writer and waiter threads, UTF-8 chunking, a 1 MiB output buffer with backpressure, a non-blocking input queue, resize, kill and exit codes; default shell pwsh -> powershell -> cmd on Windows, $SHELL or /bin/sh. - Engine: terminal.create/input/resize/close, terminalOutput (capped per terminal and per pump, round-robin) and terminalExited through the pump; terminals close with the project and on app.quit. - UI: Terminal tab in the bottom panel (tabs next to Find), xterm.js with the fit addon, sub-tabs, copy/paste, a focus rule that leaves plain Ctrl keys to the shell, terminal.open (Mod+Shift+T), --lt-terminal-* ANSI tokens in both themes (text colours AA) and a 4.5:1 minimum contrast. - Tests: real-shell crate tests (UTF-8, backpressure), engine and TCP control tests, Vitest with a mocked xterm; live check on port 7936; docs and parity rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5fa7f0c8b3
commit
a8daf269fb
45 changed files with 3935 additions and 49 deletions
|
|
@ -1,9 +1,14 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* The bottom panel of the main window: a tool window docked under the
|
||||
* editor (Find since M2.4; later Problems, Terminal and others). A header
|
||||
* with the title, a collapse/expand button and a close button, the content
|
||||
* slot, and a splitter on the top edge to resize it.
|
||||
* The bottom panel of the main window: tool windows docked under the
|
||||
* editor (Find since M2.4, Terminal since M3.6; later Problems and others).
|
||||
* A header with the title, a collapse/expand button and a close button, the
|
||||
* content slot, and a splitter on the top edge to resize it.
|
||||
*
|
||||
* Tabs (M3.6): with `tabs`, the header shows one tab per tool window
|
||||
* instead of the title; a click (or Left/Right on a focused tab) emits
|
||||
* `update:active`. The owner shows the active tool window's content in the
|
||||
* slot, and closing hides the active one.
|
||||
*
|
||||
* The splitter is dragged with the pointer or moved with Up/Down (Shift for
|
||||
* larger steps) when focused. Collapsed, only the header shows. Height and
|
||||
|
|
@ -12,9 +17,17 @@
|
|||
* what closing means.
|
||||
*/
|
||||
import { ChevronDown, ChevronUp, X } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
import { computed, nextTick, ref } from "vue";
|
||||
import { t } from "../../i18n";
|
||||
|
||||
/** A tab of the bottom panel. */
|
||||
export interface BottomTab {
|
||||
/** Tool window id. */
|
||||
id: string;
|
||||
/** Its title. */
|
||||
title: string;
|
||||
}
|
||||
|
||||
/** Props of the bottom panel. */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
|
|
@ -28,8 +41,12 @@ const props = withDefaults(
|
|||
maxHeight?: number;
|
||||
/** Whether the panel is expanded (true) or collapsed to its header. */
|
||||
open?: boolean;
|
||||
/** Tool windows shown as tabs in the header; none shows the title. */
|
||||
tabs?: readonly BottomTab[];
|
||||
/** Id of the active tab. */
|
||||
active?: string;
|
||||
}>(),
|
||||
{ height: 240, minHeight: 80, maxHeight: 900, open: true },
|
||||
{ height: 240, minHeight: 80, maxHeight: 900, open: true, tabs: () => [], active: "" },
|
||||
);
|
||||
|
||||
/** Events of the bottom panel. */
|
||||
|
|
@ -40,8 +57,39 @@ const emit = defineEmits<{
|
|||
"update:open": [open: boolean];
|
||||
/** The close button was pressed. */
|
||||
close: [];
|
||||
/** A tab was chosen. */
|
||||
"update:active": [id: string];
|
||||
}>();
|
||||
|
||||
/** The tab list element, to move the focus between tabs. */
|
||||
const tabList = ref<HTMLElement | null>(null);
|
||||
|
||||
/**
|
||||
* Moves between tabs with Left/Right and activates the new one.
|
||||
*
|
||||
* @param event - the key event on a tab.
|
||||
* @param index - the index of that tab.
|
||||
*/
|
||||
async function onTabKey(event: KeyboardEvent, index: number): Promise<void> {
|
||||
const count = props.tabs.length;
|
||||
let next: number;
|
||||
if (event.key === "ArrowRight") {
|
||||
next = (index + 1) % count;
|
||||
} else if (event.key === "ArrowLeft") {
|
||||
next = (index - 1 + count) % count;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
const tab = props.tabs[next];
|
||||
if (!tab) {
|
||||
return;
|
||||
}
|
||||
emit("update:active", tab.id);
|
||||
await nextTick();
|
||||
tabList.value?.querySelectorAll<HTMLElement>("[role=tab]")[next]?.focus();
|
||||
}
|
||||
|
||||
/** Inline style carrying the current height. */
|
||||
const bodyStyle = computed(() => ({ height: `${String(props.height)}px` }));
|
||||
|
||||
|
|
@ -118,7 +166,31 @@ function onSplitterKey(event: KeyboardEvent): void {
|
|||
@keydown="onSplitterKey"
|
||||
/>
|
||||
<header class="bottom-panel__header">
|
||||
<span class="bottom-panel__title">{{ title }}</span>
|
||||
<span
|
||||
v-if="tabs.length === 0"
|
||||
class="bottom-panel__title"
|
||||
>{{ title }}</span>
|
||||
<span
|
||||
v-else
|
||||
ref="tabList"
|
||||
class="bottom-panel__tabs"
|
||||
role="tablist"
|
||||
:aria-label="t('common.toolWindow.bottomTabs')"
|
||||
>
|
||||
<button
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="tab.id"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="bottom-panel__tab"
|
||||
:class="{ 'bottom-panel__tab--active': tab.id === active }"
|
||||
:aria-selected="tab.id === active"
|
||||
:tabindex="tab.id === active ? 0 : -1"
|
||||
:data-test="`bottom-tab-${tab.id}`"
|
||||
@click="emit('update:active', tab.id)"
|
||||
@keydown="onTabKey($event, index)"
|
||||
>{{ tab.title }}</button>
|
||||
</span>
|
||||
<span class="bottom-panel__actions">
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -188,6 +260,39 @@ function onSplitterKey(event: KeyboardEvent): void {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bottom-panel__tabs {
|
||||
display: inline-flex;
|
||||
align-self: stretch;
|
||||
gap: var(--lt-space-xs, 2px);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bottom-panel__tab {
|
||||
padding: 0 var(--lt-space-m, 8px);
|
||||
color: var(--lt-fg-muted);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bottom-panel__tab:hover {
|
||||
color: var(--lt-fg);
|
||||
}
|
||||
|
||||
.bottom-panel__tab--active {
|
||||
color: var(--lt-fg);
|
||||
border-bottom-color: var(--lt-accent);
|
||||
}
|
||||
|
||||
.bottom-panel__tab:focus-visible {
|
||||
outline: 2px solid var(--lt-accent);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.bottom-panel__actions {
|
||||
display: inline-flex;
|
||||
gap: var(--lt-space-xs, 2px);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue