Skip to content

Commit 8cae6c3

Browse files
committed
feat: embed pane styles and expose pane style API
1 parent f8106d7 commit 8cae6c3

9 files changed

Lines changed: 329 additions & 165 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ await restty.setFontSources([
109109

110110
`restty` ships a pane manager and a default terminal context menu so you can add split panes quickly.
111111
It auto-creates pane DOM, canvas, and hidden IME inputs for you.
112+
Pane/split/divider styles are injected by the library (no separate CSS file required).
112113

113114
```ts
114115
import {
@@ -131,6 +132,10 @@ const restty = new Restty({
131132
defaultContextMenu: {
132133
getPtyUrl: () => "ws://localhost:8787/pty",
133134
},
135+
paneStyles: {
136+
inactivePaneOpacity: 0.82,
137+
dividerThicknessPx: 1,
138+
},
134139
shortcuts: true,
135140
});
136141

@@ -150,6 +155,7 @@ Main methods:
150155
- `destroy()`
151156
- `getPanes()` / `getActivePane()` / `getFocusedPane()`
152157
- `splitActivePane("vertical" | "horizontal")` / `splitPane(id, direction)` / `closePane(id)`
158+
- `getPaneStyleOptions()` / `setPaneStyleOptions({...})`
153159
- `connectPty(url)` / `disconnectPty()` / `isPtyConnected()`
154160
- `setRenderer("auto" | "webgpu" | "webgl2")`
155161
- `setFontSize(number)`

docs/usage.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Useful methods:
7272

7373
`Restty` supports split panes with default shortcuts/context-menu out of the box.
7474
It auto-creates each pane container, canvas, and hidden IME textarea.
75+
Pane, divider, and context-menu styles are injected automatically by the library.
7576

7677
```ts
7778
import {
@@ -80,12 +81,17 @@ import {
8081

8182
const restty = new Restty({
8283
root: document.getElementById("paneRoot") as HTMLElement,
84+
paneStyles: {
85+
inactivePaneOpacity: 0.82,
86+
dividerThicknessPx: 1,
87+
},
8388
defaultContextMenu: true,
8489
shortcuts: true,
8590
});
8691

8792
restty.splitActivePane("vertical");
8893
restty.splitActivePane("horizontal");
94+
restty.setPaneStyleOptions({ inactivePaneOpacity: 0.72, dividerThicknessPx: 2 });
8995
```
9096

9197
## Low-level integration (`loadResttyWasm`)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "restty",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "Browser terminal rendering library powered by WASM, WebGPU/WebGL2, and TypeScript text shaping.",
55
"keywords": [
66
"terminal",

playground/public/style.css

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ main {
5151
min-height: 0;
5252
}
5353

54-
.pane-root {
55-
display: flex;
56-
width: 100%;
57-
height: 100%;
58-
min-width: 0;
59-
min-height: 0;
60-
}
61-
6254
.settings-fab-stack {
6355
position: fixed;
6456
right: 20px;
@@ -174,162 +166,6 @@ main {
174166
line-height: 1;
175167
}
176168

177-
.pane-split {
178-
display: flex;
179-
flex: 1 1 auto;
180-
min-width: 0;
181-
min-height: 0;
182-
gap: 0;
183-
padding: 0;
184-
background: #111;
185-
}
186-
187-
.pane-split.is-vertical {
188-
flex-direction: row;
189-
}
190-
191-
.pane-split.is-horizontal {
192-
flex-direction: column;
193-
}
194-
195-
.pane {
196-
position: relative;
197-
flex: 1 1 0;
198-
min-width: 0;
199-
min-height: 0;
200-
background: #000;
201-
border: 0;
202-
overflow: hidden;
203-
opacity: 0.82;
204-
transition: opacity 140ms ease-out;
205-
}
206-
207-
.pane.is-active {
208-
opacity: 1;
209-
}
210-
211-
.pane-divider {
212-
position: relative;
213-
z-index: 2;
214-
flex: 0 0 1px;
215-
touch-action: none;
216-
}
217-
218-
.pane-divider.is-vertical {
219-
cursor: col-resize;
220-
background: transparent;
221-
}
222-
223-
.pane-divider.is-horizontal {
224-
cursor: row-resize;
225-
background: transparent;
226-
}
227-
228-
.pane-divider.is-vertical:hover,
229-
.pane-divider.is-vertical.is-dragging {
230-
background:
231-
radial-gradient(
232-
100px 46% at 50% 50%,
233-
rgba(235, 235, 235, 0.92) 0%,
234-
rgba(200, 200, 200, 0.48) 46%,
235-
rgba(155, 155, 155, 0.12) 68%,
236-
rgba(120, 120, 120, 0) 100%
237-
),
238-
rgba(185, 185, 185, 0.24);
239-
}
240-
241-
.pane-divider.is-horizontal:hover,
242-
.pane-divider.is-horizontal.is-dragging {
243-
background:
244-
radial-gradient(
245-
46% 100px at 50% 50%,
246-
rgba(235, 235, 235, 0.92) 0%,
247-
rgba(200, 200, 200, 0.48) 46%,
248-
rgba(155, 155, 155, 0.12) 68%,
249-
rgba(120, 120, 120, 0) 100%
250-
),
251-
rgba(185, 185, 185, 0.24);
252-
}
253-
254-
body.is-resizing-split {
255-
user-select: none;
256-
}
257-
258-
.pane-canvas {
259-
width: 100%;
260-
height: 100%;
261-
display: block;
262-
outline: none;
263-
}
264-
265-
.pane-ime-input {
266-
position: fixed;
267-
left: 0;
268-
top: 0;
269-
width: 1px;
270-
height: 1px;
271-
opacity: 0;
272-
pointer-events: none;
273-
}
274-
275-
.pane-term-debug {
276-
display: none;
277-
}
278-
279-
.pane-context-menu {
280-
position: fixed;
281-
z-index: 9999;
282-
min-width: 200px;
283-
padding: 6px;
284-
border: 1px solid #2a2a2a;
285-
border-radius: 8px;
286-
background: #161616;
287-
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
288-
}
289-
290-
.pane-context-menu-item {
291-
width: 100%;
292-
display: flex;
293-
align-items: center;
294-
justify-content: space-between;
295-
gap: 12px;
296-
padding: 7px 9px;
297-
border: 0;
298-
border-radius: 6px;
299-
background: transparent;
300-
color: #d6d6d6;
301-
text-align: left;
302-
cursor: pointer;
303-
}
304-
305-
.pane-context-menu-item:hover {
306-
background: #252525;
307-
}
308-
309-
.pane-context-menu-item:disabled {
310-
opacity: 0.4;
311-
cursor: default;
312-
}
313-
314-
.pane-context-menu-item.is-danger {
315-
color: #f1a1a1;
316-
}
317-
318-
.pane-context-menu-label {
319-
font-size: 12px;
320-
}
321-
322-
.pane-context-menu-shortcut {
323-
font-size: 10px;
324-
color: #868686;
325-
}
326-
327-
.pane-context-menu-separator {
328-
height: 1px;
329-
margin: 6px 4px;
330-
background: #2a2a2a;
331-
}
332-
333169
/* Panel */
334170
.panel {
335171
display: flex;

src/app/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export type {
8080
ResttyPaneSplitDirection,
8181
ResttyPaneContextMenuItem,
8282
ResttyPaneDefinition,
83+
ResttyPaneStyleOptions,
84+
ResttyPaneStylesOptions,
8385
ResttyPaneShortcutsOptions,
8486
ResttyPaneContextMenuOptions,
8587
CreateResttyPaneManagerOptions,

src/app/pane-app-manager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {
22
createDefaultResttyPaneContextMenuItems,
33
createResttyPaneManager,
4+
type ResttyPaneStyleOptions,
5+
type ResttyPaneStylesOptions,
46
type ResttyPaneContextMenuOptions,
57
type ResttyPaneManager,
68
type ResttyPaneShortcutsOptions,
@@ -23,6 +25,9 @@ export type ResttyPaneDomDefaults = {
2325
termDebugClassName?: string;
2426
};
2527

28+
export type ResttyManagedPaneStyleOptions = ResttyPaneStyleOptions;
29+
export type ResttyManagedPaneStylesOptions = ResttyPaneStylesOptions;
30+
2631
export type ResttyPaneAppOptionsInput = Omit<ResttyAppOptions, "canvas" | "imeInput" | "session">;
2732

2833
export type ResttyDefaultPaneContextMenuOptions = {
@@ -47,6 +52,7 @@ export type CreateResttyAppPaneManagerOptions = {
4752
paneDom?: ResttyPaneDomDefaults;
4853
autoInit?: boolean;
4954
minPaneSize?: number;
55+
paneStyles?: boolean | ResttyManagedPaneStylesOptions;
5056
shortcuts?: boolean | ResttyPaneShortcutsOptions;
5157
contextMenu?: ResttyPaneContextMenuOptions<ResttyManagedAppPane> | null;
5258
defaultContextMenu?: boolean | ResttyDefaultPaneContextMenuOptions;
@@ -140,6 +146,7 @@ export function createResttyAppPaneManager(
140146
const manager = createResttyPaneManager<ResttyManagedAppPane>({
141147
root: options.root,
142148
minPaneSize: options.minPaneSize,
149+
styles: options.paneStyles,
143150
shortcuts,
144151
contextMenu,
145152
createPane: ({ id, sourcePane }) => {

0 commit comments

Comments
 (0)