diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-15 20:21:45 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-15 20:21:45 +0800 |
| commit | 20dd9f182ec842a267fc48c72578c6169c121ccb (patch) | |
| tree | 57ff1690078f295581f3c54c3b0093048b1b5c42 /mingling/src/setups | |
| parent | 046ac064b6f4790f9053ad1e6109843bb38f89dd (diff) | |
refactor: rename Confirmer to ResConfirm and OSC94 to ResOSC94
Rename `Confirmer` resource to `ResConfirm`, `ConfirmerCount` to
`ConfirmCount`, and `ConfirmerPredicate` to `ConfirmPredicate`. Update
related setups, guards, and documentation references.
Diffstat (limited to 'mingling/src/setups')
| -rw-r--r-- | mingling/src/setups/confirm.rs (renamed from mingling/src/setups/confirmer.rs) | 22 | ||||
| -rw-r--r-- | mingling/src/setups/osc94.rs | 8 |
2 files changed, 15 insertions, 15 deletions
diff --git a/mingling/src/setups/confirmer.rs b/mingling/src/setups/confirm.rs index 1824745..6635420 100644 --- a/mingling/src/setups/confirmer.rs +++ b/mingling/src/setups/confirm.rs @@ -2,12 +2,12 @@ use mingling_core::{ Program, ProgramCollect, config, hook::ProgramHook, setup::ProgramSetup, this, }; -use crate::res::Confirmer; +use crate::res::ResConfirm; -/// Confirmer setup for managing confirmation state +/// Confirm setup for managing confirmation state /// /// This Setup manages the confirmation flag within the program's resource -/// store. It registers a [`Confirmer`] resource and sets up a hook that +/// store. It registers a [`ResConfirm`] resource and sets up a hook that /// checks the user's confirmation mode during program execution. /// /// # Usage @@ -19,18 +19,18 @@ use crate::res::Confirmer; /// ```rust /// # use mingling::MockProgramCollect as ThisProgram; /// use mingling::Program; -/// use mingling::setup::ConfirmerSetup; +/// use mingling::setup::ConfirmSetup; /// /// let mut program = Program::<ThisProgram>::new(); -/// program.with_setup(ConfirmerSetup); +/// program.with_setup(ConfirmSetup); /// ``` /// /// # Behavior /// -/// - Registers a [`Confirmer`] resource that tracks confirmation state. +/// - Registers a [`ResConfirm`] resource that tracks confirmation state. /// - At the beginning of command execution, checks whether the user's /// confirmation mode is set to `Skip`. -/// - If confirmation is skipped, the [`Confirmer`] resource is updated +/// - If confirmation is skipped, the [`Confirm`] resource is updated /// to record the confirmed state. /// /// # Notes @@ -38,20 +38,20 @@ use crate::res::Confirmer; /// - This Setup applies uniformly to all subcommands of the entire program. /// - The confirmation state is determined by the global `config` setting; /// it does not support per-command overrides. -pub struct ConfirmerSetup; +pub struct ConfirmSetup; -impl<C> ProgramSetup<C> for ConfirmerSetup +impl<C> ProgramSetup<C> for ConfirmSetup where C: ProgramCollect<Enum = C> + 'static, { fn setup(self, program: &mut Program<C>) { - program.with_resource(Confirmer::new()); + program.with_resource(ResConfirm::new()); program.with_hook(ProgramHook::empty().on_pre_dispatch::<_, ()>(|_| { let p = this::<C>(); let confirmed = p.user_context.confirmation == config::ConfirmationMode::Skip; if confirmed { - p.modify_res(|c: &mut Confirmer| { + p.modify_res(|c: &mut ResConfirm| { c.set_confirmed(); }); } diff --git a/mingling/src/setups/osc94.rs b/mingling/src/setups/osc94.rs index 548005a..b08312f 100644 --- a/mingling/src/setups/osc94.rs +++ b/mingling/src/setups/osc94.rs @@ -1,11 +1,11 @@ use mingling_core::{Program, ProgramCollect, setup::ProgramSetup}; -use crate::res::OSC94; +use crate::res::ResOSC94; /// `OSC 9;4` Setup for managing terminal progress notification state /// /// This Setup manages the terminal's `OSC 9;4` protocol support state within the -/// program's resource store. It registers an [`OSC94`] resource that tracks whether +/// program's resource store. It registers an [`ResOSC94`] resource that tracks whether /// the current terminal supports the protocol, and provides a helper resource that /// can be used to send progress notification messages. /// @@ -26,7 +26,7 @@ use crate::res::OSC94; /// /// # Behavior /// -/// - Registers an [`OSC94`] resource that tracks whether the current terminal +/// - Registers an [`ResOSC94`] resource that tracks whether the current terminal /// supports the `OSC 9;4` protocol. /// - The support check inspects various environment variables such as `TERM_PROGRAM`, /// `WT_SESSION`, `VTE_VERSION`, and `TERM`. @@ -42,7 +42,7 @@ where C: ProgramCollect<Enum = C> + 'static, { fn setup(self, program: &mut Program<C>) { - program.with_resource(OSC94 { + program.with_resource(ResOSC94 { is_support: is_support_osc94(), }); } |
