summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-06-02 00:53:38 -0400
committerGitHub <noreply@github.com>2023-06-02 00:53:38 -0400
commit852e2e86c7230cb339c7d0482d596194dbb59415 (patch)
tree93cc8f5f6909487e3fe5f5b958846f715f64455f
parent87a793f50176d29565268ef176248b2bb736d9b7 (diff)
refactor: remove typed-builder (#1181)
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml1
-rw-r--r--src/app/layout_manager.rs87
-rw-r--r--src/options/layout_options.rs6
4 files changed, 52 insertions, 54 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8e4888e9..577b98de 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -176,7 +176,6 @@ dependencies = [
"thiserror",
"time",
"toml_edit",
- "typed-builder",
"unicode-segmentation",
"unicode-width",
"windows",
@@ -1277,17 +1276,6 @@ dependencies = [
]
[[package]]
-name = "typed-builder"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "64cba322cb9b7bc6ca048de49e83918223f35e7a86311267013afff257004870"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 1.0.109",
-]
-
-[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 2ae3efae..d5f3861f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -102,7 +102,6 @@ thiserror = "1.0.40"
time = { version = "0.3.21", features = ["formatting", "macros"] }
toml_edit = { version = "0.19.10", features = ["serde"] }
tui = { version = "0.21.0", package = "ratatui" }
-typed-builder = "0.14.0"
unicode-segmentation = "1.10.1"
unicode-width = "0.1.10"
diff --git a/src/app/layout_manager.rs b/src/app/layout_manager.rs
index 1f692e9b..4e7d3b0e 100644
--- a/src/app/layout_manager.rs
+++ b/src/app/layout_manager.rs
@@ -1,7 +1,5 @@
use std::collections::BTreeMap;
-use typed_builder::*;
-
use crate::constants::DEFAULT_WIDGET_ID;
use crate::error::{BottomError, Result};
@@ -675,32 +673,23 @@ impl BottomLayout {
BottomLayout {
total_row_height_ratio: 3,
rows: vec![
- BottomRow::builder()
- .canvas_handle_height(true)
- .children(vec![BottomCol::new(vec![
- BottomColRow::new(vec![cpu]).canvas_handle_height(true)
- ])
- .canvas_handle_width(true)])
- .build(),
- BottomRow::builder()
- .canvas_handle_height(true)
- .children(vec![BottomCol::new(vec![BottomColRow::new(vec![
- mem, net,
- ])
- .canvas_handle_height(true)])
- .canvas_handle_width(true)])
- .build(),
- BottomRow::builder()
- .canvas_handle_height(true)
- .children(vec![BottomCol::new(vec![
- BottomColRow::new(vec![table]).canvas_handle_height(true)
- ])
- .canvas_handle_width(true)])
- .build(),
- BottomRow::builder()
- .canvas_handle_height(true)
- .children(table_widgets)
- .build(),
+ BottomRow::new(vec![BottomCol::new(vec![
+ BottomColRow::new(vec![cpu]).canvas_handle_height(true)
+ ])
+ .canvas_handle_width(true)])
+ .canvas_handle_height(true),
+ BottomRow::new(vec![BottomCol::new(vec![BottomColRow::new(vec![
+ mem, net,
+ ])
+ .canvas_handle_height(true)])
+ .canvas_handle_width(true)])
+ .canvas_handle_height(true),
+ BottomRow::new(vec![BottomCol::new(vec![
+ BottomColRow::new(vec![table]).canvas_handle_height(true)
+ ])
+ .canvas_handle_width(true)])
+ .canvas_handle_height(true),
+ BottomRow::new(table_widgets).canvas_handle_height(true),
],
}
}
@@ -729,23 +718,47 @@ impl BottomLayout {
// }
/// Represents a single row in the layout.
-#[derive(Clone, Debug, TypedBuilder)]
+#[derive(Clone, Debug)]
pub struct BottomRow {
pub children: Vec<BottomCol>,
-
- #[builder(default = 1)]
pub total_col_ratio: u32,
-
- #[builder(default = 1)]
pub row_height_ratio: u32,
-
- #[builder(default = false)]
pub canvas_handle_height: bool,
-
- #[builder(default = false)]
pub flex_grow: bool,
}
+impl BottomRow {
+ pub fn new(children: Vec<BottomCol>) -> Self {
+ Self {
+ children,
+ total_col_ratio: 1,
+ row_height_ratio: 1,
+ canvas_handle_height: false,
+ flex_grow: false,
+ }
+ }
+
+ pub fn total_col_ratio(mut self, total_col_ratio: u32) -> Self {
+ self.total_col_ratio = total_col_ratio;
+ self
+ }
+
+ pub fn row_height_ratio(mut self, row_height_ratio: u32) -> Self {
+ self.row_height_ratio = row_height_ratio;
+ self
+ }
+
+ pub fn canvas_handle_height(mut self, canvas_handle_height: bool) -> Self {
+ self.canvas_handle_height = canvas_handle_height;
+ self
+ }
+
+ pub fn flex_grow(mut self, flex_grow: bool) -> Self {
+ self.flex_grow = flex_grow;
+ self
+ }
+}
+
/// Represents a single column in the layout. We assume that even if the column
/// contains only ONE element, it is still a column (rather than either a col or
/// a widget, as per the config, for simplicity's sake).
diff --git a/src/options/layout_options.rs b/src/options/layout_options.rs
index d1a584d0..54a07f12 100644
--- a/src/options/layout_options.rs
+++ b/src/options/layout_options.rs
@@ -218,11 +218,9 @@ impl Row {
}
}
- Ok(BottomRow::builder()
+ Ok(BottomRow::new(children)
.total_col_ratio(total_col_ratio)
- .row_height_ratio(row_ratio)
- .children(children)
- .build())
+ .row_height_ratio(row_ratio))
}
}