Skip to content

Commit 94af383

Browse files
committed
feat: unicode example from ratatui#121
1 parent c46f010 commit 94af383

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

examples/unicode/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "minimal"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
ratzilla = { path = "../../" }
9+
examples-shared = { path = "../shared" }

examples/unicode/index.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
7+
<link rel="preload" as="style" crossorigin href="https://fontsapi.zeoseven.com/442/main/result.css"
8+
onload="this.rel='stylesheet'" onerror="this.href='https://fontsapi-storage.zeoseven.com/442/main/result.css'" />
9+
<noscript>
10+
<link rel="stylesheet" href="https://fontsapi.zeoseven.com/442/main/result.css" />
11+
</noscript>
12+
<title>Ratzilla</title>
13+
<style>
14+
body {
15+
margin: 0;
16+
width: 100%;
17+
height: 100vh;
18+
display: flex;
19+
flex-direction: column;
20+
justify-content: center;
21+
align-items: center;
22+
align-content: center;
23+
background-color: #121212;
24+
}
25+
26+
pre {
27+
font-family: "Maple Mono NF CN", monospace;
28+
font-size: 15px;
29+
margin: 0px;
30+
}
31+
</style>
32+
</head>
33+
34+
<body></body>
35+
36+
</html>

examples/unicode/src/main.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use std::io;
2+
3+
use ratzilla::ratatui::{
4+
layout::Alignment,
5+
style::Color,
6+
widgets::{Block, Paragraph},
7+
};
8+
9+
use ratzilla::WebRenderer;
10+
11+
use examples_shared::backend::{BackendType, MultiBackendBuilder};
12+
13+
fn main() -> io::Result<()> {
14+
let terminal = MultiBackendBuilder::with_fallback(BackendType::Dom).build_terminal()?;
15+
16+
terminal.draw_web(move |f| {
17+
f.render_widget(
18+
Paragraph::new(
19+
[
20+
"Hello, world!",
21+
"你好,世界!",
22+
"世界、こんにちは。",
23+
// "헬로우 월드!",
24+
// "👨💻👋🌐",
25+
]
26+
.join("\n"),
27+
)
28+
.alignment(Alignment::Center)
29+
.block(
30+
Block::bordered()
31+
.title("Ratzilla")
32+
.title_alignment(Alignment::Center)
33+
.border_style(Color::Yellow),
34+
),
35+
f.area(),
36+
);
37+
});
38+
39+
Ok(())
40+
}

0 commit comments

Comments
 (0)