-
Hello, first of thank you for building this library. I would literally abandon the whole TUI in my application if it wasn't for this library. After successfully running the example, I have found myself searching the source code for more example usage because I do not understand how the components fit together. I want to display figlet (https://deno.land/x/deno_figlet@1.0.0) text in the center of the screen (multi line), with text above and bellow that text. Something like this:
And have that all centered in the middle of the screen, with the text being centered. Something like a box centered in the middle of the terminal and then text inside that box not centered (single lines) and figlet should be centered. I don't know if that makes sense. Is this possible to do? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Ok, I think I got the placement correct. First I define a grid with 9 elements, and only use the center/center element. Then inside that I place a VerticalLayout with 8 elements: 1 text, 1 text, 1 text, 2 blanks, 3 for figlet. And now the placement is correct, but the multi line string is broken. It starts good, then it breaks to the left of the terminal in row bellow, and then it goes back to first row of the multi line text but to the right. Is there a way to display multiline strings so that they span rows? |
Beta Was this translation helpful? Give feedback.
-
You can achieve the same thing with some maths and use of const figlet = `\
____ ______ _ __ __
/ __ \\ ___ ____ ____ / ____/ (_) ____ _ / / ___ / /_
/ / / / / _ \\ / __ \\ / __ \\ ______ / /_ / / / __ \`/ / / / _ \\ / __/
/ /_/ / / __/ / / / // /_/ //_____/ / __/ / / / /_/ / / / / __// /_
/_____/ \\___/ /_/ /_/ \\____/ /_/ /_/ \\__, / /_/ \\___/ \\__/
/____/
`;
new Label({
parent: tui,
rectangle: new Computed(() => {
const tuiRectangle = tui.rectangle.value;
const figletWidth = textWidth(figlet.slice(0, figlet.indexOf("\n")));
return {
column: Math.round(tuiRectangle.width / 2 - figletWidth / 2),
row: Math.round(tuiRectangle.height / 2 - 7),
};
}),
theme: {
base: crayon.red,
},
text: `Some other
random and multiline
text`,
zIndex: 0,
});
new Label({
parent: tui,
theme: {
base: crayon.bgBlue.bold.rgb(255, 255, 255),
},
text: figlet,
rectangle: new Computed(() => {
const tuiRectangle = tui.rectangle.value;
const figletWidth = textWidth(figlet.slice(0, figlet.indexOf("\n")));
return {
column: Math.round(tuiRectangle.width / 2 - figletWidth / 2),
row: Math.round(tuiRectangle.height / 2 - 3),
};
}),
zIndex: 0,
});
new Label({
parent: tui,
rectangle: new Computed(() => {
const tuiRectangle = tui.rectangle.value;
const figletWidth = textWidth(figlet.slice(0, figlet.indexOf("\n")));
return {
column: Math.round(tuiRectangle.width / 2 - figletWidth / 2),
row: Math.round(tuiRectangle.height / 2 + 4),
};
}),
theme: {
base: crayon.yellow,
},
text: `Some other
random and multiline
text`,
zIndex: 0,
}); This essentially computes the middle and center position of the figlet. Tui's biggest pain right now is layouts. |
Beta Was this translation helpful? Give feedback.
You can achieve the same thing with some maths and use of
Computed
, e.g.: