mirror of
https://github.com/Routstr/routstrd.git
synced 2026-07-22 12:22:20 +00:00
super stable
This commit is contained in:
15
test_box.ts
Normal file
15
test_box.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { renderBox } from "./src/tui/usage/render.ts";
|
||||
import { stripAnsi } from "./src/tui/usage/terminal.ts";
|
||||
|
||||
const w = 40;
|
||||
const testBox = renderBox(["Hello World", "Line 2"], w, "Title");
|
||||
console.log(testBox);
|
||||
const lines = testBox.split("\n");
|
||||
lines.forEach((l, i) => console.log(`Line ${i} length: ${stripAnsi(l).length}`));
|
||||
|
||||
console.log("---");
|
||||
|
||||
const testBoxNoTitle = renderBox(["Hello World", "Line 2"], w);
|
||||
console.log(testBoxNoTitle);
|
||||
const lines2 = testBoxNoTitle.split("\n");
|
||||
lines2.forEach((l, i) => console.log(`Line ${i} length: ${stripAnsi(l).length}`));
|
||||
17
test_split_box.ts
Normal file
17
test_split_box.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { renderBox } from "./src/tui/usage/render.ts";
|
||||
|
||||
const width = 80;
|
||||
const halfWidth1 = Math.floor(width / 2);
|
||||
const halfWidth2 = width - halfWidth1;
|
||||
|
||||
const leftBox = ["Total Spent: 12.78k sats", "Total Requests: 1.0k"];
|
||||
const rightBox = ["Total Tokens: 25.8M", "Avg Tokens/Req: 25.8K"];
|
||||
|
||||
const leftBoxStr = renderBox(leftBox, halfWidth1, "Stats of Sats");
|
||||
const rightBoxStr = renderBox(rightBox, halfWidth2, "Token Stats");
|
||||
|
||||
const leftLines = leftBoxStr.split("\n");
|
||||
const rightLines = rightBoxStr.split("\n");
|
||||
|
||||
const combinedContent = leftLines.map((l, i) => l + (rightLines[i] || " ".repeat(halfWidth2))).join("\n");
|
||||
console.log(combinedContent);
|
||||
23
test_split_box2.ts
Normal file
23
test_split_box2.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { renderBox } from "./src/tui/usage/render.ts";
|
||||
|
||||
const width = 80;
|
||||
const halfWidth1 = Math.floor(width / 2);
|
||||
const halfWidth2 = width - halfWidth1;
|
||||
|
||||
const leftBox = ["Total Spent: 12.78k sats", "Total Requests: 1.0k"];
|
||||
const rightBox = ["Total Tokens: 25.8M", "Avg Tokens/Req: 25.8K"];
|
||||
|
||||
const leftBoxStr = renderBox(leftBox, halfWidth1, "Stats of Sats");
|
||||
const rightBoxStr = renderBox(rightBox, halfWidth2, "Token Stats");
|
||||
|
||||
const leftLines = leftBoxStr.split("\n");
|
||||
const rightLines = rightBoxStr.split("\n");
|
||||
|
||||
const maxLines = Math.max(leftLines.length, rightLines.length);
|
||||
const combinedLines: string[] = [];
|
||||
for (let i = 0; i < maxLines; i++) {
|
||||
const l = leftLines[i] || " ".repeat(Math.floor(width / 2));
|
||||
const r = rightLines[i] || " ".repeat(Math.ceil(width / 2));
|
||||
combinedLines.push(l + r);
|
||||
}
|
||||
console.log(combinedLines.join("\n"));
|
||||
Reference in New Issue
Block a user