summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorextrawurst <776816+extrawurst@users.noreply.github.com>2024-02-19 17:18:30 +0100
committerGitHub <noreply@github.com>2024-02-19 17:18:30 +0100
commite22cc70a7d16186a0bec3ef38537a7e2da3f49ed (patch)
tree7a1beb7ddccc523b4b5146e70c0fa25487deea9c /src
parentaf9da9517836615f2f9ec6ebea3d8cece9cf9ca9 (diff)
moving popups in its own module (#2066)
Diffstat (limited to 'src')
-rw-r--r--src/app.rs154
-rw-r--r--src/components/mod.rs86
-rw-r--r--src/components/revision_files.rs7
-rw-r--r--src/components/status_tree.rs6
-rw-r--r--src/main.rs1
-rw-r--r--src/popups/blame_file.rs (renamed from src/components/blame_file.rs)22
-rw-r--r--src/popups/branchlist.rs (renamed from src/components/branchlist.rs)17
-rw-r--r--src/popups/commit.rs (renamed from src/components/commit.rs)19
-rw-r--r--src/popups/compare_commits.rs (renamed from src/components/compare_commits.rs)13
-rw-r--r--src/popups/confirm.rs (renamed from src/components/reset.rs)14
-rw-r--r--src/popups/create_branch.rs (renamed from src/components/create_branch.rs)17
-rw-r--r--src/popups/externaleditor.rs (renamed from src/components/externaleditor.rs)8
-rw-r--r--src/popups/fetch.rs (renamed from src/components/fetch.rs)12
-rw-r--r--src/popups/file_revlog.rs (renamed from src/components/file_revlog.rs)27
-rw-r--r--src/popups/fuzzy_find.rs (renamed from src/components/fuzzy_find_popup.rs)8
-rw-r--r--src/popups/help.rs (renamed from src/components/help.rs)10
-rw-r--r--src/popups/inspect_commit.rs (renamed from src/components/inspect_commit.rs)10
-rw-r--r--src/popups/log_search.rs (renamed from src/components/log_search_popup.rs)14
-rw-r--r--src/popups/mod.rs85
-rw-r--r--src/popups/msg.rs (renamed from src/components/msg.rs)10
-rw-r--r--src/popups/options.rs (renamed from src/components/options_popup.rs)19
-rw-r--r--src/popups/pull.rs (renamed from src/components/pull.rs)16
-rw-r--r--src/popups/push.rs (renamed from src/components/push.rs)12
-rw-r--r--src/popups/push_tags.rs (renamed from src/components/push_tags.rs)14
-rw-r--r--src/popups/rename_branch.rs (renamed from src/components/rename_branch.rs)17
-rw-r--r--src/popups/reset.rs (renamed from src/components/reset_popup.rs)10
-rw-r--r--src/popups/revision_files.rs (renamed from src/components/revision_files_popup.rs)10
-rw-r--r--src/popups/stashmsg.rs (renamed from src/components/stashmsg.rs)17
-rw-r--r--src/popups/submodules.rs (renamed from src/components/submodules.rs)17
-rw-r--r--src/popups/tag_commit.rs (renamed from src/components/tag_commit.rs)17
-rw-r--r--src/popups/taglist.rs (renamed from src/components/taglist.rs)16
-rw-r--r--src/queue.rs5
-rw-r--r--src/tabs/revlog.rs4
-rw-r--r--src/tabs/stashlist.rs2
34 files changed, 364 insertions, 352 deletions
diff --git a/src/app.rs b/src/app.rs
index bb8d0333..c25f72bf 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -2,23 +2,23 @@ use crate::{
accessors,
cmdbar::CommandBar,
components::{
- command_pump, event_pump, AppOption, BlameFileComponent,
- BranchListComponent, CommandInfo, CommitComponent,
- 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,
+ command_pump, event_pump, CommandInfo, Component,
+ DrawableComponent, FuzzyFinderTarget,
},
input::{Input, InputEvent, InputState},
keys::{key_match, KeyConfig, SharedKeyConfig},
options::{Options, SharedOptions},
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::{
Action, AppTabs, InternalEvent, NeedsUpdate, Queue,
StackablePopupOpen,
@@ -68,31 +68,31 @@ pub enum QuitState {
pub struct App {
repo: RepoPathRef,
do_quit: QuitState,
- help: HelpComponent,
- msg: MsgComponent,
- reset: ConfirmComponent,
- commit: CommitComponent,
- blame_file_popup: BlameFileComponent,
- file_revlog_popup: FileRevlogComponent,
- stashmsg_popup: StashMsgComponent,
- inspect_commit_popup: InspectCommitComponent,
- compare_commits_popup: CompareCommitsComponent,
- external_editor_popup: ExternalEditorComponent,
+ help_popup: HelpPopup,
+ msg_popup: MsgPopup,
+ confirm_popup: ConfirmPopup,
+ commit_popup: CommitPopup,
+ blame_file_popup: BlameFilePopup,
+ file_revlog_popup: FileRevlogPopup,
+ stashmsg_popup: StashMsgPopup,
+ inspect_commit_popup: InspectCommitPopup,
+ compare_commits_popup: CompareCommitsPopup,
+ external_editor_popup: ExternalEditorPopup,
revision_files_popup: RevisionFilesPopup,
fuzzy_find_popup: FuzzyFindPopup,
- log_search_popup: LogSearchPopupComponent,
- push_popup: PushComponent,
- push_tags_popup: PushTagsComponent,
- pull_popup: PullComponent,
- fetch_popup: FetchComponent,
- tag_commit_popup: TagCommitComponent,
- create_branch_popup: CreateBranchComponent,
- rename_branch_popup: RenameBranchComponent,
- select_branch_popup: BranchListComponent,
- options_popup: OptionsPopupComponent,
- submodule_popup: SubmodulesListComponent,
- tags_popup: TagListComponent,
- reset_popup: ResetPopupComponent,
+ log_search_popup: LogSearchPopupPopup,
+ push_popup: PushPopup,
+ push_tags_popup: PushTagsPopup,
+ pull_popup: PullPopup,
+ fetch_popup: FetchPopup,
+ tag_commit_popup: TagCommitPopup,
+ create_branch_popup: CreateBranchPopup,
+ rename_branch_popup: RenameBranchPopup,
+ select_branch_popup: BranchListPopup,
+ options_popup: OptionsPopup,
+ submodule_popup: SubmodulesListPopup,
+ tags_popup: TagListPopup,
+ reset_popup: ResetPopup,
cmdbar: RefCell<CommandBar>,
tab: usize,
revlog: Revlog,
@@ -171,39 +171,39 @@ impl App {
let mut app = Self {
input,
- reset: ConfirmComponent::new(&env),
- commit: CommitComponent::new(&env),
- blame_file_popup: BlameFileComponent::new(
+ confirm_popup: ConfirmPopup::new(&env),
+ commit_popup: CommitPopup::new(&env),
+ blame_file_popup: BlameFilePopup::new(
&env,
&strings::blame_title(&env.key_config),
),
- file_revlog_popup: FileRevlogComponent::new(&env),
+ file_revlog_popup: FileRevlogPopup::new(&env),
revision_files_popup: RevisionFilesPopup::new(&env),
- stashmsg_popup: StashMsgComponent::new(&env),
- inspect_commit_popup: InspectCommitComponent::new(&env),
- compare_commits_popup: CompareCommitsComponent::new(&env),
- external_editor_popup: ExternalEditorComponent::new(&env),
- push_popup: PushComponent::new(&env),
- push_tags_popup: PushTagsComponent::new(&env),
- reset_popup: ResetPopupComponent::new(&env),
- pull_popup: PullComponent::new(&env),
- fetch_popup: FetchComponent::new(&env),
- tag_commit_popup: TagCommitComponent::new(&env),
- create_branch_popup: CreateBranchComponent::new(&env),
- rename_branch_popup: RenameBranchComponent::new(&env),
- select_branch_popup: BranchListComponent::new(&env),
- tags_popup: TagListComponent::new(&env),
- options_popup: OptionsPopupComponent::new(&env),
- submodule_popup: SubmodulesListComponent::new(&env),
- log_search_popup: LogSearchPopupComponent::new(&env),
+ stashmsg_popup: StashMsgPopup::new(&env),
+ inspect_commit_popup: InspectCommitPopup::new(&env),
+ compare_commits_popup: CompareCommitsPopup::new(&env),
+ external_editor_popup: ExternalEditorPopup::new(&env),
+ push_popup: PushPopup::new(&env),
+ push_tags_popup: PushTagsPopup::new(&env),
+ reset_popup: ResetPopup::new(&env),
+ pull_popup: PullPopup::new(&env),
+ fetch_popup: FetchPopup::new(&env),
+ tag_commit_popup: TagCommitPopup::new(&env),
+ create_branch_popup: CreateBranchPopup::new(&env),
+ rename_branch_popup: RenameBranchPopup::new(&env),
+ select_branch_popup: BranchListPopup::new(&env),
+ tags_popup: TagListPopup::new(&env),
+ options_popup: OptionsPopup::new(&env),
+ submodule_popup: SubmodulesListPopup::new(&env),
+ log_search_popup: LogSearchPopupPopup::new(&env),
fuzzy_find_popup: FuzzyFindPopup::new(&env),
do_quit: QuitState::None,
cmdbar: RefCell::new(CommandBar::new(
env.theme.clone(),
env.key_config.clone(),
)),
- help: HelpComponent::new(&env),
- msg: MsgComponent::new(&env),
+ help_popup: HelpPopup::new(&env),
+ msg_popup: MsgPopup::new(&env),
revlog: Revlog::new(&env),
status_tab: Status::new(&env),
stashing_tab: Stashing::new(&env),
@@ -345,21 +345,21 @@ impl App {
if matches!(polling_state, InputState::Paused) {
let result =
if let Some(path) = self.file_to_open.take() {
- ExternalEditorComponent::open_file_in_editor(
+ ExternalEditorPopup::open_file_in_editor(
&self.repo.borrow(),
Path::new(&path),
)
} else {
let changes =
self.status_tab.get_files_changes()?;
- self.commit.show_editor(changes)
+ self.commit_popup.show_editor(changes)
};
if let Err(e) = result {
let msg =
format!("failed to launch editor:\n{e}");
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);
@@ -375,7 +375,7 @@ impl App {
pub fn update(&mut self) -> Result<()> {
log::trace!("update");
- self.commit.update();
+ self.commit_popup.update();
self.status_tab.update()?;
self.revlog.update()?;
self.files_tab.update()?;
@@ -469,9 +469,9 @@ impl App {
[
log_search_popup,
fuzzy_find_popup,
- msg,
- reset,
- commit,
+ msg_popup,
+ confirm_popup,
+ commit_popup,
blame_file_popup,
file_revlog_popup,
stashmsg_popup,
@@ -491,7 +491,7 @@ impl App {
tags_popup,
reset_popup,
options_popup,
- help,
+ help_popup,
revlog,
status_tab,
files_tab,
@@ -503,9 +503,9 @@ impl App {
setup_popups!(
self,
[
- commit,
+ commit_popup,
stashmsg_popup,
- help,
+ help_popup,
inspect_commit_popup,
compare_commits_popup,
blame_file_popup,
@@ -526,8 +526,8 @@ impl App {
pull_popup,
fetch_popup,
options_popup,
- reset,
- msg
+ confirm_popup,
+ msg_popup
]
);
@@ -619,8 +619,8 @@ impl App {
}
fn update_commands(&mut self) {
- if self.help.is_visible() {
- self.help.set_cmds(self.commands(true));
+ if self.help_popup.is_visible() {
+ self.help_popup.set_cmds(self.commands(true));
}
self.cmdbar.borrow_mut().set_cmds(self.commands(false));
}
@@ -703,23 +703,23 @@ impl App {
self.process_confirmed_action(action, &mut flags)?;
}
InternalEvent::ConfirmAction(action) => {
- self.reset.open(action)?;
+ self.confirm_popup.open(action)?;
flags.insert(NeedsUpdate::COMMANDS);
}
InternalEvent::ShowErrorMsg(msg) => {
- self.msg.show_error(msg.as_str())?;
+ self.msg_popup.show_error(msg.as_str())?;
flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
}
InternalEvent::ShowInfoMsg(msg) => {
- self.msg.show_info(msg.as_str())?;
+ self.msg_popup.show_info(msg.as_str())?;
flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
}
InternalEvent::Update(u) => flags.insert(u),
- InternalEvent::OpenCommit => self.commit.show()?,
+ InternalEvent::OpenCommit => self.commit_popup.show()?,
InternalEvent::RewordCommit(id) => {
- self.commit.open(Some(id))?;
+ self.commit_popup.open(Some(id))?;
}
InternalEvent::PopupStashing(opts) => {
self.stashmsg_popup.options(opts);
diff --git a/src/components/mod.rs b/src/components/mod.rs
index ae29777a..7b2b5a7e 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -1,75 +1,30 @@
-mod blame_file;
-mod branchlist;
mod changes;
mod command;
-mod commit;
mod commit_details;
mod commitlist;
-mod compare_commits;
-mod create_branch;
mod cred;
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_popup;
-mod stashmsg;
mod status_tree;
-mod submodules;
mod syntax_text;
-mod tag_commit;
-mod taglist;
mod textinput;
mod utils;
pub use self::status_tree::StatusTreeComponent;
-pub use blame_file::{BlameFileComponent, BlameFileOpen};
-pub use branchlist::BranchListComponent;
pub use changes::ChangesComponent;
pub use command::{CommandInfo, CommandText};
-pub use commit::CommitComponent;
pub use commit_details::CommitDetailsComponent;
pub use commitlist::CommitList;
-pub use compare_commits::CompareCommitsComponent;
-pub use create_branch::CreateBranchComponent;
+pub use cred::CredComponent;
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_popup::{FileTreeOpen, RevisionFilesPopup};
-pub use stashmsg::StashMsgComponent;
-pub use submodules::SubmodulesListComponent;
pub use syntax_text::SyntaxTextComponent;
-pub use tag_commit::TagCommitComponent;
-pub use taglist::TagListComponent;
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 anyhow::Result;
@@ -78,7 +33,7 @@ use ratatui::{
backend::Backend,
layout::{Alignment, Rect},
text::{Span, Text},
- widgets::{Block, BorderType, Borders, Paragraph, Wrap},
+ widgets::{Block, Borders, Paragraph},
Frame,
};
@@ -312,30 +267,3 @@ fn dialog_paragraph<'a>(
)
.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
- }
-}
diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs
index 62c3f685..d8725619 100644
--- a/src/components/revision_files.rs
+++ b/src/components/revision_files.rs
@@ -1,11 +1,12 @@
use super::{
- utils::scroll_vertical::VerticalScroll, BlameFileOpen,
- CommandBlocking, CommandInfo, Component, DrawableComponent,
- EventState, FileRevOpen, FuzzyFinderTarget, SyntaxTextComponent,
+ utils::scroll_vertical::VerticalScroll, CommandBlocking,
+ CommandInfo, Component, DrawableComponent, EventState,
+ FuzzyFinderTarget, SyntaxTextComponent,
};
use crate::{
app::Environment,
keys::{key_match, SharedKeyConfig},
+ popups::{BlameFileOpen, FileRevOpen},
queue::{InternalEvent, Queue, StackablePopupOpen},
strings::{self, order, symbol},
try_or_popup,
diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs
index 5c8c3692..a3087de3 100644
--- a/src/components/status_tree.rs
+++ b/src/components/status_tree.rs
@@ -3,16 +3,16 @@ use super::{
filetree::{FileTreeItem, FileTreeItemKind},
statustree::{MoveSelection, StatusTree},
},
- BlameFileOpen, CommandBlocking, DrawableComponent, FileRevOpen,
+ CommandBlocking, DrawableComponent,
};
use crate::{
app::Environment,
components::{CommandInfo, Component, EventState},
keys::{key_match, SharedKeyConfig},
+ popups::{BlameFileOpen, FileRevOpen},
queue::{InternalEvent, NeedsUpdate, Queue, StackablePopupOpen},
strings::{self, order},
- ui,
- ui::style::SharedTheme,
+ ui::{self, style::SharedTheme},
};
use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
diff --git a/src/main.rs b/src/main.rs
index 6c5f2352..96c806d9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,6 +38,7 @@ mod keys;
mod notify_mutex;
mod options;
mod popup_stack;
+mod popups;
mod queue;
mod spinner;
mod string_utils;
diff --git a/src/components/blame_file.rs b/src/popups/blame_file.rs
index 435284d4..93773ef5 100644
--- a/src/components/blame_file.rs
+++ b/src/popups/blame_file.rs
@@ -1,12 +1,12 @@
-use super::{
- utils, visibility_blocking, CommandBlocking, CommandInfo,
- Component, DrawableComponent, EventState, FileRevOpen,
- InspectCommitOpen,
-};
use crate::{
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},
+ popups::{FileRevOpen, InspectCommitOpen},
queue::{InternalEvent, Queue, StackablePopupOpen},
string_utils::tabs_to_spaces,
strings,
@@ -84,7 +84,7 @@ pub struct BlameFileOpen {
pub selection: Option<usize>,
}
-pub struct BlameFileComponent {
+pub struct BlameFilePopup {
title: String,
theme: SharedTheme,
queue: Queue,
@@ -99,7 +99,7 @@ pub struct BlameFileComponent {
git_sender: Sender<AsyncGitNotification>,
repo: RepoPathRef,
}
-impl DrawableComponent for BlameFileComponent {
+impl DrawableComponent for BlameFilePopup {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
@@ -192,7 +192,7 @@ impl DrawableComponent for BlameFileComponent {
}
}
-impl Component for BlameFileComponent {
+impl Component for BlameFilePopup {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
@@ -329,7 +329,7 @@ impl Component for BlameFileComponent {
}
}
-impl BlameFileComponent {
+impl BlameFilePopup {
///
pub fn new(env: &Environment, title: &str) -> Self {
Self {
@@ -648,7 +648,7 @@ impl BlameFileComponent {
);
let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}");
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();
diff --git a/src/components/branchlist.rs b/src/popups/branchlist.rs
index 81ad9b98..0b2299d8 100644
--- a/src/components/branchlist.rs
+++ b/src/popups/branchlist.rs
@@ -1,7 +1,6 @@
-use super::{
- utils::scroll_vertical::VerticalScroll, visibility_blocking,
- CommandBlocking, CommandInfo, Component, DrawableComponent,
- EventState, FuzzyFinderTarget, InspectCommitOpen,
+use crate::components::{
+ visibility_blocking, CommandBlocking, CommandInfo, Component,
+ DrawableComponent, EventState, FuzzyFinderTarget, VerticalScroll,
};
use crate::{
app::Environment,
@@ -40,8 +39,10 @@ use std::cell::Cell;
use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr;
+use super::InspectCommitOpen;
+
///
-pub struct BranchListComponent {
+pub struct BranchListPopup {
repo: RepoPathRef,
branches: Vec<BranchInfo>,
local: bool,
@@ -55,7 +56,7 @@ pub struct BranchListComponent {
key_config: SharedKeyConfig,
}
-impl DrawableComponent for BranchListComponent {
+impl DrawableComponent for BranchListPopup {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
@@ -105,7 +106,7 @@ impl DrawableComponent for BranchListComponent {
}
}
-impl Component for BranchListComponent {
+impl Component for BranchListPopup {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
@@ -329,7 +330,7 @@ impl Component for BranchListComponent {
}
}
-impl BranchListComponent {
+impl BranchListPopup {
pub fn new(env: &Environment) -> Self {
Self {
branches: Vec::new(),
diff --git a/src/components/commit.rs b/src/popups/commit.rs
index b2824956..4bf4a07b 100644
--- a/src/components/commit.rs
+++ b/src/popups/commit.rs
@@ -1,7 +1,6 @@
-use super::{
- textinput::TextInputComponent, visibility_blocking,
- CommandBlocking, CommandInfo, Component, DrawableComponent,
- EventState, ExternalEditorComponent,
+use crate::components::{
+ visibility_blocking, CommandBlocking, CommandInfo, Component,
+ DrawableComponent, EventState, TextInputComponent,
};
use crate::{
app::Environment,
@@ -35,6 +34,8 @@ use std::{
str::FromStr,
};
+use super::ExternalEditorPopup;
+
enum CommitResult {
ComitDone,
Aborted,
@@ -48,7 +49,7 @@ enum Mode {
Reword(CommitId),
}
-pub struct CommitComponent {
+pub struct CommitPopup {
repo: RepoPathRef,
input: TextInputComponent,
mode: Mode,
@@ -64,7 +65,7 @@ pub struct CommitComponent {
const FIRST_LINE_LIMIT: usize = 50;
-impl CommitComponent {
+impl CommitPopup {
///
pub fn new(env: &Environment) -> Self {
Self {
@@ -183,7 +184,7 @@ impl CommitComponent {
}
}
- ExternalEditorComponent::open_file_in_editor(
+ ExternalEditorPopup::open_file_in_editor(
&self.repo.borrow(),
&file_path,
)?;
@@ -486,7 +487,7 @@ impl CommitComponent {
}
}
-impl DrawableComponent for CommitComponent {
+impl DrawableComponent for CommitPopup {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
@@ -502,7 +503,7 @@ impl DrawableComponent for CommitComponent {
}
}
-impl Component for CommitComponent {
+impl Component for CommitPopup {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
diff --git a/src/components/compare_commits.rs b/src/popups/compare_commits.rs
index 19de2539..31a164cb 100644
--- a/src/components/compare_commits.rs
+++ b/src/popups/compare_commits.rs
@@ -1,13 +1,14 @@
-use super::{
+use crate::components::{
command_pump, event_pump, visibility_blocking, CommandBlocking,
CommandInfo, CommitDetailsComponent, Component, DiffComponent,
- DrawableComponent, EventState, InspectCommitOpen,
+ DrawableComponent, EventState,
};
use crate::{
accessors,
app::Environment,
keys::{key_match, SharedKeyConfig},
options::SharedOptions,
+ popups::InspectCommitOpen,
queue::{InternalEvent, Queue, StackablePopupOpen},
strings,
};
@@ -25,7 +26,7 @@ use ratatui::{
Frame,
};
-pub struct CompareCommitsComponent {
+pub struct CompareCommitsPopup {
repo: RepoPathRef,
open_request: Option<InspectCommitOpen>,
diff: DiffComponent,
@@ -37,7 +38,7 @@ pub struct CompareCommitsComponent {
options: SharedOptions,
}
-impl DrawableComponent for CompareCommitsComponent {
+impl DrawableComponent for CompareCommitsPopup {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
@@ -71,7 +72,7 @@ impl DrawableComponent for CompareCommitsComponent {
}
}
-impl Component for CompareCommitsComponent {
+impl Component for CompareCommitsPopup {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
@@ -163,7 +164,7 @@ impl Component for CompareCommitsComponent {
}
}
-impl CompareCommitsComponent {
+impl CompareCommitsPopup {
accessors!(self, [diff, details]);
///
diff --git a/src/components/reset.rs b/src/popups/confirm.rs
index 51d4781a..acdd9021 100644
--- a/src/components/reset.rs
+++ b/src/popups/confirm.rs
@@ -1,8 +1,8 @@
use crate::{
app::Environment,
components::{
- popup_paragraph, visibility_blocking, CommandBlocking,
- CommandInfo, Component, DrawableComponent, EventState,
+ visibility_blocking, CommandBlocking, CommandInfo, Component,
+ DrawableComponent, EventState,
},
keys::{key_match, SharedKeyConfig},
queue::{Action, InternalEvent, Queue},
@@ -16,8 +16,10 @@ use ratatui::{
use std::borrow::Cow;
use ui::style::SharedTheme;
+use super::popup_paragraph;
+
///
-pub struct ConfirmComponent {
+pub struct ConfirmPopup {
target: Option<Action>,
visible: bool,
queue: Queue,
@@ -25,7 +27,7 @@ pub struct ConfirmComponent {
key_config: SharedKeyConfig,
}
-impl DrawableComponent for ConfirmComponent {
+impl DrawableComponent for ConfirmPopup {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
@@ -51,7 +53,7 @@ impl DrawableComponent for ConfirmComponent {
}
}
-impl Component for ConfirmComponent {
+impl Component for ConfirmPopup {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
@@ -102,7 +104,7 @@ impl Component for ConfirmComponent {
}
}
-impl ConfirmComponent {
+impl ConfirmPopup {
///