mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-03 23:23:21 +00:00
Shape rows in native Canvas and CoreText, then place clusters on xterm columns so fallback font advances cannot separate text from its cursor. Wait for measured dimensions before attachment and repaint overhanging ink with affected rows. Use Android platform ICU to avoid bundling approximately 14 MB of data; retain and document the Android 10 conjunct limitation.
48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { requireNativeView } from "expo";
|
|
import { useCallback, useMemo } from "react";
|
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
|
|
import type { PaseoTerminalCellMetrics, PaseoTerminalFrame, PaseoTerminalTheme } from "./contract";
|
|
import { encodeTerminalCustomGlyphs, type PaseoTerminalCustomGlyph } from "./custom-glyphs";
|
|
import { encodeTerminalFrame, type NativePaseoTerminalFrame } from "./frame-encoding";
|
|
|
|
export * from "./contract";
|
|
|
|
export interface PaseoTerminalViewProps {
|
|
frame: PaseoTerminalFrame;
|
|
theme: PaseoTerminalTheme;
|
|
fontFamily: string;
|
|
/** Font size in points after the system font scale is applied. */
|
|
fontSize: number;
|
|
onCellMetrics?: (metrics: PaseoTerminalCellMetrics) => void;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
interface NativePaseoTerminalViewProps extends Omit<
|
|
PaseoTerminalViewProps,
|
|
"frame" | "onCellMetrics"
|
|
> {
|
|
frame: NativePaseoTerminalFrame;
|
|
customGlyphs: PaseoTerminalCustomGlyph[];
|
|
onCellMetrics?: (event: { nativeEvent: PaseoTerminalCellMetrics }) => void;
|
|
}
|
|
|
|
const NativePaseoTerminalView = requireNativeView<NativePaseoTerminalViewProps>("PaseoTerminal");
|
|
const CUSTOM_GLYPHS = encodeTerminalCustomGlyphs();
|
|
|
|
export function PaseoTerminalView({ frame, onCellMetrics, ...props }: PaseoTerminalViewProps) {
|
|
const nativeFrame = useMemo(() => encodeTerminalFrame(frame), [frame]);
|
|
const handleCellMetrics = useCallback(
|
|
(event: { nativeEvent: PaseoTerminalCellMetrics }) => onCellMetrics?.(event.nativeEvent),
|
|
[onCellMetrics],
|
|
);
|
|
return (
|
|
<NativePaseoTerminalView
|
|
{...props}
|
|
frame={nativeFrame}
|
|
customGlyphs={CUSTOM_GLYPHS}
|
|
onCellMetrics={handleCellMetrics}
|
|
/>
|
|
);
|
|
}
|