Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Make global quit event clause configurable
Erik Kundt committed 2 years ago
commit 2c4b947e2d676691c0309e71034167e428b9b8f7
parent 52417a2eff126855dc3235312a33cdabcbbda376
5 files changed +20 -7
modified bin/commands/issue/suite.rs
@@ -10,6 +10,7 @@ use anyhow::Result;
use radicle::cob::issue::IssueId;

use tuirealm::application::PollStrategy;
+
use tuirealm::event::Key;
use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause};

use radicle_tui as tui;
@@ -309,7 +310,7 @@ impl Tui<Cid, Message> for App {
        app.mount(
            Cid::GlobalListener,
            global,
-
            vec![Sub::new(subscription::global_clause(), SubClause::Always)],
+
            vec![Sub::new(subscription::quit_clause(Key::Char('q')), SubClause::Always)],
        )?;

        Ok(())
modified bin/commands/issue/suite/page.rs
@@ -4,6 +4,7 @@ use anyhow::Result;

use radicle::cob::issue::{Issue, IssueId};

+
use tuirealm::event::Key;
use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, State, StateValue, Sub, SubClause};

use radicle_tui as tui;
@@ -435,7 +436,10 @@ impl ViewPage<Cid, Message> for IssuePage {
                app.remount(Cid::Issue(IssueCid::Form), new_form, vec![])?;
                app.active(&Cid::Issue(IssueCid::Form))?;

-
                app.unsubscribe(&Cid::GlobalListener, subscription::global_clause())?;
+
                app.unsubscribe(
+
                    &Cid::GlobalListener,
+
                    subscription::quit_clause(Key::Char('q')),
+
                )?;

                return Ok(Some(Message::Issue(IssueMessage::Focus(IssueCid::Form))));
            }
@@ -447,7 +451,7 @@ impl ViewPage<Cid, Message> for IssuePage {

                app.subscribe(
                    &Cid::GlobalListener,
-
                    Sub::new(subscription::global_clause(), SubClause::Always),
+
                    Sub::new(subscription::quit_clause(Key::Char('q')), SubClause::Always),
                )?;

                if self.issue.is_none() {
modified bin/commands/patch/list.rs
@@ -12,6 +12,7 @@ use anyhow::Result;
use radicle::cob::patch::PatchId;

use tuirealm::application::PollStrategy;
+
use tuirealm::event::Key;
use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause};

use radicle_tui as tui;
@@ -194,7 +195,10 @@ impl Tui<Cid, Message> for App {
        app.mount(
            Cid::GlobalListener,
            global,
-
            vec![Sub::new(subscription::global_clause(), SubClause::Always)],
+
            vec![Sub::new(
+
                subscription::quit_clause(Key::Char('q')),
+
                SubClause::Always,
+
            )],
        )?;

        Ok(())
modified bin/commands/patch/suite.rs
@@ -12,6 +12,7 @@ use anyhow::Result;
use radicle::cob::patch::PatchId;

use tuirealm::application::PollStrategy;
+
use tuirealm::event::Key;
use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause};

use radicle_tui as tui;
@@ -240,7 +241,10 @@ impl Tui<Cid, Message> for App {
        app.mount(
            Cid::GlobalListener,
            global,
-
            vec![Sub::new(subscription::global_clause(), SubClause::Always)],
+
            vec![Sub::new(
+
                subscription::quit_clause(Key::Char('q')),
+
                SubClause::Always,
+
            )],
        )?;

        Ok(())
modified src/ui/subscription.rs
@@ -11,12 +11,12 @@ where
    })
}

-
pub fn global_clause<UserEvent>() -> SubEventClause<UserEvent>
+
pub fn quit_clause<UserEvent>(key: Key) -> SubEventClause<UserEvent>
where
    UserEvent: Clone + Eq + PartialEq + PartialOrd,
{
    SubEventClause::Keyboard(KeyEvent {
-
        code: Key::Char('q'),
+
        code: key,
        modifiers: KeyModifiers::NONE,
    })
}