Skip to content

Commit

Permalink
json editor part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacperacy committed Apr 20, 2024
1 parent 8a01fbb commit 2f5341f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use std::collections::HashMap;

pub enum CurrentScreen {
Main,
Editing,
Exiting,
}

pub enum CurrentlyEditing {
Key,
Value,
}

pub struct App {
pub key_input: String,
pub value_input: String,
pub pairs: HashMap<String, String>,
pub current_screen: CurrentScreen,
pub currently_editing: Option<CurrentlyEditing>,
}

impl App {
pub fn new() -> App {
App {
key_input: String::new(),
value_input: String::new(),
pairs: HashMap::new(),
current_screen: CurrentScreen::Main,
currently_editing: None,
}
}

pub fn save_key_value(&mut self) {
self.pairs
.insert(self.key_input.clone(), self.value_input.clone());

self.key_input = String::new();
self.value_input = String::new();
self.currently_editing = None;
}
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use color_eyre::{
Result,
};

mod app;
mod errors;
mod tui;

Expand Down

0 comments on commit 2f5341f

Please sign in to comment.