Something went wrong. Try again.
more up to date at codeberg https://codeberg.org/cowie/tau.git
Something went wrong. Try again.
1.1 kB · 42 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243import { Box, Container, Markdown, type MarkdownTheme } from "@earendil-works/pi-tui";import { getMarkdownTheme, theme } from "../theme/theme.ts";
const OSC133_ZONE_START = "\x1b]133;A\x07";const OSC133_ZONE_END = "\x1b]133;B\x07";const OSC133_ZONE_FINAL = "\x1b]133;C\x07";
/** * Component that renders a user message */export class UserMessageComponent extends Container { private contentBox: Box;
constructor(text: string, markdownTheme: MarkdownTheme = getMarkdownTheme()) { super(); this.contentBox = new Box(1, 1, (content: string) => theme.bg("userMessageBg", content)); this.contentBox.addChild( new Markdown( text, 0, 0, markdownTheme, { color: (content: string) => theme.fg("userMessageText", content), }, { preserveOrderedListMarkers: true }, ), ); this.addChild(this.contentBox); }
override render(width: number): string[] { const lines = super.render(width); if (lines.length === 0) { return lines; }
lines[0] = OSC133_ZONE_START + lines[0]; lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1]; return lines; }}