Skip to content

Commit

Permalink
rename ide to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
achristmascarl committed Jun 8, 2024
1 parent 3e0052d commit 273449b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ pub enum Action {
Help,
Query(String),
FocusMenu,
FocusIDE,
FocusEditor,
FocusData,
}
18 changes: 9 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tokio::sync::mpsc;

use crate::{
action::Action,
components::{data::Data, ide::IDE, menu::Menu, Component},
components::{data::Data, editor::Editor, menu::Menu, Component},
config::Config,
database,
database::{DbError, DbPool, Rows},
Expand All @@ -32,13 +32,13 @@ pub struct AppState {

pub struct Components {
pub menu: Box<dyn Component>,
pub ide: Box<dyn Component>,
pub editor: Box<dyn Component>,
pub data: Box<dyn Component>,
}

impl Components {
pub fn to_array(&mut self) -> [&mut Box<dyn Component>; 3] {
[&mut self.menu, &mut self.ide, &mut self.data]
[&mut self.menu, &mut self.editor, &mut self.data]
}
}

Expand All @@ -58,14 +58,14 @@ impl App {
let focus = Focus::Menu;
let state = Arc::new(Mutex::new(AppState { connection_string, focus, data: None }));
let menu = Menu::new(Arc::clone(&state));
let ide = IDE::new(Arc::clone(&state));
let editor = Editor::new(Arc::clone(&state));
let data = Data::new(Arc::clone(&state));
let config = Config::new()?;
Ok(Self {
state: Arc::clone(&state),
tick_rate,
frame_rate,
components: Components { menu: Box::new(menu), ide: Box::new(ide), data: Box::new(data) },
components: Components { menu: Box::new(menu), editor: Box::new(editor), data: Box::new(data) },
should_quit: false,
config,
last_tick_key_events: Vec::new(),
Expand Down Expand Up @@ -168,7 +168,7 @@ impl App {
.split(root_layout[1]);

self.components.menu.draw(f, root_layout[0]).unwrap();
self.components.ide.draw(f, right_layout[0]).unwrap();
self.components.editor.draw(f, right_layout[0]).unwrap();
self.components.data.draw(f, right_layout[1]).unwrap();
})?;
},
Expand All @@ -177,10 +177,10 @@ impl App {
let mut state = self.state.lock().unwrap();
state.focus = Focus::Menu;
},
Action::FocusIDE => {
log::info!("FocusIDE");
Action::FocusEditor => {
log::info!("FocusEditor");
let mut state = self.state.lock().unwrap();
state.focus = Focus::IDE;
state.focus = Focus::Editor;
},
Action::FocusData => {
log::info!("FocusData");
Expand Down
2 changes: 1 addition & 1 deletion src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
};

pub mod data;
pub mod ide;
pub mod editor;
pub mod menu;

/// `Component` is a trait that represents a visual and interactive element of the user interface.
Expand Down
12 changes: 6 additions & 6 deletions src/components/ide.rs → src/components/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Selection {
pub end: CursorPosition,
}

pub struct IDE {
pub struct Editor {
command_tx: Option<UnboundedSender<Action>>,
config: Config,
state: Arc<Mutex<AppState>>,
Expand All @@ -38,9 +38,9 @@ pub struct IDE {
selection: Option<Selection>,
}

impl IDE {
impl Editor {
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
IDE {
Editor {
command_tx: None,
config: Config::default(),
state,
Expand All @@ -51,7 +51,7 @@ impl IDE {
}
}

impl Component for IDE {
impl Component for Editor {
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
self.command_tx = Some(tx);
Ok(())
Expand All @@ -64,7 +64,7 @@ impl Component for IDE {

fn handle_events(&mut self, event: Option<Event>) -> Result<Option<Action>> {
let state = self.state.lock().unwrap();
if state.focus != Focus::IDE {
if state.focus != Focus::Editor {
return Ok(None);
}
if let Some(Event::Key(key)) = event {
Expand All @@ -90,7 +90,7 @@ impl Component for IDE {

fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()> {
let state = self.state.lock().unwrap();
let focused = state.focus == Focus::IDE;
let focused = state.focus == Focus::Editor;
let block = Block::default().title("top").borders(Borders::ALL).border_style(if focused {
Style::new().green()
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ use serde::{Deserialize, Serialize};
pub enum Focus {
#[default]
Menu,
IDE,
Editor,
Data,
}

0 comments on commit 273449b

Please sign in to comment.