Add the start of a rust program to switch options
- This program will be used to switch options, as well as to rebuild
configuration
- Although it's in this git repo right now, it may not stay there in the long
term (TBD)
diff --git a/switching/src/main.rs b/switching/src/main.rs
new file mode 100644
index 0000000..04c57fb
--- /dev/null
+++ b/switching/src/main.rs
@@ -0,0 +1,57 @@
+use cursive::theme;
+use cursive::theme::BaseColor;
+use cursive::theme::Color;
+use cursive::traits::Nameable;
+use cursive::views::Checkbox;
+use cursive::views::Dialog;
+use cursive::views::ListView;
+use cursive::views::NamedView;
+use cursive::views::TextView;
+use cursive::Cursive;
+
+fn button_pressed(siv: &mut Cursive) {
+ siv.quit();
+}
+
+fn checkbox_changed(i: i8) -> impl Fn(&mut Cursive, bool) {
+ return move |siv: &mut Cursive, value: bool| {
+ let un = if value { "" } else { "un" };
+ let mut dialog = Dialog::around(TextView::new(format!("You {un}checked checkbox {i}")));
+ dialog.add_button("Close", |siv| {
+ siv.pop_layer();
+ });
+ siv.add_layer(dialog);
+ };
+}
+
+fn main() {
+ let mut siv = cursive::default();
+
+ let mut siv_theme = theme::load_default();
+ siv_theme
+ .palette
+ .set_color("background", Color::Dark(BaseColor::Black));
+ siv_theme.palette.set_color("view", Color::Rgb(49, 54, 64));
+ siv_theme
+ .palette
+ .set_color("primary", Color::Dark(BaseColor::White));
+ siv_theme.shadow = false;
+ siv.set_theme(siv_theme);
+ // siv.set_theme()
+
+ let mut list = ListView::new();
+
+ for i in 0..3 {
+ let checkbox = Checkbox::new()
+ .on_change(checkbox_changed(i))
+ .with_name("checkbox".to_owned() + i.to_string().as_str());
+ list.add_child((i.to_string() + ": A checkbox").as_str(), checkbox);
+ }
+
+ let mut base_layer = Dialog::around(NamedView::new("checkboxes", list));
+ base_layer.add_button("I'm done", button_pressed);
+
+ siv.add_layer(base_layer);
+
+ siv.run();
+}