moving popups in its own module (#2066)

This commit is contained in:
extrawurst 2024-02-19 17:18:30 +01:00 committed by GitHub
parent af9da95178
commit e22cc70a7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 364 additions and 352 deletions

View file

@ -2,23 +2,23 @@ use crate::{
accessors, accessors,
cmdbar::CommandBar, cmdbar::CommandBar,
components::{ components::{
command_pump, event_pump, AppOption, BlameFileComponent, command_pump, event_pump, CommandInfo, Component,
BranchListComponent, CommandInfo, CommitComponent, DrawableComponent, FuzzyFinderTarget,
CompareCommitsComponent, Component, ConfirmComponent,
CreateBranchComponent, DrawableComponent,
ExternalEditorComponent, FetchComponent, FileRevlogComponent,
FuzzyFindPopup, FuzzyFinderTarget, HelpComponent,
InspectCommitComponent, LogSearchPopupComponent,
MsgComponent, OptionsPopupComponent, PullComponent,
PushComponent, PushTagsComponent, RenameBranchComponent,
ResetPopupComponent, RevisionFilesPopup, StashMsgComponent,
SubmodulesListComponent, TagCommitComponent,
TagListComponent,
}, },
input::{Input, InputEvent, InputState}, input::{Input, InputEvent, InputState},
keys::{key_match, KeyConfig, SharedKeyConfig}, keys::{key_match, KeyConfig, SharedKeyConfig},
options::{Options, SharedOptions}, options::{Options, SharedOptions},
popup_stack::PopupStack, popup_stack::PopupStack,
popups::{
AppOption, BlameFilePopup, BranchListPopup, CommitPopup,
CompareCommitsPopup, ConfirmPopup, CreateBranchPopup,
ExternalEditorPopup, FetchPopup, FileRevlogPopup,
FuzzyFindPopup, HelpPopup, InspectCommitPopup,
LogSearchPopupPopup, MsgPopup, OptionsPopup, PullPopup,
PushPopup, PushTagsPopup, RenameBranchPopup, ResetPopup,
RevisionFilesPopup, StashMsgPopup, SubmodulesListPopup,
TagCommitPopup, TagListPopup,
},
queue::{ queue::{
Action, AppTabs, InternalEvent, NeedsUpdate, Queue, Action, AppTabs, InternalEvent, NeedsUpdate, Queue,
StackablePopupOpen, StackablePopupOpen,
@ -68,31 +68,31 @@ pub enum QuitState {
pub struct App { pub struct App {
repo: RepoPathRef, repo: RepoPathRef,
do_quit: QuitState, do_quit: QuitState,
help: HelpComponent, help_popup: HelpPopup,
msg: MsgComponent, msg_popup: MsgPopup,
reset: ConfirmComponent, confirm_popup: ConfirmPopup,
commit: CommitComponent, commit_popup: CommitPopup,
blame_file_popup: BlameFileComponent, blame_file_popup: BlameFilePopup,
file_revlog_popup: FileRevlogComponent, file_revlog_popup: FileRevlogPopup,
stashmsg_popup: StashMsgComponent, stashmsg_popup: StashMsgPopup,
inspect_commit_popup: InspectCommitComponent, inspect_commit_popup: InspectCommitPopup,
compare_commits_popup: CompareCommitsComponent, compare_commits_popup: CompareCommitsPopup,
external_editor_popup: ExternalEditorComponent, external_editor_popup: ExternalEditorPopup,
revision_files_popup: RevisionFilesPopup, revision_files_popup: RevisionFilesPopup,
fuzzy_find_popup: FuzzyFindPopup, fuzzy_find_popup: FuzzyFindPopup,
log_search_popup: LogSearchPopupComponent, log_search_popup: LogSearchPopupPopup,
push_popup: PushComponent, push_popup: PushPopup,
push_tags_popup: PushTagsComponent, push_tags_popup: PushTagsPopup,
pull_popup: PullComponent, pull_popup: PullPopup,
fetch_popup: FetchComponent, fetch_popup: FetchPopup,
tag_commit_popup: TagCommitComponent, tag_commit_popup: TagCommitPopup,
create_branch_popup: CreateBranchComponent, create_branch_popup: CreateBranchPopup,
rename_branch_popup: RenameBranchComponent, rename_branch_popup: RenameBranchPopup,
select_branch_popup: BranchListComponent, select_branch_popup: BranchListPopup,
options_popup: OptionsPopupComponent, options_popup: OptionsPopup,
submodule_popup: SubmodulesListComponent, submodule_popup: SubmodulesListPopup,
tags_popup: TagListComponent, tags_popup: TagListPopup,
reset_popup: ResetPopupComponent, reset_popup: ResetPopup,
cmdbar: RefCell<CommandBar>, cmdbar: RefCell<CommandBar>,
tab: usize, tab: usize,
revlog: Revlog, revlog: Revlog,
@ -171,39 +171,39 @@ impl App {
let mut app = Self { let mut app = Self {
input, input,
reset: ConfirmComponent::new(&env), confirm_popup: ConfirmPopup::new(&env),
commit: CommitComponent::new(&env), commit_popup: CommitPopup::new(&env),
blame_file_popup: BlameFileComponent::new( blame_file_popup: BlameFilePopup::new(
&env, &env,
&strings::blame_title(&env.key_config), &strings::blame_title(&env.key_config),
), ),
file_revlog_popup: FileRevlogComponent::new(&env), file_revlog_popup: FileRevlogPopup::new(&env),
revision_files_popup: RevisionFilesPopup::new(&env), revision_files_popup: RevisionFilesPopup::new(&env),
stashmsg_popup: StashMsgComponent::new(&env), stashmsg_popup: StashMsgPopup::new(&env),
inspect_commit_popup: InspectCommitComponent::new(&env), inspect_commit_popup: InspectCommitPopup::new(&env),
compare_commits_popup: CompareCommitsComponent::new(&env), compare_commits_popup: CompareCommitsPopup::new(&env),
external_editor_popup: ExternalEditorComponent::new(&env), external_editor_popup: ExternalEditorPopup::new(&env),
push_popup: PushComponent::new(&env), push_popup: PushPopup::new(&env),
push_tags_popup: PushTagsComponent::new(&env), push_tags_popup: PushTagsPopup::new(&env),
reset_popup: ResetPopupComponent::new(&env), reset_popup: ResetPopup::new(&env),
pull_popup: PullComponent::new(&env), pull_popup: PullPopup::new(&env),
fetch_popup: FetchComponent::new(&env), fetch_popup: FetchPopup::new(&env),
tag_commit_popup: TagCommitComponent::new(&env), tag_commit_popup: TagCommitPopup::new(&env),
create_branch_popup: CreateBranchComponent::new(&env), create_branch_popup: CreateBranchPopup::new(&env),
rename_branch_popup: RenameBranchComponent::new(&env), rename_branch_popup: RenameBranchPopup::new(&env),
select_branch_popup: BranchListComponent::new(&env), select_branch_popup: BranchListPopup::new(&env),
tags_popup: TagListComponent::new(&env), tags_popup: TagListPopup::new(&env),
options_popup: OptionsPopupComponent::new(&env), options_popup: OptionsPopup::new(&env),
submodule_popup: SubmodulesListComponent::new(&env), submodule_popup: SubmodulesListPopup::new(&env),
log_search_popup: LogSearchPopupComponent::new(&env), log_search_popup: LogSearchPopupPopup::new(&env),
fuzzy_find_popup: FuzzyFindPopup::new(&env), fuzzy_find_popup: FuzzyFindPopup::new(&env),
do_quit: QuitState::None, do_quit: QuitState::None,
cmdbar: RefCell::new(CommandBar::new( cmdbar: RefCell::new(CommandBar::new(
env.theme.clone(), env.theme.clone(),
env.key_config.clone(), env.key_config.clone(),
)), )),
help: HelpComponent::new(&env), help_popup: HelpPopup::new(&env),
msg: MsgComponent::new(&env), msg_popup: MsgPopup::new(&env),
revlog: Revlog::new(&env), revlog: Revlog::new(&env),
status_tab: Status::new(&env), status_tab: Status::new(&env),
stashing_tab: Stashing::new(&env), stashing_tab: Stashing::new(&env),
@ -345,21 +345,21 @@ impl App {
if matches!(polling_state, InputState::Paused) { if matches!(polling_state, InputState::Paused) {
let result = let result =
if let Some(path) = self.file_to_open.take() { if let Some(path) = self.file_to_open.take() {
ExternalEditorComponent::open_file_in_editor( ExternalEditorPopup::open_file_in_editor(
&self.repo.borrow(), &self.repo.borrow(),
Path::new(&path), Path::new(&path),
) )
} else { } else {
let changes = let changes =
self.status_tab.get_files_changes()?; self.status_tab.get_files_changes()?;
self.commit.show_editor(changes) self.commit_popup.show_editor(changes)
}; };
if let Err(e) = result { if let Err(e) = result {
let msg = let msg =
format!("failed to launch editor:\n{e}"); format!("failed to launch editor:\n{e}");
log::error!("{}", msg.as_str()); log::error!("{}", msg.as_str());
self.msg.show_error(msg.as_str())?; self.msg_popup.show_error(msg.as_str())?;
} }
self.requires_redraw.set(true); self.requires_redraw.set(true);
@ -375,7 +375,7 @@ impl App {
pub fn update(&mut self) -> Result<()> { pub fn update(&mut self) -> Result<()> {
log::trace!("update"); log::trace!("update");
self.commit.update(); self.commit_popup.update();
self.status_tab.update()?; self.status_tab.update()?;
self.revlog.update()?; self.revlog.update()?;
self.files_tab.update()?; self.files_tab.update()?;
@ -469,9 +469,9 @@ impl App {
[ [
log_search_popup, log_search_popup,
fuzzy_find_popup, fuzzy_find_popup,
msg, msg_popup,
reset, confirm_popup,
commit, commit_popup,
blame_file_popup, blame_file_popup,
file_revlog_popup, file_revlog_popup,
stashmsg_popup, stashmsg_popup,
@ -491,7 +491,7 @@ impl App {
tags_popup, tags_popup,
reset_popup, reset_popup,
options_popup, options_popup,
help, help_popup,
revlog, revlog,
status_tab, status_tab,
files_tab, files_tab,
@ -503,9 +503,9 @@ impl App {
setup_popups!( setup_popups!(
self, self,
[ [
commit, commit_popup,
stashmsg_popup, stashmsg_popup,
help, help_popup,
inspect_commit_popup, inspect_commit_popup,
compare_commits_popup, compare_commits_popup,
blame_file_popup, blame_file_popup,
@ -526,8 +526,8 @@ impl App {
pull_popup, pull_popup,
fetch_popup, fetch_popup,
options_popup, options_popup,
reset, confirm_popup,
msg msg_popup
] ]
); );
@ -619,8 +619,8 @@ impl App {
} }
fn update_commands(&mut self) { fn update_commands(&mut self) {
if self.help.is_visible() { if self.help_popup.is_visible() {
self.help.set_cmds(self.commands(true)); self.help_popup.set_cmds(self.commands(true));
} }
self.cmdbar.borrow_mut().set_cmds(self.commands(false)); self.cmdbar.borrow_mut().set_cmds(self.commands(false));
} }
@ -703,23 +703,23 @@ impl App {
self.process_confirmed_action(action, &mut flags)?; self.process_confirmed_action(action, &mut flags)?;
} }
InternalEvent::ConfirmAction(action) => { InternalEvent::ConfirmAction(action) => {
self.reset.open(action)?; self.confirm_popup.open(action)?;
flags.insert(NeedsUpdate::COMMANDS); flags.insert(NeedsUpdate::COMMANDS);
} }
InternalEvent::ShowErrorMsg(msg) => { InternalEvent::ShowErrorMsg(msg) => {
self.msg.show_error(msg.as_str())?; self.msg_popup.show_error(msg.as_str())?;
flags flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS); .insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
} }
InternalEvent::ShowInfoMsg(msg) => { InternalEvent::ShowInfoMsg(msg) => {
self.msg.show_info(msg.as_str())?; self.msg_popup.show_info(msg.as_str())?;
flags flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS); .insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
} }
InternalEvent::Update(u) => flags.insert(u), InternalEvent::Update(u) => flags.insert(u),
InternalEvent::OpenCommit => self.commit.show()?, InternalEvent::OpenCommit => self.commit_popup.show()?,
InternalEvent::RewordCommit(id) => { InternalEvent::RewordCommit(id) => {
self.commit.open(Some(id))?; self.commit_popup.open(Some(id))?;
} }
InternalEvent::PopupStashing(opts) => { InternalEvent::PopupStashing(opts) => {
self.stashmsg_popup.options(opts); self.stashmsg_popup.options(opts);

View file

@ -1,75 +1,30 @@
mod blame_file;
mod branchlist;
mod changes; mod changes;
mod command; mod command;
mod commit;
mod commit_details; mod commit_details;
mod commitlist; mod commitlist;
mod compare_commits;
mod create_branch;
mod cred; mod cred;
mod diff; mod diff;
mod externaleditor;
mod fetch;
mod file_revlog;
mod fuzzy_find_popup;
mod help;
mod inspect_commit;
mod log_search_popup;
mod msg;
mod options_popup;
mod pull;
mod push;
mod push_tags;
mod rename_branch;
mod reset;
mod reset_popup;
mod revision_files; mod revision_files;
mod revision_files_popup;
mod stashmsg;
mod status_tree; mod status_tree;
mod submodules;
mod syntax_text; mod syntax_text;
mod tag_commit;
mod taglist;
mod textinput; mod textinput;
mod utils; mod utils;
pub use self::status_tree::StatusTreeComponent; pub use self::status_tree::StatusTreeComponent;
pub use blame_file::{BlameFileComponent, BlameFileOpen};
pub use branchlist::BranchListComponent;
pub use changes::ChangesComponent; pub use changes::ChangesComponent;
pub use command::{CommandInfo, CommandText}; pub use command::{CommandInfo, CommandText};
pub use commit::CommitComponent;
pub use commit_details::CommitDetailsComponent; pub use commit_details::CommitDetailsComponent;
pub use commitlist::CommitList; pub use commitlist::CommitList;
pub use compare_commits::CompareCommitsComponent; pub use cred::CredComponent;
pub use create_branch::CreateBranchComponent;
pub use diff::DiffComponent; pub use diff::DiffComponent;
pub use externaleditor::ExternalEditorComponent;
pub use fetch::FetchComponent;
pub use file_revlog::{FileRevOpen, FileRevlogComponent};
pub use fuzzy_find_popup::FuzzyFindPopup;
pub use help::HelpComponent;
pub use inspect_commit::{InspectCommitComponent, InspectCommitOpen};
pub use log_search_popup::LogSearchPopupComponent;
pub use msg::MsgComponent;
pub use options_popup::{AppOption, OptionsPopupComponent};
pub use pull::PullComponent;
pub use push::PushComponent;
pub use push_tags::PushTagsComponent;
pub use rename_branch::RenameBranchComponent;
pub use reset::ConfirmComponent;
pub use reset_popup::ResetPopupComponent;
pub use revision_files::RevisionFilesComponent; pub use revision_files::RevisionFilesComponent;
pub use revision_files_popup::{FileTreeOpen, RevisionFilesPopup};
pub use stashmsg::StashMsgComponent;
pub use submodules::SubmodulesListComponent;
pub use syntax_text::SyntaxTextComponent; pub use syntax_text::SyntaxTextComponent;
pub use tag_commit::TagCommitComponent;
pub use taglist::TagListComponent;
pub use textinput::{InputType, TextInputComponent}; pub use textinput::{InputType, TextInputComponent};
pub use utils::filetree::FileTreeItemKind; pub use utils::{
filetree::FileTreeItemKind, logitems::ItemBatch,
scroll_vertical::VerticalScroll, string_width_align,
time_to_string,
};
use crate::ui::style::Theme; use crate::ui::style::Theme;
use anyhow::Result; use anyhow::Result;
@ -78,7 +33,7 @@ use ratatui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Span, Text}, text::{Span, Text},
widgets::{Block, BorderType, Borders, Paragraph, Wrap}, widgets::{Block, Borders, Paragraph},
Frame, Frame,
}; };
@ -312,30 +267,3 @@ fn dialog_paragraph<'a>(
) )
.alignment(Alignment::Left) .alignment(Alignment::Left)
} }
fn popup_paragraph<'a, T>(
title: &'a str,
content: T,
theme: &Theme,
focused: bool,
block: bool,
) -> Paragraph<'a>
where
T: Into<Text<'a>>,
{
let paragraph = Paragraph::new(content.into())
.alignment(Alignment::Left)
.wrap(Wrap { trim: true });
if block {
paragraph.block(
Block::default()
.title(Span::styled(title, theme.title(focused)))
.borders(Borders::ALL)
.border_type(BorderType::Thick)
.border_style(theme.block(focused)),
)
} else {
paragraph
}
}

View file

@ -1,11 +1,12 @@
use super::{ use super::{
utils::scroll_vertical::VerticalScroll, BlameFileOpen, utils::scroll_vertical::VerticalScroll, CommandBlocking,
CommandBlocking, CommandInfo, Component, DrawableComponent, CommandInfo, Component, DrawableComponent, EventState,
EventState, FileRevOpen, FuzzyFinderTarget, SyntaxTextComponent, FuzzyFinderTarget, SyntaxTextComponent,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
popups::{BlameFileOpen, FileRevOpen},
queue::{InternalEvent, Queue, StackablePopupOpen}, queue::{InternalEvent, Queue, StackablePopupOpen},
strings::{self, order, symbol}, strings::{self, order, symbol},
try_or_popup, try_or_popup,

View file

@ -3,16 +3,16 @@ use super::{
filetree::{FileTreeItem, FileTreeItemKind}, filetree::{FileTreeItem, FileTreeItemKind},
statustree::{MoveSelection, StatusTree}, statustree::{MoveSelection, StatusTree},
}, },
BlameFileOpen, CommandBlocking, DrawableComponent, FileRevOpen, CommandBlocking, DrawableComponent,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
components::{CommandInfo, Component, EventState}, components::{CommandInfo, Component, EventState},
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
popups::{BlameFileOpen, FileRevOpen},
queue::{InternalEvent, NeedsUpdate, Queue, StackablePopupOpen}, queue::{InternalEvent, NeedsUpdate, Queue, StackablePopupOpen},
strings::{self, order}, strings::{self, order},
ui, ui::{self, style::SharedTheme},
ui::style::SharedTheme,
}; };
use anyhow::Result; use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType}; use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};

View file

@ -38,6 +38,7 @@ mod keys;
mod notify_mutex; mod notify_mutex;
mod options; mod options;
mod popup_stack; mod popup_stack;
mod popups;
mod queue; mod queue;
mod spinner; mod spinner;
mod string_utils; mod string_utils;

View file

@ -1,12 +1,12 @@
use super::{
utils, visibility_blocking, CommandBlocking, CommandInfo,
Component, DrawableComponent, EventState, FileRevOpen,
InspectCommitOpen,
};
use crate::{ use crate::{
app::Environment, app::Environment,
components::{utils::string_width_align, ScrollType}, components::{
string_width_align, time_to_string, visibility_blocking,
CommandBlocking, CommandInfo, Component, DrawableComponent,
EventState, ScrollType,
},
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
popups::{FileRevOpen, InspectCommitOpen},
queue::{InternalEvent, Queue, StackablePopupOpen}, queue::{InternalEvent, Queue, StackablePopupOpen},
string_utils::tabs_to_spaces, string_utils::tabs_to_spaces,
strings, strings,
@ -84,7 +84,7 @@ pub struct BlameFileOpen {
pub selection: Option<usize>, pub selection: Option<usize>,
} }
pub struct BlameFileComponent { pub struct BlameFilePopup {
title: String, title: String,
theme: SharedTheme, theme: SharedTheme,
queue: Queue, queue: Queue,
@ -99,7 +99,7 @@ pub struct BlameFileComponent {
git_sender: Sender<AsyncGitNotification>, git_sender: Sender<AsyncGitNotification>,
repo: RepoPathRef, repo: RepoPathRef,
} }
impl DrawableComponent for BlameFileComponent { impl DrawableComponent for BlameFilePopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -192,7 +192,7 @@ impl DrawableComponent for BlameFileComponent {
} }
} }
impl Component for BlameFileComponent { impl Component for BlameFilePopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -329,7 +329,7 @@ impl Component for BlameFileComponent {
} }
} }
impl BlameFileComponent { impl BlameFilePopup {
/// ///
pub fn new(env: &Environment, title: &str) -> Self { pub fn new(env: &Environment, title: &str) -> Self {
Self { Self {
@ -648,7 +648,7 @@ impl BlameFileComponent {
); );
let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}"); let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}");
let time = blame_hunk.map_or_else(String::new, |hunk| { let time = blame_hunk.map_or_else(String::new, |hunk| {
utils::time_to_string(hunk.time, true) time_to_string(hunk.time, true)
}); });
let file_blame = self.blame.result(); let file_blame = self.blame.result();

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
utils::scroll_vertical::VerticalScroll, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, FuzzyFinderTarget, VerticalScroll,
EventState, FuzzyFinderTarget, InspectCommitOpen,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -40,8 +39,10 @@ use std::cell::Cell;
use ui::style::SharedTheme; use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
use super::InspectCommitOpen;
/// ///
pub struct BranchListComponent { pub struct BranchListPopup {
repo: RepoPathRef, repo: RepoPathRef,
branches: Vec<BranchInfo>, branches: Vec<BranchInfo>,
local: bool, local: bool,
@ -55,7 +56,7 @@ pub struct BranchListComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for BranchListComponent { impl DrawableComponent for BranchListPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -105,7 +106,7 @@ impl DrawableComponent for BranchListComponent {
} }
} }
impl Component for BranchListComponent { impl Component for BranchListPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -329,7 +330,7 @@ impl Component for BranchListComponent {
} }
} }
impl BranchListComponent { impl BranchListPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
branches: Vec::new(), branches: Vec::new(),

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
textinput::TextInputComponent, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, TextInputComponent,
EventState, ExternalEditorComponent,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -35,6 +34,8 @@ use std::{
str::FromStr, str::FromStr,
}; };
use super::ExternalEditorPopup;
enum CommitResult { enum CommitResult {
ComitDone, ComitDone,
Aborted, Aborted,
@ -48,7 +49,7 @@ enum Mode {
Reword(CommitId), Reword(CommitId),
} }
pub struct CommitComponent { pub struct CommitPopup {
repo: RepoPathRef, repo: RepoPathRef,
input: TextInputComponent, input: TextInputComponent,
mode: Mode, mode: Mode,
@ -64,7 +65,7 @@ pub struct CommitComponent {
const FIRST_LINE_LIMIT: usize = 50; const FIRST_LINE_LIMIT: usize = 50;
impl CommitComponent { impl CommitPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -183,7 +184,7 @@ impl CommitComponent {
} }
} }
ExternalEditorComponent::open_file_in_editor( ExternalEditorPopup::open_file_in_editor(
&self.repo.borrow(), &self.repo.borrow(),
&file_path, &file_path,
)?; )?;
@ -486,7 +487,7 @@ impl CommitComponent {
} }
} }
impl DrawableComponent for CommitComponent { impl DrawableComponent for CommitPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -502,7 +503,7 @@ impl DrawableComponent for CommitComponent {
} }
} }
impl Component for CommitComponent { impl Component for CommitPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,13 +1,14 @@
use super::{ use crate::components::{
command_pump, event_pump, visibility_blocking, CommandBlocking, command_pump, event_pump, visibility_blocking, CommandBlocking,
CommandInfo, CommitDetailsComponent, Component, DiffComponent, CommandInfo, CommitDetailsComponent, Component, DiffComponent,
DrawableComponent, EventState, InspectCommitOpen, DrawableComponent, EventState,
}; };
use crate::{ use crate::{
accessors, accessors,
app::Environment, app::Environment,
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
options::SharedOptions, options::SharedOptions,
popups::InspectCommitOpen,
queue::{InternalEvent, Queue, StackablePopupOpen}, queue::{InternalEvent, Queue, StackablePopupOpen},
strings, strings,
}; };
@ -25,7 +26,7 @@ use ratatui::{
Frame, Frame,
}; };
pub struct CompareCommitsComponent { pub struct CompareCommitsPopup {
repo: RepoPathRef, repo: RepoPathRef,
open_request: Option<InspectCommitOpen>, open_request: Option<InspectCommitOpen>,
diff: DiffComponent, diff: DiffComponent,
@ -37,7 +38,7 @@ pub struct CompareCommitsComponent {
options: SharedOptions, options: SharedOptions,
} }
impl DrawableComponent for CompareCommitsComponent { impl DrawableComponent for CompareCommitsPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -71,7 +72,7 @@ impl DrawableComponent for CompareCommitsComponent {
} }
} }
impl Component for CompareCommitsComponent { impl Component for CompareCommitsPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -163,7 +164,7 @@ impl Component for CompareCommitsComponent {
} }
} }
impl CompareCommitsComponent { impl CompareCommitsPopup {
accessors!(self, [diff, details]); accessors!(self, [diff, details]);
/// ///

View file

@ -1,8 +1,8 @@
use crate::{ use crate::{
app::Environment, app::Environment,
components::{ components::{
popup_paragraph, visibility_blocking, CommandBlocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandInfo, Component, DrawableComponent, EventState, DrawableComponent, EventState,
}, },
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
queue::{Action, InternalEvent, Queue}, queue::{Action, InternalEvent, Queue},
@ -16,8 +16,10 @@ use ratatui::{
use std::borrow::Cow; use std::borrow::Cow;
use ui::style::SharedTheme; use ui::style::SharedTheme;
use super::popup_paragraph;
/// ///
pub struct ConfirmComponent { pub struct ConfirmPopup {
target: Option<Action>, target: Option<Action>,
visible: bool, visible: bool,
queue: Queue, queue: Queue,
@ -25,7 +27,7 @@ pub struct ConfirmComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for ConfirmComponent { impl DrawableComponent for ConfirmPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -51,7 +53,7 @@ impl DrawableComponent for ConfirmComponent {
} }
} }
impl Component for ConfirmComponent { impl Component for ConfirmPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -102,7 +104,7 @@ impl Component for ConfirmComponent {
} }
} }
impl ConfirmComponent { impl ConfirmPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
textinput::TextInputComponent, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, InputType, TextInputComponent,
EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -18,7 +17,7 @@ use ratatui::{
backend::Backend, layout::Rect, widgets::Paragraph, Frame, backend::Backend, layout::Rect, widgets::Paragraph, Frame,
}; };
pub struct CreateBranchComponent { pub struct CreateBranchPopup {
repo: RepoPathRef, repo: RepoPathRef,
input: TextInputComponent, input: TextInputComponent,
queue: Queue, queue: Queue,
@ -26,7 +25,7 @@ pub struct CreateBranchComponent {
theme: SharedTheme, theme: SharedTheme,
} }
impl DrawableComponent for CreateBranchComponent { impl DrawableComponent for CreateBranchPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -41,7 +40,7 @@ impl DrawableComponent for CreateBranchComponent {
} }
} }
impl Component for CreateBranchComponent { impl Component for CreateBranchPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -94,7 +93,7 @@ impl Component for CreateBranchComponent {
} }
} }
impl CreateBranchComponent { impl CreateBranchPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -105,7 +104,7 @@ impl CreateBranchComponent {
&strings::create_branch_popup_msg(&env.key_config), &strings::create_branch_popup_msg(&env.key_config),
true, true,
) )
.with_input_type(super::InputType::Singleline), .with_input_type(InputType::Singleline),
theme: env.theme.clone(), theme: env.theme.clone(),
key_config: env.key_config.clone(), key_config: env.key_config.clone(),
repo: env.repo.clone(), repo: env.repo.clone(),

View file

@ -29,13 +29,13 @@ use std::ffi::OsStr;
use std::{env, io, path::Path, process::Command}; use std::{env, io, path::Path, process::Command};
/// ///
pub struct ExternalEditorComponent { pub struct ExternalEditorPopup {
visible: bool, visible: bool,
theme: SharedTheme, theme: SharedTheme,
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl ExternalEditorComponent { impl ExternalEditorPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -120,7 +120,7 @@ impl ExternalEditorComponent {
} }
} }
impl DrawableComponent for ExternalEditorComponent { impl DrawableComponent for ExternalEditorPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -155,7 +155,7 @@ impl DrawableComponent for ExternalEditorComponent {
} }
} }
impl Component for ExternalEditorComponent { impl Component for ExternalEditorPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,8 +1,8 @@
use crate::{ use crate::{
app::Environment, app::Environment,
components::{ components::{
cred::CredComponent, visibility_blocking, CommandBlocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandInfo, Component, DrawableComponent, EventState, CredComponent, DrawableComponent, EventState,
}, },
keys::SharedKeyConfig, keys::SharedKeyConfig,
queue::{InternalEvent, NeedsUpdate, Queue}, queue::{InternalEvent, NeedsUpdate, Queue},
@ -32,7 +32,7 @@ use ratatui::{
}; };
/// ///
pub struct FetchComponent { pub struct FetchPopup {
repo: RepoPathRef, repo: RepoPathRef,
visible: bool, visible: bool,
async_fetch: AsyncSingleJob<AsyncFetchJob>, async_fetch: AsyncSingleJob<AsyncFetchJob>,
@ -44,7 +44,7 @@ pub struct FetchComponent {
input_cred: CredComponent, input_cred: CredComponent,
} }
impl FetchComponent { impl FetchPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -116,7 +116,7 @@ impl FetchComponent {
} }
} }
impl DrawableComponent for FetchComponent { impl DrawableComponent for FetchPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -151,7 +151,7 @@ impl DrawableComponent for FetchComponent {
} }
} }
impl Component for FetchComponent { impl Component for FetchPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,16 +1,13 @@
use super::utils::logitems::ItemBatch;
use super::{visibility_blocking, BlameFileOpen, InspectCommitOpen};
use crate::app::Environment;
use crate::keys::key_match;
use crate::options::SharedOptions;
use crate::queue::StackablePopupOpen;
use crate::{ use crate::{
app::Environment,
components::{ components::{
event_pump, CommandBlocking, CommandInfo, Component, event_pump, visibility_blocking, CommandBlocking,
DiffComponent, DrawableComponent, EventState, ScrollType, CommandInfo, Component, DiffComponent, DrawableComponent,
EventState, ItemBatch, ScrollType,
}, },
keys::SharedKeyConfig, keys::{key_match, SharedKeyConfig},
queue::{InternalEvent, NeedsUpdate, Queue}, options::SharedOptions,
queue::{InternalEvent, NeedsUpdate, Queue, StackablePopupOpen},
strings, strings,
ui::{draw_scrollbar, style::SharedTheme, Orientation}, ui::{draw_scrollbar, style::SharedTheme, Orientation},
}; };
@ -32,6 +29,8 @@ use ratatui::{
Frame, Frame,
}; };
use super::{BlameFileOpen, InspectCommitOpen};
const SLICE_SIZE: usize = 1200; const SLICE_SIZE: usize = 1200;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -50,7 +49,7 @@ impl FileRevOpen {
} }
/// ///
pub struct FileRevlogComponent { pub struct FileRevlogPopup {
git_log: Option<AsyncLog>, git_log: Option<AsyncLog>,
git_diff: AsyncDiff, git_diff: AsyncDiff,
theme: SharedTheme, theme: SharedTheme,
@ -69,7 +68,7 @@ pub struct FileRevlogComponent {
current_height: std::cell::Cell<usize>, current_height: std::cell::Cell<usize>,
} }
impl FileRevlogComponent { impl FileRevlogPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -464,7 +463,7 @@ impl FileRevlogComponent {
} }
} }
impl DrawableComponent for FileRevlogComponent { impl DrawableComponent for FileRevlogPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -498,7 +497,7 @@ impl DrawableComponent for FileRevlogComponent {
} }
} }
impl Component for FileRevlogComponent { impl Component for FileRevlogPopup {
fn event(&mut self, event: &Event) -> Result<EventState> { fn event(&mut self, event: &Event) -> Result<EventState> {
if self.is_visible() { if self.is_visible() {
if event_pump( if event_pump(

View file

@ -1,7 +1,7 @@
use super::{ use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component, visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, FuzzyFinderTarget, ScrollType, DrawableComponent, EventState, FuzzyFinderTarget, InputType,
TextInputComponent, ScrollType, TextInputComponent,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -43,7 +43,7 @@ impl FuzzyFindPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
let mut find_text = let mut find_text =
TextInputComponent::new(env, "", "start typing..", false) TextInputComponent::new(env, "", "start typing..", false)
.with_input_type(super::InputType::Singleline); .with_input_type(InputType::Singleline);
find_text.embed(); find_text.embed();
Self { Self {

View file

@ -1,4 +1,4 @@
use super::{ use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component, visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, DrawableComponent, EventState,
}; };
@ -24,7 +24,7 @@ use std::{borrow::Cow, cmp};
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///
pub struct HelpComponent { pub struct HelpPopup {
cmds: Vec<CommandInfo>, cmds: Vec<CommandInfo>,
visible: bool, visible: bool,
selection: u16, selection: u16,
@ -32,7 +32,7 @@ pub struct HelpComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for HelpComponent { impl DrawableComponent for HelpPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -87,7 +87,7 @@ impl DrawableComponent for HelpComponent {
} }
} }
impl Component for HelpComponent { impl Component for HelpPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -167,7 +167,7 @@ impl Component for HelpComponent {
} }
} }
impl HelpComponent { impl HelpPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
cmds: vec![], cmds: vec![],

View file

@ -1,4 +1,4 @@
use super::{ use crate::components::{
command_pump, event_pump, visibility_blocking, CommandBlocking, command_pump, event_pump, visibility_blocking, CommandBlocking,
CommandInfo, CommitDetailsComponent, Component, DiffComponent, CommandInfo, CommitDetailsComponent, Component, DiffComponent,
DrawableComponent, EventState, DrawableComponent, EventState,
@ -53,7 +53,7 @@ impl InspectCommitOpen {
} }
} }
pub struct InspectCommitComponent { pub struct InspectCommitPopup {
queue: Queue, queue: Queue,
open_request: Option<InspectCommitOpen>, open_request: Option<InspectCommitOpen>,
diff: DiffComponent, diff: DiffComponent,
@ -64,7 +64,7 @@ pub struct InspectCommitComponent {
options: SharedOptions, options: SharedOptions,
} }
impl DrawableComponent for InspectCommitComponent { impl DrawableComponent for InspectCommitPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -98,7 +98,7 @@ impl DrawableComponent for InspectCommitComponent {
} }
} }
impl Component for InspectCommitComponent { impl Component for InspectCommitPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -199,7 +199,7 @@ impl Component for InspectCommitComponent {
} }
} }
impl InspectCommitComponent { impl InspectCommitPopup {
accessors!(self, [diff, details]); accessors!(self, [diff, details]);
/// ///

View file

@ -1,6 +1,6 @@
use super::{ use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component, visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, TextInputComponent, DrawableComponent, EventState, InputType, TextInputComponent,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -41,7 +41,7 @@ enum PopupMode {
JumpCommitSha, JumpCommitSha,
} }
pub struct LogSearchPopupComponent { pub struct LogSearchPopupPopup {
repo: RepoPathRef, repo: RepoPathRef,
queue: Queue, queue: Queue,
visible: bool, visible: bool,
@ -54,12 +54,12 @@ pub struct LogSearchPopupComponent {
jump_commit_id: Option<CommitId>, jump_commit_id: Option<CommitId>,
} }
impl LogSearchPopupComponent { impl LogSearchPopupPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
let mut find_text = let mut find_text =
TextInputComponent::new(env, "", "search text", false) TextInputComponent::new(env, "", "search text", false)
.with_input_type(super::InputType::Singleline); .with_input_type(InputType::Singleline);
find_text.embed(); find_text.embed();
find_text.enabled(true); find_text.enabled(true);
@ -524,7 +524,7 @@ impl LogSearchPopupComponent {
} }
} }
impl DrawableComponent for LogSearchPopupComponent { impl DrawableComponent for LogSearchPopupPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -545,7 +545,7 @@ impl DrawableComponent for LogSearchPopupComponent {
} }
} }
impl Component for LogSearchPopupComponent { impl Component for LogSearchPopupPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

85
src/popups/mod.rs Normal file
View file

@ -0,0 +1,85 @@
mod blame_file;
mod branchlist;
mod commit;
mod compare_commits;
mod confirm;
mod create_branch;
mod externaleditor;
mod fetch;
mod file_revlog;
mod fuzzy_find;
mod help;
mod inspect_commit;
mod log_search;
mod msg;
mod options;
mod pull;
mod push;
mod push_tags;
mod rename_branch;
mod reset;
mod revision_files;
mod stashmsg;
mod submodules;
mod tag_commit;
mod taglist;
pub use blame_file::{BlameFileOpen, BlameFilePopup};
pub use branchlist::BranchListPopup;
pub use commit::CommitPopup;
pub use compare_commits::CompareCommitsPopup;
pub use confirm::ConfirmPopup;
pub use create_branch::CreateBranchPopup;
pub use externaleditor::ExternalEditorPopup;
pub use fetch::FetchPopup;
pub use file_revlog::{FileRevOpen, FileRevlogPopup};
pub use fuzzy_find::FuzzyFindPopup;
pub use help::HelpPopup;
pub use inspect_commit::{InspectCommitOpen, InspectCommitPopup};
pub use log_search::LogSearchPopupPopup;
pub use msg::MsgPopup;
pub use options::{AppOption, OptionsPopup};
pub use pull::PullPopup;
pub use push::PushPopup;
pub use push_tags::PushTagsPopup;
pub use rename_branch::RenameBranchPopup;
pub use reset::ResetPopup;
pub use revision_files::{FileTreeOpen, RevisionFilesPopup};
pub use stashmsg::StashMsgPopup;
pub use submodules::SubmodulesListPopup;
pub use tag_commit::TagCommitPopup;
pub use taglist::TagListPopup;
use crate::ui::style::Theme;
use ratatui::{
layout::Alignment,
text::{Span, Text},
widgets::{Block, BorderType, Borders, Paragraph, Wrap},
};
fn popup_paragraph<'a, T>(
title: &'a str,
content: T,
theme: &Theme,
focused: bool,
block: bool,
) -> Paragraph<'a>
where
T: Into<Text<'a>>,
{
let paragraph = Paragraph::new(content.into())
.alignment(Alignment::Left)
.wrap(Wrap { trim: true });
if block {
paragraph.block(
Block::default()
.title(Span::styled(title, theme.title(focused)))
.borders(Borders::ALL)
.border_type(BorderType::Thick)
.border_style(theme.block(focused)),
)
} else {
paragraph
}
}

View file

@ -1,4 +1,4 @@
use super::{ use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component, visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, DrawableComponent, EventState,
}; };
@ -17,7 +17,7 @@ use ratatui::{
}; };
use ui::style::SharedTheme; use ui::style::SharedTheme;
pub struct MsgComponent { pub struct MsgPopup {
title: String, title: String,
msg: String, msg: String,
visible: bool, visible: bool,
@ -27,7 +27,7 @@ pub struct MsgComponent {
use anyhow::Result; use anyhow::Result;
impl DrawableComponent for MsgComponent { impl DrawableComponent for MsgPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -78,7 +78,7 @@ impl DrawableComponent for MsgComponent {
} }
} }
impl Component for MsgComponent { impl Component for MsgPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -121,7 +121,7 @@ impl Component for MsgComponent {
} }
} }
impl MsgComponent { impl MsgPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
title: String::new(), title: String::new(),

View file

@ -1,14 +1,13 @@
use super::{
visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState,
};
use crate::{ use crate::{
app::Environment, app::Environment,
components::utils::string_width_align, components::{
string_width_align, visibility_blocking, CommandBlocking,
CommandInfo, Component, DrawableComponent, EventState,
},
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
options::SharedOptions, options::SharedOptions,
queue::{InternalEvent, Queue}, queue::{InternalEvent, Queue},
strings::{self}, strings,
ui::{self, style::SharedTheme}, ui::{self, style::SharedTheme},
}; };
use anyhow::Result; use anyhow::Result;
@ -31,7 +30,7 @@ pub enum AppOption {
DiffInterhunkLines, DiffInterhunkLines,
} }
pub struct OptionsPopupComponent { pub struct OptionsPopup {
selection: AppOption, selection: AppOption,
queue: Queue, queue: Queue,
visible: bool, visible: bool,
@ -40,7 +39,7 @@ pub struct OptionsPopupComponent {
theme: SharedTheme, theme: SharedTheme,
} }
impl OptionsPopupComponent { impl OptionsPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -256,7 +255,7 @@ impl OptionsPopupComponent {
} }
} }
impl DrawableComponent for OptionsPopupComponent { impl DrawableComponent for OptionsPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -290,7 +289,7 @@ impl DrawableComponent for OptionsPopupComponent {
} }
} }
impl Component for OptionsPopupComponent { impl Component for OptionsPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,11 +1,11 @@
use super::PushComponent;
use crate::{ use crate::{
app::Environment, app::Environment,
components::{ components::{
cred::CredComponent, visibility_blocking, CommandBlocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandInfo, Component, DrawableComponent, EventState, CredComponent, DrawableComponent, EventState,
}, },
keys::SharedKeyConfig, keys::SharedKeyConfig,
popups::PushPopup,
queue::{Action, InternalEvent, Queue}, queue::{Action, InternalEvent, Queue},
strings, try_or_popup, strings, try_or_popup,
ui::{self, style::SharedTheme}, ui::{self, style::SharedTheme},
@ -33,7 +33,7 @@ use ratatui::{
}; };
/// ///
pub struct PullComponent { pub struct PullPopup {
repo: RepoPathRef, repo: RepoPathRef,
visible: bool, visible: bool,
git_fetch: AsyncPull, git_fetch: AsyncPull,
@ -46,7 +46,7 @@ pub struct PullComponent {
input_cred: CredComponent, input_cred: CredComponent,
} }
impl PullComponent { impl PullPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -197,7 +197,7 @@ impl PullComponent {
} }
} }
impl DrawableComponent for PullComponent { impl DrawableComponent for PullPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -205,7 +205,7 @@ impl DrawableComponent for PullComponent {
) -> Result<()> { ) -> Result<()> {
if self.visible { if self.visible {
let (state, progress) = let (state, progress) =
PushComponent::get_progress(&self.progress); PushPopup::get_progress(&self.progress);
let area = ui::centered_rect_absolute(30, 3, f.size()); let area = ui::centered_rect_absolute(30, 3, f.size());
@ -234,7 +234,7 @@ impl DrawableComponent for PullComponent {
} }
} }
impl Component for PullComponent { impl Component for PullPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,8 +1,8 @@
use crate::{ use crate::{
app::Environment, app::Environment,
components::{ components::{
cred::CredComponent, visibility_blocking, CommandBlocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandInfo, Component, DrawableComponent, EventState, CredComponent, DrawableComponent, EventState,
}, },
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
queue::{InternalEvent, Queue}, queue::{InternalEvent, Queue},
@ -49,7 +49,7 @@ impl PushComponentModifier {
} }
/// ///
pub struct PushComponent { pub struct PushPopup {
repo: RepoPathRef, repo: RepoPathRef,
modifier: PushComponentModifier, modifier: PushComponentModifier,
visible: bool, visible: bool,
@ -64,7 +64,7 @@ pub struct PushComponent {
input_cred: CredComponent, input_cred: CredComponent,
} }
impl PushComponent { impl PushPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -226,7 +226,7 @@ impl PushComponent {
} }
} }
impl DrawableComponent for PushComponent { impl DrawableComponent for PushPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -267,7 +267,7 @@ impl DrawableComponent for PushComponent {
} }
} }
impl Component for PushComponent { impl Component for PushPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,12 +1,12 @@
use crate::{ use crate::{
app::Environment, app::Environment,
components::{ components::{
cred::CredComponent, visibility_blocking, CommandBlocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandInfo, Component, DrawableComponent, EventState, CredComponent, DrawableComponent, EventState,
}, },
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
queue::{InternalEvent, Queue}, queue::{InternalEvent, Queue},
strings::{self}, strings,
ui::{self, style::SharedTheme}, ui::{self, style::SharedTheme},
}; };
use anyhow::Result; use anyhow::Result;
@ -31,7 +31,7 @@ use ratatui::{
}; };
/// ///
pub struct PushTagsComponent { pub struct PushTagsPopup {
repo: RepoPathRef, repo: RepoPathRef,
visible: bool, visible: bool,
git_push: AsyncPushTags, git_push: AsyncPushTags,
@ -43,7 +43,7 @@ pub struct PushTagsComponent {
input_cred: CredComponent, input_cred: CredComponent,
} }
impl PushTagsComponent { impl PushTagsPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -157,7 +157,7 @@ impl PushTagsComponent {
} }
} }
impl DrawableComponent for PushTagsComponent { impl DrawableComponent for PushTagsPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -194,7 +194,7 @@ impl DrawableComponent for PushTagsComponent {
} }
} }
impl Component for PushTagsComponent { impl Component for PushTagsPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
textinput::TextInputComponent, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, InputType, TextInputComponent,
EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -14,7 +13,7 @@ use asyncgit::sync::{self, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
pub struct RenameBranchComponent { pub struct RenameBranchPopup {
repo: RepoPathRef, repo: RepoPathRef,
input: TextInputComponent, input: TextInputComponent,
branch_ref: Option<String>, branch_ref: Option<String>,
@ -22,7 +21,7 @@ pub struct RenameBranchComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for RenameBranchComponent { impl DrawableComponent for RenameBranchPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -34,7 +33,7 @@ impl DrawableComponent for RenameBranchComponent {
} }
} }
impl Component for RenameBranchComponent { impl Component for RenameBranchPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -87,7 +86,7 @@ impl Component for RenameBranchComponent {
} }
} }
impl RenameBranchComponent { impl RenameBranchPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -99,7 +98,7 @@ impl RenameBranchComponent {
&strings::rename_branch_popup_msg(&env.key_config), &strings::rename_branch_popup_msg(&env.key_config),
true, true,
) )
.with_input_type(super::InputType::Singleline), .with_input_type(InputType::Singleline),
branch_ref: None, branch_ref: None,
key_config: env.key_config.clone(), key_config: env.key_config.clone(),
} }

View file

@ -1,4 +1,4 @@
use super::{ use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component, visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, DrawableComponent, EventState,
}; };
@ -40,7 +40,7 @@ const fn type_to_string(
} }
} }
pub struct ResetPopupComponent { pub struct ResetPopup {
queue: Queue, queue: Queue,
repo: RepoPath, repo: RepoPath,
commit: Option<CommitId>, commit: Option<CommitId>,
@ -51,7 +51,7 @@ pub struct ResetPopupComponent {
theme: SharedTheme, theme: SharedTheme,
} }
impl ResetPopupComponent { impl ResetPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -155,7 +155,7 @@ impl ResetPopupComponent {
} }
} }
impl DrawableComponent for ResetPopupComponent { impl DrawableComponent for ResetPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -189,7 +189,7 @@ impl DrawableComponent for ResetPopupComponent {
} }
} }
impl Component for ResetPopupComponent { impl Component for ResetPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,

View file

@ -1,9 +1,6 @@
use std::path::Path; use crate::components::{
visibility_blocking, CommandBlocking, CommandInfo, Component,
use super::{ DrawableComponent, EventState, RevisionFilesComponent,
revision_files::RevisionFilesComponent, visibility_blocking,
CommandBlocking, CommandInfo, Component, DrawableComponent,
EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -18,6 +15,7 @@ use crossterm::event::Event;
use ratatui::{ use ratatui::{
backend::Backend, layout::Rect, widgets::Clear, Frame, backend::Backend, layout::Rect, widgets::Clear, Frame,
}; };
use std::path::Path;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct FileTreeOpen { pub struct FileTreeOpen {

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
textinput::TextInputComponent, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, InputType, TextInputComponent,
EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -15,7 +14,7 @@ use asyncgit::sync::{self, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
pub struct StashMsgComponent { pub struct StashMsgPopup {
repo: RepoPathRef, repo: RepoPathRef,
options: StashingOptions, options: StashingOptions,
input: TextInputComponent, input: TextInputComponent,
@ -23,7 +22,7 @@ pub struct StashMsgComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for StashMsgComponent { impl DrawableComponent for StashMsgPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -35,7 +34,7 @@ impl DrawableComponent for StashMsgComponent {
} }
} }
impl Component for StashMsgComponent { impl Component for StashMsgPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -124,7 +123,7 @@ impl Component for StashMsgComponent {
} }
} }
impl StashMsgComponent { impl StashMsgPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -136,7 +135,7 @@ impl StashMsgComponent {
&strings::stash_popup_msg(&env.key_config), &strings::stash_popup_msg(&env.key_config),
true, true,
) )
.with_input_type(super::InputType::Singleline), .with_input_type(InputType::Singleline),
key_config: env.key_config.clone(), key_config: env.key_config.clone(),
repo: env.repo.clone(), repo: env.repo.clone(),
} }

View file

@ -1,10 +1,9 @@
use super::{
utils::scroll_vertical::VerticalScroll, visibility_blocking,
CommandBlocking, CommandInfo, Component, DrawableComponent,
EventState, ScrollType,
};
use crate::{ use crate::{
app::Environment, app::Environment,
components::{
visibility_blocking, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState, ScrollType, VerticalScroll,
},
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
queue::{InternalEvent, NeedsUpdate, Queue}, queue::{InternalEvent, NeedsUpdate, Queue},
strings, try_or_popup, strings, try_or_popup,
@ -31,7 +30,7 @@ use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
/// ///
pub struct SubmodulesListComponent { pub struct SubmodulesListPopup {
repo: RepoPathRef, repo: RepoPathRef,
repo_path: String, repo_path: String,
queue: Queue, queue: Queue,
@ -45,7 +44,7 @@ pub struct SubmodulesListComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for SubmodulesListComponent { impl DrawableComponent for SubmodulesListPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -103,7 +102,7 @@ impl DrawableComponent for SubmodulesListComponent {
} }
} }
impl Component for SubmodulesListComponent { impl Component for SubmodulesListPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -245,7 +244,7 @@ impl Component for SubmodulesListComponent {
} }
} }
impl SubmodulesListComponent { impl SubmodulesListPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
submodules: Vec::new(), submodules: Vec::new(),

View file

@ -1,7 +1,6 @@
use super::{ use crate::components::{
textinput::TextInputComponent, visibility_blocking, visibility_blocking, CommandBlocking, CommandInfo, Component,
CommandBlocking, CommandInfo, Component, DrawableComponent, DrawableComponent, EventState, InputType, TextInputComponent,
EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -21,7 +20,7 @@ enum Mode {
Annotation { tag_name: String }, Annotation { tag_name: String },
} }
pub struct TagCommitComponent { pub struct TagCommitPopup {
repo: RepoPathRef, repo: RepoPathRef,
mode: Mode, mode: Mode,
input: TextInputComponent, input: TextInputComponent,
@ -30,7 +29,7 @@ pub struct TagCommitComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for TagCommitComponent { impl DrawableComponent for TagCommitPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -42,7 +41,7 @@ impl DrawableComponent for TagCommitComponent {
} }
} }
impl Component for TagCommitComponent { impl Component for TagCommitPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -124,7 +123,7 @@ impl Component for TagCommitComponent {
} }
} }
impl TagCommitComponent { impl TagCommitPopup {
/// ///
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
@ -135,7 +134,7 @@ impl TagCommitComponent {
&strings::tag_popup_name_msg(), &strings::tag_popup_name_msg(),
true, true,
) )
.with_input_type(super::InputType::Singleline), .with_input_type(InputType::Singleline),
commit_id: None, commit_id: None,
key_config: env.key_config.clone(), key_config: env.key_config.clone(),
repo: env.repo.clone(), repo: env.repo.clone(),

View file

@ -1,6 +1,6 @@
use super::{ use crate::components::{
utils, visibility_blocking, CommandBlocking, CommandInfo, time_to_string, visibility_blocking, CommandBlocking,
Component, DrawableComponent, EventState, CommandInfo, Component, DrawableComponent, EventState,
}; };
use crate::{ use crate::{
app::Environment, app::Environment,
@ -39,7 +39,7 @@ use ratatui::{
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///
pub struct TagListComponent { pub struct TagListPopup {
repo: RepoPathRef, repo: RepoPathRef,
theme: SharedTheme, theme: SharedTheme,
queue: Queue, queue: Queue,
@ -54,7 +54,7 @@ pub struct TagListComponent {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
} }
impl DrawableComponent for TagListComponent { impl DrawableComponent for TagListPopup {
fn draw<B: Backend>( fn draw<B: Backend>(
&self, &self,
f: &mut Frame<B>, f: &mut Frame<B>,
@ -139,7 +139,7 @@ impl DrawableComponent for TagListComponent {
} }
} }
impl Component for TagListComponent { impl Component for TagListPopup {
fn commands( fn commands(
&self, &self,
out: &mut Vec<CommandInfo>, out: &mut Vec<CommandInfo>,
@ -291,7 +291,7 @@ impl Component for TagListComponent {
} }
} }
impl TagListComponent { impl TagListPopup {
pub fn new(env: &Environment) -> Self { pub fn new(env: &Environment) -> Self {
Self { Self {
theme: env.theme.clone(), theme: env.theme.clone(),
@ -477,7 +477,7 @@ impl TagListComponent {
.style(self.theme.commit_author(false)), .style(self.theme.commit_author(false)),
Cell::from(tag.name.clone()) Cell::from(tag.name.clone())
.style(self.theme.text(true, false)), .style(self.theme.text(true, false)),
Cell::from(utils::time_to_string(tag.time, true)) Cell::from(time_to_string(tag.time, true))
.style(self.theme.commit_time(false)), .style(self.theme.commit_time(false)),
Cell::from(tag.author.clone()) Cell::from(tag.author.clone())
.style(self.theme.commit_author(false)), .style(self.theme.commit_author(false)),

View file

@ -1,7 +1,8 @@
use crate::{ use crate::{
components::{ components::FuzzyFinderTarget,
popups::{
AppOption, BlameFileOpen, FileRevOpen, FileTreeOpen, AppOption, BlameFileOpen, FileRevOpen, FileTreeOpen,
FuzzyFinderTarget, InspectCommitOpen, InspectCommitOpen,
}, },
tabs::StashingOptions, tabs::StashingOptions,
}; };

View file

@ -3,10 +3,10 @@ use crate::{
components::{ components::{
visibility_blocking, CommandBlocking, CommandInfo, visibility_blocking, CommandBlocking, CommandInfo,
CommitDetailsComponent, CommitList, Component, CommitDetailsComponent, CommitList, Component,
DrawableComponent, EventState, FileTreeOpen, DrawableComponent, EventState,
InspectCommitOpen,
}, },
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
popups::{FileTreeOpen, InspectCommitOpen},
queue::{InternalEvent, Queue, StackablePopupOpen}, queue::{InternalEvent, Queue, StackablePopupOpen},
strings::{self, order}, strings::{self, order},
try_or_popup, try_or_popup,

View file

@ -3,9 +3,9 @@ use crate::{
components::{ components::{
visibility_blocking, CommandBlocking, CommandInfo, visibility_blocking, CommandBlocking, CommandInfo,
CommitList, Component, DrawableComponent, EventState, CommitList, Component, DrawableComponent, EventState,
InspectCommitOpen,
}, },
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
popups::InspectCommitOpen,
queue::{Action, InternalEvent, Queue, StackablePopupOpen}, queue::{Action, InternalEvent, Queue, StackablePopupOpen},
strings, strings,
}; };