Skip to content

Commit ac0dc0a

Browse files
authored
refactor: revamp the simple template (#87)
* docs(readme): revamp the simple template docs * docs(simple): add more comments and fix links * chore(simple): generate the simple template * docs(simple): update comments * refactor(simple): rename draw to render
1 parent 1bd3c7a commit ac0dc0a

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

simple-generated/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "simple-generated"
33
version = "0.1.0"
4-
authors = ["Josh McKinney <[email protected].com>"]
4+
authors = ["Orhun Parmaksız <orhunparmaksiz@gmail.com>"]
55
license = "MIT"
66
edition = "2021"
77

simple-generated/LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) Josh McKinney <[email protected].com>
3+
Copyright (c) Orhun Parmaksız <orhunparmaksiz@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

simple-generated/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# simple-generated
22

3-
This is a [Ratatui] app generated by the [Simple template].
3+
This is a [Ratatui] app generated by the [Simple Template].
44

55
[Ratatui]: https://ratatui.rs
66
[Simple Template]: https://github.com/ratatui/templates/tree/main/simple
77

88
## License
99

10-
Copyright (c) Josh McKinney <[email protected].com>
10+
Copyright (c) Orhun Parmaksız <orhunparmaksiz@gmail.com>
1111

1212
This project is licensed under the MIT license ([LICENSE] or <http://opensource.org/licenses/MIT>)
1313

simple-generated/src/app.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use ratatui::{
77
DefaultTerminal, Frame,
88
};
99

10+
/// The main application which holds the state and logic of the application.
1011
#[derive(Debug, Default)]
1112
pub struct App {
1213
/// Is the application running?
@@ -23,7 +24,7 @@ impl App {
2324
pub fn run(mut self, mut terminal: DefaultTerminal) -> Result<()> {
2425
self.running = true;
2526
while self.running {
26-
terminal.draw(|frame| self.draw(frame))?;
27+
terminal.draw(|frame| self.render(frame))?;
2728
self.handle_crossterm_events()?;
2829
}
2930
Ok(())
@@ -32,9 +33,10 @@ impl App {
3233
/// Renders the user interface.
3334
///
3435
/// This is where you add new widgets. See the following resources for more information:
36+
///
3537
/// - <https://docs.rs/ratatui/latest/ratatui/widgets/index.html>
36-
/// - <https://github.com/ratatui/ratatui/tree/master/examples>
37-
fn draw(&mut self, frame: &mut Frame) {
38+
/// - <https://github.com/ratatui/ratatui/tree/main/ratatui-widgets/examples>
39+
fn render(&mut self, frame: &mut Frame) {
3840
let title = Line::from("Ratatui Simple Template")
3941
.bold()
4042
.blue()

simple/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Ratatui Simple template
1+
# Ratatui Simple Template
22

33
The simple template will create the following project structure:
44

55
```text
66
src/
77
├── app.rs -> holds the state and application logic
8-
── main.rs -> entry-point
8+
── main.rs -> entry-point
99
```
1010

1111
## Design choices
1212

1313
We have a small `App` struct that has a main loop that calls methods to handle events and draw the
14-
ui. The app can be quit by pressing any of Q/Esc/Ctrl+C.
14+
UI. The app can be quit by pressing any of Q/Esc/Ctrl+C.
1515

16-
We use [color-eyre](https://docs.rs/color-eyre/latest/color_eyre/) for simplifying any errors that
17-
need to be reported to the console.
16+
We use [color-eyre](https://docs.rs/color-eyre) for simplifying any errors that need to be reported
17+
to the console.

simple/template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# {{project-name}}
22

3-
This is a [Ratatui] app generated by the [Simple template].
3+
This is a [Ratatui] app generated by the [Simple Template].
44

55
[Ratatui]: https://ratatui.rs
66
[Simple Template]: https://github.com/ratatui/templates/tree/main/simple

simple/template/src/app.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use ratatui::{
77
DefaultTerminal, Frame,
88
};
99

10+
/// The main application which holds the state and logic of the application.
1011
#[derive(Debug, Default)]
1112
pub struct App {
1213
/// Is the application running?
@@ -23,7 +24,7 @@ impl App {
2324
pub fn run(mut self, mut terminal: DefaultTerminal) -> Result<()> {
2425
self.running = true;
2526
while self.running {
26-
terminal.draw(|frame| self.draw(frame))?;
27+
terminal.draw(|frame| self.render(frame))?;
2728
self.handle_crossterm_events()?;
2829
}
2930
Ok(())
@@ -32,9 +33,10 @@ impl App {
3233
/// Renders the user interface.
3334
///
3435
/// This is where you add new widgets. See the following resources for more information:
36+
///
3537
/// - <https://docs.rs/ratatui/latest/ratatui/widgets/index.html>
36-
/// - <https://github.com/ratatui/ratatui/tree/master/examples>
37-
fn draw(&mut self, frame: &mut Frame) {
38+
/// - <https://github.com/ratatui/ratatui/tree/main/ratatui-widgets/examples>
39+
fn render(&mut self, frame: &mut Frame) {
3840
let title = Line::from("Ratatui Simple Template")
3941
.bold()
4042
.blue()

0 commit comments

Comments
 (0)