Loading...
Loading...
Compare original and translation side by side
undefinedundefinedundefinedundefined| Component | Purpose | Import |
|---|---|---|
| Text display with styling | |
| Container with borders/backgrounds | |
| Layout containers | |
| Single-line text input | |
| Dropdown selection | |
| Scrollable content areas | |
| Syntax-highlighted code | |
| 组件 | 用途 | 导入方式 |
|---|---|---|
| 带样式的文本显示 | |
| 带边框/背景的容器 | |
| 布局容器 | |
| 单行文本输入 | |
| 下拉选择器 | |
| 可滚动内容区域 | |
| 语法高亮代码显示 | |
import { createCliRenderer } from "@opentui/core"
import { BoxRenderable, TextRenderable } from "@opentui/core"
async function main() {
const renderer = await createCliRenderer()
const box = new BoxRenderable()
const text = new TextRenderable("Hello, OpenTUI!")
box.add(text)
renderer.getRoot().add(box)
renderer.start()
// Handle Ctrl+C to exit
renderer.on("key", (key) => {
if (key.name === "c" && key.ctrl) {
renderer.destroy()
process.exit(0)
}
})
}
main()import { createCliRenderer } from "@opentui/core"
import { BoxRenderable, TextRenderable } from "@opentui/core"
async function main() {
const renderer = await createCliRenderer()
const box = new BoxRenderable()
const text = new TextRenderable("Hello, OpenTUI!")
box.add(text)
renderer.getRoot().add(box)
renderer.start()
// 处理Ctrl+C退出
renderer.on("key", (key) => {
if (key.name === "c" && key.ctrl) {
renderer.destroy()
process.exit(0)
}
})
}
main()import { Yoga } from "@opentui/core"
const group = new GroupRenderable()
group.setStyle({
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
width: 80,
height: 24,
})import { Yoga } from "@opentui/core"
const group = new GroupRenderable()
group.setStyle({
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
width: 80,
height: 24,
})renderer.on("key", (key: KeyEvent) => {
if (key.name === "escape") process.exit(0)
if (key.name === "c" && key.ctrl) process.exit(0)
})renderer.on("key", (key: KeyEvent) => {
if (key.name === "escape") process.exit(0)
if (key.name === "c" && key.ctrl) process.exit(0)
})const input = new InputRenderable()
input.on("submit", (value: string) => {
console.log("Submitted:", value)
})
input.on("change", (value: string) => {
console.log("Changed:", value)
})const input = new InputRenderable()
input.on("submit", (value: string) => {
console.log("Submitted:", value)
})
input.on("change", (value: string) => {
console.log("Changed:", value)
})import { Color, parseColor } from "@opentui/core"
// Create colors
const red = new Color(255, 0, 0) // RGB integers
const blue = Color.fromInts(0, 0, 255) // Static method
const green = parseColor("#00FF00") // Parse hex
// Apply styles
box.setStyle({
backgroundColor: red,
foregroundColor: blue,
borderStyle: "double",
paddingLeft: 2,
paddingRight: 2,
})import { Color, parseColor } from "@opentui/core"
// 创建颜色
const red = new Color(255, 0, 0) // RGB整数
const blue = Color.fromInts(0, 0, 255) // 静态方法
const green = parseColor("#00FF00") // 解析十六进制颜色
// 应用样式
box.setStyle({
backgroundColor: red,
foregroundColor: blue,
borderStyle: "double",
paddingLeft: 2,
paddingRight: 2,
})import { Timeline } from "@opentui/core"
const box = new BoxRenderable()
const timeline = new Timeline({
duration: 1000,
easing: (t) => t * (2 - t), // easeOutQuad
})
timeline.to(box, {
backgroundColor: new Color(255, 0, 0),
}, {
onUpdate: () => renderer.render()
})
timeline.play()import { Timeline } from "@opentui/core"
const box = new BoxRenderable()
const timeline = new Timeline({
duration: 1000,
easing: (t) => t * (2 - t), // easeOutQuad
})
timeline.to(box, {
backgroundColor: new Color(255, 0, 0),
}, {
onUpdate: () => renderer.render()
})
timeline.play()// Enable console overlay
import { consoleOverlay } from "@opentui/core"
renderer.attach(consoleOverlay())
// Now console.log() appears in terminal overlay
console.log("Debug: initialized")// 启用控制台覆盖层
import { consoleOverlay } from "@opentui/core"
renderer.attach(consoleOverlay())
// 现在console.log()会显示在终端覆盖层中
console.log("Debug: initialized")/opentui/opentui-react/opentui-solid/opentui-projects/opentui/opentui-react/opentui-solid/opentui-projects/sst/opentui.search-data/research/opentui//sst/opentui.search-data/research/opentui/