Box styles, syntax themes, and error traceback handling.
RichJS supports multiple box drawing styles for panels and tables.
| Style | Corners | Description |
|---|---|---|
rounded | ╭╮╰╯ | Rounded corners (default) |
single / square | ┌┐└┘ | Single line, square corners |
double | ╔╗╚╝ | Double lines |
heavy / bold | ┏┓┗┛ | Heavy/bold lines |
ascii | ++++ | ASCII-safe characters |
minimal | (none) | No visible borders |
simple | ──── | Horizontal lines only |
markdown | |--- | Markdown table style |
import { Panel, Table, getBox, listBoxStyles } from "terminal-richjs";
// Use in Panel
new Panel("Content", { box: "rounded" });
// Use in Table
new Table({ box: "double" });
// Get box characters directly
const box = getBox("heavy");
console.log(box.topLeft); // ┏
// List all available styles
const styles = listBoxStyles();import {
getTheme,
MONOKAI,
DRACULA,
GITHUB_LIGHT,
ONE_DARK,
} from "terminal-richjs";
// Get theme by name
const theme = getTheme("monokai");
// Access theme directly
const { styles, baseStyle, lineNumberStyle } = MONOKAI;import { type SyntaxTheme, Style } from "terminal-richjs";
const myTheme: SyntaxTheme = {
name: "my-theme",
baseStyle: Style.parse("#f8f8f2"),
lineNumberStyle: Style.parse("#6e7681 dim"),
styles: {
keyword: Style.parse("#ff79c6 bold"),
string: Style.parse("#f1fa8c"),
comment: Style.parse("#6272a4 italic"),
function: Style.parse("#50fa7b"),
number: Style.parse("#bd93f9"),
},
};Beautiful error tracebacks with syntax-highlighted code snippets.
import { Traceback, installTracebackHandler } from "terminal-richjs";
// Option 1: Install global handler
installTracebackHandler({
theme: "monokai",
extraLines: 3,
suppressInternal: true,
maxFrames: 100,
});
// Option 2: Manual rendering
try {
throw new Error("Something went wrong");
} catch (error) {
const traceback = new Traceback(error as Error, {
theme: "dracula",
extraLines: 2,
});
new Console().print(traceback);
}| Option | Type | Default | Description |
|---|---|---|---|
showLocals | boolean | false | Show local variables (not yet implemented) |
extraLines | number | 3 | Context lines around error |
theme | string | 'monokai' | Syntax highlighting theme |
suppressInternal | boolean | true | Hide node_modules and internal frames |
maxFrames | number | 100 | Maximum frames to show |
MIT