Enter, l and a click (a Ctrl-, Cmd- or middle click too) open into the next column beside what is there; Shift+Enter and a Shift-click open in place of the focused branch's pane there. Opening what is open focuses it; a second Enter on an open row keeps it. A document from the menu or /open still opens in place. A crowded column now stacks its panes the way the strip stacks columns, by the same code (stack.ts): each pane stuck a tab below the one before, the one looked at whole, the others slid under it, partly and at the limit down to a tab, a pinned one never covered. What is covered down to its strip is not painted. The mouse resting on a covered pane, tab or spine peeks it out over its neighbours; a click makes it the active pane. A pane's grip, the band above its title, or its tab drags it up or down its column (Esc cancels). Curves from words start at the end of their underline. Curves keep their elements and are drawn on a layer of their own, so a change repaints only what moved; with many curves in a gutter, lanes are ordered by swapping neighbours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
38 lines
2.0 KiB
TypeScript
38 lines
2.0 KiB
TypeScript
/** The stacking shared by the panes view's strip and its crowded columns (src/ui/stack.ts). */
|
|
import { describe, expect, it } from "vitest";
|
|
import { coverage, offsets, reveal, starts, whole } from "../src/ui/stack";
|
|
|
|
describe("stack", () => {
|
|
it("sticks each item a strip after the one before, a pinned one its whole size, never past where the rest can still be reached", () => {
|
|
expect(offsets([700, 700, 700, 700], [false, false, false, false], 40, 1920)).toEqual([0, 40, 80, 120]);
|
|
expect(offsets([700, 700, 700, 700], [false, true, false, false], 40, 1920)).toEqual([0, 40, 740, 780]);
|
|
// Two pinned columns would push the last out of reach: it stays where the window ends.
|
|
expect(offsets([700, 700, 700, 700], [true, true, false, false], 40, 1920).at(-1)).toBe(1920 - 700);
|
|
// Down a column: tabs.
|
|
expect(offsets([300, 500, 400], [false, false, false], 30, 900)).toEqual([0, 30, 60]);
|
|
});
|
|
|
|
it("an item is overlapped where the next begins before it ends, and covered when less than 40% of it shows", () => {
|
|
const { over, covered } = coverage([0, 40, 480], [700, 700, 700], Infinity);
|
|
expect(over).toEqual([true, true, false]);
|
|
expect(covered).toEqual([true, false, false]);
|
|
// Down a column the box's foot covers too.
|
|
expect(coverage([0, 300], [300, 600], 600).covered).toEqual([false, false]);
|
|
expect(coverage([0, 500], [300, 600], 600).over).toEqual([false, true]);
|
|
});
|
|
|
|
it("scrolls as little as it can to show an item whole", () => {
|
|
const sizes = [700, 700, 700, 700];
|
|
const at = starts(sizes);
|
|
expect(at).toEqual([0, 700, 1400, 2100]);
|
|
// The last column whole: its far edge in view.
|
|
expect(reveal(0, 1920, at[3], 700, 120, 880)).toBe(880);
|
|
// Already whole: no move.
|
|
expect(reveal(500, 1920, at[2], 700, 80, 880)).toBe(500);
|
|
// Column 1 uncovered: not yet stuck under column 0.
|
|
expect(reveal(880, 1920, at[1], 700, 40, 880)).toBe(660);
|
|
expect(whole(660, 1920, at[1], 700, 40)).toBe(true);
|
|
expect(whole(880, 1920, at[1], 700, 40)).toBe(false);
|
|
});
|
|
});
|