pi-mono/packages/tui/src/index.ts
Petr Houška 3bae85274a fix(tui,coding-agent): handle selection page keys in all scrolling lists
tui.select.pageUp/pageDown were configurable but ignored by SelectList,
SettingsList, editor autocomplete, and most coding-agent selectors. In
fullscreen mode, the default PageUp/PageDown also scrolled the transcript
instead of reaching the focused list.

- add getSelectPageIndex() and handle page keys in SelectList, SettingsList,
  editor autocomplete, and the model, scoped models, auth, user message,
  settings submenu, llama search, and /mcp selectors
- add Component.capturesViewportInput: a focused component that sets it
  receives fullscreen viewport keys instead of the transcript, as a focused
  overlay already does
- let page keys move an open autocomplete menu before app actions, so a
  remapped Ctrl+V pages the menu instead of pasting an image

closes #7629

Co-authored-by: muyiyr <940955635@qq.com>
2026-10-28 19:05:21 +01:00

197 lines
5.1 KiB
TypeScript

// Core TUI interfaces and classes
export { Marked, type Token, type Tokens } from "marked";
// Autocomplete support
export {
type AutocompleteItem,
type AutocompleteProvider,
type AutocompleteSuggestions,
CombinedAutocompleteProvider,
type SlashCommand,
} from "./autocomplete.ts";
// Colors and styling
export {
backgroundAnsi,
type Color,
type ColorMixSpace,
colorToHex,
colorToOkhsl,
colorToOklch,
colorToRgb,
foregroundAnsi,
type IndexedColor,
indexedColor,
mixColors,
type OkhslChannels,
type OklchChannels,
type OklchColorValue,
okhslColor,
oklchColor,
parseColor,
type RgbColorValue,
rgbColor,
styleText,
styleTextWithAnsi,
type TerminalColorMode,
type TextAttributes,
type TextStyle,
} from "./colors.ts";
// Components
export { Box } from "./components/box.ts";
export { CancellableLoader } from "./components/cancellable-loader.ts";
export { Editor, type EditorOptions, type EditorTheme } from "./components/editor.ts";
export { HStack } from "./components/h-stack.ts";
export {
Image,
type ImageOptions,
type ImageTheme,
type ImageTranscoder,
setImageTranscoder,
} from "./components/image.ts";
export { Input } from "./components/input.ts";
export { Loader, type LoaderIndicatorOptions } from "./components/loader.ts";
export { type DefaultTextStyle, Markdown, type MarkdownOptions, type MarkdownTheme } from "./components/markdown.ts";
export { MouseRegion, type MouseRegionHandler } from "./components/mouse-region.ts";
export {
ScrollView,
type ScrollViewOptions,
type ScrollViewScrollbar,
type ScrollViewScrollToOptions,
} from "./components/scroll-view.ts";
export {
type SelectItem,
SelectList,
type SelectListLayoutOptions,
type SelectListTheme,
type SelectListTruncatePrimaryContext,
} from "./components/select-list.ts";
export { type SettingItem, SettingsList, type SettingsListTheme } from "./components/settings-list.ts";
export { Spacer } from "./components/spacer.ts";
export { Text } from "./components/text.ts";
export { TruncatedText } from "./components/truncated-text.ts";
export {
type StackChild,
type StackEntry,
type StackEntryOptions,
type StackOptions,
VStack,
} from "./components/v-stack.ts";
// Editor component interface (for custom editors)
export type { EditorComponent } from "./editor-component.ts";
// Fuzzy matching
export { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from "./fuzzy.ts";
// Keybindings
export {
getKeybindings,
getSelectPageIndex,
type Keybinding,
type KeybindingConflict,
type KeybindingDefinition,
type KeybindingDefinitions,
type Keybindings,
type KeybindingsConfig,
KeybindingsManager,
setKeybindings,
TUI_KEYBINDINGS,
} from "./keybindings.ts";
// Keyboard input handling
export {
decodeKittyPrintable,
isKeyRelease,
isKeyRepeat,
isKittyProtocolActive,
Key,
type KeyEventType,
type KeyId,
matchesKey,
parseKey,
setKittyProtocolActive,
} from "./keys.ts";
// LaTeX rendering
export { type RenderLatexOptions, renderLatex } from "./latex.ts";
// Native platform integration
export { getNativeClipboard, type NativeClipboard } from "./native-platform.ts";
export { oklabToOkhslLightness } from "./oklab.ts";
// Program status reporting (OSC 7501)
export { formatProgramStatus, type ProgramStatus } from "./program-status.ts";
// Input buffering for batch splitting
export { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from "./stdin-buffer.ts";
// Terminal interface and implementations
export { isAppleTerminalSession, ProcessTerminal, type Terminal } from "./terminal.ts";
// Terminal colors
export {
parseTerminalColorSchemeReport,
type RgbColor,
type TerminalColorScheme,
type TerminalColors,
} from "./terminal-colors.ts";
// Terminal image support
export {
allocateImageId,
type CellDimensions,
calculateImageRows,
deleteAllKittyImages,
deleteKittyImage,
detectCapabilities,
encodeITerm2,
encodeKitty,
getCapabilities,
getCellDimensions,
getGifDimensions,
getImageDimensions,
getJpegDimensions,
getPngDimensions,
getTerminalColorMode,
getWebpDimensions,
hyperlink,
type ImageDimensions,
type ImageProtocol,
type ImageRenderOptions,
imageFallback,
renderImage,
resetCapabilitiesCache,
setCapabilities,
setCapabilityOverrides,
setCellDimensions,
type TerminalCapabilities,
} from "./terminal-image.ts";
export {
type Component,
Container,
CURSOR_MARKER,
compositeTuiLine,
type Focusable,
isFocusable,
isViewportTUI,
type OverlayAnchor,
type OverlayBounds,
type OverlayHandle,
type OverlayMargin,
type OverlayOptions,
type OverlayUnfocusOptions,
renderFakeCursor,
type SizeValue,
type TUI,
type TuiInputListener,
type TuiInputListenerResult,
type TuiMode,
type TuiMouseButton,
type TuiMouseEvent,
type TuiMouseEventResult,
type TuiMouseEventType,
type TuiStopOptions,
type ViewportTUI,
} from "./tui.ts";
export { TuiAltScreen, type TuiAltScreenOptions } from "./tui-alt-screen.ts";
export { TuiMainScreen, type TuiMainScreenRenderState } from "./tui-main-screen.ts";
// Utilities
export {
getOsc8LinkAtColumn,
replaceControlCharacters,
sliceByColumn,
stripTerminalSequences,
truncateToWidth,
visibleWidth,
wrapTextWithAnsi,
} from "./utils.ts";
export type { WheelScrollLines } from "./wheel-scroll.ts";