mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 08:02:24 +00:00
fix(settings): show the pause a keybinding is waiting on
Recording a shortcut commits after a 650ms pause, and the hint asked people to time something they could not see: "pause to save · Esc", with no countdown behind it. A two-pixel bar under the hint now runs the same clock the commit does, and restarts with every extra chord — so a key sequence reads as one gesture with a visible deadline instead of a guess.
This commit is contained in:
+2
-2
@@ -67,7 +67,7 @@ const MAX_CLOSED_TABS: usize = 20;
|
||||
|
||||
const RESIZE_STEP: f32 = 0.05;
|
||||
|
||||
const RECORD_COMMIT_DELAY_MS: u64 = 650;
|
||||
pub(crate) const RECORD_COMMIT_DELAY_MS: u64 = 650;
|
||||
|
||||
pub(crate) const TITLE_BAR_HEIGHT: f32 = 40.;
|
||||
|
||||
@@ -380,7 +380,7 @@ pub struct Tty7App {
|
||||
pub(crate) maximized: Option<Entity<TerminalView>>,
|
||||
pub(crate) mod_hint_badges: bool,
|
||||
pub(crate) mod_hint_gen: u64,
|
||||
record_gen: u64,
|
||||
pub(crate) record_gen: u64,
|
||||
pub(crate) home_focus: gpui::FocusHandle,
|
||||
pub(crate) shells: ShellInventory,
|
||||
pub(crate) shells_host: HostId,
|
||||
|
||||
+33
-7
@@ -1,7 +1,7 @@
|
||||
use gpui::{
|
||||
AnyElement, App, Context, Div, Entity, FontWeight, Image, ImageFormat, KeyDownEvent,
|
||||
MouseButton, SharedString, Stateful, Subscription, Window, div, img, prelude::*, px, relative,
|
||||
rgb,
|
||||
Animation, AnimationExt as _, AnyElement, App, Context, Div, Entity, FontWeight, Image,
|
||||
ImageFormat, KeyDownEvent, MouseButton, SharedString, Stateful, Subscription, Window, div, img,
|
||||
prelude::*, px, relative, rgb,
|
||||
};
|
||||
use gpui_component::InteractiveElementExt as _;
|
||||
use gpui_component::button::{Button, ButtonVariants as _};
|
||||
@@ -4454,6 +4454,7 @@ impl Tty7App {
|
||||
.active_settings()
|
||||
.and_then(|s| s.recording.as_ref())
|
||||
.map(|r| (r.action.clone(), r.chords.clone()));
|
||||
let record_gen = self.record_gen;
|
||||
let note = self
|
||||
.active_settings()
|
||||
.and_then(|s| s.rebinding_note.clone());
|
||||
@@ -4558,11 +4559,36 @@ impl Tty7App {
|
||||
.child(t(L10nKey::SettingsPressKeys)),
|
||||
)
|
||||
} else {
|
||||
// The binding commits on a pause, and the pause was
|
||||
// invisible: the hint asked people to time something they
|
||||
// could not see. The bar runs the same clock the commit
|
||||
// does, and restarts with every extra chord.
|
||||
row.child(keycaps(&chords.join(" "))).child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(muted)
|
||||
.child(t(L10nKey::SettingsPauseToSaveEsc)),
|
||||
v_flex()
|
||||
.gap(px(3.))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(muted)
|
||||
.child(t(L10nKey::SettingsPauseToSaveEsc)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.h(px(2.))
|
||||
.w_full()
|
||||
.overflow_hidden()
|
||||
.rounded_full()
|
||||
.bg(border)
|
||||
.child(
|
||||
div().h_full().rounded_full().bg(accent).with_animation(
|
||||
("kb-record-countdown", record_gen as usize),
|
||||
Animation::new(std::time::Duration::from_millis(
|
||||
crate::ui::app::RECORD_COMMIT_DELAY_MS,
|
||||
)),
|
||||
|bar, delta| bar.w(relative(delta)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
};
|
||||
row.into_any_element()
|
||||
|
||||
Reference in New Issue
Block a user