Skip to content

Commit

Permalink
chore: refactor module structure and file naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
rvigo committed May 27, 2024
1 parent fd45222 commit 9f6decf
Show file tree
Hide file tree
Showing 53 changed files with 70 additions and 74 deletions.
2 changes: 0 additions & 2 deletions cl-gui/src/entities/events/mod.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{commands_context::CommandsContext, namespaces::DEFAULT_NAMESPACE};
use crate::entities::clipboard::Clipboard;
use crate::entity::clipboard::Clipboard;
use anyhow::Result;
use cl_core::{
command::Command, commands::Commands, preferences::Preferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{
namespaces::{Namespaces, DEFAULT_NAMESPACE},
Selectable,
};
use crate::entities::{fuzzy::Fuzzy, states::State};
use crate::entity::{fuzzy::Fuzzy, state::State};
use anyhow::Result;
use cl_core::{
command::Command, commands::Commands, resource::commands_file_handler::CommandsFileHandler,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Selectable;
use crate::{
entities::{states::State, terminal::TerminalSize},
widgets::{
entity::{state::State, terminal::TerminalSize},
widget::{
field_state::FieldState,
text_field::{FieldType, TextField},
},
Expand Down Expand Up @@ -290,7 +290,7 @@ impl ToOption for Vec<String> {
#[cfg(test)]
mod test {
use super::*;
use crate::{entities::terminal::TerminalSize, widgets::WidgetKeyHandler};
use crate::{entity::terminal::TerminalSize, widget::WidgetKeyHandler};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};

fn create_fields() -> FieldState<'static> {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use crate::entities::states::namespaces_state::NamespacesState;
use crate::entity::state::namespaces_state::NamespacesState;
use cl_core::Namespace;
use itertools::Itertools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Selectable;
use crate::{
entities::{popup_info::PopupInfo, states::State},
widgets::popup::choice::Choice,
entity::{popup_info::PopupInfo, state::State},
widget::popup::choice::Choice,
};

#[derive(Default)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{fields::Fields, popup_context::PopupContext, Selectable};
use crate::{
entities::{
events::app_events::PopupCallbackAction,
entity::{
event::app_event::PopupCallbackAction,
popup_info::PopupInfo,
states::{clipboard_state::ClipboardState, State},
state::{clipboard_state::ClipboardState, State},
terminal::TerminalSize,
view_mode::ViewMode,
},
widgets::{
widget::{
popup::{choice::Choice, popup_type::PopupType},
statusbar::querybox::QueryBox,
text_field::{FieldType, TextField},
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<'ui> UI<'ui> {
#[cfg(test)]
mod tests {
use super::*;
use crate::entities::terminal::TerminalSize;
use crate::entity::terminal::TerminalSize;

#[test]
fn should_clear_input_when_enter_insert_screen() {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions cl-gui/src/entity/event/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod app_event;
pub mod input_event;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{
contexts::{application_context::ApplicationContext, ui::UI, Selectable},
events::app_events::{
context::{application_context::ApplicationContext, ui::UI, Selectable},
event::app_event::{
AppEvent, CommandEvent, FormScreenEvent, MainScreenEvent, PopupCallbackAction, PopupEvent,
PopupType, QueryboxEvent, RenderEvent, ScreenEvent,
},
view_mode::ViewMode,
};
use crate::widgets::popup::{choice::Choice, popup_type::PopupType as PopupMessageType};
use crate::widget::popup::{choice::Choice, popup_type::PopupType as PopupMessageType};
use log::debug;
use parking_lot::Mutex;
use std::sync::{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{contexts::ui::UI, view_mode::ViewMode};
use super::{context::ui::UI, view_mode::ViewMode};
use crate::{
entities::events::{app_events::AppEvent, input_events::InputMessages},
key_handlers::{
entity::event::{app_event::AppEvent, input_event::InputMessages},
key_handler::{
edit_handler::EditScreenHandler, help_popup_handler::HelpPopupHandler,
insert_handler::InsertScreenHandler, main_handler::MainScreenHandler,
popup_handler::PopupHandler, querybox_handler::QueryboxHandler, HandlerType,
Expand Down
6 changes: 3 additions & 3 deletions cl-gui/src/entities/mod.rs → cl-gui/src/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod clipboard;
pub mod contexts;
pub mod context;
pub(super) mod event;
pub(super) mod event_handler;
pub(super) mod events;
mod fuzzy;
pub(super) mod input_handler;
pub mod popup_info;
pub(super) mod states;
pub(super) mod state;
pub(super) mod terminal;
pub(super) mod tui_application;
pub mod view_mode;
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
entities::events::app_events::PopupCallbackAction, widgets::popup::popup_type::PopupType,
};
use crate::{entity::event::app_event::PopupCallbackAction, widget::popup::popup_type::PopupType};

#[derive(Default, Clone, Debug)]
pub struct PopupInfo {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::contexts::{application_context::ApplicationContext, ui::UI};
use crate::screens::Screen;
use super::context::{application_context::ApplicationContext, ui::UI};
use crate::screen::Screen;
use anyhow::Result;
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{
contexts::{application_context::ApplicationContext, ui::UI},
events::input_events::InputMessages,
context::{application_context::ApplicationContext, ui::UI},
event::input_event::InputMessages,
terminal::Terminal,
view_mode::ViewMode,
};
use crate::screens::Screens;
use crate::screen::Screens;
use anyhow::{Context, Result};
use crossterm::event::{self, Event};
use log::debug;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{
use crate::entity::event::app_event::{
AppEvent, CommandEvent, FormScreenEvent, PopupEvent, PopupType, RenderEvent, ScreenEvent,
};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{AppEvent, PopupEvent::Disable};
use crate::entity::event::app_event::{AppEvent, PopupEvent::Disable};
use crossterm::event::KeyEvent;

pub struct HelpPopupHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{
use crate::entity::event::app_event::{
AppEvent, CommandEvent, FormScreenEvent, PopupEvent, PopupType, RenderEvent, ScreenEvent,
};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{
use crate::entity::event::app_event::{
AppEvent, CommandEvent, MainScreenEvent, PopupCallbackAction, PopupEvent, PopupType,
QueryboxEvent, RenderEvent, ScreenEvent,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(super) mod main_handler;
pub(super) mod popup_handler;
pub(super) mod querybox_handler;

use super::entities::events::app_events::AppEvent;
use super::entity::event::app_event::AppEvent;
use anyhow::Result;
use crossterm::event::KeyEvent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{AppEvent, PopupEvent};
use crate::entity::event::app_event::{AppEvent, PopupEvent};
use crossterm::event::{KeyCode, KeyEvent};

pub struct PopupHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{AppEventResult, KeyEventHandler};
use crate::entities::events::app_events::{AppEvent, QueryboxEvent};
use crate::entity::event::app_event::{AppEvent, QueryboxEvent};
use crossterm::event::{KeyCode, KeyEvent};

pub struct QueryboxHandler;
Expand Down
18 changes: 9 additions & 9 deletions cl-gui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod entities;
pub mod key_handlers;
pub mod screens;
pub mod widgets;
pub mod entity;
pub mod key_handler;
pub mod screen;
pub mod widget;

use anyhow::Result;
use cl_core::config::Config;
Expand All @@ -15,16 +15,16 @@ pub async fn start_gui(config: Config) -> Result<()> {
}

mod core {
use super::entities::terminal::Terminal;
use super::entity::terminal::Terminal;
use crate::{
entities::{
contexts::{application_context::ApplicationContext, ui::UI},
entity::{
context::{application_context::ApplicationContext, ui::UI},
event::{app_event::AppEvent, input_event::InputMessages},
event_handler::EventHandler,
events::{app_events::AppEvent, input_events::InputMessages},
input_handler::InputHandler,
tui_application::TuiApplication,
},
screens::Screens,
screen::Screens,
};
use anyhow::{Context, Result};
use cl_core::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{Screen, ScreenExt};
use crate::{
default_block,
entities::{
contexts::{application_context::ApplicationContext, ui::UI},
entity::{
context::{application_context::ApplicationContext, ui::UI},
terminal::{TerminalSize, TerminalSizeExt},
},
popup, render,
widgets::{
widget::{
popup::{help_popup::HelpPopup, RenderPopup},
statusbar::{help::Help, info::Info, navigation_info::NavigationInfo},
text_field::FieldType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{Screen, ScreenExt};
use crate::{
default_block, display_widget,
entities::{
contexts::{application_context::ApplicationContext, ui::UI},
states::State,
entity::{
context::{application_context::ApplicationContext, ui::UI},
state::State,
terminal::{TerminalSize, TerminalSizeExt},
},
popup, render,
widgets::{
widget::{
alias_list::AliasListWidget,
display::DisplayWidget,
highlight::Highlight,
Expand Down
8 changes: 4 additions & 4 deletions cl-gui/src/screens/mod.rs → cl-gui/src/screen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod form_screen;
mod main_screen;

use super::entities::contexts::{application_context::ApplicationContext, ui::UI};
use super::entity::context::{application_context::ApplicationContext, ui::UI};
use crate::{
entities::{terminal::TerminalSizeExt, view_mode::ViewMode},
entity::{terminal::TerminalSizeExt, view_mode::ViewMode},
register, render,
screens::{form_screen::FormScreen, main_screen::MainScreen},
widgets::{base_widget::BaseWidget, statusbar::StatusBarItem},
screen::{form_screen::FormScreen, main_screen::MainScreen},
widget::{base_widget::BaseWidget, statusbar::StatusBarItem},
};
use std::collections::HashMap;
use tui::Frame;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::StatusBarItem;
use crate::entities::terminal::TerminalSize;
use crate::entity::terminal::TerminalSize;
use tui::{
buffer::Buffer,
layout::{Alignment, Constraint, Direction, Layout, Rect},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a> Widget for DisplayWidget<'a> {
#[cfg(test)]
mod test {
use super::{DisplayWidget, *};
use crate::widgets::highlight::Highlight;
use crate::widget::highlight::Highlight;
use tui::{
style::Modifier,
text::{Line, Span},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
text_field::{FieldType, TextField, TextFieldBuilder},
WidgetKeyHandler,
};
use crate::{create_fields_map, entities::terminal::TerminalSize};
use crate::{create_fields_map, entity::terminal::TerminalSize};
use std::{
collections::HashMap,
ops::{Deref, DerefMut},
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cl-gui/src/widgets/macros.rs → cl-gui/src/widget/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ macro_rules! render {
#[macro_export]
macro_rules! display_widget {
($title:expr, $content:expr, $trim:expr, $highlight:expr) => {
$crate::widgets::display::DisplayWidget::new($content, $trim, $highlight)
$crate::widget::display::DisplayWidget::new($content, $trim, $highlight)
.block(default_block!($title))
};

($title:expr, $content:expr, $trim:expr, $highlight:expr, $query:expr) => {
$crate::widgets::display::DisplayWidget::new($content, $trim, $highlight)
$crate::widget::display::DisplayWidget::new($content, $trim, $highlight)
.block(default_block!($title))
.highlight($query)
};
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{popup_type::PopupType, Popup};
use crate::{
entities::{contexts::popup_context::PopupContext, view_mode::ViewMode},
entity::{context::popup_context::PopupContext, view_mode::ViewMode},
DEFAULT_SELECTED_COLOR,
};
use tui::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ pub mod popup_type;
pub mod question_popup;

use self::choice::Choice;
use crate::{
centered_rect, entities::contexts::popup_context::PopupContext, DEFAULT_SELECTED_COLOR,
};
use crate::{centered_rect, entity::context::popup_context::PopupContext, DEFAULT_SELECTED_COLOR};
use std::{rc::Rc, vec};
use tui::{
buffer::Buffer,
Expand Down Expand Up @@ -144,7 +142,7 @@ pub mod macros {
};

($info:expr, $choiches:expr) => {{
use $crate::widgets::popup::question_popup::QuestionPopup;
use $crate::widget::popup::question_popup::QuestionPopup;

QuestionPopup::new(
$info.message.to_owned(),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{choice::Choice, popup_type::PopupType, Popup, WithChoices};
use crate::{default_block, entities::contexts::popup_context::PopupContext, DEFAULT_TEXT_COLOR};
use crate::{default_block, entity::context::popup_context::PopupContext, DEFAULT_TEXT_COLOR};
use tui::{
buffer::Buffer,
layout::{Alignment, Rect},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::widgets::display::DisplayWidget;
use crate::widget::display::DisplayWidget;
use tui::{
buffer::Buffer,
layout::{Alignment, Rect},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{widgets::display::DisplayWidget, DEFAULT_SELECTED_COLOR};
use crate::{widget::display::DisplayWidget, DEFAULT_SELECTED_COLOR};
use tui::{
buffer::Buffer,
layout::{Alignment, Rect},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::widgets::display::DisplayWidget;
use crate::widget::display::DisplayWidget;
use tui::{buffer::Buffer, layout::Rect, widgets::Widget};

#[derive(Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{widgets::WidgetKeyHandler, DEFAULT_SELECTED_COLOR, DEFAULT_TEXT_COLOR};
use crate::{widget::WidgetKeyHandler, DEFAULT_SELECTED_COLOR, DEFAULT_TEXT_COLOR};
use crossterm::event::{KeyCode, KeyEvent};
use tui::{
buffer::Buffer,
Expand Down
File renamed without changes.

0 comments on commit 9f6decf

Please sign in to comment.