From ae55c05622273ed22e6ae56fd3a2ed706e253b25 Mon Sep 17 00:00:00 2001 From: "Carlos Miguel C. Resurreccion" Date: Fri, 19 Jun 2026 18:37:39 +0800 Subject: [PATCH] feat: label remaining time with 'rem' in ETD mode and widen column to fit --- src/localization/dutch.rs | 1 + src/localization/english.rs | 1 + src/localization/french.rs | 1 + src/localization/german.rs | 1 + src/localization/japanese.rs | 1 + src/localization/korean.rs | 1 + src/localization/mod.rs | 1 + src/localization/portuguese_brazil.rs | 1 + src/localization/russian.rs | 1 + src/localization/spanish.rs | 1 + src/localization/traditional_chinese.rs | 1 + src/poller.rs | 14 ++++++++++---- src/window.rs | 14 +++++++------- 13 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/localization/dutch.rs b/src/localization/dutch.rs index 112fb7b..7931b29 100644 --- a/src/localization/dutch.rs +++ b/src/localization/dutch.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex-gebruiksmonitor", show_etd: "Toon ETD", etd_suffix: "ETD", + rem: "rem", second_suffix: "s", }; diff --git a/src/localization/english.rs b/src/localization/english.rs index 99b232b..3290a05 100644 --- a/src/localization/english.rs +++ b/src/localization/english.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex Usage Monitor", show_etd: "Show ETD", etd_suffix: "ETD", + rem: "rem", second_suffix: "s", }; diff --git a/src/localization/french.rs b/src/localization/french.rs index 8b4a0a9..6592c4c 100644 --- a/src/localization/french.rs +++ b/src/localization/french.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Moniteur d'utilisation Codex", show_etd: "Afficher l'ETD", etd_suffix: "ETD", + rem: "rem", second_suffix: "s", }; diff --git a/src/localization/german.rs b/src/localization/german.rs index 7a7666f..179ebf2 100644 --- a/src/localization/german.rs +++ b/src/localization/german.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex-Nutzungsmonitor", show_etd: "ETD anzeigen", etd_suffix: "ETD", + rem: "rem", second_suffix: "s", }; diff --git a/src/localization/japanese.rs b/src/localization/japanese.rs index 960d0f2..9c1702b 100644 --- a/src/localization/japanese.rs +++ b/src/localization/japanese.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex 使用量モニター", show_etd: "ETD を表示", etd_suffix: "ETD", + rem: "rem", second_suffix: "秒", }; diff --git a/src/localization/korean.rs b/src/localization/korean.rs index 5f7b374..80f5608 100644 --- a/src/localization/korean.rs +++ b/src/localization/korean.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex 사용량 모니터", show_etd: "ETD 표시", etd_suffix: "ETD", + rem: "rem", second_suffix: "초", }; diff --git a/src/localization/mod.rs b/src/localization/mod.rs index 5f0a1f7..cb4d54d 100644 --- a/src/localization/mod.rs +++ b/src/localization/mod.rs @@ -179,6 +179,7 @@ pub struct Strings { pub codex_window_title: &'static str, pub show_etd: &'static str, pub etd_suffix: &'static str, + pub rem: &'static str, } pub fn resolve_language(language_override: Option) -> LanguageId { diff --git a/src/localization/portuguese_brazil.rs b/src/localization/portuguese_brazil.rs index 4a47489..c665d60 100644 --- a/src/localization/portuguese_brazil.rs +++ b/src/localization/portuguese_brazil.rs @@ -45,4 +45,5 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Monitor de uso do Codex", show_etd: "Mostrar ETD", etd_suffix: "ETD", + rem: "rem", }; diff --git a/src/localization/russian.rs b/src/localization/russian.rs index f26552d..8f31035 100644 --- a/src/localization/russian.rs +++ b/src/localization/russian.rs @@ -45,4 +45,5 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Монитор использования Codex", show_etd: "Показывать ETD", etd_suffix: "ETD", + rem: "rem", }; \ No newline at end of file diff --git a/src/localization/spanish.rs b/src/localization/spanish.rs index 8e1f4e9..0dbca7a 100644 --- a/src/localization/spanish.rs +++ b/src/localization/spanish.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Monitor de uso de Codex", show_etd: "Mostrar ETD", etd_suffix: "ETD", + rem: "rem", second_suffix: "s", }; diff --git a/src/localization/traditional_chinese.rs b/src/localization/traditional_chinese.rs index e976b00..84426a7 100644 --- a/src/localization/traditional_chinese.rs +++ b/src/localization/traditional_chinese.rs @@ -44,5 +44,6 @@ pub(super) const STRINGS: Strings = Strings { codex_window_title: "Codex 使用量監控", show_etd: "顯示 ETD", etd_suffix: "ETD", + rem: "rem", second_suffix: "秒", }; diff --git a/src/poller.rs b/src/poller.rs index a6c6bf4..e6017ce 100644 --- a/src/poller.rs +++ b/src/poller.rs @@ -1127,15 +1127,20 @@ fn etd_secs(actual_pct: f64, remaining_secs: u64, window_secs: u64) -> Option Option { let reset = section.resets_at?; let remaining_secs = reset.duration_since(SystemTime::now()).ok()?.as_secs(); let secs = etd_secs(section.percentage, remaining_secs, window_secs)?; let dur = format_countdown_from_secs(secs, strings); - Some(format!(" \u{00b7} {dur} {}", strings.etd_suffix)) + Some(format!( + " {} \u{00b7} {dur} {}", + strings.rem, strings.etd_suffix + )) } #[cfg(test)] @@ -1158,7 +1163,8 @@ mod tests { let out = etd_suffix(&s, 2 * 3600, LanguageId::English.strings()); let out = out.expect("expected a suffix when at risk"); assert!(out.contains("ETD"), "suffix was: {out}"); - assert!(out.starts_with(" \u{00b7} "), "suffix was: {out}"); + // Labels the preceding countdown with "rem", then the ETD segment. + assert!(out.starts_with(" rem \u{00b7} "), "suffix was: {out}"); } #[test] diff --git a/src/window.rs b/src/window.rs index 872a876..4eb0125 100644 --- a/src/window.rs +++ b/src/window.rs @@ -849,10 +849,10 @@ const LABEL_RIGHT_MARGIN: i32 = 10; const BAR_RIGHT_MARGIN: i32 = 4; const TEXT_WIDTH: i32 = 62; // fits the worst-case "100% · 59m" /// Text column when the ETD suffix is shown. The ETD form is worst-case -/// "100% · 59m · 59m ETD" — the base "100% · 59m" plus a roughly equal-length -/// " · 59m ETD" suffix — so the column is sized to twice the base to fit the -/// widest possible remaining-time and ETD without clipping. -const ETD_TEXT_WIDTH: i32 = TEXT_WIDTH * 2; +/// "100% · 59m rem · 59m ETD" — the base "100% · 59m" plus a " rem · 59m ETD" +/// label-and-estimate of similar length — so the column is sized to fit the +/// widest possible remaining-time and ETD (~2.6x the base) without clipping. +const ETD_TEXT_WIDTH: i32 = 160; const MODEL_RIGHT_MARGIN: i32 = 5; const RIGHT_MARGIN: i32 = 1; const WIDGET_HEIGHT: i32 = 46; @@ -2947,9 +2947,9 @@ mod tests { use super::*; #[test] - fn etd_text_column_is_twice_the_base() { - // Sized for the worst case "100% · 59m · 59m ETD" (~2x "100% · 59m"). - assert_eq!(ETD_TEXT_WIDTH, TEXT_WIDTH * 2); + fn etd_text_column_is_wider_than_base() { + // Sized for the worst case "100% · 59m rem · 59m ETD". + assert!(ETD_TEXT_WIDTH > TEXT_WIDTH); assert_eq!(text_width(false), TEXT_WIDTH); assert_eq!(text_width(true), ETD_TEXT_WIDTH); }