diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 109437b..c5dc42c 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -51,6 +51,7 @@ jobs: # No --all: that would also format the vendored path dependencies. cargo fmt -- --check cargo clippy --workspace --locked --quiet --all-features --all-targets -- -D warnings + RUSTDOCFLAGS="-D warnings" \ cargo doc --workspace --locked --quiet --no-deps --document-private-items msrv: diff --git a/AGENTS.md b/AGENTS.md index 5b950a5..03ae1a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,11 +35,11 @@ cargo fmt # Run Code Quality CI checks locally cargo fmt -- --check cargo clippy --workspace --all-features -- -D warnings -cargo doc --workspace --no-deps --document-private-items +RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items ``` > [!TIP] -> Avoid running the full `cargo test` suite locally. The integration tests (`tests/docker_integration_tests.rs`) spawn Docker containers testing multiple versions of Bash, which is extremely slow. Prefer running `cargo test --lib` or testing specific packages. Before pushing, verify code quality with `cargo fmt -- --check`, `cargo clippy --workspace --all-features -- -D warnings`, and `cargo doc --workspace --no-deps --document-private-items`. +> Avoid running the full `cargo test` suite locally. The integration tests (`tests/docker_integration_tests.rs`) spawn Docker containers testing multiple versions of Bash, which is extremely slow. Prefer running `cargo test --lib` or testing specific packages. Before pushing, verify code quality with `cargo fmt -- --check`, `cargo clippy --workspace --all-features -- -D warnings`, and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items`. ## Guidelines 1. **Safety & Stability**: `flyline` runs inside the active shell process. Avoid unwinding panics across the C FFI boundary; wrap entry points in `catch_unwind_safe` to prevent shell crashes. Never create an `App` instance in library unit tests, as `App` depends on global FFI symbols (like `history_list` or `current_readline_prompt`) that are only resolved dynamically when loaded inside Bash, causing linker failures in library test targets. diff --git a/Cargo.lock b/Cargo.lock index b0a6a4b..9bbeb3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,17 +303,16 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "compact_str" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" +checksum = "79fcda08c33bb58b97008b2cdada6622500e949e060f5913361763121abd2416" dependencies = [ "castaway", "cfg-if", "itoa", - "rustversion", - "ryu", "serde", "static_assertions", + "zmij", ] [[package]] @@ -463,12 +462,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" -[[package]] -name = "deranged" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" - [[package]] name = "derive_more" version = "2.1.1" @@ -519,7 +512,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -567,7 +560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -640,7 +633,7 @@ name = "flybuffer" version = "0.1.0" dependencies = [ "anyhow", - "itertools 0.15.0", + "itertools", "log", "serde", "unicode-segmentation", @@ -673,7 +666,7 @@ dependencies = [ "clap", "clap_complete", "easing-function", - "itertools 0.15.0", + "itertools", "lscolors", "parse-style", "pulldown-cmark", @@ -703,7 +696,7 @@ dependencies = [ "flybuffer", "flycomp", "flycontent", - "itertools 0.15.0", + "itertools", "libc", "log", "lscolors", @@ -889,7 +882,7 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82cb6a9f675da968c63b6208c641b9dca58fc0133ae53375736b1767b0cab8bd" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -898,15 +891,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.15.0" @@ -922,6 +906,58 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" +[[package]] +name = "jiff" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e77cbfb9fff4798e283c2d69dff39fc2c45e7da017e5ce95b654e46ea41236" +dependencies = [ + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-link", +] + +[[package]] +name = "jiff-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9067a0b23e5be3147d56b2dcf652b18e6b1364caca93fb157653b6fbcab23a9" +dependencies = [ + "jiff-core", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "jiff-tzdb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" + +[[package]] +name = "jiff-tzdb-platform" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "js-sys" version = "0.3.107" @@ -1030,9 +1066,9 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "lru" -version = "0.18.5" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5" +checksum = "83be4da409554841af087163ad187608824ad8ca8713d8e124c8e0f704a2f92f" dependencies = [ "hashbrown", ] @@ -1177,15 +1213,9 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] -[[package]] -name = "num-conv" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" - [[package]] name = "num-derive" version = "0.4.2" @@ -1206,15 +1236,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_threads" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4" -dependencies = [ - "libc", -] - [[package]] name = "numtoa" version = "0.2.4" @@ -1488,10 +1509,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" [[package]] -name = "powerfmt" -version = "0.2.1" +name = "portable-atomic-util" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] [[package]] name = "proc-macro2" @@ -1588,6 +1612,7 @@ version = "0.30.2" dependencies = [ "instability", "log", + "ratatui-calendar", "ratatui-core", "ratatui-crossterm", "ratatui-macros", @@ -1598,6 +1623,16 @@ dependencies = [ "serde", ] +[[package]] +name = "ratatui-calendar" +version = "0.1.0" +dependencies = [ + "hashbrown", + "jiff", + "ratatui-core", + "ratatui-widgets", +] + [[package]] name = "ratatui-core" version = "0.1.2" @@ -1605,7 +1640,7 @@ dependencies = [ "bitflags 2.13.2", "compact_str", "hashbrown", - "itertools 0.14.0", + "itertools", "kasuari", "log", "lru", @@ -1669,15 +1704,13 @@ name = "ratatui-widgets" version = "0.3.2" dependencies = [ "bitflags 2.13.2", - "hashbrown", "indoc", "instability", - "itertools 0.14.0", + "itertools", "line-clipping", "ratatui-core", "serde", "strum", - "time", "unicode-segmentation", "unicode-width", ] @@ -1797,7 +1830,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1818,12 +1851,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "ryu" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" - [[package]] name = "scopeguard" version = "1.2.0" @@ -2057,7 +2084,7 @@ dependencies = [ "getrandom 0.4.3", "once_cell", "rustix 1.1.6", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2195,27 +2222,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "time" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" -dependencies = [ - "deranged", - "libc", - "num-conv", - "num_threads", - "powerfmt", - "serde_core", - "time-core", -] - -[[package]] -name = "time-core" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" - [[package]] name = "tui-scrollbar" version = "0.2.8" @@ -2258,11 +2264,11 @@ checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-truncate" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" +checksum = "f5dde200aa133f5b6d9cc616878815ffaa45ad9529ef4a2f04d86bab91d63984" dependencies = [ - "itertools 0.14.0", + "itertools", "unicode-segmentation", "unicode-width", ] diff --git a/crates/flycontent/src/utils.rs b/crates/flycontent/src/utils.rs index f2fa975..97fe2a8 100644 --- a/crates/flycontent/src/utils.rs +++ b/crates/flycontent/src/utils.rs @@ -393,7 +393,7 @@ pub fn highlight_matching_indices( normal_lines } -/// Format a [`Duration`] as a compact, exactly-5-character string. +/// Format a [`Duration`](std::time::Duration) as a compact, exactly-5-character string. /// /// The output always occupies exactly 5 terminal columns so it can be used /// as a fixed-width column in the history list UI. diff --git a/src/active_suggestions.rs b/src/active_suggestions.rs index 13132d8..10e0639 100644 --- a/src/active_suggestions.rs +++ b/src/active_suggestions.rs @@ -1426,7 +1426,7 @@ impl Ord for ProcessedSuggestion { } /// Raw completion from bash plus the metadata needed to post-process it into -/// a [`ProcessedSuggestion`] via [`into_processed`]. +/// a [`ProcessedSuggestion`] via [`UnprocessedSuggestion::into_processed`]. /// /// The expensive filesystem calls (`is_dir`, `style_for_path`, /// `fully_expand_path`) only happen when this is converted to a @@ -1680,7 +1680,7 @@ const CHUNK_PROCESSING_TIMEOUT: std::time::Duration = std::time::Duration::from_ /// (env vars, tilde expansion, flyline's own clap completions, ...) are never /// re-wrapped, while raw bash completions stay queued in `unprocessed` and /// are converted lazily. `auto_accept_if_solo` controls whether -/// [`ActiveSuggestions::try_accept`] will silently accept the candidate when +/// `apply_tab_complete_to_buffer` will silently accept the candidate when /// there is only one of them (set to `false` for fuzzy filename matching, where /// the user generally wants to see and confirm the match). #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] @@ -1713,7 +1713,7 @@ impl ActiveSuggestionsBuilder { } } - /// Override [`auto_accept_if_solo`]. Set to `false` for fuzzy filename + /// Override [`Self::auto_accept_if_solo`]. Set to `false` for fuzzy filename /// matching, where the user should confirm the match even when only a /// single candidate survives the fuzzy scoring. pub fn with_auto_accept_if_solo(mut self, auto_accept_if_solo: bool) -> Self { @@ -1860,7 +1860,7 @@ pub struct ColumnInfo { #[derive(Debug)] pub struct ActiveSuggestions { /// Raw completions waiting to be post-processed. Drained from the front - /// in chunks each time [`into_grid`] is called or fuzzy matching runs. + /// in chunks each time [`Self::into_grid`] is called or fuzzy matching runs. unprocessed_suggestions: VecDeque, /// Fully post-processed suggestions. This is the only collection used by /// fuzzy matching, rendering, and acceptance logic. @@ -1873,7 +1873,7 @@ pub struct ActiveSuggestions { pub original_word_under_cursor: SubString, pub word_under_cursor: SubString, /// Number of suggestion rows per column as used in the last rendered - /// grid. Kept in sync by [`update_grid_size`]. + /// grid. Kept in sync by [`Self::into_grid`]. last_num_rows_per_col: usize, /// Number of columns that were actually visible in the last rendered /// grid. Used to compute the scroll offset. diff --git a/src/app/actions/keyboard.rs b/src/app/actions/keyboard.rs index 32ce965..63c015f 100644 --- a/src/app/actions/keyboard.rs +++ b/src/app/actions/keyboard.rs @@ -1156,9 +1156,9 @@ impl From for KeyEventMatch { } } -/// Add a set of [`KeyModifiers`] to a [`KeyEventMatch`], OR-ing them into the +/// Add a set of [`KeyModifiers`] to a `KeyEventMatch`, OR-ing them into the /// match's existing modifier set. Combined with [`From`] for -/// [`KeyEventMatch`], this lets binding definitions read like keyboard +/// `KeyEventMatch`, this lets binding definitions read like keyboard /// chords: /// /// ```ignore @@ -1168,7 +1168,7 @@ impl From for KeyEventMatch { /// /// Direct `KeyModifiers + KeyCode` is not supported because both types are /// foreign to this crate (orphan rule); convert one side to -/// [`KeyEventMatch`] first. For "any char" matches with modifiers, write +/// `KeyEventMatch` first. For "any char" matches with modifiers, write /// `KeyEventMatch::AnyCharAndMods(KeyModifiers::SHIFT)` directly. impl Add for KeyModifiers { type Output = KeyEventMatch; @@ -1917,7 +1917,7 @@ pub fn expand_variations_one(kem: KeyEventMatch) -> Vec { /// /// # Example /// -/// ```ignore +/// ```text /// // expand_variations![KeyCode::Enter.into()] → [Enter, Ctrl+j] /// // expand_variations![KeyModifiers::ALT + KeyCode::Enter.into()] /// // → [Alt+Enter, Meta+Enter] @@ -2212,7 +2212,7 @@ fn capitalize_first(s: &str) -> String { } } -/// MacOs: https://stackoverflow.com/questions/12827888/what-is-the-representation-of-the-mac-command-key-in-the-terminal +/// MacOs: /// MacOs command keyboard shortcuts are not sent to terminal apps by default. /// They are often captured by the terminal emulator itself for various commands /// Try `ghostty +list-keybinds --default` on ghostty. Most @@ -2221,7 +2221,7 @@ fn capitalize_first(s: &str) -> String { /// SUPER: Windows key or Mac Command key /// HYPER: Often as as result of pressing Ctrl + Shift + Alt + Windows/Command key. rarely used. /// -/// https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts#Command_line_shortcuts +/// /// /// Meta vs Alt: /// On iterm2, there is a setting in Profiles->Keys->Left option key. diff --git a/src/app/actions/mouse.rs b/src/app/actions/mouse.rs index 618ab9b..55d78bd 100644 --- a/src/app/actions/mouse.rs +++ b/src/app/actions/mouse.rs @@ -909,7 +909,7 @@ impl MouseEventAction { if let Err(e) = crate::flush_stdout!( "{}{}", Csi::Edit(Edit::EraseInDisplay(EraseInDisplay::EraseDisplay)), - Csi::Cursor(Cursor::goto(0, 0)) + Csi::Cursor(Cursor::default_position()) ) { log::warn!("Failed to clear terminal: {}", e); } diff --git a/src/cli.rs b/src/cli.rs index 9dc2096..2b5b0ee 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,3 +1,11 @@ +// The doc comments in this module are clap's `--help` text, which README.md mirrors, so they +// use placeholders like and bare URLs rather than rustdoc markup. +#![allow( + rustdoc::bare_urls, + rustdoc::broken_intra_doc_links, + rustdoc::invalid_html_tags +)] + #[cfg(not(test))] macro_rules! return_usage_error { ($($arg:tt)*) => {{ @@ -1535,7 +1543,7 @@ pub(crate) fn call(words: *const bash_symbols::WordList) -> c_int { if let Err(e) = crate::flush_stdout!( "{}{}", Csi::Edit(Edit::EraseInDisplay(EraseInDisplay::EraseDisplay)), - Csi::Cursor(Cursor::goto(0, 0)) + Csi::Cursor(Cursor::default_position()) ) { log::warn!("Failed to clear terminal: {}", e); } diff --git a/src/completions/flags.rs b/src/completions/flags.rs index 4a3f556..2860134 100644 --- a/src/completions/flags.rs +++ b/src/completions/flags.rs @@ -163,7 +163,7 @@ fn should_infer_filename_completion(completions: &[String], flags: &CompletionFl /// Some completion scripts like gh or docker put descriptions inline with /// the suggestion when there are multiple suggestions. -/// So here I convert those to the format "suggestiondescription" so that +/// So here I convert those to the format `"suggestiondescription"` so that /// flyline can show the description in a separate column. pub fn detect_and_convert_inline_descriptions(completions: &mut [String], flags: &CompletionFlags) { if flags.filename_completion_desired || completions.iter().any(|s| s.contains('\t')) { diff --git a/src/completions/tab_completion.rs b/src/completions/tab_completion.rs index 198d921..114a82b 100644 --- a/src/completions/tab_completion.rs +++ b/src/completions/tab_completion.rs @@ -985,7 +985,7 @@ fn tab_complete_tilde_expansion(pattern: &str) -> Vec { suggestions } -/// Outcome of applying tab-completion results directly to a [`TextBuffer`]. +/// Outcome of applying tab-completion results directly to a [`TextBuffer`](flybuffer::TextBuffer). /// /// This is the buffer-mutation half of `finish_tab_complete` factored out so /// it can be exercised from unit tests without constructing a full `App`. diff --git a/src/prompt_manager.rs b/src/prompt_manager.rs index 0e90e97..7e31e9e 100644 --- a/src/prompt_manager.rs +++ b/src/prompt_manager.rs @@ -258,11 +258,11 @@ struct PromptStringBuilder<'a> { /// Used during `expand_prompt_string` to recognise which spans contain /// time placeholders and convert them into [`PromptSegment::DynamicTime`]. time_map: HashMap, - /// Pre-processed animations. Used by [`expand_span_to_segments`] to + /// Pre-processed animations. Used by [`PromptStringBuilder::expand_span_to_segments`] to /// recognise animation-name placeholders and produce /// [`PromptSegment::Animation`] segments in the same pass. animations: Vec, - /// Raw prompt widget definitions. Used by [`expand_span_to_segments`] to + /// Raw prompt widget definitions. Used by [`PromptStringBuilder::expand_span_to_segments`] to /// recognise widget-name placeholders and produce the appropriate /// `PromptSegment::Widget*` segments. Each occurrence of a widget name in /// the prompt text produces a fully independent segment (and, for custom @@ -405,12 +405,12 @@ impl<'a> PromptStringBuilder<'a> { /// [`PromptSegment`]s. /// /// The pipeline is: - /// 1. [`extract_time_codes`] — replace bash time escape sequences with + /// 1. [`PromptStringBuilder::extract_time_codes`] — replace bash time escape sequences with /// unique placeholders, recording the mapping in `self.time_map`. /// 2. [`expand_prompt_through_bash`] — run the modified string through /// bash's `decode_prompt_string` and parse ANSI colour codes into /// `Line<'static>` values. - /// 3. [`expand_span_to_segments`] — split each decoded span at + /// 3. [`PromptStringBuilder::expand_span_to_segments`] — split each decoded span at /// time-placeholder boundaries, producing `Static` or `DynamicTime` /// segments. /// @@ -977,7 +977,7 @@ fn split_into_spans(path: &str, style: ratatui::style::Style, result: &mut Vec Vec> { stdout_to_tagged_spans_with_tag(stdout, Tag::Prompt) } @@ -1254,7 +1254,7 @@ fn spawn_widget_child(command: &[String]) -> Result = parking_lot::ReentrantMutex::new(()); -/// Reset [`BASH_LOCK`] in a forked child so it is not left held. +/// Reset `BASH_LOCK` in a forked child so it is not left held. /// /// # Safety /// /// Call only in the child, immediately after `fork`, before any other code in -/// this process observes [`BASH_LOCK`]. The parent may have held the lock at +/// this process observes `BASH_LOCK`. The parent may have held the lock at /// fork time; this force-unlocks it so the child does not deadlock. pub unsafe fn reset_bash_lock_after_fork() { while BASH_LOCK.is_locked() { @@ -467,7 +467,7 @@ pub unsafe fn reset_bash_lock_after_fork() { } } -/// Allocate via Bash `xmalloc` while holding [`BASH_LOCK`]. +/// Allocate via Bash `xmalloc` while holding `BASH_LOCK`. /// /// # Safety /// @@ -479,7 +479,7 @@ pub unsafe fn locked_xmalloc(size: libc::size_t) -> *mut libc::c_void { unsafe { xmalloc(size) } } -/// Free via Bash `xfree` while holding [`BASH_LOCK`]. +/// Free via Bash `xfree` while holding `BASH_LOCK`. /// /// # Safety /// diff --git a/src/shell_integration.rs b/src/shell_integration.rs index 42b4e71..be126c2 100644 --- a/src/shell_integration.rs +++ b/src/shell_integration.rs @@ -2,9 +2,9 @@ use crate::content::RelativePosition; use crate::shell; use crate::term_info; -/// https://code.visualstudio.com/docs/terminal/shell-integration#_supported-escape-sequences -/// https://sw.kovidgoyal.net/kitty/shell-integration/ -/// https://ghostty.org/docs/features/shell-integration#troubleshooting +/// +/// +/// /// Ghostty right click -> Terminal inspector -> Terminal IO -> Filter for osc /// And you click on the event to see more details. diff --git a/vendor/README.md b/vendor/README.md index d0974af..51abb5f 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -6,8 +6,8 @@ update them itself. | Directory | Upstream | Base commit | flyline's changes | |---|---|---|---| -| `ratatui/` | [ratatui/ratatui](https://github.com/ratatui/ratatui) `main` | `e665c36cb1` (241 commits behind; see below) | Inline viewport: resizable, no cursor-position query, absolute positions for mouse events, synchronized output, autowrap off, erase-instead-of-space for reflow, wide-character cursor tracking, no redraw sequences when nothing changed (HalFrgrd/ratatui `inline_viewport_improvments`, 30 commits) | -| `termina/` | [helix-editor/termina](https://github.com/helix-editor/termina) `master` | `7be7389f` (v0.4.0) | SGR mouse reports, text pixel size and OSC 52 responses, a long-lived event reader that keeps unread stdin, Ghostty DA2 deadlock fix, raw device attributes, kitty base-layout key (HalFrgrd/termina, 13 commits; two are upstream PRs #31 and #32) | +| `ratatui/` | [ratatui/ratatui](https://github.com/ratatui/ratatui) `main` | `5a28bec1` | An inline viewport positioned relative to its top row: cursor tracked in memory and never queried, resizable height, `viewport_top` for mapping mouse rows, synchronized output, autowrap off while drawing, erase instead of spaces, cells hidden behind wide glyphs skipped, no redundant cursor show/hide (HalFrgrd/ratatui `inline_viewport_improvments`, merged with upstream; see below) | +| `termina/` | [helix-editor/termina](https://github.com/helix-editor/termina) `master` | `7be7389f` (v0.4.0) | Raw device-attribute responses and no parser deadlock on DA2/DA3 or unhandled CSI (upstream PR #32), OSC 52 replies as `Paste`, the kitty base-layout key, `PlatformTerminal::with_reader` (upstream PR #31), an event buffer that keeps arrival order, and `TCSANOW` so typed-ahead input survives entering raw mode | | `skim/` | [skim-rs/skim](https://github.com/skim-rs/skim) `master` | `2160abbd` (5.9.0) | A `tui` feature, so `default-features = false, features = ["algos_only"]` builds only the matchers, without the TUI and runtime stack (HalFrgrd/skim, 1 commit) | Each directory is a `git subtree --squash`. It holds upstream's tree at the @@ -33,15 +33,22 @@ git subtree pull --prefix vendor/ratatui https://github.com/ratatui/ratatui.git 2. Run `cargo update -w`, then the checks in AGENTS.md and the Docker bash integration tests. 3. Update the base commit in the table above. -## ratatui is behind upstream +## How ratatui differs from upstream -Upstream has since rewritten the same inline-viewport code: `set_viewport_height` -(#1964), horizontal-shrink fixes (#2670, #2731), cursor fixes (#2694, #2752, -#2807), and scrolling regions split into their own trait (#2121, breaking). A -`git subtree pull` conflicts in 19 files (43 hunks), mostly in -`ratatui-core/src/terminal/`. Merge it on its own branch, adopting upstream's -inline resizing where it covers flyline's needs. Then test resizing, wide -characters, mouse positions and the bash integration suite before it ships. +Upstream positions an inline viewport in absolute screen coordinates and asks +the terminal for the cursor position. flyline's fork tracks the cursor relative +to the viewport's top row and never queries it, which avoids racing bash for +the terminal's replies. Where upstream rewrote the same code, the fork's +behaviour stays: + +- `set_viewport_height`, inline resize and inline `clear` keep the fork's + versions. Upstream's `Terminal::with_cursor_position` and `insert_before` + are not included, since both need absolute coordinates. +- `backend_mut()` does not reset the tracked cursor visibility. flyline calls it + every frame, and re-showing the cursor each frame restarts its blink. + +When pulling upstream again, expect conflicts in `ratatui-core/src/terminal/` +and in the backends' `draw` functions, and resolve them the same way. ## Change a fork diff --git a/vendor/ratatui/deny.toml b/vendor/ratatui/.config/deny.toml similarity index 81% rename from vendor/ratatui/deny.toml rename to vendor/ratatui/.config/deny.toml index e75843c..a062903 100644 --- a/vendor/ratatui/deny.toml +++ b/vendor/ratatui/.config/deny.toml @@ -29,6 +29,10 @@ license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] [advisories] version = 2 +ignore = [ + # chrono is only a dev dependency for ratatui-calendar's interoperability example. + { id = "RUSTSEC-2026-0543", reason = "Used only by a dev-only compatibility example; downstream users do not compile it." }, +] [bans] multiple-versions = "allow" diff --git a/vendor/ratatui/.github/workflows/check-dependencies.yml b/vendor/ratatui/.github/workflows/check-dependencies.yml new file mode 100644 index 0000000..47b3788 --- /dev/null +++ b/vendor/ratatui/.github/workflows/check-dependencies.yml @@ -0,0 +1,48 @@ +name: Check Dependencies + +# Checks dependencies with cargo-deny on PRs that change them. These results can only change with +# the files below, so other PRs skip this workflow. Advisories published at other times are handled +# by the daily checks, so unrelated PRs don't fail because of them. +# +# This must not be a required check or part of the `required` job in ci.yml: a required check from a +# path-filtered workflow stays pending on PRs that don't touch these paths. A failure here is visible +# but doesn't block merging, so a maintainer can still merge when an advisory has no fix yet. +on: + pull_request: + branches: + - main + paths: + - .github/workflows/check-dependencies.yml + - Cargo.lock + - "**/Cargo.toml" + - .config/deny.toml + +permissions: {} + +# Only the latest run for a PR matters, so subsequent pushes cancel the previous run. +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + # Check for any disallowed dependencies in the codebase due to license / security issues. + # See + cargo-deny: + name: Check ${{ matrix.checks }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + checks: + - advisories + - bans licenses sources + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2 + with: + rust-version: stable + log-level: info + arguments: --all-features --exclude-unpublished --config .config/deny.toml + command: check ${{ matrix.checks }} diff --git a/vendor/ratatui/.github/workflows/check-pr.yml b/vendor/ratatui/.github/workflows/check-pr.yml index 94fc392..e8ee82c 100644 --- a/vendor/ratatui/.github/workflows/check-pr.yml +++ b/vendor/ratatui/.github/workflows/check-pr.yml @@ -24,12 +24,12 @@ jobs: steps: - name: Check PR title if: github.event_name == 'pull_request_target' - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v5 + uses: amannn/action-semantic-pull-request@2252a14e810aa9b85c2d560bd7070c802206ecf6 # v5 id: check_pr_title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Add comment indicating we require pull request titles to follow conventional commits specification - - uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4 + - uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 if: always() && (steps.check_pr_title.outputs.error_message != null) with: header: pr-title-lint-error @@ -44,7 +44,7 @@ jobs: # Delete a previous comment when the issue has been resolved - if: ${{ steps.check_pr_title.outputs.error_message == null }} - uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4 + uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 with: header: pr-title-lint-error delete: true @@ -70,7 +70,7 @@ jobs: fi - name: Add label if: steps.check_breaking_change.outputs.breaking_change == 'true' - uses: actions/github-script@v8 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/vendor/ratatui/.github/workflows/check-semver.yml b/vendor/ratatui/.github/workflows/check-semver.yml index c1bb718..22bf099 100644 --- a/vendor/ratatui/.github/workflows/check-semver.yml +++ b/vendor/ratatui/.github/workflows/check-semver.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Check semver diff --git a/vendor/ratatui/.github/workflows/ci.yml b/vendor/ratatui/.github/workflows/ci.yml index a50b029..3ebd406 100644 --- a/vendor/ratatui/.github/workflows/ci.yml +++ b/vendor/ratatui/.github/workflows/ci.yml @@ -29,15 +29,15 @@ jobs: name: Check Formatting runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: nightly components: rustfmt - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 - - uses: tombi-toml/setup-tombi@af12994358821d8b3dc91a00288a9360606e545d # v1.1.3 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + - uses: tombi-toml/setup-tombi@8ddc6b91b6fa3ad0ce192a68b409930851e4886c # v1.11.2 with: version: "0.9.19" - run: cargo xtask format --check @@ -48,32 +48,10 @@ jobs: name: Check Typos runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: crate-ci/typos@37bb98842b0d8c4ffebdb75301a13db0267cef89 # master - - # Check for any disallowed dependencies in the codebase due to license / security issues. - # See - cargo-deny: - runs-on: ubuntu-latest - strategy: - matrix: - checks: - - advisories - - bans licenses sources - # Prevent sudden announcement of a new advisory from failing ci: - continue-on-error: ${{ matrix.checks == 'advisories' }} - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe # v2 - with: - rust-version: stable - log-level: info - arguments: --all-features --exclude-unpublished - command: check ${{ matrix.checks }} + - uses: crate-ci/typos@276087d9a4f06398b3e04825487805e2d7375888 # v1.52.2 # Check for any unused dependencies in the codebase. # See @@ -81,7 +59,7 @@ jobs: name: Check Unused Dependencies runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: bnjbvr/cargo-machete@ac30a525c0a8d163a92d727b3ff079ee3f6ecb08 # v0.9.2 @@ -91,54 +69,46 @@ jobs: cargo-udeps: name: Check Unused Dependencies runs-on: ubuntu-latest + # cargo-udeps requires nightly; pin it so nightly lint changes do not break CI unexpectedly. + env: + RATATUI_NIGHTLY_TOOLCHAIN: nightly-2026-07-14 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: - toolchain: nightly - - uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8 + toolchain: ${{ env.RATATUI_NIGHTLY_TOOLCHAIN }} + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-udeps - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - run: cargo xtask udeps # Run cargo clippy. - # - # We check for clippy warnings on beta, but these are not hard failures. They should often be - # fixed to prevent clippy failing on the next stable release, but don't block PRs on them unless - # they are introduced by the PR. lint-clippy: name: Check Clippy runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - toolchain: ["stable", "beta"] - continue-on-error: ${{ matrix.toolchain == 'beta' }} steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: - toolchain: ${{ matrix.toolchain }} + toolchain: stable components: clippy - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask clippy - env: - RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }} # Run markdownlint on all markdown files in the repository. lint-markdown: name: Check Markdown runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: DavidAnson/markdownlint-cli2-action@ded1f9488f68a970bc66ea5619e13e9b52e601cd # v21 + - uses: DavidAnson/markdownlint-cli2-action@696eb3f2509270d7b882d2aa68347bc676e7af34 # v25.0.0 with: globs: | '**/*.md' @@ -150,19 +120,19 @@ jobs: name: Coverage Report runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable components: llvm-tools - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-llvm-cov - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask coverage - - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v5 + - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true @@ -177,32 +147,49 @@ jobs: toolchain: ["1.88.0", "stable"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: ${{ matrix.toolchain }} - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-hack - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask check --all-features env: RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }} + # Check that dependency lower bounds are accurate. + minimal-versions: + name: Check Minimal Versions + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 + with: + toolchain: stable + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 + with: + tool: cargo-minimal-versions,cargo-hack + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 + - run: cargo minimal-versions check --direct --workspace --all-features --all-targets + build-no-std: name: Build No-Std runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - targets: x86_64-unknown-none - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + targets: x86_64-unknown-none, thumbv6m-none-eabi + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 # This makes it easier to debug the exact versions of the dependencies - run: cargo tree --target x86_64-unknown-none -p ratatui-core - run: cargo tree --target x86_64-unknown-none -p ratatui-widgets @@ -212,19 +199,29 @@ jobs: - run: cargo build --target x86_64-unknown-none -p ratatui-widgets - run: cargo build --target x86_64-unknown-none -p ratatui-macros - run: cargo build --target x86_64-unknown-none -p ratatui --no-default-features + # Regression check for targets without native atomic pointers (e.g. thumbv6m-none-eabi). + # x86_64-unknown-none still has atomics, so it does not exercise the portable-atomic path. + # The single-core cfg stands in for a critical-section implementation at check time. + - run: cargo check --target thumbv6m-none-eabi -p ratatui-widgets --features portable-atomic + env: + RUSTFLAGS: --cfg portable_atomic_unsafe_assume_single_core + - run: cargo check --target thumbv6m-none-eabi -p ratatui --no-default-features --features portable-atomic + env: + RUSTFLAGS: --cfg portable_atomic_unsafe_assume_single_core # Check if README.md is up-to-date with the crate's documentation. check-readme: name: Check README runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-rdme + - run: cargo rdme install-rust-toolchain-for-intralinks - run: cargo xtask readme --check # Run cargo rustdoc with the same options that would be used by docs.rs, taking into account the @@ -235,19 +232,19 @@ jobs: env: RUSTDOCFLAGS: -Dwarnings steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: nightly - uses: dtolnay/install@74f735cdf643820234e37ae1c4089a08fd266d8a # master with: crate: cargo-docs-rs - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-hack - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask docs # Run cargo test on the documentation of the crate. This will catch any code examples that don't @@ -256,37 +253,38 @@ jobs: name: Test Docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-hack - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask test-docs # Run cargo test on the libraries of the crate. + # + # Test the libraries on stable only. `ratatui-macros` uses trybuild snapshots that intentionally + # assert complete rustc diagnostics, including toolchain-specific details. The `check` matrix + # verifies MSRV compatibility; this job verifies the full test suite on the toolchain contributors + # use. test-libs: - name: Test Libs ${{ matrix.toolchain }} + name: Test Libs runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - toolchain: ["1.88.0", "stable"] steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2 + - uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3 with: tool: cargo-hack - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask test-libs # Run cargo test on all the backends. @@ -303,13 +301,13 @@ jobs: - os: windows-latest backend: termion steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - run: cargo xtask test-backend ${{ matrix.backend }} required: @@ -317,13 +315,13 @@ jobs: needs: - lint-formatting - lint-typos - - cargo-deny - cargo-machete - cargo-udeps - lint-clippy - lint-markdown - coverage - check + - minimal-versions - build-no-std - check-readme - lint-docs diff --git a/vendor/ratatui/.github/workflows/daily.yml b/vendor/ratatui/.github/workflows/daily.yml new file mode 100644 index 0000000..e1a544f --- /dev/null +++ b/vendor/ratatui/.github/workflows/daily.yml @@ -0,0 +1,88 @@ +name: Daily Checks + +# Finds problems caused by changes outside this repository, such as new beta lints and advisories. +on: + schedule: + - cron: "30 6 * * *" + workflow_dispatch: + +permissions: {} + +# Avoid overlapping runs racing to update the tracking issues. +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + beta: + name: Check Beta + if: ${{ github.repository_owner == 'ratatui' }} + runs-on: ubuntu-latest + env: + RUSTUP_TOOLCHAIN: beta + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 + with: + toolchain: beta + components: clippy + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + - run: cargo xtask clippy + # Skip ratatui-macros: its trybuild tests snapshot complete rustc diagnostics, so reworded + # compiler errors on beta would fail without any problem for users. Stable CI still runs them. + - run: cargo test --workspace --exclude ratatui-macros --all-features --lib --tests + + advisories: + name: Check Advisories + if: ${{ github.repository_owner == 'ratatui' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2 + with: + rust-version: stable + log-level: info + arguments: --all-features --exclude-unpublished --config .config/deny.toml + command: check advisories + + # Keeps one issue per check in sync with the latest result. Repeat failures edit the issue body + # instead of commenting, so an ongoing failure doesn't notify everyone watching the repo each day. + # The issue closes itself once the check passes again. + report: + name: Report ${{ matrix.title }} + needs: [beta, advisories] + if: ${{ !cancelled() && github.repository_owner == 'ratatui' }} + runs-on: ubuntu-latest + permissions: + issues: write # open, update and close the tracking issues + strategy: + fail-fast: false + matrix: + include: + - title: Daily check failed on beta Rust + result: ${{ needs.beta.result }} + - title: Daily check failed on security advisories + result: ${{ needs.advisories.result }} + steps: + - name: Sync the tracking issue + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RESULT: ${{ matrix.result }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + TITLE: ${{ matrix.title }} + run: | + number=$(gh issue list --state open --search "\"$TITLE\" in:title" \ + --json number --jq '.[0].number // empty') + if [ "$RESULT" = "success" ] && [ -n "$number" ]; then + gh issue close "$number" --comment "Passing again: $RUN_URL" + elif [ "$RESULT" = "failure" ] && [ -n "$number" ]; then + gh issue edit "$number" --body "Latest failed run: $RUN_URL" + elif [ "$RESULT" = "failure" ]; then + gh issue create --title "$TITLE" --label "Type: Maintenance" \ + --body "Latest failed run: $RUN_URL" + fi diff --git a/vendor/ratatui/.github/workflows/release-plz.yml b/vendor/ratatui/.github/workflows/release-plz.yml index ddbd5d8..aa181ad 100644 --- a/vendor/ratatui/.github/workflows/release-plz.yml +++ b/vendor/ratatui/.github/workflows/release-plz.yml @@ -8,6 +8,7 @@ on: push: branches: - main + # The privileged jobs below also require refs/heads/main for manual runs. workflow_dispatch: jobs: @@ -20,21 +21,21 @@ jobs: contents: write id-token: write runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'ratatui' }} + if: ${{ github.repository_owner == 'ratatui' && github.ref == 'refs/heads/main' }} steps: - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - - uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1 + - uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1 id: auth - name: Run release-plz - uses: release-plz/action@e8792575c7f2366cf6ff3ccc33ead9ace5b691c7 # v0.5 + uses: release-plz/action@66b324fd6c72d05d2a08568492ecdd62bfb8a62b # v0.5 with: command: release env: @@ -42,28 +43,29 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} # Create a PR with the new versions and changelog, preparing the next release. + # Only runs when triggered manually, so the release PR doesn't churn on every push. release-plz-pr: name: Release-plz PR permissions: pull-requests: write contents: write runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'ratatui' }} + if: ${{ github.repository_owner == 'ratatui' && github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' }} concurrency: group: release-plz-${{ github.ref }} cancel-in-progress: false steps: - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master + uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with: toolchain: stable - name: Run release-plz - uses: release-plz/action@e8792575c7f2366cf6ff3ccc33ead9ace5b691c7 # v0.5 + uses: release-plz/action@66b324fd6c72d05d2a08568492ecdd62bfb8a62b # v0.5 with: command: release-pr env: diff --git a/vendor/ratatui/.github/workflows/zizmor.yml b/vendor/ratatui/.github/workflows/zizmor.yml index dba794d..bbbb04e 100644 --- a/vendor/ratatui/.github/workflows/zizmor.yml +++ b/vendor/ratatui/.github/workflows/zizmor.yml @@ -18,9 +18,9 @@ jobs: security-events: write steps: - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6 + uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1 diff --git a/vendor/ratatui/ARCHITECTURE.md b/vendor/ratatui/ARCHITECTURE.md index 8f7aa6b..1924a4b 100644 --- a/vendor/ratatui/ARCHITECTURE.md +++ b/vendor/ratatui/ARCHITECTURE.md @@ -51,6 +51,15 @@ The Ratatui project is now organized as a Cargo workspace containing the followi - Optimized implementations - Comprehensive documentation and examples +#### `ratatui-calendar` + +- **Purpose**: Calendar widget implementation +- **Contents**: The `Monthly` calendar widget and the `DateStyler` trait for styling dates +- **Target Users**: Applications showing calendars, widget library authors +- **Key Features**: + - Kept separate because its public API uses a third-party date type, so that dependency can + change without a breaking release of `ratatui-widgets` + ### Backend Crates #### `ratatui-crossterm` @@ -92,6 +101,7 @@ The Ratatui project is now organized as a Cargo workspace containing the followi ratatui ├── ratatui-core ├── ratatui-widgets → ratatui-core +├── ratatui-calendar → ratatui-core, ratatui-widgets ├── ratatui-crossterm → ratatui-core ├── ratatui-termion → ratatui-core ├── ratatui-termina → ratatui-core @@ -103,6 +113,8 @@ ratatui - **ratatui-core**: Foundation for all other crates - **ratatui-widgets**: Depends on `ratatui-core` for widget traits and types +- **ratatui-calendar**: Depends on `ratatui-core` for widget traits and on `ratatui-widgets` for + `Block` - **Backend crates**: Each depends on `ratatui-core` for backend traits and types - **ratatui**: Depends on all other crates and re-exports their public APIs diff --git a/vendor/ratatui/BREAKING-CHANGES.md b/vendor/ratatui/BREAKING-CHANGES.md index b42bb6e..04e2413 100644 --- a/vendor/ratatui/BREAKING-CHANGES.md +++ b/vendor/ratatui/BREAKING-CHANGES.md @@ -10,6 +10,18 @@ GitHub with a [breaking change] label. This is a quick summary of the sections below: +- [v0.31.0](#v0310) + - `Flex::SpaceBetween` with a single item now preserves fixed-size constraints + - `Scrollbar` thumb now reaches the end of the track when the content is fully scrolled + - `Backend` adds cursor save and restore methods + - The calendar widget moved from `ratatui-widgets` to the new `ratatui-calendar` crate + - The calendar widget uses `jiff` dates instead of `time` dates + - `Widget` is implemented for `&Box` and `WidgetRef` for `Box`, which conflicts with manual + impls for boxed widgets + - Removed APIs deprecated in v0.26.x + - The `scrolling-regions` feature is removed. `Terminal::insert_before` now requires a backend + that implements the new `ScrollByRegion` trait + - `HighlightSpacing` is split into `ListHighlightSpacing` and `TableHighlightSpacing` - [v0.30.1](#v0301) - Adding `AsRef` impls for widgets may affect type inference in rare cases - MSRV is now 1.88.0 @@ -97,6 +109,224 @@ This is a quick summary of the sections below: - MSRV is now 1.63.0 - `List` no longer ignores empty strings +## v0.31.0 + +### `Flex::SpaceBetween` with a single item now preserves fixed-size constraints + +Previously, `Flex::SpaceBetween` stretched a single layout item to fill the full area, even when the +item used a fixed-size constraint such as `Length`, `Max`, `Percentage`, or `Ratio`. A single item +now falls back to start alignment because there is no space to distribute between items. + +`Min` and `Fill` constraints still grow to fill the available area. If you relied on the previous +single-item stretching behavior with a fixed-size constraint, use `Flex::Legacy` or switch the item +to a growing constraint such as `Fill` or `Min`. + +### `Scrollbar` thumb now reaches the end of the track when the content is fully scrolled + +The scrollbar handle (thumb) now reaches the end when the last page is fully visible. With 100 items, +22 visible, and scroll position 78: + +```text +Before: <--------------####----> +After: <------------------####> +``` + +Set `viewport_content_length` to the number of visible items so the built-in scrolling controls +also stop at the last full page. Leaving it at zero preserves their previous behavior. + +### `Backend` adds cursor save and restore methods + +`Backend` now provides default `save_cursor_position` and `restore_cursor_position` methods. +Existing backend implementations continue to compile because both methods have default +implementations. However, this may cause method-call ambiguity in the unlikely case that another +trait in scope defines a method with the same name for a backend type. Use fully qualified syntax to +disambiguate such calls. + +Backends that can save the cursor without querying terminal input should override both methods and +return `Ok(true)` from `save_cursor_position`. Other backends can use the default implementations, +which select the cursor get-and-set fallback. + +### The calendar widget uses `jiff` dates instead of `time` dates + +`ratatui-calendar` (and so `ratatui::widgets::calendar`) now uses [`jiff::civil::Date`] instead of +`time::Date`. This affects `Monthly::new`, `DateStyler::get_style`, `CalendarEventStore::add` and +the `HashMap` inside `CalendarEventStore`. `ratatui` no longer depends on `time`. + +Build dates with [`jiff::civil::date`][jiff-date-fn] and get today's date with `jiff::ZonedDateTime::now()`: + +```diff +- use time::{Date, Month, OffsetDateTime}; ++ use jiff::ZonedDateTime; ++ use jiff::civil::date; + +- let new_year = Date::from_calendar_date(2026, Month::January, 1)?; ++ let new_year = date(2026, 1, 1); +- let today = OffsetDateTime::now_local()?.date(); ++ let today = ZonedDateTime::now().date(); +``` + +If the rest of your app keeps using `time`, convert at the boundary: + +```rust +fn to_jiff(date: time::Date) -> jiff::civil::Date { + let year = i16::try_from(date.year()).expect("year in jiff's range"); + jiff::civil::date(year, u8::from(date.month()) as i8, date.day() as i8) +} +``` + +`CalendarEventStore::today` now uses the system time zone through jiff. Previously it used `time`'s +local offset, which fails in multithreaded programs on Unix, so `today` could silently fall back to +UTC and mark the wrong day. + +[`jiff::civil::Date`]: https://docs.rs/jiff/latest/jiff/civil/struct.Date.html +[jiff-date-fn]: https://docs.rs/jiff/latest/jiff/civil/fn.date.html + +### The calendar widget moved from `ratatui-widgets` to the new `ratatui-calendar` crate + +The `calendar` module of `ratatui-widgets` (`Monthly`, `DateStyler` and `CalendarEventStore`) has +moved to the new `ratatui-calendar` crate. `ratatui-widgets` no longer has the `calendar` and +`all-widgets` features, its default features are now empty, and it no longer depends on `time`. + +If you use the calendar through `ratatui::widgets::calendar`, nothing changes: the +`widget-calendar` feature (enabled by default through `all-widgets`) now pulls in +`ratatui-calendar` and re-exports it at the same path. + +If you depend on `ratatui-widgets` directly and use its calendar, add `ratatui-calendar` and update +the imports: + +```diff +- use ratatui_widgets::calendar::{CalendarEventStore, Monthly}; ++ use ratatui_calendar::{CalendarEventStore, Monthly}; +``` + +Remove `calendar` and `all-widgets` from any `features` list for `ratatui-widgets`. + +### `Widget` is implemented for `&Box` and `WidgetRef` for `Box` ([#2883]) + +[#2883]: https://github.com/ratatui/ratatui/pull/2883 + +`Widget` is now implemented for `&Box` whenever `&W` implements `Widget`, so boxed widgets can be +rendered directly. If your crate has its own impl for a boxed widget, it now conflicts with this +one: + +```rust +impl Widget for &MyWidget { ... } + +// error[E0119]: conflicting implementations of trait `Widget` for type `&Box` +impl Widget for &Box { + fn render(self, area: Rect, buf: &mut Buffer) { + (**self).render(area, buf); + } +} +``` + +Remove the `&Box` impl. The new impl renders the boxed widget the same way. Impls for +boxed trait objects such as `&Box` are not affected unless `&dyn MyTrait` also +implements `Widget`. + +With the `unstable-widget-ref` feature, `WidgetRef` is likewise implemented for `Box`, `Rc`, +and `Arc` whenever `&W` implements `Widget`. Remove any `impl WidgetRef for Box` in +the same way. + +### Removed APIs deprecated in v0.26.x + +The following APIs, deprecated since February to May 2024, have been removed: + +- `Constraint::apply`. It has no replacement; layout computes sizes from constraints internally. +- `Span::to_left_aligned_line`, `Span::to_centered_line` and `Span::to_right_aligned_line`. Use + `Span::into_left_aligned_line`, `Span::into_centered_line` and `Span::into_right_aligned_line` + instead. +- `assert_buffer_eq!`. Use `assert_eq!(&actual, &expected)` instead. + +`TestBackend::assert_buffer` now uses `assert_eq!` internally, so its panic message is the standard +``assertion `left == right` failed`` output instead of the `assert_buffer_eq!` message. + +### The `scrolling-regions` feature is removed and `insert_before` requires `ScrollByRegion` ([#2121]) + +[#2121]: https://github.com/ratatui/ratatui/pull/2121 + +The `scrolling-regions` feature added `scroll_region_up` and `scroll_region_down` to `Backend` only +when it was enabled. Cargo features should only add things, so a crate that enabled the feature +could break another crate in the same build that implemented `Backend`. The feature is removed, and +the two methods move from `Backend` to a new `ScrollByRegion` trait, which has `Backend` as a +supertrait. + +`Terminal::insert_before` now always uses scrolling regions, so it no longer clears the viewport +when inserting lines. The implementation that moved the cursor and cleared the viewport is removed, +and `insert_before` is only available when the backend implements `ScrollByRegion`. The built-in +Crossterm, Termina, Termion, Termwiz, and `TestBackend` backends implement it. + +Remove `scrolling-regions` from any `features` list for `ratatui`, `ratatui-core`, +`ratatui-crossterm`, `ratatui-termina`, `ratatui-termion`, or `ratatui-termwiz`: + +```diff +- ratatui = { version = "0.30", features = ["scrolling-regions"] } ++ ratatui = "0.31" +``` + +Code that calls `insert_before` through a generic backend needs a `ScrollByRegion` bound instead of +`Backend`. `Backend` is a supertrait, so all other `Terminal` methods remain available: + +```diff +- fn run(terminal: &mut Terminal) -> Result<(), B::Error> { ++ fn run(terminal: &mut Terminal) -> Result<(), B::Error> { + terminal.insert_before(1, |buf| { /* ... */ }) + } +``` + +Backends that implemented `scroll_region_up` and `scroll_region_down` behind the feature should move +those methods into an `impl ScrollByRegion` block: + +```diff + impl Backend for MyBackend { + // ... +- #[cfg(feature = "scrolling-regions")] +- fn scroll_region_up(&mut self, region: Range, amount: u16) -> Result<(), Self::Error> { +- // ... +- } +- +- #[cfg(feature = "scrolling-regions")] +- fn scroll_region_down(&mut self, region: Range, amount: u16) -> Result<(), Self::Error> { +- // ... +- } + } ++ ++ impl ScrollByRegion for MyBackend { ++ fn scroll_region_up(&mut self, region: Range, amount: u16) -> Result<(), Self::Error> { ++ // ... ++ } ++ ++ fn scroll_region_down(&mut self, region: Range, amount: u16) -> Result<(), Self::Error> { ++ // ... ++ } ++ } +``` + +Backends without scrolling regions no longer support `insert_before`. To keep supporting it, they +can implement `ScrollByRegion` by emulating the region scroll, as `TestBackend` does. + +### `HighlightSpacing` is split into `ListHighlightSpacing` and `TableHighlightSpacing` ([#2265]) + +[#2265]: https://github.com/ratatui/ratatui/pull/2265 + +`List` and `Table` used to share one `HighlightSpacing` enum, defined in the table module. Each +widget now has its own type so the two can evolve independently. `List::highlight_spacing` takes a +`ListHighlightSpacing` and `Table::highlight_spacing` takes a `TableHighlightSpacing`. The variants +are unchanged. + +```diff +- use ratatui::widgets::{HighlightSpacing, List, Table}; ++ use ratatui::widgets::{List, ListHighlightSpacing, Table, TableHighlightSpacing}; + +- let list = List::new(items).highlight_spacing(HighlightSpacing::Always); ++ let list = List::new(items).highlight_spacing(ListHighlightSpacing::Always); +- let table = Table::new(rows, widths).highlight_spacing(HighlightSpacing::Always); ++ let table = Table::new(rows, widths).highlight_spacing(TableHighlightSpacing::Always); +``` + +`HighlightSpacing` has been removed. Replace it with `ListHighlightSpacing` where it is passed to a +`List` and with `TableHighlightSpacing` where it is passed to a `Table`. + ## [v0.30.1](https://github.com/ratatui/ratatui/releases/tag/ratatui-v0.30.1) ### MSRV is now 1.88.0 @@ -283,7 +513,7 @@ The minimum supported Rust version (MSRV) is now 1.86.0. ### `layout::Alignment` is renamed to `layout::HorizontalAlignment` ([#1735]) -[#1735]: https://github.com/ratatui/ratatui/pull/1691 +[#1735]: https://github.com/ratatui/ratatui/pull/1735 The `Alignment` enum has been renamed to `HorizontalAlignment` to better reflect its purpose. A type alias has been added to maintain backwards compatibility, however there are some cases where type @@ -609,7 +839,7 @@ This change simplifies the trait and makes it easier to implement. ### List no clamps the selected index to list ([#1159]) -[#1149]: https://github.com/ratatui/ratatui/pull/1149 +[#1159]: https://github.com/ratatui/ratatui/pull/1159 The `List` widget now clamps the selected index to the bounds of the list when navigating with `first`, `last`, `previous`, and `next`, as well as when setting the index directly with `select`. @@ -729,7 +959,7 @@ flexible types from calling scopes, though it can break some type inference in t ### `LineGauge::gauge_style` is deprecated ([#565]) -[#565]: https://github.com/ratatui/ratatui/pull/1148 +[#565]: https://github.com/ratatui/ratatui/pull/565 `LineGauge::gauge_style` is deprecated and replaced with `LineGauge::filled_style` and `LineGauge::unfilled_style`: diff --git a/vendor/ratatui/CONTRIBUTING.md b/vendor/ratatui/CONTRIBUTING.md index 9eb9549..6ddfe72 100644 --- a/vendor/ratatui/CONTRIBUTING.md +++ b/vendor/ratatui/CONTRIBUTING.md @@ -335,7 +335,8 @@ discussion](https://github.com/ratatui/ratatui/discussions/66) for more about th We use GitHub Actions for the CI where we perform the following checks: - The code should compile on `stable` and the Minimum Supported Rust Version (MSRV). -- The tests (docs, lib, tests and examples) should pass. +- The tests (docs, lib, tests, and examples) should pass on `stable`. Compiler-diagnostic snapshots + are also tested on `stable`, because rustc's diagnostic text may differ across supported versions. - The code should conform to the default format enforced by `rustfmt`. - The code should not contain common style issues `clippy`. diff --git a/vendor/ratatui/Cargo.lock b/vendor/ratatui/Cargo.lock index 59db5e1..77f3bab 100644 --- a/vendor/ratatui/Cargo.lock +++ b/vendor/ratatui/Cargo.lock @@ -154,17 +154,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "async-trait" -version = "0.1.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "atomic" version = "0.6.1" @@ -180,6 +169,30 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "aws-lc-rs" +version = "1.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faac5829c2b74c28f830747e7818ccfb684261b5f48a1118b1e2a13d36dfab13" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1622d8446a2d4b2ce0c7eefc73dd43a99779028d5ee5c2dd8073a658ba8a2bc" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + [[package]] name = "backtrace" version = "0.3.75" @@ -195,12 +208,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64" version = "0.22.1" @@ -208,10 +215,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] -name = "base64ct" -version = "1.8.0" +name = "base64" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" [[package]] name = "bit-set" @@ -236,9 +243,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.13.0" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" dependencies = [ "serde_core", ] @@ -276,16 +283,6 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" -[[package]] -name = "calendar-explorer" -version = "0.0.0" -dependencies = [ - "color-eyre", - "crossterm 0.29.0", - "ratatui", - "time", -] - [[package]] name = "camino" version = "1.2.1" @@ -301,7 +298,7 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "itertools 0.14.0", + "itertools 0.15.0", "ratatui", ] @@ -325,7 +322,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 2.0.18", + "thiserror 2.0.21", ] [[package]] @@ -345,10 +342,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.33" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f" +checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838" dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -366,9 +366,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chacha20" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures 0.3.0", @@ -428,9 +428,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.6.1" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" dependencies = [ "clap_builder", "clap_derive", @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.6.0" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" dependencies = [ "anstream", "anstyle", @@ -460,14 +460,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.6.1" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] @@ -476,13 +476,22 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "color-explorer" version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "itertools 0.14.0", + "itertools 0.15.0", "ratatui", ] @@ -521,11 +530,11 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "colorgrad" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aee94de557db6ddae3ca7b37b5fbe77ed6f159219f1815a8c2c1a9854c73087e" +checksum = "b4115799a737d62b06bc1028358f8cb69a753e174d6470f3be679ef643c55a53" dependencies = [ - "csscolorparser 0.8.1", + "csscolorparser 0.9.0", "libm", ] @@ -539,34 +548,37 @@ dependencies = [ "ratatui", ] +[[package]] +name = "combine" +version = "4.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "compact_str" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" +checksum = "79fcda08c33bb58b97008b2cdada6622500e949e060f5913361763121abd2416" dependencies = [ "castaway", "cfg-if", "itoa", - "rustversion", - "ryu", "serde", "static_assertions", + "zmij", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "constraint-explorer" version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "itertools 0.14.0", + "itertools 0.15.0", "ratatui", "strum", ] @@ -686,9 +698,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.18" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" dependencies = [ "crossbeam-utils", ] @@ -705,7 +717,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "crossterm_winapi", "mio", "parking_lot", @@ -722,7 +734,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "crossterm_winapi", "derive_more", "document-features", @@ -751,18 +763,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -785,42 +785,15 @@ dependencies = [ [[package]] name = "csscolorparser" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02ee6eae4d99456f92dc379ba21cf08f783ef5525f193c3854b4e921ece045c5" +checksum = "75c9db70df93ea049adaa5ef1a727079ada6ccb33d4b358f262923aef4fcac8c" dependencies = [ "num-traits", - "phf 0.13.1", + "phf 0.14.0", "serde", ] -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "curve25519-dalek-derive", - "digest", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "custom-widget" version = "0.0.0" @@ -832,9 +805,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +checksum = "88490bf1b990d87eaaa7ac8aa887f629a08e7359765b4911faf63c3763347d23" dependencies = [ "darling_core", "darling_macro", @@ -842,26 +815,26 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +checksum = "084e274f91c482280130e1e34e0b8d6e66776a060d7b6de7b84289ca778868c4" dependencies = [ "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] name = "darling_macro" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +checksum = "68f5792fa0d41cd2325ce0ffa64f0a340eaebd4971a3a0c5e1ffd2cc488a355e" dependencies = [ "darling_core", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] @@ -876,7 +849,7 @@ version = "0.0.0" dependencies = [ "clap", "crossterm 0.29.0", - "rand 0.10.1", + "rand 0.10.3", "ratatui", "termion", "termwiz", @@ -889,27 +862,16 @@ dependencies = [ "color-eyre", "crossterm 0.29.0", "indoc", - "itertools 0.14.0", + "itertools 0.15.0", + "jiff", "palette", - "rand 0.10.1", + "rand 0.10.3", "rand_chacha 0.10.0", "ratatui", "strum", - "time", "unicode-width", ] -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - [[package]] name = "deranged" version = "0.5.8" @@ -950,7 +912,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", "subtle", ] @@ -983,9 +944,9 @@ dependencies = [ [[package]] name = "duct" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e66e9c0c03d094e1a0ba1be130b849034aa80c3a2ab8ee94316bc809f3fa684" +checksum = "61b9e2a29ff01e8bb526a571ad06c10ed72aae80d5999ed204f7971f99f19974" dependencies = [ "libc", "os_pipe", @@ -994,42 +955,10 @@ dependencies = [ ] [[package]] -name = "ecdsa" -version = "0.16.9" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8", - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" -dependencies = [ - "curve25519-dalek", - "ed25519", - "serde", - "sha2", - "subtle", - "zeroize", -] +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "either" @@ -1037,27 +966,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "hkdf", - "pem-rfc7468", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -1099,7 +1007,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ff50593e569e8da220e12d8c171c89794fb2dab023f6391edbe5d16f3cdb311" dependencies = [ - "rand 0.9.2", + "rand 0.9.5", "simplerand", "uuid 0.8.2", ] @@ -1114,34 +1022,12 @@ dependencies = [ "regex", ] -[[package]] -name = "fast-srgb8" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1" - [[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - [[package]] name = "filedescriptor" version = "0.8.3" @@ -1153,6 +1039,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + [[package]] name = "finl_unicode" version = "1.3.0" @@ -1202,6 +1094,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.31" @@ -1219,9 +1117,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -1229,9 +1127,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" @@ -1246,32 +1144,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-timer" @@ -1281,9 +1179,9 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -1293,7 +1191,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -1314,7 +1211,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -1349,11 +1245,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "rand_core 0.10.0", "wasip2", "wasip3", + "wasm-bindgen", ] [[package]] @@ -1368,17 +1266,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "half" version = "2.6.0" @@ -1398,17 +1285,6 @@ dependencies = [ "foldhash 0.1.5", ] -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.2.0", -] - [[package]] name = "hashbrown" version = "0.17.1" @@ -1441,15 +1317,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac", -] - [[package]] name = "hmac" version = "0.12.1" @@ -1565,6 +1432,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" dependencies = [ + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -1572,7 +1440,9 @@ dependencies = [ "http", "http-body", "hyper", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", "tokio", @@ -1586,7 +1456,7 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "itertools 0.14.0", + "itertools 0.15.0", "ratatui", ] @@ -1741,20 +1611,21 @@ checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" [[package]] name = "indexmap" -version = "2.10.0" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", - "hashbrown 0.15.5", + "hashbrown 0.17.1", "serde", + "serde_core", ] [[package]] name = "indoc" -version = "2.0.7" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1" dependencies = [ "rustversion", ] @@ -1765,7 +1636,7 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "rand 0.10.1", + "rand 0.10.3", "ratatui", ] @@ -1791,26 +1662,22 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.12" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971" +checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" dependencies = [ "darling", "indoc", "proc-macro2", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] -name = "iri-string" -version = "0.7.8" +name = "ipnet" +version = "2.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" -dependencies = [ - "memchr", - "serde", -] +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" [[package]] name = "is_terminal_polyfill" @@ -1829,9 +1696,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" dependencies = [ "either", ] @@ -1842,6 +1709,117 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cc767b5763de45e810109520123bb2829a653f3a7ed9be40b2bc4f81158f595" +dependencies = [ + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-link 0.2.1", +] + +[[package]] +name = "jiff-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "894f7ac42105f584100691b3bf6e6b92dd12fcfa225f6c397f95c8a94b47b68f" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955491488dc99b572ea6d67b172dcd98787d00744b1fb44a5689b4e6413695a6" +dependencies = [ + "jiff-core", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "jiff-tzdb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" + +[[package]] +name = "jiff-tzdb-platform" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" +dependencies = [ + "jiff-tzdb", +] + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link 0.2.1", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.117", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.1", + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -1858,33 +1836,27 @@ version = "10.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0529410abe238729a60b108898784df8984c87f6054c9c4fcacc47e4803c1ce1" dependencies = [ - "base64", - "ed25519-dalek", + "aws-lc-rs", + "base64 0.22.1", "getrandom 0.2.16", - "hmac", "js-sys", - "p256", - "p384", "pem", - "rand 0.8.5", - "rsa", "serde", "serde_json", - "sha2", "signature", "simple_asn1", ] [[package]] name = "kasuari" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde5057d6143cc94e861d90f591b9303d6716c6b9602309150bd068853c10899" +checksum = "72f14c90e40a6133f4805b83542a7ed7364f56070b447f56e7f4e90297122209" dependencies = [ - "hashbrown 0.16.1", + "hashbrown 0.17.1", "portable-atomic", "portable-atomic-util", - "thiserror 2.0.18", + "thiserror 2.0.21", ] [[package]] @@ -1898,9 +1870,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "leb128fmt" @@ -1922,11 +1891,11 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "line-clipping" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f50e8f47623268b5407192d26876c4d7f89d686ca130fdc53bced4814cd29f8" +checksum = "e752191d037c44ad111a8caa762921926658402f01cc1253f7bef2020ece4f5e" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", ] [[package]] @@ -1980,13 +1949,19 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9" +checksum = "4a9f71e3591c7ec44d3e563e87bf14ddc2bada8519dca046e5b0e560cd004e2d" dependencies = [ "hashbrown 0.17.1", ] +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + [[package]] name = "mac_address" version = "1.1.8" @@ -2068,7 +2043,6 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "itertools 0.14.0", "ratatui", ] @@ -2079,7 +2053,7 @@ dependencies = [ "color-eyre", "crossterm 0.29.0", "line_drawing", - "rand 0.10.1", + "rand 0.10.3", "ratatui", ] @@ -2089,7 +2063,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "cfg-if", "cfg_aliases", "libc", @@ -2125,22 +2099,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" -dependencies = [ - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.5", - "smallvec", - "zeroize", -] - [[package]] name = "num-conv" version = "0.2.2" @@ -2167,17 +2125,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2188,15 +2135,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - [[package]] name = "numtoa" version = "0.2.4" @@ -2214,13 +2152,12 @@ dependencies = [ [[package]] name = "octocrab" -version = "0.53.1" +version = "0.54.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe45bd53ce50c9e85e8a27259675f65d772165fe5eef3e278c1b6168c3f97623" +checksum = "319b72643e8fa16dc3278f66439534513b2b65d47ec9cf2b26e7316c0c8ef24a" dependencies = [ "arc-swap", - "async-trait", - "base64", + "base64 0.22.1", "bytes", "cargo_metadata", "cfg-if", @@ -2228,6 +2165,8 @@ dependencies = [ "futures", "futures-util", "getrandom 0.2.16", + "hex", + "hmac", "http", "http-body", "http-body-util", @@ -2239,11 +2178,14 @@ dependencies = [ "jsonwebtoken", "percent-encoding", "pin-project", + "reqwest", + "rustls", "secrecy", "serde", "serde_json", "serde_path_to_error", "serde_urlencoded", + "sha2", "snafu", "tokio", "tower", @@ -2302,30 +2244,6 @@ version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2", -] - -[[package]] -name = "p384" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2", -] - [[package]] name = "page_size" version = "0.6.0" @@ -2338,21 +2256,21 @@ dependencies = [ [[package]] name = "palette" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" +checksum = "ddeed8580d347d2abf3dcf06a5f0b3dc020258338526b277847cd4248a70fc64" dependencies = [ "approx", - "fast-srgb8", "libm", "palette_derive", + "palette_math", ] [[package]] name = "palette_derive" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30" +checksum = "88537020289b719d81be994ccf1bbf4990f477e2f69ee52fe3e45f43a02e56be" dependencies = [ "by_address", "proc-macro2", @@ -2360,6 +2278,15 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "palette_math" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e6eb142958d64335fb0e345c5b9ead2ecd6fc438c307e9d7d3c4fd428dbaf12" +dependencies = [ + "libm", +] + [[package]] name = "panic" version = "0.0.0" @@ -2398,19 +2325,10 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" dependencies = [ - "base64", + "base64 0.22.1", "serde", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -2424,7 +2342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", - "thiserror 2.0.18", + "thiserror 2.0.21", "ucd-trie", ] @@ -2473,12 +2391,12 @@ dependencies = [ [[package]] name = "phf" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" dependencies = [ - "phf_macros 0.13.1", - "phf_shared 0.13.1", + "phf_macros 0.14.0", + "phf_shared 0.14.0", "serde", ] @@ -2499,17 +2417,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared 0.11.3", - "rand 0.8.5", + "rand 0.8.8", ] [[package]] name = "phf_generator" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" dependencies = [ "fastrand", - "phf_shared 0.13.1", + "phf_shared 0.14.0", ] [[package]] @@ -2527,12 +2445,12 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" dependencies = [ - "phf_generator 0.13.1", - "phf_shared 0.13.1", + "phf_generator 0.14.0", + "phf_shared 0.14.0", "proc-macro2", "quote", "syn 2.0.117", @@ -2550,9 +2468,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" dependencies = [ "siphasher", "uncased", @@ -2585,31 +2503,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" +name = "pkg-config" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "plotters" @@ -2656,9 +2553,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" dependencies = [ "portable-atomic", ] @@ -2707,20 +2604,11 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - [[package]] name = "proc-macro-crate" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ "toml_edit", ] @@ -2734,6 +2622,63 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.21", + "tokio", + "tracing 0.1.44", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.4.1", + "lru-slab", + "rand 0.10.3", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing 0.1.44", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing 0.1.44", + "windows-sys 0.61.2", +] + [[package]] name = "quote" version = "1.0.45" @@ -2751,20 +2696,18 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ - "libc", - "rand_chacha 0.3.1", "rand_core 0.6.4", ] [[package]] name = "rand" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", @@ -2772,25 +2715,15 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ "chacha20", "getrandom 0.4.1", "rand_core 0.10.0", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.9.0" @@ -2835,6 +2768,15 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core 0.10.0", +] + [[package]] name = "ratatui" version = "0.30.2" @@ -2845,10 +2787,12 @@ dependencies = [ "fakeit", "indoc", "instability", + "jiff", "log", "palette", "pretty_assertions", - "rand 0.10.1", + "rand 0.10.3", + "ratatui-calendar", "ratatui-core", "ratatui-crossterm", "ratatui-macros", @@ -2859,6 +2803,22 @@ dependencies = [ "rstest", "serde", "serde_json", +] + +[[package]] +name = "ratatui-calendar" +version = "0.1.0" +dependencies = [ + "chrono", + "color-eyre", + "crossterm 0.29.0", + "document-features", + "hashbrown 0.17.1", + "jiff", + "ratatui", + "ratatui-core", + "ratatui-widgets", + "rstest", "time", ] @@ -2867,13 +2827,13 @@ name = "ratatui-core" version = "0.1.2" dependencies = [ "anstyle", - "bitflags 2.13.0", + "bitflags 2.13.2", "compact_str", "critical-section", "document-features", "hashbrown 0.17.1", "indoc", - "itertools 0.14.0", + "itertools 0.15.0", "kasuari", "log", "lru", @@ -2883,7 +2843,7 @@ dependencies = [ "serde", "serde_json", "strum", - "thiserror 2.0.18", + "thiserror 2.0.21", "unicode-segmentation", "unicode-truncate", "unicode-width", @@ -2957,22 +2917,21 @@ dependencies = [ name = "ratatui-widgets" version = "0.3.2" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "color-eyre", "crossterm 0.29.0", "document-features", - "hashbrown 0.17.1", "indoc", "instability", - "itertools 0.14.0", + "itertools 0.15.0", "line-clipping", + "portable-atomic-util", "pretty_assertions", "ratatui", "ratatui-core", "rstest", "serde", "strum", - "time", "unicode-segmentation", "unicode-width", ] @@ -3003,7 +2962,7 @@ version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", ] [[package]] @@ -3050,13 +3009,40 @@ dependencies = [ ] [[package]] -name = "rfc6979" -version = "0.4.0" +name = "reqwest" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" dependencies = [ - "hmac", - "subtle", + "base64 0.23.1", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] @@ -3069,35 +3055,15 @@ dependencies = [ "cfg-if", "getrandom 0.2.16", "libc", - "untrusted", + "untrusted 0.9.0", "windows-sys 0.52.0", ] -[[package]] -name = "rsa" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "signature", - "spki", - "subtle", - "zeroize", -] - [[package]] name = "rstest" -version = "0.26.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a3193c063baaa2a95a33f03035c8a72b83d97a54916055ba22d35ed3839d49" +checksum = "b376e512f30a7686a8dbc6aeaace99b3ade1c26c1c63473473a817ade226dafc" dependencies = [ "futures-timer", "futures-util", @@ -3106,9 +3072,9 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.26.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c845311f0ff7951c5506121a9ad75aec44d083c31583b2ea5a30bcb0b0abba0" +checksum = "88512dbfb5b73a0dfa38aef7bc73b5657035fce477b923faf12d332dd83051ea" dependencies = [ "cfg-if", "glob", @@ -3128,6 +3094,12 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + [[package]] name = "rustc_version" version = "0.4.1" @@ -3143,7 +3115,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.4.15", @@ -3156,7 +3128,7 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.9.4", @@ -3165,10 +3137,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.31" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ + "aws-lc-rs", "log", "once_cell", "ring", @@ -3196,18 +3169,47 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" dependencies = [ + "web-time", "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + [[package]] name = "rustls-webpki" -version = "0.103.13" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", - "untrusted", + "untrusted 0.9.0", ] [[package]] @@ -3255,20 +3257,6 @@ dependencies = [ "ratatui", ] -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secrecy" version = "0.10.3" @@ -3280,11 +3268,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.3.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80fb1d92c5028aa318b4b8bd7302a5bfcf48be96a37fc6fc790f806b0004ee0c" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "core-foundation", "core-foundation-sys", "libc", @@ -3293,9 +3281,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -3312,9 +3300,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -3322,29 +3310,29 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ "itoa", "memchr", @@ -3365,11 +3353,11 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -3423,9 +3411,9 @@ checksum = "52b86057fcb5423f5018e331ac04623e32d6b5ce85e33300f92c79a1973928b0" [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "sigchld" @@ -3474,10 +3462,25 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", "rand_core 0.6.4", ] +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "simple_asn1" version = "0.6.3" @@ -3486,7 +3489,7 @@ checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" dependencies = [ "num-bigint", "num-traits", - "thiserror 2.0.18", + "thiserror 2.0.21", "time", ] @@ -3548,22 +3551,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3637,11 +3624,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -3661,16 +3662,25 @@ dependencies = [ "color-eyre", "crossterm 0.29.0", "fakeit", - "itertools 0.14.0", + "itertools 0.15.0", "ratatui", "unicode-width", ] [[package]] -name = "target-triple" -version = "1.0.0" +name = "table-detail-tea" +version = "0.0.0" +dependencies = [ + "color-eyre", + "crossterm 0.29.0", + "ratatui", +] + +[[package]] +name = "target-tuple" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591ef38edfb78ca4771ee32cf494cb8771944bee237a9b91fc9c1424ac4b777b" +checksum = "876fef147edbcbddc8ac5cbbba92c7b86519e314e86638596c09673b2ed01e7f" [[package]] name = "termcolor" @@ -3687,7 +3697,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881a7f20ade48167027822c52a0aeca879afa3174b15c71997827826bce669f9" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "parking_lot", "rustix 1.0.8", "signal-hook", @@ -3733,8 +3743,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7" dependencies = [ "anyhow", - "base64", - "bitflags 2.13.0", + "base64 0.22.1", + "bitflags 2.13.2", "fancy-regex", "filedescriptor", "finl_unicode", @@ -3780,11 +3790,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.18" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" dependencies = [ - "thiserror-impl 2.0.18", + "thiserror-impl 2.0.21", ] [[package]] @@ -3800,13 +3810,13 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.18" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 3.0.10", ] [[package]] @@ -3820,14 +3830,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.49" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" dependencies = [ "deranged", - "libc", "num-conv", - "num_threads", "powerfmt", "serde_core", "time-core", @@ -3842,9 +3850,9 @@ checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.29" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c652a3727a9cbb9a02f707f530b618ce00d0ccd762009c8c23bd191df3c17d" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" dependencies = [ "num-conv", "time-core", @@ -3870,6 +3878,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + [[package]] name = "todo-list" version = "0.0.0" @@ -3885,6 +3899,7 @@ version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ + "bytes", "libc", "mio", "pin-project-lite", @@ -3916,9 +3931,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" dependencies = [ "futures-core", "pin-project-lite", @@ -3940,14 +3955,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.5" +version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8" +checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" dependencies = [ "indexmap", - "serde", + "serde_core", "serde_spanned", - "toml_datetime 0.7.0", + "toml_datetime", "toml_parser", "toml_writer", "winnow", @@ -3955,44 +3970,39 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" - -[[package]] -name = "toml_datetime" -version = "0.7.0" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ - "serde", + "serde_core", ] [[package]] name = "toml_edit" -version = "0.22.27" +version = "0.25.15+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614" dependencies = [ "indexmap", - "toml_datetime 0.6.11", + "toml_datetime", + "toml_parser", "winnow", ] [[package]] name = "toml_parser" -version = "1.0.2" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow", ] [[package]] name = "toml_writer" -version = "1.0.2" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "tower" @@ -4013,21 +4023,21 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "bytes", "futures-util", "http", "http-body", - "iri-string", "pin-project-lite", "tower", "tower-layer", "tower-service", "tracing 0.1.44", + "url", ] [[package]] @@ -4074,7 +4084,7 @@ checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" dependencies = [ "crossbeam-channel", "symlink", - "thiserror 2.0.18", + "thiserror 2.0.21", "time", "tracing-subscriber", ] @@ -4147,16 +4157,16 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "trybuild" -version = "1.0.115" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f614c21bd3a61bad9501d75cbb7686f00386c806d7f456778432c25cf86948a" +checksum = "62db9c92d704393fbf2132041720cc80b689f2d3f28521015c2ac866223c11b8" dependencies = [ "dissimilar", "glob", "serde", "serde_derive", "serde_json", - "target-triple", + "target-tuple", "termcolor", "toml", ] @@ -4196,20 +4206,20 @@ checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-truncate" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" +checksum = "f5dde200aa133f5b6d9cc616878815ffaa45ad9529ef4a2f04d86bab91d63984" dependencies = [ - "itertools 0.14.0", + "itertools 0.15.0", "unicode-segmentation", "unicode-width", ] [[package]] name = "unicode-width" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" [[package]] name = "unicode-xid" @@ -4217,6 +4227,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "untrusted" version = "0.9.0" @@ -4297,7 +4313,7 @@ dependencies = [ "color-eyre", "colorgrad", "crossterm 0.29.0", - "rand 0.10.1", + "rand 0.10.3", "ratatui", ] @@ -4388,6 +4404,19 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.100" @@ -4448,7 +4477,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "hashbrown 0.15.5", "indexmap", "semver", @@ -4460,7 +4489,7 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm 0.29.0", - "rand 0.10.1", + "rand 0.10.3", "ratatui", ] @@ -4485,6 +4514,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "wezterm-bidi" version = "0.2.3" @@ -4831,9 +4869,9 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.7.12" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" dependencies = [ "memchr", ] @@ -4864,7 +4902,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", ] [[package]] @@ -4905,7 +4943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.13.0", + "bitflags 2.13.2", "indexmap", "log", "serde", diff --git a/vendor/ratatui/Cargo.toml b/vendor/ratatui/Cargo.toml index cfc554d..6a80d9d 100644 --- a/vendor/ratatui/Cargo.toml +++ b/vendor/ratatui/Cargo.toml @@ -5,6 +5,7 @@ default-members = [ "examples/apps/*", "examples/concepts/*", "ratatui", + "ratatui-calendar", "ratatui-core", "ratatui-crossterm", "ratatui-macros", @@ -16,7 +17,6 @@ default-members = [ ] [workspace.package] -authors = ["Florian Dehau ", "The Ratatui Developers"] documentation = "https://docs.rs/ratatui/latest/ratatui/" repository = "https://github.com/ratatui/ratatui" homepage = "https://ratatui.rs" @@ -29,31 +29,34 @@ edition = "2024" rust-version = "1.88.0" [workspace.dependencies] -anstyle = "1" -bitflags = "2.12" -clap = { version = "4.6", features = ["derive"] } +anstyle = "1.0.3" +bitflags = "2.11" +chrono = { version = "0.4.41", default-features = false } +clap = { version = "4.5", features = ["derive"] } color-eyre = "0.6" -compact_str = { version = "0.9", default-features = false } +compact_str = { version = "0.10", default-features = false } criterion = { version = "0.8", features = ["html_reports"] } critical-section = "1.2" crossterm = "0.29" -document-features = "0.2" +document-features = "0.2.11" fakeit = "1" -futures = "0.3" hashbrown = "0.17" -indoc = "2" -instability = "0.3" -itertools = { version = "0.14", default-features = false, features = ["use_alloc"] } -kasuari = { version = "0.4", default-features = false } -line-clipping = "0.3" +indoc = "2.0.5" +instability = "0.3.7" +jiff = { version = "1.0.0", default-features = false } +itertools = { version = "0.15", default-features = false, features = ["use_alloc"] } +kasuari = { version = "0.4.9", default-features = false } +line-clipping = "0.3.8" log = "0.4" -lru = "0.18" -octocrab = "0.53" -palette = { version = "0.7.6", default-features = false, features = ["libm"] } +lru = "0.19.0" +octocrab = "0.54" +palette = { version = "0.7.7", default-features = false, features = ["libm"] } +portable-atomic-util = { version = "0.2.4", default-features = false } pretty_assertions = "1" rand = "0.10" rand_chacha = "0.10" ratatui = { path = "ratatui", version = "0.30.2" } +ratatui-calendar = { path = "ratatui-calendar", version = "0.1.0", default-features = false } ratatui-core = { path = "ratatui-core", version = "0.1.2" } ratatui-crossterm = { path = "ratatui-crossterm", version = "0.1.2" } ratatui-macros = { path = "ratatui-macros", version = "0.7.2" } @@ -61,25 +64,25 @@ ratatui-termina = { path = "ratatui-termina", version = "0.1.0" } ratatui-termion = { path = "ratatui-termion", version = "0.1.2" } ratatui-termwiz = { path = "ratatui-termwiz", version = "0.1.2" } ratatui-widgets = { path = "ratatui-widgets", version = "0.3.2", default-features = false } -rstest = "0.26" -serde = { version = "1", default-features = false, features = ["derive"] } -serde_json = "1" +rstest = "0.28" +serde = { version = "1.0.228", default-features = false, features = ["derive"] } +serde_json = "1.0.142" strum = { version = "0.28", default-features = false, features = ["derive"] } termina = "0.4" termion = "4" termwiz = "0.23" -thiserror = { version = "2", default-features = false } -time = { version = "0.3.47", default-features = false } -tokio = "1" +thiserror = { version = "2.0.12", default-features = false } +time = { version = "0.3.55", default-features = false } +tokio = "1.35" tokio-stream = "0.1" -tracing = "0.1" +tracing = "0.1.37" tracing-appender = "0.2" -tracing-subscriber = "0.3" -trybuild = "1" -unicode-segmentation = "1" -unicode-truncate = { version = "2", default-features = false } +tracing-subscriber = "0.3.10" +trybuild = "1.0.19" +unicode-segmentation = "1.9" +unicode-truncate = { version = "3", default-features = false } # See for information about why we pin unicode-width -unicode-width = ">=0.2.0" +unicode-width = ">=0.2.3" [workspace.lints.rust] unsafe_code = "forbid" diff --git a/vendor/ratatui/LICENSE b/vendor/ratatui/LICENSE index 776bf20..bc8bc59 100644 --- a/vendor/ratatui/LICENSE +++ b/vendor/ratatui/LICENSE @@ -1,7 +1,7 @@ The MIT License (MIT) Copyright (c) 2016-2022 Florian Dehau -Copyright (c) 2023-2025 The Ratatui Developers +Copyright (c) 2023-2026 The Ratatui Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/ratatui/README.md b/vendor/ratatui/README.md index 0b8918b..d725ba6 100644 --- a/vendor/ratatui/README.md +++ b/vendor/ratatui/README.md @@ -5,7 +5,6 @@ - [Documentation](#documentation) - [Templates](#templates) - [Built with Ratatui](#built-with-ratatui) -- [Alternatives](#alternatives) - [Contributing](#contributing) - [Acknowledgements](#acknowledgements) - [License](#license) @@ -89,6 +88,18 @@ If you're looking to get started quickly, you can use one of the available templ cargo generate ratatui/templates ``` +## Embedded and `no_std` + +Ratatui also runs on `no_std` targets such as microcontrollers, using a backend like [Mousefood]. +Turning off default features also turns off the layout cache, which matters most on these +targets, so enable it again and size it for the device: + +```toml +ratatui = { version = "0.30", default-features = false, features = ["layout-cache"] } +``` + +See [Using Ratatui without std] in the docs for details. + ## Built with Ratatui [![Awesome](https://awesome.re/badge-flat2.svg)][awesome-ratatui] @@ -96,11 +107,6 @@ cargo generate ratatui/templates Check out the [showcase] section of the website, or the [awesome-ratatui] repository for a curated list of awesome apps and libraries built with Ratatui! -## Alternatives - -- [Cursive](https://crates.io/crates/cursive) - a ncurses-based TUI library. -- [iocraft](https://crates.io/crates/iocraft) - a declarative TUI library. - ## Contributing [![Discord Badge]][Discord Server] [![Matrix Badge]][Matrix] [![Forum Badge]][Ratatui Forum] @@ -141,6 +147,8 @@ This project is licensed under the [MIT License][License]. [Ratatui Website]: https://ratatui.rs/ [Ratatui Forum]: https://forum.ratatui.rs [Docs]: https://docs.rs/ratatui +[Mousefood]: https://github.com/ratatui/mousefood +[Using Ratatui without std]: https://docs.rs/ratatui/latest/ratatui/#using-ratatui-without-std [Widget Examples]: https://github.com/ratatui/ratatui/tree/main/ratatui-widgets/examples [App Examples]: https://github.com/ratatui/ratatui/tree/main/examples [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md diff --git a/vendor/ratatui/RELEASE.md b/vendor/ratatui/RELEASE.md index b05f319..b9808f0 100644 --- a/vendor/ratatui/RELEASE.md +++ b/vendor/ratatui/RELEASE.md @@ -7,15 +7,17 @@ Our release strategy is: > > Versioning scheme being `0.x.y`, where `x` is the major version and `y` is the minor version. -[crates.io](https://crates.io/crates/ratatui) releases are automated via [GitHub -actions](.github/workflows/cd.yml) and triggered by pushing a tag. +[crates.io](https://crates.io/crates/ratatui) releases are automated by +[release-plz](https://release-plz.dev/), configured in +[release-plz.toml](./release-plz.toml) and run by the +[Release-plz](https://github.com/ratatui/ratatui/actions/workflows/release-plz.yml) workflow. 1. Record a new demo gif if necessary. The preferred tool for this is [vhs](https://github.com/charmbracelet/vhs) (installation instructions in README). ```shell - cargo build --example demo2 - vhs examples/demo2.tape + cargo build -p demo2 + vhs examples/vhs/demo2.tape ``` 1. Switch branches to the images branch and copy demo2.gif to examples/, commit, and push. @@ -23,29 +25,16 @@ actions](.github/workflows/cd.yml) and triggered by pushing a tag. append `?raw=true` to redirect to the actual image url. Then update the link in the main README. Avoid adding the gif to the git repo as binary files tend to bloat repositories. -1. Bump the version in [Cargo.toml](Cargo.toml). -1. Ensure [CHANGELOG.md](CHANGELOG.md) is updated. [git-cliff](https://github.com/orhun/git-cliff) - can be used for generating the entries. 1. Ensure that any breaking changes are documented in [BREAKING-CHANGES.md](./BREAKING-CHANGES.md) -1. Commit and push the changes. -1. Create a new tag: `git tag -a v[0.x.y]` -1. Push the tag: `git push --tags` -1. Wait for [Continuous Deployment](https://github.com/ratatui/ratatui/actions) workflow to - finish. - -## Alpha Releases - -Alpha releases are automatically released every Saturday via [cd.yml](./.github/workflows/cd.yml) -and can be manually created when necessary by triggering the [Continuous -Deployment](https://github.com/ratatui/ratatui/actions/workflows/cd.yml) workflow. - -We automatically release an alpha release with a patch level bump + alpha.num weekly (and when we -need to manually). E.g. the last release was 0.22.0, and the most recent alpha release is -0.22.1-alpha.1. - -These releases will have whatever happened to be in main at the time of release, so they're useful -for apps that need to get releases from crates.io, but may contain more bugs and be generally less -tested than normal releases. - -See [#147](https://github.com/ratatui/ratatui/issues/147) and -[#359](https://github.com/ratatui/ratatui/pull/359) for more info on the alpha release process. +1. Commit and push the changes to `main`. +1. Run the [Release-plz + workflow](https://github.com/ratatui/ratatui/actions/workflows/release-plz.yml) manually on + `main` (Actions → Release-plz → Run workflow, or `gh workflow run release-plz.yml --ref main`). + This opens (or updates) a release PR that bumps the version in + [Cargo.toml](Cargo.toml) and updates [CHANGELOG.md](CHANGELOG.md) (generated via + [git-cliff](https://github.com/orhun/git-cliff), configured in [cliff.toml](./cliff.toml)). +1. Merging that release PR into `main` triggers the release job: it tags the release (e.g. + `ratatui-v0.30.2`), publishes to [crates.io](https://crates.io/crates/ratatui), and creates a + GitHub Release. Watch the [Release-plz + workflow](https://github.com/ratatui/ratatui/actions/workflows/release-plz.yml) run to + completion. diff --git a/vendor/ratatui/assets/logo-inverted.svg b/vendor/ratatui/assets/logo-inverted.svg new file mode 100644 index 0000000..fb85e2e --- /dev/null +++ b/vendor/ratatui/assets/logo-inverted.svg @@ -0,0 +1 @@ +Ratatui \ No newline at end of file diff --git a/vendor/ratatui/cliff.toml b/vendor/ratatui/cliff.toml index 696c5db..e927504 100644 --- a/vendor/ratatui/cliff.toml +++ b/vendor/ratatui/cliff.toml @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. """ # template for the changelog body -# https://keats.github.io/tera/docs/#introduction +# https://git-cliff.org/docs/templating/syntax # note that the - before / after the % controls whether whitespace is rendered between each line. # Getting this right so that the markdown renders with the correct number of lines between headings # code fences and list items is pretty finicky. Note also that the 4 backticks in the commit macro diff --git a/vendor/ratatui/examples/README.md b/vendor/ratatui/examples/README.md index 213963b..7a6959f 100644 --- a/vendor/ratatui/examples/README.md +++ b/vendor/ratatui/examples/README.md @@ -57,13 +57,13 @@ easily be productive in creating applications: This is the original demo example from the main README. It is available for each of the backends. [Source](./apps/demo/). -![Demo](demo.gif) +![Demo][demo.gif] ## Demo2 This is the demo example from the main README and crate page. [Source](./apps/demo2/). -![Demo2](demo2.gif) +![Demo2][demo2.gif] ## Async GitHub @@ -73,7 +73,9 @@ Shows how to fetch data from GitHub API asynchronously. [Source](./apps/async-gi ## Calendar Explorer -Shows how to render a calendar with different styles. [Source](./apps/calendar-explorer/). +Shows how to render a calendar with different styles. This now lives with the calendar widget in +[`ratatui-calendar/examples`](../ratatui-calendar/examples/calendar-explorer.rs), alongside smaller +calendar examples. ![Calendar explorer demo][calendar-explorer.gif] @@ -103,7 +105,8 @@ Shows the full range of RGB colors in an animation. [Source](./apps/colors-rgb/) ## Constraint Explorer -Shows how different constraints can be used to layout widgets. [Source](./apps/constraint-explorer/). +An interactive layout playground for experimenting with constraint types and values, spacing, and +`Flex` modes. [Source](./apps/constraint-explorer/). ![Constraint Explorer demo][constraint-explorer.gif] @@ -198,6 +201,13 @@ Shows how to create an interactive table. [Source](./apps/table/). ![Table demo][table.gif] +## Table detail TEA + +Shows how to structure an app with the Elm architecture, using commands for background work and a +tick that only runs while loading. [Source](./apps/table-detail-tea/). + +![Table detail tea demo][table-detail-tea.gif] + ## Todo List Shows how to create a simple todo list application. [Source](./apps/todo-list/). @@ -263,6 +273,8 @@ vhs/generate.bash [constraint-explorer.gif]: https://github.com/ratatui/ratatui/blob/images/examples/constraint-explorer.gif?raw=true [constraints.gif]: https://github.com/ratatui/ratatui/blob/images/examples/constraints.gif?raw=true [custom-widget.gif]: https://github.com/ratatui/ratatui/blob/images/examples/custom-widget.gif?raw=true +[demo.gif]: https://github.com/ratatui/ratatui/blob/images/examples/demo.gif?raw=true +[demo2.gif]: https://github.com/ratatui/ratatui/blob/images/examples/demo2.gif?raw=true [flex.gif]: https://github.com/ratatui/ratatui/blob/images/examples/flex.gif?raw=true [hello-world.gif]: https://github.com/ratatui/ratatui/blob/images/examples/hello-world.gif?raw=true [hyperlink.gif]: https://github.com/ratatui/ratatui/blob/images/examples/hyperlink.gif?raw=true @@ -274,6 +286,7 @@ vhs/generate.bash [popup.gif]: https://github.com/ratatui/ratatui/blob/images/examples/popup.gif?raw=true [scrollbar.gif]: https://github.com/ratatui/ratatui/blob/images/examples/scrollbar.gif?raw=true [table.gif]: https://github.com/ratatui/ratatui/blob/images/examples/table.gif?raw=true +[table-detail-tea.gif]: https://github.com/ratatui/ratatui/blob/images/examples/table-detail-tea.gif?raw=true [todo-list.gif]: https://github.com/ratatui/ratatui/blob/images/examples/todo-list.gif?raw=true [tracing.gif]: https://github.com/ratatui/ratatui/blob/images/examples/tracing.gif?raw=true [user-input.gif]: https://github.com/ratatui/ratatui/blob/images/examples/user-input.gif?raw=true diff --git a/vendor/ratatui/examples/apps/async-github/Cargo.toml b/vendor/ratatui/examples/apps/async-github/Cargo.toml index 61af3a8..071b19b 100644 --- a/vendor/ratatui/examples/apps/async-github/Cargo.toml +++ b/vendor/ratatui/examples/apps/async-github/Cargo.toml @@ -1,7 +1,6 @@ [package] name = "async-github" publish = false -authors.workspace = true documentation.workspace = true repository.workspace = true homepage.workspace = true @@ -20,3 +19,6 @@ octocrab.workspace = true ratatui.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tokio-stream.workspace = true + +[lints] +workspace = true diff --git a/vendor/ratatui/examples/apps/async-github/src/main.rs b/vendor/ratatui/examples/apps/async-github/src/main.rs index 622f248..b0fd712 100644 --- a/vendor/ratatui/examples/apps/async-github/src/main.rs +++ b/vendor/ratatui/examples/apps/async-github/src/main.rs @@ -39,7 +39,9 @@ use ratatui::buffer::Buffer; use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::style::{Style, Stylize}; use ratatui::text::Line; -use ratatui::widgets::{Block, HighlightSpacing, Row, StatefulWidget, Table, TableState, Widget}; +use ratatui::widgets::{ + Block, Row, StatefulWidget, Table, TableHighlightSpacing, TableState, Widget, +}; use ratatui::{DefaultTerminal, Frame}; use tokio_stream::StreamExt; @@ -189,7 +191,7 @@ type OctoPullRequest = octocrab::models::pulls::PullRequest; impl PullRequest { fn from_octo(pr: &OctoPullRequest) -> Option { Some(Self { - id: pr.number?.to_string(), + id: pr.number.to_string(), title: pr.title.clone()?, url: pr.html_url.as_ref()?.to_string(), }) @@ -216,7 +218,7 @@ impl Widget for &PullRequestListWidget { ]; let table = Table::new(rows, widths) .block(block) - .highlight_spacing(HighlightSpacing::Always) + .highlight_spacing(TableHighlightSpacing::Always) .highlight_symbol(">>") .row_highlight_style(Style::new().on_blue()); diff --git a/vendor/ratatui/examples/apps/calendar-explorer/README.md b/vendor/ratatui/examples/apps/calendar-explorer/README.md deleted file mode 100644 index 670287e..0000000 --- a/vendor/ratatui/examples/apps/calendar-explorer/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Calendar explorer demo - -This example shows how to render a calendar with different styles. - -To run this demo: - -```shell -cargo run -p calendar-explorer -``` diff --git a/vendor/ratatui/examples/apps/calendar-explorer/src/main.rs b/vendor/ratatui/examples/apps/calendar-explorer/src/main.rs deleted file mode 100644 index a0aae7d..0000000 --- a/vendor/ratatui/examples/apps/calendar-explorer/src/main.rs +++ /dev/null @@ -1,236 +0,0 @@ -//! A Ratatui example that demonstrates how to render calendar with different styles. -//! -//! Marks the holidays and seasons on the calendar. -//! -//! This example runs with the Ratatui library code in the branch that you are currently reading. -//! See the [`latest`] branch for the code which works with the most recent Ratatui release. -//! -//! [`latest`]: https://github.com/ratatui/ratatui/tree/latest -//! [`BarChart`]: https://docs.rs/ratatui/latest/ratatui/widgets/struct.BarChart.html - -use std::fmt; - -use color_eyre::Result; -use crossterm::event::{self, KeyCode}; -use ratatui::layout::{Constraint, Layout, Margin, Rect}; -use ratatui::style::{Color, Modifier, Style, Stylize}; -use ratatui::text::{Line, Text}; -use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; -use ratatui::{DefaultTerminal, Frame}; -use time::ext::NumericalDuration; -use time::{Date, Month, OffsetDateTime}; - -fn main() -> Result<()> { - color_eyre::install()?; - ratatui::run(run) -} - -/// Run the application. -fn run(terminal: &mut DefaultTerminal) -> Result<()> { - let mut selected_date = OffsetDateTime::now_local()?.date(); - let mut calendar_style = StyledCalendar::Default; - loop { - terminal.draw(|frame| render(frame, calendar_style, selected_date))?; - if let Some(key) = event::read()?.as_key_press_event() { - match key.code { - KeyCode::Char('q') => break Ok(()), - KeyCode::Char('s') => calendar_style = calendar_style.next(), - KeyCode::Char('n') | KeyCode::Tab => selected_date = next_month(selected_date), - KeyCode::Char('p') | KeyCode::BackTab => selected_date = prev_month(selected_date), - KeyCode::Char('h') | KeyCode::Left => selected_date -= 1.days(), - KeyCode::Char('j') | KeyCode::Down => selected_date += 1.weeks(), - KeyCode::Char('k') | KeyCode::Up => selected_date -= 1.weeks(), - KeyCode::Char('l') | KeyCode::Right => selected_date += 1.days(), - _ => {} - } - } - } -} - -fn next_month(date: Date) -> Date { - if date.month() == Month::December { - date.replace_month(Month::January) - .unwrap() - .replace_year(date.year() + 1) - .unwrap() - } else { - date.replace_month(date.month().next()).unwrap() - } -} - -fn prev_month(date: Date) -> Date { - if date.month() == Month::January { - date.replace_month(Month::December) - .unwrap() - .replace_year(date.year() - 1) - .unwrap() - } else { - date.replace_month(date.month().previous()).unwrap() - } -} - -/// Render the UI with a calendar. -fn render(frame: &mut Frame, calendar_style: StyledCalendar, selected_date: Date) { - let header = Text::from_iter([ - Line::from("Calendar Example".bold()), - Line::from( - " Quit | Change Style | Next Month |

Previous Month, Move", - ), - Line::from(format!( - "Current date: {selected_date} | Current style: {calendar_style}" - )), - ]); - - let [text_area, area] = frame.area().layout(&Layout::vertical([ - Constraint::Length(header.height() as u16), - Constraint::Fill(1), - ])); - frame.render_widget(header.centered(), text_area); - calendar_style - .render_year(frame, area, selected_date) - .unwrap(); -} - -#[derive(Debug, Clone, Copy)] -enum StyledCalendar { - Default, - Surrounding, - WeekdaysHeader, - SurroundingAndWeekdaysHeader, - MonthHeader, - MonthAndWeekdaysHeader, -} - -impl StyledCalendar { - // Cycle through the different styles. - const fn next(self) -> Self { - match self { - Self::Default => Self::Surrounding, - Self::Surrounding => Self::WeekdaysHeader, - Self::WeekdaysHeader => Self::SurroundingAndWeekdaysHeader, - Self::SurroundingAndWeekdaysHeader => Self::MonthHeader, - Self::MonthHeader => Self::MonthAndWeekdaysHeader, - Self::MonthAndWeekdaysHeader => Self::Default, - } - } -} - -impl fmt::Display for StyledCalendar { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Default => write!(f, "Default"), - Self::Surrounding => write!(f, "Show Surrounding"), - Self::WeekdaysHeader => write!(f, "Show Weekdays Header"), - Self::SurroundingAndWeekdaysHeader => write!(f, "Show Surrounding and Weekdays Header"), - Self::MonthHeader => write!(f, "Show Month Header"), - Self::MonthAndWeekdaysHeader => write!(f, "Show Month Header and Weekdays Header"), - } - } -} - -impl StyledCalendar { - fn render_year(self, frame: &mut Frame, area: Rect, date: Date) -> Result<()> { - let events = events(date)?; - - let vertical = Layout::vertical([Constraint::Ratio(1, 3); 3]); - let horizontal = &Layout::horizontal([Constraint::Ratio(1, 4); 4]); - let areas = area - .inner(Margin::new(1, 1)) - .layout_vec(&vertical) - .into_iter() - .flat_map(|row| row.layout_vec(horizontal)); - for (i, area) in areas.enumerate() { - let month = date - .replace_day(1) - .unwrap() - .replace_month(Month::try_from(i as u8 + 1).unwrap()) - .unwrap(); - self.render_month(frame, area, month, &events); - } - Ok(()) - } - - fn render_month(self, frame: &mut Frame, area: Rect, date: Date, events: &CalendarEventStore) { - let calendar = match self { - Self::Default => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()), - Self::Surrounding => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()) - .show_surrounding(Style::new().dim()), - Self::WeekdaysHeader => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()) - .show_weekdays_header(Style::new().bold().green()), - Self::SurroundingAndWeekdaysHeader => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()) - .show_surrounding(Style::new().dim()) - .show_weekdays_header(Style::new().bold().green()), - Self::MonthHeader => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()) - .show_month_header(Style::new().bold().green()), - Self::MonthAndWeekdaysHeader => Monthly::new(date, events) - .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) - .show_month_header(Style::default()) - .show_weekdays_header(Style::new().bold().dim().light_yellow()), - }; - frame.render_widget(calendar, area); - } -} - -/// Makes a list of dates for the current year. -fn events(selected_date: Date) -> Result { - const SELECTED: Style = Style::new() - .fg(Color::White) - .bg(Color::Red) - .add_modifier(Modifier::BOLD); - const HOLIDAY: Style = Style::new() - .fg(Color::Red) - .add_modifier(Modifier::UNDERLINED); - const SEASON: Style = Style::new() - .fg(Color::Green) - .bg(Color::Black) - .add_modifier(Modifier::UNDERLINED); - - let mut list = CalendarEventStore::today( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(Color::Blue), - ); - let y = selected_date.year(); - - // new year's - list.add(Date::from_calendar_date(y, Month::January, 1)?, HOLIDAY); - // next new_year's for December "show surrounding" - list.add(Date::from_calendar_date(y + 1, Month::January, 1)?, HOLIDAY); - // groundhog day - list.add(Date::from_calendar_date(y, Month::February, 2)?, HOLIDAY); - // april fool's - list.add(Date::from_calendar_date(y, Month::April, 1)?, HOLIDAY); - // earth day - list.add(Date::from_calendar_date(y, Month::April, 22)?, HOLIDAY); - // star wars day - list.add(Date::from_calendar_date(y, Month::May, 4)?, HOLIDAY); - // festivus - list.add(Date::from_calendar_date(y, Month::December, 23)?, HOLIDAY); - // new year's eve - list.add(Date::from_calendar_date(y, Month::December, 31)?, HOLIDAY); - - // seasons - // spring equinox - list.add(Date::from_calendar_date(y, Month::March, 22)?, SEASON); - // summer solstice - list.add(Date::from_calendar_date(y, Month::June, 21)?, SEASON); - // fall equinox - list.add(Date::from_calendar_date(y, Month::September, 22)?, SEASON); - // winter solstice - list.add(Date::from_calendar_date(y, Month::December, 21)?, SEASON); - - // selected date - list.add(selected_date, SELECTED); - - Ok(list) -} diff --git a/vendor/ratatui/examples/apps/constraint-explorer/README.md b/vendor/ratatui/examples/apps/constraint-explorer/README.md index 1996567..a877840 100644 --- a/vendor/ratatui/examples/apps/constraint-explorer/README.md +++ b/vendor/ratatui/examples/apps/constraint-explorer/README.md @@ -1,9 +1,18 @@ # Constraint explorer demo -This interactive example shows how different constraints can be used to layout widgets. +This interactive example helps build intuition for Ratatui's layout engine. Experiment with +different constraint types and values, add or remove layout blocks, change the spacing between them +(including overlap), and compare how the `Flex` modes distribute the available space. + +Use the arrow keys to select and edit a block, `1`–`6` to change its constraint type, `a` and `x` +to add or remove blocks, and `+` and `-` to change spacing. Press `q` or `Esc` to quit. + +![Constraint Explorer demo][constraint-explorer.gif] To run this demo: ```shell cargo run -p constraint-explorer ``` + +[constraint-explorer.gif]: https://github.com/ratatui/ratatui/blob/images/examples/constraint-explorer.gif?raw=true diff --git a/vendor/ratatui/examples/apps/constraint-explorer/src/main.rs b/vendor/ratatui/examples/apps/constraint-explorer/src/main.rs index e8c523e..06a7546 100644 --- a/vendor/ratatui/examples/apps/constraint-explorer/src/main.rs +++ b/vendor/ratatui/examples/apps/constraint-explorer/src/main.rs @@ -1,9 +1,9 @@ use std::cmp::Ordering; -/// A Ratatui example that demonstrates how different layout constraints work. +/// A Ratatui example that demonstrates how different layout constraints and flex modes work. /// -/// It also supports swapping constraints, adding and removing blocks, and changing the spacing -/// between blocks. +/// It compares how each flex mode distributes space and supports swapping constraints, adding +/// and removing blocks, and changing the spacing between blocks. /// /// This example runs with the Ratatui library code in the branch that you are currently /// reading. See the [`latest`] branch for the code which works with the most recent Ratatui @@ -271,7 +271,8 @@ impl App { } fn instructions() -> impl Widget { - let text = "◄ ►: select, ▲ ▼: edit, 1-6: swap, a: add, x: delete, q: quit, +/-: spacing"; + let text = + "◄ ►: select, ▲ ▼: edit, 1-6: swap, a: add, x: delete, q/Esc: quit, +/-: spacing"; Paragraph::new(text) .fg(Self::TEXT_COLOR) .centered() @@ -328,14 +329,16 @@ impl App { self.render_user_constraints_legend(user_constraints, buf); let [ + legacy, start, center, end, space_between, space_around, space_evenly, - ] = area.layout(&Layout::vertical([Length(7); 6])); + ] = area.layout(&Layout::vertical([Length(7); 7])); + self.render_layout_block(Flex::Legacy, legacy, buf); self.render_layout_block(Flex::Start, start, buf); self.render_layout_block(Flex::Center, center, buf); self.render_layout_block(Flex::End, end, buf); diff --git a/vendor/ratatui/examples/apps/constraints/README.md b/vendor/ratatui/examples/apps/constraints/README.md index cb9de80..0d72254 100644 --- a/vendor/ratatui/examples/apps/constraints/README.md +++ b/vendor/ratatui/examples/apps/constraints/README.md @@ -1,6 +1,7 @@ # Constraints demo -This example shows different types of constraints. +This example shows different types of constraints. For an interactive comparison of constraints +with flex modes and spacing, see the [Constraint Explorer](../constraint-explorer/) demo. To run this demo: diff --git a/vendor/ratatui/examples/apps/demo/Cargo.toml b/vendor/ratatui/examples/apps/demo/Cargo.toml index e4a904e..e8bd6ed 100644 --- a/vendor/ratatui/examples/apps/demo/Cargo.toml +++ b/vendor/ratatui/examples/apps/demo/Cargo.toml @@ -21,3 +21,6 @@ termwiz = { workspace = true, optional = true } [target.'cfg(not(windows))'.dependencies] termion = { workspace = true, optional = true } + +[lints] +workspace = true diff --git a/vendor/ratatui/examples/apps/demo/src/app.rs b/vendor/ratatui/examples/apps/demo/src/app.rs index e54e5f3..dff5f22 100644 --- a/vendor/ratatui/examples/apps/demo/src/app.rs +++ b/vendor/ratatui/examples/apps/demo/src/app.rs @@ -123,11 +123,11 @@ impl<'a> TabsState<'a> { pub const fn new(titles: Vec<&'a str>) -> Self { Self { titles, index: 0 } } - pub fn next(&mut self) { + pub const fn next(&mut self) { self.index = (self.index + 1) % self.titles.len(); } - pub fn previous(&mut self) { + pub const fn previous(&mut self) { if self.index > 0 { self.index -= 1; } else { @@ -149,7 +149,7 @@ impl StatefulList { } } - pub fn next(&mut self) { + pub const fn next(&mut self) { let i = match self.state.selected() { Some(i) => { if i >= self.items.len() - 1 { @@ -163,7 +163,7 @@ impl StatefulList { self.state.select(Some(i)); } - pub fn previous(&mut self) { + pub const fn previous(&mut self) { let i = match self.state.selected() { Some(i) => { if i == 0 { @@ -297,23 +297,23 @@ impl<'a> App<'a> { } } - pub fn on_up(&mut self) { + pub const fn on_up(&mut self) { self.tasks.previous(); } - pub fn on_down(&mut self) { + pub const fn on_down(&mut self) { self.tasks.next(); } - pub fn on_right(&mut self) { + pub const fn on_right(&mut self) { self.tabs.next(); } - pub fn on_left(&mut self) { + pub const fn on_left(&mut self) { self.tabs.previous(); } - pub fn on_key(&mut self, c: char) { + pub const fn on_key(&mut self, c: char) { match c { 'q' => { self.should_quit = true; diff --git a/vendor/ratatui/examples/apps/demo/src/main.rs b/vendor/ratatui/examples/apps/demo/src/main.rs index 459329a..3291f7b 100644 --- a/vendor/ratatui/examples/apps/demo/src/main.rs +++ b/vendor/ratatui/examples/apps/demo/src/main.rs @@ -38,7 +38,7 @@ struct Cli { tick_rate: u64, /// whether unicode symbols are used to improve the overall look of the app - #[arg(short, long, default_value_t = true)] + #[arg(short, long, default_value_t = true, action = clap::ArgAction::Set)] unicode: bool, } diff --git a/vendor/ratatui/examples/apps/demo/src/termina.rs b/vendor/ratatui/examples/apps/demo/src/termina.rs index 2251db7..a5a96eb 100644 --- a/vendor/ratatui/examples/apps/demo/src/termina.rs +++ b/vendor/ratatui/examples/apps/demo/src/termina.rs @@ -83,7 +83,7 @@ fn run_app( } } -fn is_key_event(event: &Event) -> bool { +const fn is_key_event(event: &Event) -> bool { matches!(event, Event::Key(_)) } diff --git a/vendor/ratatui/examples/apps/demo/src/ui.rs b/vendor/ratatui/examples/apps/demo/src/ui.rs index f05099f..b160784 100644 --- a/vendor/ratatui/examples/apps/demo/src/ui.rs +++ b/vendor/ratatui/examples/apps/demo/src/ui.rs @@ -27,7 +27,7 @@ pub fn render(frame: &mut Frame, app: &mut App) { 1 => draw_second_tab(frame, app, chunks[1]), 2 => draw_third_tab(frame, app, chunks[1]), _ => {} - }; + } } fn draw_first_tab(frame: &mut Frame, app: &mut App, area: Rect) { @@ -179,7 +179,7 @@ fn draw_charts(frame: &mut Frame, app: &mut App, area: Rect) { ), Span::raw(format!( "{}", - (app.signals.window[0] + app.signals.window[1]) / 2.0 + f64::midpoint(app.signals.window[0], app.signals.window[1]) )), Span::styled( format!("{}", app.signals.window[1]), diff --git a/vendor/ratatui/examples/apps/demo2/Cargo.toml b/vendor/ratatui/examples/apps/demo2/Cargo.toml index a614561..b95ddc9 100644 --- a/vendor/ratatui/examples/apps/demo2/Cargo.toml +++ b/vendor/ratatui/examples/apps/demo2/Cargo.toml @@ -15,5 +15,8 @@ rand.workspace = true rand_chacha.workspace = true ratatui = { workspace = true, features = ["all-widgets"] } strum.workspace = true -time.workspace = true +jiff = { workspace = true, features = ["std"] } unicode-width.workspace = true + +[lints] +workspace = true diff --git a/vendor/ratatui/examples/apps/demo2/src/app.rs b/vendor/ratatui/examples/apps/demo2/src/app.rs index 8981388..5fda257 100644 --- a/vendor/ratatui/examples/apps/demo2/src/app.rs +++ b/vendor/ratatui/examples/apps/demo2/src/app.rs @@ -86,12 +86,12 @@ impl App { KeyCode::Char('j') | KeyCode::Down => self.next(), KeyCode::Char('d') | KeyCode::Delete => self.destroy(), _ => {} - }; + } } Ok(()) } - fn prev(&mut self) { + const fn prev(&mut self) { match self.tab { Tab::About => self.about_tab.prev_row(), Tab::Recipe => self.recipe_tab.prev(), @@ -101,7 +101,7 @@ impl App { } } - fn next(&mut self) { + const fn next(&mut self) { match self.tab { Tab::About => self.about_tab.next_row(), Tab::Recipe => self.recipe_tab.next(), @@ -119,7 +119,7 @@ impl App { self.tab = self.tab.next(); } - fn destroy(&mut self) { + const fn destroy(&mut self) { self.mode = Mode::Destroy; } } @@ -166,7 +166,7 @@ impl App { Tab::Email => self.email_tab.render(area, buf), Tab::Traceroute => self.traceroute_tab.render(area, buf), Tab::Weather => self.weather_tab.render(area, buf), - }; + } } fn render_bottom_bar(area: Rect, buf: &mut Buffer) { diff --git a/vendor/ratatui/examples/apps/demo2/src/tabs/about.rs b/vendor/ratatui/examples/apps/demo2/src/tabs/about.rs index 2f5b240..2bb6da6 100644 --- a/vendor/ratatui/examples/apps/demo2/src/tabs/about.rs +++ b/vendor/ratatui/examples/apps/demo2/src/tabs/about.rs @@ -12,11 +12,11 @@ pub struct AboutTab { } impl AboutTab { - pub fn prev_row(&mut self) { + pub const fn prev_row(&mut self) { self.row_index = self.row_index.saturating_sub(1); } - pub fn next_row(&mut self) { + pub const fn next_row(&mut self) { self.row_index = self.row_index.saturating_add(1); } } diff --git a/vendor/ratatui/examples/apps/demo2/src/tabs/email.rs b/vendor/ratatui/examples/apps/demo2/src/tabs/email.rs index a729480..9ae059a 100644 --- a/vendor/ratatui/examples/apps/demo2/src/tabs/email.rs +++ b/vendor/ratatui/examples/apps/demo2/src/tabs/email.rs @@ -53,12 +53,12 @@ pub struct EmailTab { impl EmailTab { /// Select the previous email (with wrap around). - pub fn prev(&mut self) { + pub const fn prev(&mut self) { self.row_index = self.row_index.saturating_add(EMAILS.len() - 1) % EMAILS.len(); } /// Select the next email (with wrap around). - pub fn next(&mut self) { + pub const fn next(&mut self) { self.row_index = self.row_index.saturating_add(1) % EMAILS.len(); } } diff --git a/vendor/ratatui/examples/apps/demo2/src/tabs/recipe.rs b/vendor/ratatui/examples/apps/demo2/src/tabs/recipe.rs index e421c5c..a5070e2 100644 --- a/vendor/ratatui/examples/apps/demo2/src/tabs/recipe.rs +++ b/vendor/ratatui/examples/apps/demo2/src/tabs/recipe.rs @@ -99,12 +99,12 @@ pub struct RecipeTab { impl RecipeTab { /// Select the previous item in the ingredients list (with wrap around) - pub fn prev(&mut self) { + pub const fn prev(&mut self) { self.row_index = self.row_index.saturating_add(INGREDIENTS.len() - 1) % INGREDIENTS.len(); } /// Select the next item in the ingredients list (with wrap around) - pub fn next(&mut self) { + pub const fn next(&mut self) { self.row_index = self.row_index.saturating_add(1) % INGREDIENTS.len(); } } diff --git a/vendor/ratatui/examples/apps/demo2/src/tabs/traceroute.rs b/vendor/ratatui/examples/apps/demo2/src/tabs/traceroute.rs index 1f761d2..3280358 100644 --- a/vendor/ratatui/examples/apps/demo2/src/tabs/traceroute.rs +++ b/vendor/ratatui/examples/apps/demo2/src/tabs/traceroute.rs @@ -18,12 +18,12 @@ pub struct TracerouteTab { impl TracerouteTab { /// Select the previous row (with wrap around). - pub fn prev_row(&mut self) { + pub const fn prev_row(&mut self) { self.row_index = self.row_index.saturating_add(HOPS.len() - 1) % HOPS.len(); } /// Select the next row (with wrap around). - pub fn next_row(&mut self) { + pub const fn next_row(&mut self) { self.row_index = self.row_index.saturating_add(1) % HOPS.len(); } } diff --git a/vendor/ratatui/examples/apps/demo2/src/tabs/weather.rs b/vendor/ratatui/examples/apps/demo2/src/tabs/weather.rs index f463449..26c6adc 100644 --- a/vendor/ratatui/examples/apps/demo2/src/tabs/weather.rs +++ b/vendor/ratatui/examples/apps/demo2/src/tabs/weather.rs @@ -1,4 +1,5 @@ use itertools::Itertools; +use jiff::ZonedDateTime; use palette::Okhsv; use ratatui::buffer::Buffer; use ratatui::layout::{Constraint, Direction, Layout, Margin, Rect}; @@ -6,7 +7,6 @@ use ratatui::style::{Color, Style}; use ratatui::symbols; use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; use ratatui::widgets::{Bar, BarChart, BarGroup, Block, Clear, LineGauge, Padding, Widget}; -use time::OffsetDateTime; use crate::{RgbSwatch, THEME, color_from_oklab}; @@ -17,12 +17,12 @@ pub struct WeatherTab { impl WeatherTab { /// Simulate a download indicator by decrementing the row index. - pub fn prev(&mut self) { + pub const fn prev(&mut self) { self.download_progress = self.download_progress.saturating_sub(1); } /// Simulate a download indicator by incrementing the row index. - pub fn next(&mut self) { + pub const fn next(&mut self) { self.download_progress = self.download_progress.saturating_add(1); } } @@ -60,7 +60,7 @@ impl Widget for WeatherTab { } fn render_calendar(area: Rect, buf: &mut Buffer) { - let date = OffsetDateTime::now_utc().date(); + let date = ZonedDateTime::now().date(); Monthly::new(date, CalendarEventStore::today(Style::new().red().bold())) .block(Block::new().padding(Padding::new(0, 0, 2, 0))) .show_month_header(Style::new().bold()) diff --git a/vendor/ratatui/examples/apps/flex/README.md b/vendor/ratatui/examples/apps/flex/README.md index 03e64f1..0d7f769 100644 --- a/vendor/ratatui/examples/apps/flex/README.md +++ b/vendor/ratatui/examples/apps/flex/README.md @@ -1,6 +1,7 @@ # Flex demo -This interactive example shows how to use the flex layouts. +This interactive example shows how to use flex layouts. For an interactive comparison with different +constraint types and spacing, see the [Constraint Explorer](../constraint-explorer/) demo. To run this demo: diff --git a/vendor/ratatui/examples/apps/gauge/src/main.rs b/vendor/ratatui/examples/apps/gauge/src/main.rs index 14764fc..c7d29d1 100644 --- a/vendor/ratatui/examples/apps/gauge/src/main.rs +++ b/vendor/ratatui/examples/apps/gauge/src/main.rs @@ -5,6 +5,7 @@ /// release. /// /// [`latest`]: https://github.com/ratatui/ratatui/tree/latest +use std::sync::LazyLock; use std::time::Duration; use color_eyre::Result; @@ -17,11 +18,10 @@ use ratatui::style::{Color, Style, Stylize}; use ratatui::text::{Line, Span}; use ratatui::widgets::{Block, Borders, Gauge, Padding, Paragraph, Widget}; -const GAUGE1_COLOR: Color = tailwind::RED.c800; -const GAUGE2_COLOR: Color = tailwind::GREEN.c800; -const GAUGE3_COLOR: Color = tailwind::BLUE.c800; -const GAUGE4_COLOR: Color = tailwind::ORANGE.c800; -const CUSTOM_LABEL_COLOR: Color = tailwind::SLATE.c200; +// Colors are resolved once at startup. On terminals that don't support 24-bit color +// (e.g. Apple Terminal.app before build 465) the truecolor tailwind palette looks bad, +// so we fall back to 4-bit/indexed colors. See issue #1972. +static THEME: LazyLock = LazyLock::new(Theme::new); #[derive(Debug, Default, Clone, Copy)] struct App { @@ -122,14 +122,14 @@ fn render_header(area: Rect, buf: &mut Buffer) { Paragraph::new("Ratatui Gauge Example") .bold() .alignment(Alignment::Center) - .fg(CUSTOM_LABEL_COLOR) + .fg(THEME.custom_label) .render(area, buf); } fn render_footer(area: Rect, buf: &mut Buffer) { Paragraph::new("Press ENTER to start") .alignment(Alignment::Center) - .fg(CUSTOM_LABEL_COLOR) + .fg(THEME.custom_label) .bold() .render(area, buf); } @@ -139,7 +139,7 @@ impl App { let title = title_block("Gauge with percentage"); Gauge::default() .block(title) - .gauge_style(GAUGE1_COLOR) + .gauge_style(THEME.gauge1) .percent(self.progress1) .render(area, buf); } @@ -148,11 +148,11 @@ impl App { let title = title_block("Gauge with ratio and custom label"); let label = Span::styled( format!("{:.1}/100", self.progress2), - Style::new().italic().bold().fg(CUSTOM_LABEL_COLOR), + Style::new().italic().bold().fg(THEME.custom_label), ); Gauge::default() .block(title) - .gauge_style(GAUGE2_COLOR) + .gauge_style(THEME.gauge2) .ratio(self.progress2 / 100.0) .label(label) .render(area, buf); @@ -163,7 +163,7 @@ impl App { let label = format!("{:.1}%", self.progress3); Gauge::default() .block(title) - .gauge_style(GAUGE3_COLOR) + .gauge_style(THEME.gauge3) .ratio(self.progress3 / 100.0) .label(label) .render(area, buf); @@ -174,7 +174,7 @@ impl App { let label = format!("{:.1}%", self.progress3); Gauge::default() .block(title) - .gauge_style(GAUGE4_COLOR) + .gauge_style(THEME.gauge4) .ratio(self.progress4 / 100.0) .label(label) .use_unicode(true) @@ -188,5 +188,61 @@ fn title_block(title: &str) -> Block<'_> { .borders(Borders::NONE) .padding(Padding::vertical(1)) .title(title) - .fg(CUSTOM_LABEL_COLOR) + .fg(THEME.custom_label) +} + +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +struct Theme { + gauge1: Color, + gauge2: Color, + gauge3: Color, + gauge4: Color, + custom_label: Color, +} + +impl Theme { + fn new() -> Self { + use tailwind::{BLUE, GREEN, ORANGE, RED, SLATE}; + + let is_true_color = Self::is_true_color_supported(); + let color = |true_color, ansi_color| { + if is_true_color { + true_color + } else { + ansi_color + } + }; + + // The fallbacks are 4-bit/indexed colors chosen to read reasonably on + // pre-truecolor terminals. Tune these on a real pre-Tahoe Terminal.app. + Self { + gauge1: color(RED.c800, Color::Red), + gauge2: color(GREEN.c800, Color::Green), + gauge3: color(BLUE.c800, Color::Blue), + gauge4: color(ORANGE.c800, Color::Indexed(208)), + custom_label: color(SLATE.c200, Color::Gray), + } + } + + // Checks whether truecolor (24-bit color) is supported in the current terminal. + // + // Terminals known *not* to support truecolor: + // - Apple Terminal.app: all versions before 2.15 (build 465) + // + // Environment variables used: + // - "TERM_PROGRAM": identifies the terminal application in use + // - "TERM_PROGRAM_VERSION": version number of that terminal application + fn is_true_color_supported() -> bool { + let term = std::env::var("TERM_PROGRAM").unwrap_or_default(); + if term == "Apple_Terminal" { + let term_v = std::env::var("TERM_PROGRAM_VERSION") + .unwrap_or_default() + .parse() + .unwrap_or(0); + if term_v < 465 { + return false; + } + } + true + } } diff --git a/vendor/ratatui/examples/apps/inline-resizable/README.md b/vendor/ratatui/examples/apps/inline-resizable/README.md index 3552ad2..8ee9a04 100644 --- a/vendor/ratatui/examples/apps/inline-resizable/README.md +++ b/vendor/ratatui/examples/apps/inline-resizable/README.md @@ -1,51 +1,11 @@ -# Resizable Inline Viewport +# Inline resizable demo -This example demonstrates the new resizable inline viewport functionality in Ratatui. It shows how -to create an inline viewport with a fixed height that can be dynamically resized during runtime -using the `set_viewport_height()` method. +This example demonstrates the resizable inline viewport. It shows how to create +an inline viewport with a fixed height that can be changed at runtime using +`terminal.set_viewport_height()`. -## Features +Run it with: -- **Dynamic Resizing**: Increase or decrease the viewport height in real-time -- **Interactive Controls**: Simple keyboard controls for resizing operations -- **Visual Feedback**: Live display of current height and runtime statistics -- **Message Log**: Track all resize operations with timestamps -- **Height Indicator**: Visual gauge showing current height as percentage of maximum - -## Controls - -- **`+` or `=`**: Increase viewport height (max: 20 lines) -- **`-` or `_`**: Decrease viewport height (min: 3 lines) -- **`r`**: Reset viewport to initial height (6 lines) -- **`i`**: Insert a line before the viewport using `insert_before()` -- **`q`**: Quit the application - -## Key Concepts Demonstrated - -1. **Inline Viewport Creation**: Using `Viewport::Inline(height)` to create a viewport that appears - inline with terminal content -2. **Dynamic Resizing**: Using `terminal.set_viewport_height(new_height)` to change the viewport - size after creation -3. **Content Insertion**: Using `terminal.insert_before(height, draw_fn)` to add content above the viewport -4. **Buffer Management**: The terminal automatically handles buffer reallocation and clearing when resizing -5. **Event Handling**: Responding to keyboard input to trigger resize and insertion operations - -## Running the Example - -```bash -cargo run --project inline-resizable +```shell +cargo run -p inline-resizable ``` - -## Code Structure - -- **AppState**: Manages application state including current height, messages, and statistics -- **Event Handling**: Separate thread for input and tick events -- **Render Function**: Displays the UI with status information, controls, message log, and height gauge -- **Resize Logic**: Handles viewport height changes with validation and feedback - -## Implementation Notes - -- The viewport height is constrained between 3 and 20 lines for demonstration purposes -- Each resize operation is logged to show the functionality in action -- The example uses a tick-based rendering system to update runtime statistics -- Auto-resize is handled for terminal window changes diff --git a/vendor/ratatui/examples/apps/inline-resizable/src/main.rs b/vendor/ratatui/examples/apps/inline-resizable/src/main.rs index 64dd7ed..e46378a 100644 --- a/vendor/ratatui/examples/apps/inline-resizable/src/main.rs +++ b/vendor/ratatui/examples/apps/inline-resizable/src/main.rs @@ -25,7 +25,7 @@ use ratatui::layout::{Constraint, Layout}; use ratatui::macros::line; use ratatui::style::{Color, Stylize}; use ratatui::text::Span; -use ratatui::widgets::{Block, Gauge, List, ListItem}; +use ratatui::widgets::{Block, Gauge, List, ListItem, Widget}; use ratatui::{DefaultTerminal, Frame, TerminalOptions, Viewport}; const INITIAL_HEIGHT: u16 = 6; @@ -123,10 +123,21 @@ impl App { terminal.set_viewport_height(self.height) } - fn insert_line(&mut self, _terminal: &mut DefaultTerminal) -> io::Result<()> { + fn insert_line(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> { self.insert_count += 1; let message = format!("Inserted line #{}", self.insert_count); self.messages.push(message); + + let now = self.start_time.elapsed(); + terminal.insert_before(1, |buf| { + let inserted_line = format!( + "📝 Inserted line #{} at {:02}:{:02}", + self.insert_count, + now.as_secs() / 60, + now.as_secs() % 60 + ); + inserted_line.green().bold().render(buf.area, buf); + })?; Ok(()) } @@ -181,11 +192,11 @@ impl App { frame.render_widget(message_list, messages_area); // Bottom info with dynamic gauge showing height percentage - let height_percentage = (f64::from(self.height) / 20.0).min(1.0); + let height_percentage = (f64::from(self.height) / f64::from(MAX_HEIGHT)).min(1.0); let gauge = Gauge::default() .gauge_style(Color::Blue) .ratio(height_percentage) - .label(format!("Height: {}/20", self.height)); + .label(format!("Height: {}/{MAX_HEIGHT}", self.height)); frame.render_widget(gauge, bottom_area); } } diff --git a/vendor/ratatui/examples/apps/inline/README.md b/vendor/ratatui/examples/apps/inline/README.md index cb6f447..eaf0ae1 100644 --- a/vendor/ratatui/examples/apps/inline/README.md +++ b/vendor/ratatui/examples/apps/inline/README.md @@ -1,6 +1,10 @@ # Inline demo -This example shows how to use the inlined viewport to render in a specific area of the screen. +This example shows how to use an inline viewport to render in a specific area of the screen. + +It simulates a small pool of workers downloading a queue of files. The viewport shows the total +progress and a row for each worker, and each finished download is printed above the viewport with +`Terminal::insert_before`, so it stays in the terminal's scrollback. To run this demo: diff --git a/vendor/ratatui/examples/apps/inline/src/main.rs b/vendor/ratatui/examples/apps/inline/src/main.rs index 30790fb..d496da8 100644 --- a/vendor/ratatui/examples/apps/inline/src/main.rs +++ b/vendor/ratatui/examples/apps/inline/src/main.rs @@ -1,269 +1,380 @@ -/// A Ratatui example that demonstrates how to use the inlined viewport. +/// A Ratatui example that demonstrates how to use an inline viewport. /// -/// It shows a list of downloads in progress, with a progress bar for each download. +/// The example simulates downloading a queue of files using a small pool of worker threads. +/// There are more downloads ([`NUM_DOWNLOADS`]) than workers ([`NUM_WORKERS`]), so each worker +/// runs one download at a time and takes the next download from the queue when it finishes. +/// +/// The inline viewport shows the total progress and one row per worker, with that worker's +/// current download and a progress bar. When a download finishes, a line naming the worker and +/// the download is printed above the viewport with [`Terminal::insert_before`], so it stays in +/// the terminal's scrollback after the example exits. +/// +/// Press `q` or `Ctrl+C` to quit early. /// /// This example runs with the Ratatui library code in the branch that you are currently /// reading. See the [`latest`] branch for the code which works with the most recent Ratatui /// release. /// +/// [`Terminal::insert_before`]: ratatui::Terminal::insert_before /// [`latest`]: https://github.com/ratatui/ratatui/tree/latest -use std::{ - collections::{BTreeMap, VecDeque}, - sync::mpsc, - thread, - time::{Duration, Instant}, -}; +use std::collections::VecDeque; +use std::sync::mpsc::{self, SendError}; +use std::time::{Duration, Instant}; +use std::{io, thread}; use color_eyre::Result; -use crossterm::event; +use crossterm::event::{self, KeyCode, KeyModifiers}; use rand::distr::{Distribution, Uniform}; -use ratatui::backend::Backend; +use ratatui::buffer::Buffer; use ratatui::layout::{Constraint, Layout, Rect}; -use ratatui::style::{Color, Modifier, Style}; +use ratatui::macros::{line, span}; +use ratatui::style::{Color, Stylize}; use ratatui::text::{Line, Span}; -use ratatui::widgets::{Block, Gauge, LineGauge, List, ListItem}; -use ratatui::{Frame, Terminal, TerminalOptions, Viewport, symbols}; +use ratatui::widgets::{Gauge, LineGauge, Widget}; +use ratatui::{DefaultTerminal, TerminalOptions, Viewport}; + +/// How many downloads are queued at the start. +const NUM_DOWNLOADS: u32 = 10; + +/// How many worker threads run the downloads. +/// +/// This is fewer than [`NUM_DOWNLOADS`], so at most this many downloads run at the same time and +/// the rest wait in the queue. Each worker has its own row in the viewport. +const NUM_WORKERS: usize = 4; + +/// How long to wait for a key press before redrawing and applying worker updates. +const TICK_RATE: Duration = Duration::from_millis(200); +/// Runs the example in an inline viewport, restoring the terminal afterwards. +/// +/// The viewport is 6 lines high: the total progress, a blank line, and one row for each of the +/// [`NUM_WORKERS`] workers. fn main() -> Result<()> { color_eyre::install()?; let mut terminal = ratatui::init_with_options(TerminalOptions { - viewport: Viewport::Inline(8), + viewport: Viewport::Inline(6), }); + let result = App::new().run(&mut terminal); + ratatui::restore(); + result +} + +/// A queue of downloads and the pool of workers that take downloads from it. +struct App { + /// Downloads waiting for a free worker, in the order they will start. + queue: VecDeque, + /// The workers, indexed by worker id, each with the download it is running. + workers: Vec, + /// How many downloads have finished. + finished: u32, + /// Receives progress updates from all of the worker threads. + update_rx: mpsc::Receiver, +} - let (tx, rx) = mpsc::channel(); - input_handling(tx.clone()); - let workers = workers(tx); - let mut downloads = downloads(); +impl App { + /// Spawns the worker threads, with an empty queue of downloads. + fn new() -> Self { + let (update_tx, update_rx) = mpsc::channel(); + let workers = (0..NUM_WORKERS) + .map(|id| Worker::spawn(id, update_tx.clone())) + .collect(); - for w in &workers { - let d = downloads.next(w.id).unwrap(); - w.tx.send(d).unwrap(); + Self { + queue: VecDeque::new(), + workers, + finished: 0, + update_rx, + } } - let app_result = run(&mut terminal, workers, downloads, rx); + /// Runs until every download has finished or the user presses `q` or `Ctrl+C`. + fn run(mut self, terminal: &mut DefaultTerminal) -> Result<()> { + self.queue_downloads(); + for worker_id in 0..NUM_WORKERS { + self.start_next_download(worker_id)?; + } - ratatui::restore(); + while !self.is_finished() { + terminal.draw(|frame| frame.render_widget(&self, frame.area()))?; + if Self::quit_requested()? { + return Self::print_line(terminal, self.cancelled_line()); + } + self.apply_updates(terminal)?; + } + Self::print_line(terminal, line!["Done!"]) + } - app_result -} + /// Adds downloads with random sizes to the queue. + fn queue_downloads(&mut self) { + let sizes = Uniform::new(0, 1000).expect("valid range"); + let mut rng = rand::rng(); + let downloads = (0..NUM_DOWNLOADS).map(|id| Download { + id, + size: sizes.sample(&mut rng), + }); + self.queue.extend(downloads); + } -const NUM_DOWNLOADS: usize = 10; + /// Gives the worker the next download from the queue, if there is one. + fn start_next_download(&mut self, worker_id: usize) -> Result<()> { + if let Some(download) = self.queue.pop_front() { + self.workers[worker_id].start(download)?; + } + Ok(()) + } -type DownloadId = usize; -type WorkerId = usize; -enum Event { - Input(event::KeyEvent), - Tick, - Resize, - DownloadUpdate(WorkerId, DownloadId, f64), - DownloadDone(WorkerId, DownloadId), -} -struct Downloads { - pending: VecDeque, - in_progress: BTreeMap, -} + /// Whether the queue is empty and every worker is idle. + fn is_finished(&self) -> bool { + self.queue.is_empty() && self.workers.iter().all(Worker::is_idle) + } + + /// Waits up to one tick for the user to press `q` or `Ctrl+C`. + fn quit_requested() -> io::Result { + if !event::poll(TICK_RATE)? { + return Ok(false); + } + let Some(key) = event::read()?.as_key_press_event() else { + return Ok(false); + }; + let quit = match key.code { + KeyCode::Char('q') => true, + KeyCode::Char('c') => key.modifiers.contains(KeyModifiers::CONTROL), + _ => false, + }; + Ok(quit) + } -impl Downloads { - fn next(&mut self, worker_id: WorkerId) -> Option { - match self.pending.pop_front() { - Some(d) => { - self.in_progress.insert( + /// Prints a line above the inline viewport, where it stays after the example exits. + fn print_line(terminal: &mut DefaultTerminal, line: Line) -> Result<()> { + terminal.insert_before(1, |buf| line.render(buf.area, buf))?; + Ok(()) + } + + /// The line printed above the viewport when the user quits early. + fn cancelled_line(&self) -> Line<'static> { + let finished = self.finished; + let busy_workers = self.workers.iter().filter(|worker| !worker.is_idle()); + let running = busy_workers.count(); + let summary = span!(" with {finished}/{NUM_DOWNLOADS} finished and {running} running"); + line!["Cancelled".bold(), summary] + } + + /// Applies every update the worker threads have sent since the last call. + fn apply_updates(&mut self, terminal: &mut DefaultTerminal) -> Result<()> { + while let Ok(update) = self.update_rx.try_recv() { + match update { + Update::Progress { worker_id, - DownloadInProgress { - id: d.id, - started_at: Instant::now(), - progress: 0.0, - }, - ); - Some(d) + progress, + } => self.workers[worker_id].set_progress(progress), + Update::Done { worker_id } => self.finish_download(terminal, worker_id)?, } - None => None, } + Ok(()) + } + + /// Prints the worker's finished download above the viewport, then gives the now free worker + /// the next download from the queue. + fn finish_download(&mut self, terminal: &mut DefaultTerminal, worker_id: usize) -> Result<()> { + let worker = &mut self.workers[worker_id]; + if let Some(download) = worker.finish() { + self.finished += 1; + Self::print_line(terminal, worker.finished_line(&download))?; + } + self.start_next_download(worker_id) } } -struct DownloadInProgress { - id: DownloadId, - started_at: Instant, - progress: f64, + +/// Renders the total progress, then one row for each worker. +impl Widget for &App { + fn render(self, area: Rect, buf: &mut Buffer) { + let vertical = Layout::vertical([Constraint::Length(1), Constraint::Fill(1)]).spacing(1); + let [total_area, workers_area] = area.layout(&vertical); + + self.render_total_progress(total_area, buf); + for (worker, row) in self.workers.iter().zip(workers_area.rows()) { + worker.render(row, buf); + } + } } -struct Download { - id: DownloadId, - size: usize, + +impl App { + /// Renders a gauge showing how many of the downloads have finished. + fn render_total_progress(&self, area: Rect, buf: &mut Buffer) { + LineGauge::default() + .filled_style(Color::Blue) + .label(format!("{}/{NUM_DOWNLOADS}", self.finished)) + .ratio(f64::from(self.finished) / f64::from(NUM_DOWNLOADS)) + .render(area, buf); + } } + +/// The main thread's view of a worker: a handle to its thread and the download it is running. +/// +/// This follows the actor pattern: the [`WorkerThread`] owns its own state and runs on its own +/// thread, and the main thread only talks to it through this type. The thread stops once its +/// `Worker` is dropped. struct Worker { - id: WorkerId, - tx: mpsc::Sender, + /// Identifies the worker in the output. This is also its row in the viewport and its index + /// in [`App::workers`]. + id: usize, + /// Sends downloads to the worker thread. + download_tx: mpsc::Sender, + /// The download the worker is running, or `None` if it is idle. + current: Option, } -fn input_handling(tx: mpsc::Sender) { - let tick_rate = Duration::from_millis(200); - thread::spawn(move || { - let mut last_tick = Instant::now(); - loop { - // poll for tick rate duration, if no events, sent tick event. - let timeout = tick_rate.saturating_sub(last_tick.elapsed()); - if event::poll(timeout).unwrap() { - match event::read().unwrap() { - event::Event::Key(key) => tx.send(Event::Input(key)).unwrap(), - event::Event::Resize(_, _) => tx.send(Event::Resize).unwrap(), - _ => {} - } - } - if last_tick.elapsed() >= tick_rate { - tx.send(Event::Tick).unwrap(); - last_tick = Instant::now(); - } +impl Worker { + /// Spawns a worker thread with the given id, which sends its progress to `update_tx`. + fn spawn(id: usize, update_tx: mpsc::Sender) -> Self { + let (download_tx, download_rx) = mpsc::channel(); + let worker_thread = WorkerThread { + id, + download_rx, + update_tx, + }; + thread::spawn(move || worker_thread.run()); + Self { + id, + download_tx, + current: None, } - }); -} + } -#[expect(clippy::cast_precision_loss, clippy::needless_pass_by_value)] -fn workers(tx: mpsc::Sender) -> Vec { - (0..4) - .map(|id| { - let (worker_tx, worker_rx) = mpsc::channel::(); - let tx = tx.clone(); - thread::spawn(move || { - while let Ok(download) = worker_rx.recv() { - let mut remaining = download.size; - while remaining > 0 { - let wait = (remaining as u64).min(10); - thread::sleep(Duration::from_millis(wait * 10)); - remaining = remaining.saturating_sub(10); - let progress = (download.size - remaining) * 100 / download.size; - tx.send(Event::DownloadUpdate(id, download.id, progress as f64)) - .unwrap(); - } - tx.send(Event::DownloadDone(id, download.id)).unwrap(); - } - }); - Worker { id, tx: worker_tx } - }) - .collect() + /// Starts the download on this worker's thread. + /// + /// This only fails if the worker thread has stopped. + fn start(&mut self, download: Download) -> Result<()> { + self.current = Some(ActiveDownload { + id: download.id, + started_at: Instant::now(), + progress: 0.0, + }); + self.download_tx.send(download)?; + Ok(()) + } + + /// Whether the worker has no download to run. + const fn is_idle(&self) -> bool { + self.current.is_none() + } + + /// Records the progress of the worker's current download. + const fn set_progress(&mut self, progress: f64) { + if let Some(download) = &mut self.current { + download.progress = progress; + } + } + + /// Marks the worker as idle, returning the download it finished. + const fn finish(&mut self) -> Option { + self.current.take() + } + + /// The line printed above the viewport when this worker finishes a download. + fn finished_line(&self, download: &ActiveDownload) -> Line<'static> { + let name = span!("download {}", download.id).bold(); + let elapsed = span!(" in {}ms", download.started_at.elapsed().as_millis()); + line![self.label(), " finished ", name, elapsed] + } + + /// The label that identifies this worker in the viewport and in the lines printed above it. + fn label(&self) -> Span<'static> { + span!("worker {}", self.id).cyan() + } } -fn downloads() -> Downloads { - let distribution = Uniform::new(0, 1000).expect("invalid range"); - let mut rng = rand::rng(); - let pending = (0..NUM_DOWNLOADS) - .map(|id| { - let size = distribution.sample(&mut rng); - Download { id, size } - }) - .collect(); - Downloads { - pending, - in_progress: BTreeMap::new(), +/// Renders the worker's label, then its current download or that it is idle. +impl Widget for &Worker { + fn render(self, area: Rect, buf: &mut Buffer) { + let horizontal = Layout::horizontal([Constraint::Length(10), Constraint::Fill(1)]); + let [label_area, download_area] = area.layout(&horizontal); + + self.label().render(label_area, buf); + match &self.current { + Some(download) => download.render(download_area, buf), + None => "idle".dark_gray().render(download_area, buf), + } } } -#[expect(clippy::needless_pass_by_value)] -fn run( - terminal: &mut Terminal, - workers: Vec, - mut downloads: Downloads, - rx: mpsc::Receiver, -) -> Result<()> -where - B::Error: Send + Sync + 'static, -{ - let mut redraw = true; - loop { - if redraw { - terminal.draw(|frame| render(frame, &downloads))?; +/// The actor that runs on a worker's thread, simulating each download it is given. +struct WorkerThread { + /// Identifies the worker in the updates it sends. + id: usize, + /// Receives the downloads to run, one at a time. + download_rx: mpsc::Receiver, + /// Sends progress updates to the main thread. + update_tx: mpsc::Sender, +} + +impl WorkerThread { + /// Runs until the [`Worker`] is dropped or the main thread stops receiving updates. + fn run(&self) -> Result<(), SendError> { + while let Ok(download) = self.download_rx.recv() { + self.simulate(&download)?; } - redraw = true; + Ok(()) + } - match rx.recv()? { - Event::Input(event) => { - if event.code == event::KeyCode::Char('q') { - break; - } - } - Event::Resize => { - terminal.autoresize()?; - } - Event::Tick => {} - Event::DownloadUpdate(worker_id, _download_id, progress) => { - let download = downloads.in_progress.get_mut(&worker_id).unwrap(); - download.progress = progress; - redraw = false; - } - Event::DownloadDone(worker_id, _download_id) => { - let _download = downloads.in_progress.remove(&worker_id).unwrap(); - match downloads.next(worker_id) { - Some(d) => workers[worker_id].tx.send(d).unwrap(), - None => { - if downloads.in_progress.is_empty() { - break; - } - } - } - } + /// Simulates one download, sending progress updates and then a final `Done`. + /// + /// Each step downloads 10 units of the download's size and takes 100ms. + fn simulate(&self, download: &Download) -> Result<(), SendError> { + let mut downloaded = 0; + while downloaded < download.size { + thread::sleep(Duration::from_millis(100)); + downloaded = (downloaded + 10).min(download.size); + let progress = f64::from(downloaded) / f64::from(download.size); + self.update_tx.send(Update::Progress { + worker_id: self.id, + progress, + })?; } + self.update_tx.send(Update::Done { worker_id: self.id }) } - Ok(()) } -fn render(frame: &mut Frame, downloads: &Downloads) { - let area = frame.area(); - - let block = Block::new().title(Line::from("Progress").centered()); - frame.render_widget(block, area); - - let vertical = Layout::vertical([Constraint::Length(2), Constraint::Length(4)]).margin(1); - let horizontal = Layout::horizontal([Constraint::Percentage(20), Constraint::Percentage(80)]); - let [progress_area, main] = area.layout(&vertical); - let [list_area, gauge_area] = main.layout(&horizontal); - - // total progress - let done = NUM_DOWNLOADS - downloads.pending.len() - downloads.in_progress.len(); - #[expect(clippy::cast_precision_loss)] - let progress = LineGauge::default() - .filled_style(Style::default().fg(Color::Blue)) - .label(format!("{done}/{NUM_DOWNLOADS}")) - .ratio(done as f64 / NUM_DOWNLOADS as f64); - frame.render_widget(progress, progress_area); - - // in progress downloads - let items: Vec = downloads - .in_progress - .values() - .map(|download| { - ListItem::new(Line::from(vec![ - Span::raw(symbols::DOT), - Span::styled( - format!(" download {:>2}", download.id), - Style::default() - .fg(Color::LightGreen) - .add_modifier(Modifier::BOLD), - ), - Span::raw(format!( - " ({}ms)", - download.started_at.elapsed().as_millis() - )), - ])) - }) - .collect(); - let list = List::new(items); - frame.render_widget(list, list_area); - - #[expect(clippy::cast_possible_truncation)] - for (i, (_, download)) in downloads.in_progress.iter().enumerate() { - let gauge = Gauge::default() - .gauge_style(Style::default().fg(Color::Yellow)) - .ratio(download.progress / 100.0); - if gauge_area.top().saturating_add(i as u16) > area.bottom() { - continue; - } - frame.render_widget( - gauge, - Rect { - x: gauge_area.left(), - y: gauge_area.top().saturating_add(i as u16), - width: gauge_area.width, - height: 1, - }, - ); +/// Updates sent from the worker threads to the main thread. +enum Update { + /// The worker's current download has made progress, from 0.0 to 1.0. + Progress { worker_id: usize, progress: f64 }, + /// The worker has finished its current download. + Done { worker_id: usize }, +} + +/// A download to simulate, which waits in the queue until a worker takes it. +struct Download { + /// Identifies the download in the output. + id: u32, + /// The simulated size, which sets how long the download takes (see + /// [`WorkerThread::simulate`]). + size: u32, +} + +/// A download that a worker is running. +struct ActiveDownload { + /// Identifies the download in the output. + id: u32, + /// When the download was given to the worker. + started_at: Instant, + /// Progress from 0.0 to 1.0. + progress: f64, +} + +/// Renders the download's name and elapsed time, followed by a progress bar. +impl Widget for &ActiveDownload { + fn render(self, area: Rect, buf: &mut Buffer) { + let horizontal = Layout::horizontal([Constraint::Length(22), Constraint::Fill(1)]); + let [status_area, gauge_area] = area.layout(&horizontal); + + let name = span!("download {:>2}", self.id).light_green().bold(); + let elapsed = span!(" ({}ms)", self.started_at.elapsed().as_millis()); + line![name, elapsed].render(status_area, buf); + + Gauge::default() + .gauge_style(Color::Yellow) + .ratio(self.progress) + .render(gauge_area, buf); } } diff --git a/vendor/ratatui/examples/apps/modifiers/Cargo.toml b/vendor/ratatui/examples/apps/modifiers/Cargo.toml index 68529df..6741644 100644 --- a/vendor/ratatui/examples/apps/modifiers/Cargo.toml +++ b/vendor/ratatui/examples/apps/modifiers/Cargo.toml @@ -8,7 +8,6 @@ rust-version.workspace = true [dependencies] color-eyre.workspace = true crossterm.workspace = true -itertools.workspace = true ratatui.workspace = true [lints] diff --git a/vendor/ratatui/examples/apps/modifiers/src/main.rs b/vendor/ratatui/examples/apps/modifiers/src/main.rs index e5d8dc3..fe8f8e4 100644 --- a/vendor/ratatui/examples/apps/modifiers/src/main.rs +++ b/vendor/ratatui/examples/apps/modifiers/src/main.rs @@ -1,82 +1,114 @@ /// A Ratatui example that demonstrates how to use modifiers. /// -/// It will render a grid of combinations of foreground and background colors with all -/// modifiers applied to them. +/// Each row shows a modifier, each column uses a different foreground color, and tabs select +/// the background color. /// /// This example runs with the Ratatui library code in the branch that you are currently /// reading. See the [`latest`] branch for the code which works with the most recent Ratatui /// release. /// /// [`latest`]: https://github.com/ratatui/ratatui/tree/latest -use std::{error::Error, iter::once, result}; +use std::iter::{once, repeat_n}; -use crossterm::event; -use itertools::Itertools; +use color_eyre::Result; +use crossterm::event::{self, KeyCode}; use ratatui::Frame; use ratatui::layout::{Constraint, Layout}; use ratatui::style::{Color, Modifier, Style, Stylize}; use ratatui::text::Line; -use ratatui::widgets::Paragraph; +use ratatui::widgets::{Block, Cell, Paragraph, Row, Table, Tabs}; -type Result = result::Result>; +const COLORS: [(&str, Color); 5] = [ + ("Black", Color::Black), + ("Dark gray", Color::DarkGray), + ("Gray", Color::Gray), + ("White", Color::White), + ("Red", Color::Red), +]; + +const MODIFIERS: [(&str, Modifier); 14] = [ + ("None", Modifier::empty()), + ("Bold", Modifier::BOLD), + ("Dim", Modifier::DIM), + ("Italic", Modifier::ITALIC), + ("Single underline", Modifier::UNDERLINED), + ("Double underline", Modifier::DOUBLE_UNDERLINED), + ("Curly underline", Modifier::UNDER_CURLED), + ("Dotted underline", Modifier::UNDER_DOTTED), + ("Dashed underline", Modifier::UNDER_DASHED), + ("Slow blink", Modifier::SLOW_BLINK), + ("Rapid blink", Modifier::RAPID_BLINK), + ("Reversed", Modifier::REVERSED), + ("Hidden", Modifier::HIDDEN), + ("Strikethrough", Modifier::CROSSED_OUT), +]; fn main() -> Result<()> { color_eyre::install()?; + let mut background = 0; ratatui::run(|terminal| { loop { - terminal.draw(render)?; - if event::read()?.is_key_press() { - break Ok(()); + terminal.draw(|frame| render(frame, background))?; + if let Some(key) = event::read()?.as_key_press_event() { + match key.code { + KeyCode::Char('q') | KeyCode::Esc => break Ok(()), + KeyCode::Right | KeyCode::Tab => background = (background + 1) % COLORS.len(), + KeyCode::Left | KeyCode::BackTab => { + background = (background + COLORS.len() - 1) % COLORS.len(); + } + _ => {} + } } } }) } -fn render(frame: &mut Frame) { - let layout = Layout::vertical([Constraint::Length(1), Constraint::Min(0)]); - let [text_area, main_area] = frame.area().layout(&layout); +fn render(frame: &mut Frame, background: usize) { + let [area] = frame + .area() + .layout(&Layout::horizontal([Constraint::Max(76)])); + let [tabs_area, table_area, help_area] = area.layout(&Layout::vertical([ + Constraint::Length(3), + Constraint::Min(0), + Constraint::Length(2), + ])); + frame.render_widget( - Paragraph::new("Note: not all terminals support all modifiers") - .style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)), - text_area, + Tabs::new(COLORS.map(|(name, _)| name)) + .select(background) + .highlight_style(Style::new().black().on_yellow().bold()) + .block(Block::bordered().title(" Background ")), + tabs_area, ); - let layout = Layout::vertical([Constraint::Length(1); 50]) - .split(main_area) - .iter() - .flat_map(|area| { - Layout::horizontal([Constraint::Percentage(20); 5]) - .split(*area) - .to_vec() - }) - .collect_vec(); - let colors = [ - Color::Black, - Color::DarkGray, - Color::Gray, - Color::White, - Color::Red, - ]; - let all_modifiers = once(Modifier::empty()) - .chain(Modifier::all().iter()) - .collect_vec(); - let mut index = 0; - for bg in &colors { - for fg in &colors { - for modifier in &all_modifiers { - let modifier_name = format!("{modifier:11?}"); - let padding = (" ").repeat(12 - modifier_name.len()); - let paragraph = Paragraph::new(Line::from(vec![ - modifier_name.fg(*fg).bg(*bg).add_modifier(*modifier), - padding.fg(*fg).bg(*bg).add_modifier(*modifier), - // This is a hack to work around a bug in VHS which is used for rendering the - // examples to gifs. The bug is that the background color of a paragraph seems - // to bleed into the next character. - ".".black().on_black(), - ])); - frame.render_widget(paragraph, layout[index]); - index += 1; - } - } - } + let header = Row::new(once("Modifier").chain(COLORS.map(|(name, _)| name))) + .bold() + .bottom_margin(1); + let rows = MODIFIERS.map(|(name, modifier)| { + let samples = COLORS.map(|(_, foreground)| { + Cell::from("Sample").style( + Style::new() + .fg(foreground) + .bg(COLORS[background].1) + .add_modifier(modifier), + ) + }); + Row::new(once(Cell::from(name)).chain(samples)) + }); + let widths = once(Constraint::Length(16)).chain(repeat_n(Constraint::Fill(1), COLORS.len())); + frame.render_widget( + Table::new(rows, widths) + .header(header) + .column_spacing(2) + .block(Block::bordered().title(" Foreground colors ")), + table_area, + ); + frame.render_widget( + Paragraph::new(vec![ + Line::from("←/→ or Tab: background q/Esc: quit"), + Line::from("Some effects depend on your terminal; hidden samples are blank.") + .dark_gray(), + ]), + help_area, + ); } diff --git a/vendor/ratatui/examples/apps/panic/src/main.rs b/vendor/ratatui/examples/apps/panic/src/main.rs index a61af2b..a199bef 100644 --- a/vendor/ratatui/examples/apps/panic/src/main.rs +++ b/vendor/ratatui/examples/apps/panic/src/main.rs @@ -51,7 +51,9 @@ fn main() -> Result<()> { if let Some(key) = event::read()?.as_key_press_event() { match key.code { KeyCode::Char('p') => panic!("intentional demo panic"), - KeyCode::Char('e') => bail!("intentional demo error"), + KeyCode::Char('e') => { + bail!("intentional demo error"); + } KeyCode::Char('h') => { let _ = std::panic::take_hook(); panic_hook_state = PanicHandlerState::Disabled; diff --git a/vendor/ratatui/examples/apps/scrollbar/src/main.rs b/vendor/ratatui/examples/apps/scrollbar/src/main.rs index 0963982..01ada55 100644 --- a/vendor/ratatui/examples/apps/scrollbar/src/main.rs +++ b/vendor/ratatui/examples/apps/scrollbar/src/main.rs @@ -9,7 +9,6 @@ /// /// [`latest`]: https://github.com/ratatui/ratatui/tree/latest use std::rc::Rc; -use std::time::{Duration, Instant}; use color_eyre::Result; use crossterm::event::{self, KeyCode}; @@ -35,16 +34,8 @@ fn main() -> Result<()> { impl App { fn run(mut self, terminal: &mut DefaultTerminal) -> Result<()> { - let tick_rate = Duration::from_millis(250); - let mut last_tick = Instant::now(); loop { terminal.draw(|frame| self.render(frame))?; - - let timeout = tick_rate.saturating_sub(last_tick.elapsed()); - if !event::poll(timeout)? { - last_tick = Instant::now(); - continue; - } if let Some(key) = event::read()?.as_key_press_event() { match key.code { KeyCode::Char('q') => return Ok(()), diff --git a/vendor/ratatui/examples/apps/calendar-explorer/Cargo.toml b/vendor/ratatui/examples/apps/table-detail-tea/Cargo.toml similarity index 71% rename from vendor/ratatui/examples/apps/calendar-explorer/Cargo.toml rename to vendor/ratatui/examples/apps/table-detail-tea/Cargo.toml index a3862ca..9c16921 100644 --- a/vendor/ratatui/examples/apps/calendar-explorer/Cargo.toml +++ b/vendor/ratatui/examples/apps/table-detail-tea/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "calendar-explorer" +name = "table-detail-tea" publish = false license.workspace = true edition.workspace = true @@ -9,7 +9,6 @@ rust-version.workspace = true color-eyre.workspace = true crossterm.workspace = true ratatui.workspace = true -time = { workspace = true, features = ["formatting", "parsing"] } [lints] workspace = true diff --git a/vendor/ratatui/examples/apps/table-detail-tea/README.md b/vendor/ratatui/examples/apps/table-detail-tea/README.md new file mode 100644 index 0000000..ef416bf --- /dev/null +++ b/vendor/ratatui/examples/apps/table-detail-tea/README.md @@ -0,0 +1,12 @@ +# Table detail TEA demo + +This example shows how to structure an app with [the Elm architecture (TEA)][TEA]: a table of teas +with a detail view, loaded in the background with a spinner while it waits. + +[TEA]: https://guide.elm-lang.org/architecture/ + +To run this demo: + +```shell +cargo run -p table-detail-tea +``` diff --git a/vendor/ratatui/examples/apps/table-detail-tea/src/main.rs b/vendor/ratatui/examples/apps/table-detail-tea/src/main.rs new file mode 100644 index 0000000..10924da --- /dev/null +++ b/vendor/ratatui/examples/apps/table-detail-tea/src/main.rs @@ -0,0 +1,481 @@ +//! A Ratatui example that demonstrates the Elm architecture (TEA) with a table and a detail view. +//! +//! TEA splits an app into a model, the messages that change it, an `update` function that applies +//! a message to the model, and a `view` function that renders the model. Here that is [`Model`], +//! [`Message`], [`Model::update`] and [`Model::view`]. +//! +//! `update` never performs side effects. It returns a [`Command`] (Elm's `Cmd`) describing the +//! effect, and the runtime in [`run`] performs it and feeds any result back in as another message. +//! Loading the teas works this way: a background thread stands in for a slow source such as a +//! network request. Its result comes back as a `Result`, so a failed load gets its own state in +//! [`Model`], even though this stand-in never fails. +//! +//! Elm's subscriptions are the sources of messages besides commands. Terminal input is always on, +//! and [`Model::tick_rate`] asks for ticks only while the spinner is showing, so an idle app only +//! wakes up for input. +//! +//! ```text +//! Terminal input / ticks ─┐ +//! ├--> Message --> update --> Model --> view --> Screen +//! Command result ─────────┘ │ +//! └--> Command --> Runtime --> Command result +//! ``` +//! +//! Unlike Elm, `update` changes the model through `&mut self` instead of returning a new one, so +//! the model doesn't have to be rebuilt for every message. The data still flows one way: the only +//! thing `view` writes back is the table's scroll offset. +//! +//! With an async runtime, only the runtime changes: [`run`] becomes a `select!` over the terminal +//! events, the command results and an interval while [`Model::tick_rate`] asks for one, and the +//! commands become spawned tasks. [`Model`] and [`Message`] stay as they are. +//! +//! This example runs with the Ratatui library code in the branch that you are currently reading. +//! See the [`latest`] branch for the code which works with the most recent Ratatui release. +//! +//! [`latest`]: https://github.com/ratatui/ratatui/tree/latest + +use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender}; +use std::time::{Duration, Instant}; +use std::{io, thread}; + +use color_eyre::Result; +use crossterm::event::{self, Event, KeyCode}; +use ratatui::layout::{Constraint, Layout}; +use ratatui::style::{Style, Stylize}; +use ratatui::widgets::{Block, Padding, Paragraph, Row, Table, TableState, Wrap}; +use ratatui::{DefaultTerminal, Frame}; + +const TICK_RATE: Duration = Duration::from_millis(80); +const LOAD_TIME: Duration = Duration::from_secs(2); +const SPINNER: [char; 10] = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; + +const TEAS: [Tea; 14] = [ + Tea { + name: "Sencha", + kind: "Green", + origin: "Japan", + temperature: "75 °C", + steep: "1-2 minutes", + note: "Japan's everyday green tea, steamed rather than pan-fired.", + }, + Tea { + name: "Gyokuro", + kind: "Green", + origin: "Japan", + temperature: "60 °C", + steep: "2 minutes", + note: "Shaded for weeks before picking, which makes it sweet and savoury.", + }, + Tea { + name: "Longjing", + kind: "Green", + origin: "Zhejiang, China", + temperature: "80 °C", + steep: "2-3 minutes", + note: "Also called Dragon Well. Pan-fired into flat, smooth leaves.", + }, + Tea { + name: "Bai Mudan", + kind: "White", + origin: "Fujian, China", + temperature: "85 °C", + steep: "3-4 minutes", + note: "White Peony: buds and young leaves, only withered and dried.", + }, + Tea { + name: "Tieguanyin", + kind: "Oolong", + origin: "Fujian, China", + temperature: "95 °C", + steep: "1-3 minutes", + note: "A rolled, floral oolong that holds up to many infusions.", + }, + Tea { + name: "Da Hong Pao", + kind: "Oolong", + origin: "Fujian, China", + temperature: "95 °C", + steep: "1-3 minutes", + note: "A roasted rock oolong from the Wuyi mountains.", + }, + Tea { + name: "Dongfang Meiren", + kind: "Oolong", + origin: "Hsinchu, Taiwan", + temperature: "85 °C", + steep: "3 minutes", + note: "Also called Oriental Beauty. Leafhopper bites give it a honey taste.", + }, + Tea { + name: "Darjeeling", + kind: "Black", + origin: "India", + temperature: "90 °C", + steep: "3 minutes", + note: "Grown in the Himalayan foothills. The first flush is light and floral.", + }, + Tea { + name: "Assam", + kind: "Black", + origin: "India", + temperature: "100 °C", + steep: "3-5 minutes", + note: "Strong and malty, a common base for breakfast blends.", + }, + Tea { + name: "Ostfriesentee", + kind: "Black", + origin: "East Frisia, Germany", + temperature: "100 °C", + steep: "3-5 minutes", + note: "A strong Assam blend, poured over rock sugar and topped with unstirred cream.", + }, + Tea { + name: "Keemun", + kind: "Black", + origin: "Anhui, China", + temperature: "90 °C", + steep: "3-4 minutes", + note: "A smooth Chinese black tea, often used in breakfast blends too.", + }, + Tea { + name: "Lapsang Souchong", + kind: "Black", + origin: "Fujian, China", + temperature: "95 °C", + steep: "3 minutes", + note: "Dried over pine fires, which gives it a smoky taste.", + }, + Tea { + name: "Pu-erh", + kind: "Dark", + origin: "Yunnan, China", + temperature: "100 °C", + steep: "1-2 minutes", + note: "Fermented and aged, often pressed into cakes.", + }, + Tea { + name: "Rooibos", + kind: "Herbal", + origin: "South Africa", + temperature: "100 °C", + steep: "5 minutes", + note: "Not tea at all but a caffeine-free bush, steeped the same way.", + }, +]; + +#[derive(Clone, Copy)] +struct Tea { + name: &'static str, + kind: &'static str, + origin: &'static str, + temperature: &'static str, + steep: &'static str, + note: &'static str, +} + +impl Tea { + const COLUMNS: [&str; 3] = ["Name", "Kind", "Origin"]; +} + +impl From<&Tea> for Row<'static> { + fn from(tea: &Tea) -> Self { + Self::new([tea.name, tea.kind, tea.origin]) + } +} + +/// The whole state of the app. Each variant holds only what exists in that state, so there is no +/// selection to get wrong while the teas are still loading. +enum Model { + Loading { spinner: usize }, + Loaded { teas: Vec, table: TableState }, + Failed { error: String }, +} + +/// Everything that can happen to the model. +enum Message { + GotTeas(Result, String>), + Tick, + SelectNext, + SelectPrevious, + Reload, + Quit, +} + +impl Message { + fn from_event(event: &Event) -> Option { + match event.as_key_press_event()?.code { + KeyCode::Char('j') | KeyCode::Down => Some(Self::SelectNext), + KeyCode::Char('k') | KeyCode::Up => Some(Self::SelectPrevious), + KeyCode::Char('r') => Some(Self::Reload), + KeyCode::Char('q') | KeyCode::Esc => Some(Self::Quit), + _ => None, + } + } +} + +/// A side effect that `update` asks the runtime to perform. +enum Command { + LoadTeas, + Quit, +} + +/// What wakes the runtime up, besides ticks. +enum RuntimeEvent { + Message(Message), + /// The terminal changed size, which needs a redraw but doesn't change the model. + Resize, + InputFailed(io::Error), +} + +impl Model { + const fn init() -> (Self, Option) { + (Self::Loading { spinner: 0 }, Some(Command::LoadTeas)) + } + + fn update(&mut self, message: Message) -> Option { + match (message, &mut *self) { + (Message::Quit, _) => return Some(Command::Quit), + (Message::Reload, Self::Loaded { .. } | Self::Failed { .. }) => { + let (model, command) = Self::init(); + *self = model; + return command; + } + (Message::GotTeas(Ok(teas)), Self::Loading { .. }) => { + let table = TableState::default().with_selected((!teas.is_empty()).then_some(0)); + *self = Self::Loaded { teas, table }; + } + (Message::GotTeas(Err(error)), Self::Loading { .. }) => *self = Self::Failed { error }, + (Message::Tick, Self::Loading { spinner }) => *spinner += 1, + (Message::SelectNext, Self::Loaded { teas, table }) => { + let last = teas.len().saturating_sub(1); + table.select(table.selected().map(|index| (index + 1).min(last))); + } + (Message::SelectPrevious, Self::Loaded { table, .. }) => { + table.select(table.selected().map(|index| index.saturating_sub(1))); + } + // A reload while loading would start a second loader, and the rest have nothing to + // change in the state they arrive in + ( + Message::Reload | Message::SelectNext | Message::SelectPrevious, + Self::Loading { .. }, + ) + | (Message::SelectNext | Message::SelectPrevious, Self::Failed { .. }) + | (Message::GotTeas(_) | Message::Tick, Self::Loaded { .. } | Self::Failed { .. }) => {} + } + None + } + + /// Elm's `subscriptions`: the spinner ticks only while loading. + const fn tick_rate(&self) -> Option { + match self { + Self::Loading { .. } => Some(TICK_RATE), + Self::Loaded { .. } | Self::Failed { .. } => None, + } + } + + /// Takes `&mut self` because rendering the table stores its scroll offset in [`TableState`]. + fn view(&mut self, frame: &mut Frame) { + let help = match self { + Self::Loading { .. } => " (q) quit ", + Self::Loaded { .. } => " (↑/↓) select | (r) reload | (q) quit ", + Self::Failed { .. } => " (r) retry | (q) quit ", + }; + let block = Block::bordered().title(" Teas "); + match self { + Self::Loading { spinner } => { + let spinner = SPINNER[*spinner % SPINNER.len()]; + let text = format!("{spinner} Loading the tea menu"); + let paragraph = Paragraph::new(text).block(block.title_bottom(help)); + frame.render_widget(paragraph, frame.area()); + } + Self::Loaded { teas, table } => { + let layout = Layout::vertical([Constraint::Fill(1); 2]); + let [table_area, detail_area] = frame.area().layout(&layout); + let rows = teas.iter().map(Row::from); + let widths = [ + Constraint::Length(18), + Constraint::Length(8), + Constraint::Fill(1), + ]; + let tea_table = Table::new(rows, widths) + .header(Row::new(Tea::COLUMNS).bold()) + .row_highlight_style(Style::new().reversed()) + .block(block); + frame.render_stateful_widget(tea_table, table_area, table); + + let selected = table.selected().and_then(|index| teas.get(index)); + frame.render_widget(view_detail(selected, help), detail_area); + } + Self::Failed { error } => { + let text = format!("Couldn't load the tea menu: {error}"); + let paragraph = Paragraph::new(text) + .block(block.title_bottom(help)) + .wrap(Wrap { trim: true }); + frame.render_widget(paragraph, frame.area()); + } + } + } +} + +fn view_detail(tea: Option<&Tea>, help: &'static str) -> Paragraph<'static> { + let block = Block::bordered().title_bottom(help); + let Some(tea) = tea else { + return Paragraph::new("No tea selected").block(block); + }; + let text = format!( + "Brew at {} for {}.\n\n{}", + tea.temperature, tea.steep, tea.note + ); + let block = block + .title(format!(" {} ", tea.name)) + .padding(Padding::uniform(1)); + Paragraph::new(text).block(block).wrap(Wrap { trim: true }) +} + +/// Waits for the next event. While the model asks for ticks, a due tick goes before any queued +/// event, so ticks keep coming however busy the input is, like Elm's `Time.every`. +fn next_event( + events: &Receiver, + tick_rate: Option, + next_tick: &mut Option, +) -> Result { + let Some(rate) = tick_rate else { + *next_tick = None; + return Ok(events.recv()?); + }; + let deadline = *next_tick.get_or_insert_with(|| Instant::now() + rate); + let now = Instant::now(); + if now < deadline { + match events.recv_timeout(deadline - now) { + Err(RecvTimeoutError::Timeout) => {} + received => return Ok(received?), + } + } + *next_tick = None; + Ok(RuntimeEvent::Message(Message::Tick)) +} + +/// Sends terminal input to the runtime for as long as the app runs. +fn forward_input(sender: &Sender) -> io::Result<()> { + loop { + let input = match event::read()? { + Event::Resize(..) => Some(RuntimeEvent::Resize), + other => Message::from_event(&other).map(RuntimeEvent::Message), + }; + if let Some(input) = input + && sender.send(input).is_err() + { + return Ok(()); + } + } +} + +/// The runtime: performs the last command, draws the model and waits for the next event. +fn run(terminal: &mut DefaultTerminal) -> Result<()> { + let (sender, events) = mpsc::channel(); + let input_sender = sender.clone(); + thread::spawn(move || { + if let Err(error) = forward_input(&input_sender) { + input_sender.send(RuntimeEvent::InputFailed(error)).ok(); + } + }); + + let (mut model, mut command) = Model::init(); + let mut next_tick = None; + loop { + match command.take() { + Some(Command::LoadTeas) => { + let sender = sender.clone(); + thread::spawn(move || { + thread::sleep(LOAD_TIME); + let teas = Message::GotTeas(Ok(TEAS.to_vec())); + sender.send(RuntimeEvent::Message(teas)).ok(); + }); + } + Some(Command::Quit) => return Ok(()), + None => {} + } + + terminal.draw(|frame| model.view(frame))?; + match next_event(&events, model.tick_rate(), &mut next_tick)? { + RuntimeEvent::Message(message) => command = model.update(message), + RuntimeEvent::Resize => {} + RuntimeEvent::InputFailed(error) => return Err(error.into()), + } + } +} + +fn main() -> Result<()> { + color_eyre::install()?; + ratatui::run(run) +} + +#[cfg(test)] +mod tests { + use std::sync::mpsc; + use std::time::Instant; + + use color_eyre::Result; + + use super::{Command, Message, Model, RuntimeEvent, TEAS, TICK_RATE, next_event}; + + #[test] + fn quit_asks_the_runtime_to_quit() { + let (mut model, _) = Model::init(); + assert!(matches!(model.update(Message::Quit), Some(Command::Quit))); + } + + #[test] + fn failed_load_shows_the_error() { + let (mut model, _) = Model::init(); + model.update(Message::GotTeas(Err(String::from("offline")))); + assert!(matches!(model, Model::Failed { error } if error == "offline")); + } + + #[test] + fn due_tick_goes_before_queued_events() -> Result<()> { + let (sender, events) = mpsc::channel(); + sender.send(RuntimeEvent::Message(Message::SelectNext))?; + let mut next_tick = Some(Instant::now()); + let event = next_event(&events, Some(TICK_RATE), &mut next_tick)?; + assert!(matches!(event, RuntimeEvent::Message(Message::Tick))); + Ok(()) + } + + #[test] + fn reload_after_a_failed_load_starts_a_new_one() { + let mut model = Model::Failed { + error: String::from("offline"), + }; + assert!(matches!( + model.update(Message::Reload), + Some(Command::LoadTeas) + )); + assert!(matches!(model, Model::Loading { .. })); + } + + #[test] + fn reload_while_loading_is_ignored() { + let (mut model, _) = Model::init(); + assert!(model.update(Message::Reload).is_none()); + } + + #[test] + fn selection_stops_at_the_last_tea() { + let mut model = Model::Loading { spinner: 0 }; + model.update(Message::GotTeas(Ok(TEAS[..2].to_vec()))); + for _ in 0..3 { + model.update(Message::SelectNext); + } + assert!(matches!(model, Model::Loaded { table, .. } if table.selected() == Some(1))); + } + + #[test] + fn empty_menu_has_no_selection() { + let mut model = Model::Loading { spinner: 0 }; + model.update(Message::GotTeas(Ok(Vec::new()))); + model.update(Message::SelectNext); + assert!(matches!(model, Model::Loaded { table, .. } if table.selected().is_none())); + } +} diff --git a/vendor/ratatui/examples/apps/table/src/main.rs b/vendor/ratatui/examples/apps/table/src/main.rs index cc5dbfb..d3dc942 100644 --- a/vendor/ratatui/examples/apps/table/src/main.rs +++ b/vendor/ratatui/examples/apps/table/src/main.rs @@ -12,8 +12,8 @@ use ratatui::layout::{Constraint, Layout, Margin, Rect}; use ratatui::style::{self, Color, Modifier, Style, Stylize}; use ratatui::text::Text; use ratatui::widgets::{ - Block, BorderType, Cell, HighlightSpacing, Paragraph, Row, Scrollbar, ScrollbarOrientation, - ScrollbarState, Table, TableState, + Block, BorderType, Cell, Paragraph, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, + Table, TableHighlightSpacing, TableState, }; use ratatui::{DefaultTerminal, Frame}; use style::palette::tailwind; @@ -173,8 +173,8 @@ impl App { KeyCode::Char('q') | KeyCode::Esc => return Ok(()), KeyCode::Char('j') | KeyCode::Down => self.next_row(), KeyCode::Char('k') | KeyCode::Up => self.previous_row(), - KeyCode::Char('l') | KeyCode::Right if shift_pressed => self.next_color(), - KeyCode::Char('h') | KeyCode::Left if shift_pressed => { + KeyCode::Char('L') | KeyCode::Right if shift_pressed => self.next_color(), + KeyCode::Char('H') | KeyCode::Left if shift_pressed => { self.previous_color(); } KeyCode::Char('l') | KeyCode::Right => self.next_column(), @@ -260,7 +260,7 @@ impl App { "".into(), ])) .bg(self.colors.buffer_bg) - .highlight_spacing(HighlightSpacing::Always); + .highlight_spacing(TableHighlightSpacing::Always); frame.render_stateful_widget(t, area, &mut self.state); } diff --git a/vendor/ratatui/examples/apps/todo-list/src/main.rs b/vendor/ratatui/examples/apps/todo-list/src/main.rs index aaa8e01..a5e6362 100644 --- a/vendor/ratatui/examples/apps/todo-list/src/main.rs +++ b/vendor/ratatui/examples/apps/todo-list/src/main.rs @@ -13,8 +13,8 @@ use ratatui::style::palette::tailwind::{BLUE, GREEN, SLATE}; use ratatui::style::{Color, Modifier, Style, Stylize}; use ratatui::text::Line; use ratatui::widgets::{ - Block, Borders, HighlightSpacing, List, ListItem, ListState, Padding, Paragraph, - StatefulWidget, Widget, Wrap, + Block, Borders, List, ListHighlightSpacing, ListItem, ListState, Padding, Paragraph, + SelectionMode, StatefulWidget, Widget, Wrap, }; use ratatui::{DefaultTerminal, symbols}; @@ -104,8 +104,9 @@ impl FromIterator<(Status, &'static str, &'static str)> for TodoList { let items = iter .into_iter() .map(|(status, todo, info)| TodoItem::new(status, todo, info)) - .collect(); - let state = ListState::default(); + .collect::>(); + // Choosing a mode enables item-count tracking on the first render. + let state = ListState::default().with_selection_mode(SelectionMode::Clamp); Self { items, state } } } @@ -139,6 +140,7 @@ impl App { KeyCode::Char('k') | KeyCode::Up => self.select_previous(), KeyCode::Char('g') | KeyCode::Home => self.select_first(), KeyCode::Char('G') | KeyCode::End => self.select_last(), + KeyCode::Char('t') => self.toggle_selection_mode(), KeyCode::Char('l') | KeyCode::Right | KeyCode::Enter => { self.toggle_status(); } @@ -165,6 +167,14 @@ impl App { self.todo_list.state.select_last(); } + const fn toggle_selection_mode(&mut self) { + let mode = self.todo_list.state.selection_mode_mut(); + *mode = match *mode { + SelectionMode::Clamp => SelectionMode::Wrap, + SelectionMode::Wrap => SelectionMode::Clamp, + }; + } + /// Changes the status of the selected list item fn toggle_status(&mut self) { if let Some(i) = self.todo_list.state.selected() { @@ -181,7 +191,7 @@ impl Widget for &mut App { let main_layout = Layout::vertical([ Constraint::Length(2), Constraint::Fill(1), - Constraint::Length(1), + Constraint::Length(2), ]); let [header_area, content_area, footer_area] = area.layout(&main_layout); @@ -189,7 +199,7 @@ impl Widget for &mut App { let [list_area, item_area] = content_area.layout(&content_layout); App::render_header(header_area, buf); - App::render_footer(footer_area, buf); + self.render_footer(footer_area, buf); self.render_list(list_area, buf); self.render_selected_item(item_area, buf); } @@ -204,10 +214,17 @@ impl App { .render(area, buf); } - fn render_footer(area: Rect, buf: &mut Buffer) { - Paragraph::new("Use ↓↑ to move, ← to unselect, → to change status, g/G to go top/bottom.") - .centered() - .render(area, buf); + fn render_footer(&self, area: Rect, buf: &mut Buffer) { + let mode = match self.todo_list.state.selection_mode() { + SelectionMode::Clamp => "clamp", + SelectionMode::Wrap => "wrap", + }; + Paragraph::new(vec![ + Line::raw("Use ↓↑ to move, ← to unselect, → to change status, g/G to go top/bottom."), + Line::raw(format!("t: toggle clamp/wrap ({mode}) | q/Esc: quit")), + ]) + .centered() + .render(area, buf); } fn render_list(&mut self, area: Rect, buf: &mut Buffer) { @@ -235,7 +252,7 @@ impl App { .block(block) .highlight_style(SELECTED_STYLE) .highlight_symbol(">") - .highlight_spacing(HighlightSpacing::Always); + .highlight_spacing(ListHighlightSpacing::Always); // We need to disambiguate this trait method as both `Widget` and `StatefulWidget` share the // same method name `render`. diff --git a/vendor/ratatui/examples/apps/tracing/src/main.rs b/vendor/ratatui/examples/apps/tracing/src/main.rs index 973ccf7..e4276cc 100644 --- a/vendor/ratatui/examples/apps/tracing/src/main.rs +++ b/vendor/ratatui/examples/apps/tracing/src/main.rs @@ -52,7 +52,8 @@ fn main() -> Result<()> { fn should_exit(events: &[Event]) -> bool { events .iter() - .any(|event| matches!(event, Event::Key(key) if key.code == KeyCode::Char('q'))) + .filter_map(Event::as_key_press_event) + .any(|key| key.code == KeyCode::Char('q')) } /// Handle events and insert them into the events vector keeping only the last 10 events @@ -100,3 +101,25 @@ fn init_tracing() -> Result { .init(); Ok(guard) } + +#[cfg(test)] +mod tests { + use crossterm::event::{KeyEvent, KeyEventKind, KeyModifiers}; + + use super::*; + + #[test] + fn should_exit_only_on_q_key_press() { + let q_event = |kind| { + Event::Key(KeyEvent::new_with_kind( + KeyCode::Char('q'), + KeyModifiers::NONE, + kind, + )) + }; + + assert!(should_exit(&[q_event(KeyEventKind::Press)])); + assert!(!should_exit(&[q_event(KeyEventKind::Repeat)])); + assert!(!should_exit(&[q_event(KeyEventKind::Release)])); + } +} diff --git a/vendor/ratatui/examples/apps/user-input/src/main.rs b/vendor/ratatui/examples/apps/user-input/src/main.rs index e6207ef..cd9cddb 100644 --- a/vendor/ratatui/examples/apps/user-input/src/main.rs +++ b/vendor/ratatui/examples/apps/user-input/src/main.rs @@ -21,7 +21,7 @@ /// /// [`latest`]: https://github.com/ratatui/ratatui/tree/latest use color_eyre::Result; -use crossterm::event::{self, KeyCode, KeyEventKind}; +use crossterm::event::{self, KeyCode}; use ratatui::layout::{Constraint, Layout, Position}; use ratatui::style::{Color, Modifier, Style, Stylize}; use ratatui::text::{Line, Span, Text}; @@ -139,7 +139,7 @@ impl App { } _ => {} }, - InputMode::Editing if key.kind == KeyEventKind::Press => match key.code { + InputMode::Editing => match key.code { KeyCode::Enter => self.submit_message(), KeyCode::Char(to_insert) => self.enter_char(to_insert), KeyCode::Backspace => self.delete_char(), @@ -148,7 +148,6 @@ impl App { KeyCode::Esc => self.input_mode = InputMode::Normal, _ => {} }, - InputMode::Editing => {} } } } diff --git a/vendor/ratatui/examples/apps/volatility-surface/Cargo.toml b/vendor/ratatui/examples/apps/volatility-surface/Cargo.toml index 4f0a7c3..72f54cf 100644 --- a/vendor/ratatui/examples/apps/volatility-surface/Cargo.toml +++ b/vendor/ratatui/examples/apps/volatility-surface/Cargo.toml @@ -7,7 +7,7 @@ rust-version.workspace = true [dependencies] color-eyre.workspace = true -colorgrad = { version = "0.8", features = ["preset"] } +colorgrad = { version = "0.9", features = ["preset"] } crossterm.workspace = true rand.workspace = true ratatui.workspace = true diff --git a/vendor/ratatui/examples/apps/volatility-surface/src/main.rs b/vendor/ratatui/examples/apps/volatility-surface/src/main.rs index 6e0fc30..10241c3 100644 --- a/vendor/ratatui/examples/apps/volatility-surface/src/main.rs +++ b/vendor/ratatui/examples/apps/volatility-surface/src/main.rs @@ -10,7 +10,7 @@ mod volatility; use std::time::{Duration, Instant}; use color_eyre::Result; -use crossterm::event::{self, KeyCode, KeyEventKind, KeyModifiers}; +use crossterm::event::{self, KeyCode, KeyModifiers}; use display::{Surface3D, VolatilitySurface}; use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::style::palette::tailwind::SLATE; @@ -84,8 +84,7 @@ impl App { let timeout = tick_rate.saturating_sub(last_tick.elapsed()); if event::poll(timeout)? { // Only handle key press events, not repeat or release - if let event::Event::Key(key) = event::read()? - && key.kind == KeyEventKind::Press + if let Some(key) = event::read()?.as_key_press_event() && self.handle_key(key.code, key.modifiers) { break; diff --git a/vendor/ratatui/examples/concepts/state/Cargo.toml b/vendor/ratatui/examples/concepts/state/Cargo.toml index bebcefa..66b4bf2 100644 --- a/vendor/ratatui/examples/concepts/state/Cargo.toml +++ b/vendor/ratatui/examples/concepts/state/Cargo.toml @@ -9,3 +9,6 @@ rust-version.workspace = true color-eyre.workspace = true crossterm.workspace = true ratatui = { workspace = true, features = ["unstable-widget-ref"] } + +[lints] +workspace = true diff --git a/vendor/ratatui/examples/concepts/state/src/bin/immutable-consuming.rs b/vendor/ratatui/examples/concepts/state/src/bin/immutable-consuming.rs index 4006c4e..e64c929 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/immutable-consuming.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/immutable-consuming.rs @@ -73,7 +73,7 @@ struct Counter { impl Counter { /// Create a new counter widget with the given count. - fn new(count: usize) -> Self { + const fn new(count: usize) -> Self { Self { count } } } diff --git a/vendor/ratatui/examples/concepts/state/src/bin/immutable-function.rs b/vendor/ratatui/examples/concepts/state/src/bin/immutable-function.rs index 3997c0d..4f0bab0 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/immutable-function.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/immutable-function.rs @@ -68,7 +68,7 @@ struct Counter { impl Counter { /// Increment the counter value. - fn increment(&mut self) { + const fn increment(&mut self) { self.count += 1; } } diff --git a/vendor/ratatui/examples/concepts/state/src/bin/immutable-shared-ref.rs b/vendor/ratatui/examples/concepts/state/src/bin/immutable-shared-ref.rs index a538134..77aebc9 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/immutable-shared-ref.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/immutable-shared-ref.rs @@ -71,7 +71,7 @@ struct Counter { impl Counter { /// Create a new counter. - fn new() -> Self { + const fn new() -> Self { Self { count: 0 } } @@ -79,7 +79,7 @@ impl Counter { /// /// This method modifies the counter's state outside of the rendering process, /// maintaining the separation between state updates and rendering. - fn increment(&mut self) { + const fn increment(&mut self) { self.count += 1; } } diff --git a/vendor/ratatui/examples/concepts/state/src/bin/nested-mutable-widget.rs b/vendor/ratatui/examples/concepts/state/src/bin/nested-mutable-widget.rs index 47a433d..58a397d 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/nested-mutable-widget.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/nested-mutable-widget.rs @@ -14,7 +14,7 @@ //! //! - You have hierarchical widget relationships (parent-child) //! - Each widget needs to maintain its own distinct state -//! - You prefer the mutable widget pattern over StatefulWidget +//! - You prefer the mutable widget pattern over `StatefulWidget` //! - Widgets have clear ownership of their state //! //! ## Trade-offs @@ -29,7 +29,7 @@ //! - Complex borrowing scenarios can arise //! - Requires careful lifetime management //! - May lead to borrow checker issues in complex hierarchies -//! - Less flexible than StatefulWidget for state sharing +//! - Less flexible than `StatefulWidget` for state sharing //! //! ## Example Usage //! diff --git a/vendor/ratatui/examples/concepts/state/src/bin/nested-stateful-widget.rs b/vendor/ratatui/examples/concepts/state/src/bin/nested-stateful-widget.rs index 3c883ed..f6a5753 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/nested-stateful-widget.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/nested-stateful-widget.rs @@ -1,8 +1,8 @@ -//! # Nested StatefulWidget Pattern +//! # Nested `StatefulWidget` Pattern //! //! This example demonstrates composing multiple `StatefulWidget`s in a parent-child hierarchy. //! This pattern is ideal for complex applications where you need clean separation of concerns -//! and want to leverage the benefits of the StatefulWidget pattern at multiple levels. +//! and want to leverage the benefits of the `StatefulWidget` pattern at multiple levels. //! //! This example runs with the Ratatui library code in the branch that you are currently //! reading. See the [`latest`] branch for the code which works with the most recent Ratatui @@ -44,18 +44,18 @@ use ratatui::layout::Rect; use ratatui::widgets::{StatefulWidget, Widget}; use ratatui_state_examples::is_exit_key_pressed; -/// Demonstrates the nested StatefulWidget pattern for mutable state management. +/// Demonstrates the nested `StatefulWidget` pattern for mutable state management. /// -/// Creates a parent-child widget hierarchy using StatefulWidgets and runs the application loop, +/// Creates a parent-child widget hierarchy using `StatefulWidgets` and runs the application loop, /// updating the counter on each render cycle until the user exits. fn main() -> color_eyre::Result<()> { color_eyre::install()?; ratatui::run(App::run) } -/// The main application widget using the StatefulWidget pattern. +/// The main application widget using the `StatefulWidget` pattern. /// -/// Demonstrates how to compose multiple StatefulWidgets together while coordinating +/// Demonstrates how to compose multiple `StatefulWidgets` together while coordinating /// between different child widgets. struct App; @@ -65,7 +65,7 @@ impl App { let mut state = AppState { counter: 0 }; loop { - terminal.draw(|frame| frame.render_stateful_widget(App, frame.area(), &mut state))?; + terminal.draw(|frame| frame.render_stateful_widget(Self, frame.area(), &mut state))?; if is_exit_key_pressed()? { break Ok(()); } @@ -75,7 +75,7 @@ impl App { /// Application state that contains all the state needed by the app and its child widgets. /// -/// Demonstrates how to organize hierarchical state in the StatefulWidget pattern. +/// Demonstrates how to organize hierarchical state in the `StatefulWidget` pattern. struct AppState { counter: usize, } @@ -88,7 +88,7 @@ impl StatefulWidget for App { } } -/// A counter widget that uses StatefulWidget for clean state separation. +/// A counter widget that uses `StatefulWidget` for clean state separation. /// /// Focuses purely on rendering logic and can be reused with different state instances. struct Counter; diff --git a/vendor/ratatui/examples/concepts/state/src/bin/refcell.rs b/vendor/ratatui/examples/concepts/state/src/bin/refcell.rs index d1e6363..c178115 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/refcell.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/refcell.rs @@ -1,4 +1,4 @@ -//! # Interior Mutability Pattern (RefCell) +//! # Interior Mutability Pattern (`RefCell`) //! //! This example demonstrates using `Rc>` for interior mutability, allowing multiple //! widgets to share and mutate the same state. This pattern is useful when you need shared diff --git a/vendor/ratatui/examples/concepts/state/src/bin/stateful-widget.rs b/vendor/ratatui/examples/concepts/state/src/bin/stateful-widget.rs index dd678f2..3058682 100644 --- a/vendor/ratatui/examples/concepts/state/src/bin/stateful-widget.rs +++ b/vendor/ratatui/examples/concepts/state/src/bin/stateful-widget.rs @@ -1,4 +1,4 @@ -//! # StatefulWidget Pattern (Recommended) +//! # `StatefulWidget` Pattern (Recommended) //! //! This example demonstrates the `StatefulWidget` trait, which is the recommended approach for //! handling mutable state in Ratatui applications. This pattern separates the widget's rendering @@ -43,7 +43,7 @@ use ratatui::layout::Rect; use ratatui::widgets::{StatefulWidget, Widget}; use ratatui_state_examples::is_exit_key_pressed; -/// Demonstrates the StatefulWidget pattern for mutable state management. +/// Demonstrates the `StatefulWidget` pattern for mutable state management. /// /// Creates a counter widget using `StatefulWidget` and runs the application loop, /// updating the counter on each render cycle until the user exits. @@ -53,7 +53,7 @@ fn main() -> color_eyre::Result<()> { let mut counter = 0; loop { terminal.draw(|frame| { - frame.render_stateful_widget(CounterWidget, frame.area(), &mut counter) + frame.render_stateful_widget(CounterWidget, frame.area(), &mut counter); })?; if is_exit_key_pressed()? { break Ok(()); @@ -62,7 +62,7 @@ fn main() -> color_eyre::Result<()> { }) } -/// A counter widget that uses the StatefulWidget pattern for state management. +/// A counter widget that uses the `StatefulWidget` pattern for state management. /// /// Demonstrates the separation of rendering logic from state, making the widget reusable /// with different state instances and easier to test. diff --git a/vendor/ratatui/examples/vhs/constraint-explorer.tape b/vendor/ratatui/examples/vhs/constraint-explorer.tape index 98dbd78..e797a64 100644 --- a/vendor/ratatui/examples/vhs/constraint-explorer.tape +++ b/vendor/ratatui/examples/vhs/constraint-explorer.tape @@ -4,11 +4,11 @@ Output "target/constraint-explorer.gif" Set Theme "Aardvark Blue" Set FontSize 18 Set Width 1200 -Set Height 950 +Set Height 1330 Hide Type "cargo run -p constraint-explorer" Enter -Sleep 2s +Wait+Screen /Constraint Explorer/ Show Set TypingSpeed 2s Type "1" diff --git a/vendor/ratatui/examples/vhs/inline-resizable.tape b/vendor/ratatui/examples/vhs/inline-resizable.tape index 7975162..80cacb3 100644 --- a/vendor/ratatui/examples/vhs/inline-resizable.tape +++ b/vendor/ratatui/examples/vhs/inline-resizable.tape @@ -20,5 +20,3 @@ Sleep 1s Type "---------------" Sleep 1s Type "iiiii" Sleep 1s Type "+++++" Sleep 2s -Type "q" -Sleep 1s diff --git a/vendor/ratatui/examples/vhs/modifiers.tape b/vendor/ratatui/examples/vhs/modifiers.tape index 4eebbbd..a525a15 100644 --- a/vendor/ratatui/examples/vhs/modifiers.tape +++ b/vendor/ratatui/examples/vhs/modifiers.tape @@ -2,11 +2,18 @@ # To run this script, install vhs and run `vhs ./examples/vhs/modifiers.tape` Output "target/modifiers.gif" Set Theme "Aardvark Blue" -Set Width 1200 -Set Height 1460 +Set FontSize 20 +Set Padding 20 +Set Width 1000 +Set Height 700 +Env NO_COLOR "" Hide Type "cargo run -p modifiers" Enter -Sleep 2s +Wait+Screen /Foreground colors/ Show -Sleep 1s +Sleep 2s +Right@2s 4 +Sleep 2s +Tab +Sleep 2s diff --git a/vendor/ratatui/examples/vhs/table-detail-tea.tape b/vendor/ratatui/examples/vhs/table-detail-tea.tape new file mode 100644 index 0000000..9440567 --- /dev/null +++ b/vendor/ratatui/examples/vhs/table-detail-tea.tape @@ -0,0 +1,22 @@ +# This is a vhs script. See https://github.com/charmbracelet/vhs for more info. +# To run this script, install vhs and run `vhs ./examples/vhs/table-detail-tea.tape` +Output "target/table-detail-tea.gif" +Set Theme "Aardvark Blue" +Set Width 1200 +Set Height 768 +Hide +Type "cargo run -p table-detail-tea" +Enter +Sleep 1s +Show +Sleep 2s +Set TypingSpeed 1s +Down 3 +Up 1 +Sleep 1s +Down 3 +Sleep 1s +Up 1 +Sleep 1s +Type "r" +Sleep 3s diff --git a/vendor/ratatui/ratatui-calendar/Cargo.toml b/vendor/ratatui/ratatui-calendar/Cargo.toml new file mode 100644 index 0000000..12bde2b --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "ratatui-calendar" +version = "0.1.0" +description = "A calendar widget for Ratatui terminal user interfaces." +documentation = "https://docs.rs/ratatui-calendar" +readme = "README.md" +repository.workspace = true +homepage.workspace = true +keywords.workspace = true +categories.workspace = true +license.workspace = true +exclude.workspace = true +edition.workspace = true +rust-version.workspace = true + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[features] +default = [] + +## enables std, which is needed for [`CalendarEventStore::today`]. +std = ["jiff/std", "jiff/tz-system", "jiff/tzdb-bundle-platform", "jiff/tzdb-zoneinfo"] + +[dependencies] +document-features = { workspace = true, optional = true } +hashbrown.workspace = true +jiff.workspace = true +ratatui-core.workspace = true +ratatui-widgets.workspace = true + +[dev-dependencies] +chrono = { workspace = true, features = ["clock"] } +color-eyre.workspace = true +crossterm.workspace = true +ratatui = { path = "../ratatui" } +rstest.workspace = true +time = { workspace = true, features = ["std"] } + +[lints] +workspace = true diff --git a/vendor/ratatui/ratatui-calendar/LICENSE b/vendor/ratatui/ratatui-calendar/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/vendor/ratatui/ratatui-calendar/README.md b/vendor/ratatui/ratatui-calendar/README.md new file mode 100644 index 0000000..083b8c9 --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/README.md @@ -0,0 +1,135 @@ +# Ratatui Calendar + +[![Crates.io](https://img.shields.io/crates/v/ratatui-calendar)](https://crates.io/crates/ratatui-calendar) +[![Documentation](https://docs.rs/ratatui-calendar/badge.svg)](https://docs.rs/ratatui-calendar) +[![License](https://img.shields.io/crates/l/ratatui-calendar)](../LICENSE) + + + + + + +**ratatui-calendar** provides a monthly calendar widget for [Ratatui] terminal user +interfaces. + +[Ratatui]: https://crates.io/crates/ratatui + +Most applications use this crate through `ratatui::widgets::calendar` by enabling the +`widget-calendar` feature of the `ratatui` crate (on by default via `all-widgets`). Depend on +`ratatui-calendar` directly if you are building a widget library, or if you want finer-grained +dependencies than the `ratatui` crate gives you. + +Dates are [`jiff::civil::Date`](https://docs.rs/jiff/latest/jiff/civil/date/struct.Date.html) values from the [jiff] crate. Use [`jiff::civil::date`](https://docs.rs/jiff/latest/jiff/civil/fn.date.html) to +build one from a year, month and day. + +The calendar previously lived in the `calendar` module of `ratatui-widgets`. It moved to its +own crate because it is the only built-in widget whose public API uses a third-party type (the +date type), and a separate crate lets that dependency change without a breaking release of +`ratatui-widgets`. + +[jiff]: https://crates.io/crates/jiff + +## Installation + +Run the following command to add this crate to your project: + +```sh +cargo add ratatui-calendar jiff +``` + +## Usage + +[`Monthly`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/struct.Monthly.html) renders the month that contains its `display_date`, one row per week starting on +Sunday. Each day uses the default style unless the [`DateStyler`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/trait.DateStyler.html) returns a style for it, and +days outside the month are only drawn when [`Monthly::show_surrounding`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/struct.Monthly.html#method.show_surrounding) is set. Optional +headers show the month name and the weekdays, and a [`Block`] can wrap the calendar. + +[`CalendarEventStore`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/struct.CalendarEventStore.html) is a ready-made [`DateStyler`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/trait.DateStyler.html) that maps dates to styles. Implement +[`DateStyler`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/trait.DateStyler.html) yourself to compute styles on the fly, for example from an events database. + +[`Monthly::width`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/struct.Monthly.html#method.width) and [`Monthly::height`](https://docs.rs/ratatui-calendar/latest/ratatui_calendar/struct.Monthly.html#method.height) report the size the calendar needs, which is useful +for laying it out with a fixed-size constraint. + +```rust +use jiff::civil::date; +use ratatui_calendar::{CalendarEventStore, Monthly}; +use ratatui_core::buffer::Buffer; +use ratatui_core::layout::Rect; +use ratatui_core::style::{Color, Modifier, Style}; +use ratatui_core::widgets::Widget; +use ratatui_widgets::block::Block; + +let november = date(2026, 11, 1); + +let mut events = CalendarEventStore::default(); +events.add( + date(2026, 11, 26), + Style::new().fg(Color::Red).add_modifier(Modifier::BOLD), +); + +let calendar = Monthly::new(november, events) + .show_month_header(Style::new().add_modifier(Modifier::BOLD)) + .show_weekdays_header(Style::new().fg(Color::Cyan)) + .show_surrounding(Style::new().fg(Color::DarkGray)) + .block(Block::bordered().title("Calendar")); + +let area = Rect::new(0, 0, calendar.width(), calendar.height()); +let mut buf = Buffer::empty(area); +calendar.render(area, &mut buf); +``` + +## Examples + +Run these with `cargo run -p ratatui-calendar --example `. + +The main example is [`calendar-explorer`]. It is intentionally the most complex one, to show +off the features: every style option across a whole year, with holidays and recurring events +computed using jiff, and keyboard navigation. + +The smaller examples are easier to start from: + +- [`minimal`]: the current month in a bordered block. +- [`calendar`]: two months side by side with different styles. +- [`time`]: an app that keeps its own dates as `time::Date` and converts them at the boundary. +- [`chrono`]: the same for an app that uses `chrono::NaiveDate`. + +[`Block`]: https://docs.rs/ratatui_widgets/latest/ratatui_widgets/block/struct.Block.html +[`calendar-explorer`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/calendar-explorer.rs +[`minimal`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/minimal.rs +[`calendar`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/calendar.rs +[`time`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/time.rs +[`chrono`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/chrono.rs + +## Crate Organization + +`ratatui-calendar` is part of the Ratatui workspace. It builds on [`ratatui-core`] for the +widget traits and on [`ratatui-widgets`] for [`Block`], and the main [`ratatui`] crate +re-exports it as `ratatui::widgets::calendar`. + +**When to use `ratatui-calendar`:** + +- Building widget libraries that embed or wrap the calendar +- You want finer-grained dependencies than the `ratatui` crate + +**When to use the main [`ratatui`] crate:** + +- Building applications (recommended - includes everything you need) + +For detailed information about the workspace organization, see [ARCHITECTURE.md]. + +[`ratatui`]: https://crates.io/crates/ratatui +[`ratatui-core`]: https://crates.io/crates/ratatui-core +[`ratatui-widgets`]: https://crates.io/crates/ratatui-widgets +[ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md + +## Contributing + +Contributions are welcome! Please open an issue or submit a pull request on GitHub. For more +details on contributing, please see the [CONTRIBUTING](../CONTRIBUTING.md) document. + +## License + +This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. + + + diff --git a/vendor/ratatui/ratatui-calendar/examples/calendar-explorer.rs b/vendor/ratatui/ratatui-calendar/examples/calendar-explorer.rs new file mode 100644 index 0000000..105d60f --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/examples/calendar-explorer.rs @@ -0,0 +1,292 @@ +//! # [Ratatui] calendar `calendar-explorer` example +//! +//! This is the most complete calendar example, and deliberately the most complex: it shows every +//! `Monthly` style option across a whole year. It marks holidays, seasons and fortnightly +//! paydays, computing the dates that move each year (US Thanksgiving and the paydays) with jiff +//! rather than listing them by hand. Move around with the arrow keys or `hjkl`, change month with +//! `n` and `p`, cycle styles with `s`, switch weeks between starting on Sunday and Monday with +//! `w`, toggle ISO week numbers with `i`, and quit with `q` or Esc. +//! +//! For something easier to start from, see the smaller examples in the same folder: [`minimal`], +//! [`calendar`], and [`time`] or [`chrono`] for apps that use those crates for their own dates. +//! +//! The latest version of this example is available in the [calendar examples] folder in the +//! repository. The examples are designed to be run against the `main` branch of the GitHub +//! repository, so they may not compile with the latest release on crates.io. +//! +//! [Ratatui]: https://github.com/ratatui/ratatui +//! [calendar examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples +//! [`minimal`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/minimal.rs +//! [`calendar`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/calendar.rs +//! [`time`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/time.rs +//! [`chrono`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/chrono.rs + +use std::fmt; + +use color_eyre::Result; +use crossterm::event::{self, KeyCode}; +use jiff::civil::{Date, Weekday, date}; +use jiff::{ToSpan, ZonedDateTime}; +use ratatui::layout::{Constraint, Layout, Margin, Rect}; +use ratatui::style::{Color, Modifier, Style, Stylize}; +use ratatui::text::{Line, Text}; +use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; +use ratatui::{DefaultTerminal, Frame}; + +fn main() -> Result<()> { + color_eyre::install()?; + ratatui::run(|terminal| App::new().run(terminal)) +} + +/// The calendar explorer's state. +struct App { + selected_date: Date, + calendar_style: StyledCalendar, + first_day_of_week: Weekday, + show_week_numbers: bool, + exit: bool, +} + +impl App { + fn new() -> Self { + Self { + selected_date: ZonedDateTime::now().date(), + calendar_style: StyledCalendar::Default, + first_day_of_week: Weekday::Sunday, + show_week_numbers: false, + exit: false, + } + } + + /// Run the application until the user quits. + fn run(mut self, terminal: &mut DefaultTerminal) -> Result<()> { + while !self.exit { + terminal.draw(|frame| self.render(frame))?; + if let Some(key) = event::read()?.as_key_press_event() { + self.handle_key(key.code); + } + } + Ok(()) + } + + /// Render the UI with a calendar. + fn render(&self, frame: &mut Frame) { + let header = Text::from_iter([ + Line::from("Calendar Example".bold()), + Line::from( + " Quit | Change Style | Week Start | ISO Week Numbers | Next \ + Month |

Previous Month, Move", + ), + Line::from(format!( + "Current date: {} | Current style: {} | Week starts: {:?}", + self.selected_date, self.calendar_style, self.first_day_of_week + )), + ]); + + let [text_area, area] = frame.area().layout(&Layout::vertical([ + Constraint::Length(header.height() as u16), + Constraint::Fill(1), + ])); + frame.render_widget(header.centered(), text_area); + self.render_year(frame, area).unwrap(); + } + + /// Render all twelve months of the selected year in a 4x3 grid. + fn render_year(&self, frame: &mut Frame, area: Rect) -> Result<()> { + let events = events(self.selected_date)?; + + let vertical = Layout::vertical([Constraint::Ratio(1, 3); 3]); + let horizontal = &Layout::horizontal([Constraint::Ratio(1, 4); 4]); + let areas = area + .inner(Margin::new(1, 1)) + .layout_vec(&vertical) + .into_iter() + .flat_map(|row| row.layout_vec(horizontal)); + let months = self.selected_date.first_of_year().series(1.month()); + for (area, month) in areas.zip(months) { + let mut calendar = self + .calendar_style + .calendar(month, &events) + .first_day_of_week(self.first_day_of_week); + if self.show_week_numbers { + calendar = calendar.show_week_numbers(Style::new().dim()); + } + frame.render_widget(calendar, area); + } + Ok(()) + } + + fn handle_key(&mut self, code: KeyCode) { + let step = match code { + KeyCode::Char('q') | KeyCode::Esc => { + self.exit = true; + return; + } + KeyCode::Char('s') => { + self.calendar_style = self.calendar_style.next(); + return; + } + KeyCode::Char('i') => { + self.show_week_numbers = !self.show_week_numbers; + return; + } + KeyCode::Char('w') => { + self.first_day_of_week = match self.first_day_of_week { + Weekday::Sunday => Weekday::Monday, + _ => Weekday::Sunday, + }; + return; + } + KeyCode::Char('n') | KeyCode::Tab => 1.month(), + KeyCode::Char('p') | KeyCode::BackTab => -1.month(), + KeyCode::Char('h') | KeyCode::Left => -1.day(), + KeyCode::Char('j') | KeyCode::Down => 1.week(), + KeyCode::Char('k') | KeyCode::Up => -1.week(), + KeyCode::Char('l') | KeyCode::Right => 1.day(), + _ => return, + }; + // saturate at the first and last dates jiff supports instead of panicking + self.selected_date = self.selected_date.saturating_add(step); + } +} + +#[derive(Debug, Clone, Copy)] +enum StyledCalendar { + Default, + Surrounding, + WeekdaysHeader, + SurroundingAndWeekdaysHeader, + MonthHeader, + MonthAndWeekdaysHeader, +} + +impl StyledCalendar { + // Cycle through the different styles. + const fn next(self) -> Self { + match self { + Self::Default => Self::Surrounding, + Self::Surrounding => Self::WeekdaysHeader, + Self::WeekdaysHeader => Self::SurroundingAndWeekdaysHeader, + Self::SurroundingAndWeekdaysHeader => Self::MonthHeader, + Self::MonthHeader => Self::MonthAndWeekdaysHeader, + Self::MonthAndWeekdaysHeader => Self::Default, + } + } +} + +impl fmt::Display for StyledCalendar { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Default => write!(f, "Default"), + Self::Surrounding => write!(f, "Show Surrounding"), + Self::WeekdaysHeader => write!(f, "Show Weekdays Header"), + Self::SurroundingAndWeekdaysHeader => write!(f, "Show Surrounding and Weekdays Header"), + Self::MonthHeader => write!(f, "Show Month Header"), + Self::MonthAndWeekdaysHeader => write!(f, "Show Month Header and Weekdays Header"), + } + } +} + +impl StyledCalendar { + /// A calendar for the month containing `date`, in this style. + fn calendar( + self, + date: Date, + events: &CalendarEventStore, + ) -> Monthly<'static, &CalendarEventStore> { + match self { + Self::Default => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()), + Self::Surrounding => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()) + .show_surrounding(Style::new().dim()), + Self::WeekdaysHeader => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()) + .show_weekdays_header(Style::new().bold().green()), + Self::SurroundingAndWeekdaysHeader => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()) + .show_surrounding(Style::new().dim()) + .show_weekdays_header(Style::new().bold().green()), + Self::MonthHeader => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()) + .show_month_header(Style::new().bold().green()), + Self::MonthAndWeekdaysHeader => Monthly::new(date, events) + .default_style(Style::new().bold().bg(Color::Rgb(50, 50, 50))) + .show_month_header(Style::default()) + .show_weekdays_header(Style::new().bold().dim().light_yellow()), + } + } +} + +/// Makes a list of dates for the current year. +fn events(selected_date: Date) -> Result { + const SELECTED: Style = Style::new() + .fg(Color::White) + .bg(Color::Red) + .add_modifier(Modifier::BOLD); + const HOLIDAY: Style = Style::new() + .fg(Color::Red) + .add_modifier(Modifier::UNDERLINED); + const SEASON: Style = Style::new() + .fg(Color::Green) + .bg(Color::Black) + .add_modifier(Modifier::UNDERLINED); + const PAYDAY: Style = Style::new().fg(Color::Yellow); + + let mut list = CalendarEventStore::today( + Style::default() + .add_modifier(Modifier::BOLD) + .bg(Color::Blue), + ); + let y = selected_date.year(); + + // new year's + list.add(date(y, 1, 1), HOLIDAY); + // next new_year's for December "show surrounding" + let next_new_year = selected_date.last_of_year().tomorrow()?; + list.add(next_new_year, HOLIDAY); + // groundhog day + list.add(date(y, 2, 2), HOLIDAY); + // april fool's + list.add(date(y, 4, 1), HOLIDAY); + // earth day + list.add(date(y, 4, 22), HOLIDAY); + // star wars day + list.add(date(y, 5, 4), HOLIDAY); + // thanksgiving (US), the fourth Thursday of November + let thanksgiving = date(y, 11, 1).nth_weekday_of_month(4, Weekday::Thursday)?; + list.add(thanksgiving, HOLIDAY); + // festivus + list.add(date(y, 12, 23), HOLIDAY); + // new year's eve + list.add(date(y, 12, 31), HOLIDAY); + + // seasons + // spring equinox + list.add(date(y, 3, 22), SEASON); + // summer solstice + list.add(date(y, 6, 21), SEASON); + // fall equinox + list.add(date(y, 9, 22), SEASON); + // winter solstice + list.add(date(y, 12, 21), SEASON); + + // payday, every other Friday from the first Friday of the year + let first_friday = date(y, 1, 1).nth_weekday_of_month(1, Weekday::Friday)?; + for payday in first_friday + .series(2.weeks()) + .take_while(|day| day.year() == y) + { + list.add(payday, PAYDAY); + } + + // selected date + list.add(selected_date, SELECTED); + + Ok(list) +} diff --git a/vendor/ratatui/ratatui-widgets/examples/calendar.rs b/vendor/ratatui/ratatui-calendar/examples/calendar.rs similarity index 80% rename from vendor/ratatui/ratatui-widgets/examples/calendar.rs rename to vendor/ratatui/ratatui-calendar/examples/calendar.rs index 03a0d0c..25ca003 100644 --- a/vendor/ratatui/ratatui-widgets/examples/calendar.rs +++ b/vendor/ratatui/ratatui-calendar/examples/calendar.rs @@ -11,29 +11,36 @@ //! library you are using. //! //! [Ratatui]: https://github.com/ratatui/ratatui -//! [widget examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-widgets/examples +//! [widget examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples //! [examples readme]: https://github.com/ratatui/ratatui/blob/main/examples/README.md use color_eyre::Result; -use crossterm::event; -use ratatui::Frame; +use crossterm::event::{self, KeyCode}; +use jiff::ZonedDateTime; +use jiff::civil::date; use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::style::{Color, Modifier, Style, Stylize}; use ratatui::text::{Line, Span}; use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; use ratatui::widgets::{Block, Padding}; -use time::{Date, Month, OffsetDateTime}; +use ratatui::{DefaultTerminal, Frame}; fn main() -> Result<()> { color_eyre::install()?; - ratatui::run(|terminal| { - loop { - terminal.draw(render)?; - if event::read()?.is_key_press() { - break Ok(()); + ratatui::run(run) +} + +/// Run the app until `q` or Esc is pressed. +fn run(terminal: &mut DefaultTerminal) -> Result<()> { + loop { + terminal.draw(render)?; + if let Some(key) = event::read()?.as_key_press_event() { + match key.code { + KeyCode::Char('q') | KeyCode::Esc => return Ok(()), + _ => {} } } - }) + } } /// Render the UI with 2 monthly calendars side by side. @@ -45,7 +52,7 @@ fn render(frame: &mut Frame) { let title = Line::from_iter([ Span::from("Calendar Widget").bold(), - Span::from(" (Press 'q' to quit)"), + Span::from(" (Press 'q' or Esc to quit)"), ]); frame.render_widget(title.centered(), top); @@ -55,7 +62,7 @@ fn render(frame: &mut Frame) { /// Render the current month calendar. fn render_current_month(frame: &mut Frame, area: Rect) { - let date = OffsetDateTime::now_utc().date(); + let date = ZonedDateTime::now().date(); let monthly = Monthly::new( date, @@ -70,7 +77,7 @@ fn render_current_month(frame: &mut Frame, area: Rect) { /// Render an arbitrary month with more styles. fn render_styled_month(frame: &mut Frame, area: Rect) { // Release date of the movie Ratatouille. - let date = Date::from_calendar_date(2007, Month::June, 29).unwrap(); + let date = date(2007, 6, 29); let mut event_store = CalendarEventStore::today(Style::default().red().bold()); event_store.add(date, Style::default().blue().italic()); diff --git a/vendor/ratatui/ratatui-calendar/examples/chrono.rs b/vendor/ratatui/ratatui-calendar/examples/chrono.rs new file mode 100644 index 0000000..501e138 --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/examples/chrono.rs @@ -0,0 +1,59 @@ +//! # [Ratatui] calendar `chrono` example +//! +//! Shows an app that uses the `chrono` crate for its own dates. The calendar takes jiff +//! dates, so the app converts each `chrono::NaiveDate` at the boundary. +//! +//! The latest version of this example is available in the [calendar examples] folder in the +//! repository. The examples are designed to be run against the `main` branch of the GitHub +//! repository, so they may not compile with the latest release on crates.io. +//! +//! [Ratatui]: https://github.com/ratatui/ratatui +//! [calendar examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples + +use chrono::{Datelike, Local, NaiveDate}; +use color_eyre::Result; +use color_eyre::eyre::OptionExt; +use crossterm::event::{self, KeyCode}; +use ratatui::DefaultTerminal; +use ratatui::style::Style; +use ratatui::widgets::Block; +use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; + +fn main() -> Result<()> { + color_eyre::install()?; + ratatui::run(run) +} + +/// Render this month, with a deadline marked, until `q` or Esc is pressed. +fn run(terminal: &mut DefaultTerminal) -> Result<()> { + // The app's own dates, as `chrono` values. + let today = Local::now().date_naive(); + let deadline = NaiveDate::from_ymd_opt(today.year(), 12, 24).ok_or_eyre("invalid date")?; + + let today = to_jiff(today)?; + let deadline = to_jiff(deadline)?; + + let mut events = CalendarEventStore::default(); + events.add(deadline, Style::new().red().bold()); + let calendar = Monthly::new(today, events) + .show_month_header(Style::new().bold()) + .show_weekdays_header(Style::new().italic()) + .block(Block::bordered().title("chrono::NaiveDate (press q or Esc to quit)")); + loop { + terminal.draw(|frame| frame.render_widget(&calendar, frame.area()))?; + if let Some(key) = event::read()?.as_key_press_event() + && matches!(key.code, KeyCode::Char('q') | KeyCode::Esc) + { + return Ok(()); + } + } +} + +/// Converts a `chrono` date to the jiff date the calendar uses. +fn to_jiff(date: NaiveDate) -> Result { + let year = i16::try_from(date.year())?; + let month = i8::try_from(date.month())?; + let day = i8::try_from(date.day())?; + let date = jiff::civil::Date::new(year, month, day)?; + Ok(date) +} diff --git a/vendor/ratatui/ratatui-calendar/examples/minimal.rs b/vendor/ratatui/ratatui-calendar/examples/minimal.rs new file mode 100644 index 0000000..671050b --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/examples/minimal.rs @@ -0,0 +1,40 @@ +//! # [Ratatui] calendar `minimal` example +//! +//! Renders the current month and quits on `q` or Esc. +//! +//! The latest version of this example is available in the [calendar examples] folder in the +//! repository. The examples are designed to be run against the `main` branch of the GitHub +//! repository, so they may not compile with the latest release on crates.io. +//! +//! [Ratatui]: https://github.com/ratatui/ratatui +//! [calendar examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples + +use color_eyre::Result; +use crossterm::event::{self, KeyCode}; +use jiff::ZonedDateTime; +use ratatui::DefaultTerminal; +use ratatui::style::Style; +use ratatui::widgets::Block; +use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; + +fn main() -> Result<()> { + color_eyre::install()?; + ratatui::run(run) +} + +/// Render the current month until `q` or Esc is pressed. +fn run(terminal: &mut DefaultTerminal) -> Result<()> { + let today = ZonedDateTime::now().date(); + let calendar = Monthly::new(today, CalendarEventStore::today(Style::new().red().bold())) + .show_month_header(Style::new().bold()) + .show_weekdays_header(Style::new().italic()) + .block(Block::bordered().title("Press q or Esc to quit")); + loop { + terminal.draw(|frame| frame.render_widget(&calendar, frame.area()))?; + if let Some(key) = event::read()?.as_key_press_event() + && matches!(key.code, KeyCode::Char('q') | KeyCode::Esc) + { + return Ok(()); + } + } +} diff --git a/vendor/ratatui/ratatui-calendar/examples/time.rs b/vendor/ratatui/ratatui-calendar/examples/time.rs new file mode 100644 index 0000000..20000ca --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/examples/time.rs @@ -0,0 +1,58 @@ +//! # [Ratatui] calendar `time` example +//! +//! Shows an app that uses the `time` crate for its own dates. The calendar takes jiff dates, +//! so the app converts each `time::Date` at the boundary. +//! +//! The latest version of this example is available in the [calendar examples] folder in the +//! repository. The examples are designed to be run against the `main` branch of the GitHub +//! repository, so they may not compile with the latest release on crates.io. +//! +//! [Ratatui]: https://github.com/ratatui/ratatui +//! [calendar examples]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples + +use color_eyre::Result; +use crossterm::event::{self, KeyCode}; +use ratatui::DefaultTerminal; +use ratatui::style::Style; +use ratatui::widgets::Block; +use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; +use time::{Date, Month, OffsetDateTime}; + +fn main() -> Result<()> { + color_eyre::install()?; + ratatui::run(run) +} + +/// Render this month, with a deadline marked, until `q` or Esc is pressed. +fn run(terminal: &mut DefaultTerminal) -> Result<()> { + // The app's own dates, as `time` values. + let today = OffsetDateTime::now_utc().date(); + let deadline = Date::from_calendar_date(today.year(), Month::December, 24)?; + + let today = to_jiff(today)?; + let deadline = to_jiff(deadline)?; + + let mut events = CalendarEventStore::default(); + events.add(deadline, Style::new().red().bold()); + let calendar = Monthly::new(today, events) + .show_month_header(Style::new().bold()) + .show_weekdays_header(Style::new().italic()) + .block(Block::bordered().title("time::Date (press q or Esc to quit)")); + loop { + terminal.draw(|frame| frame.render_widget(&calendar, frame.area()))?; + if let Some(key) = event::read()?.as_key_press_event() + && matches!(key.code, KeyCode::Char('q') | KeyCode::Esc) + { + return Ok(()); + } + } +} + +/// Converts a `time` date to the jiff date the calendar uses. +fn to_jiff(date: Date) -> Result { + let year = i16::try_from(date.year())?; + let month = i8::try_from(u8::from(date.month()))?; + let day = i8::try_from(date.day())?; + let date = jiff::civil::Date::new(year, month, day)?; + Ok(date) +} diff --git a/vendor/ratatui/examples/vhs/calendar-explorer.tape b/vendor/ratatui/ratatui-calendar/examples/vhs/calendar-explorer.tape similarity index 62% rename from vendor/ratatui/examples/vhs/calendar-explorer.tape rename to vendor/ratatui/ratatui-calendar/examples/vhs/calendar-explorer.tape index ba21fe9..123f6b3 100644 --- a/vendor/ratatui/examples/vhs/calendar-explorer.tape +++ b/vendor/ratatui/ratatui-calendar/examples/vhs/calendar-explorer.tape @@ -1,11 +1,11 @@ # This is a vhs script. See https://github.com/charmbracelet/vhs for more info. -# To run this script, install vhs and run `vhs ./examples/vhs/calendar-explorer.tape` +# To run this script, install vhs and run `vhs ./ratatui-calendar/examples/vhs/calendar-explorer.tape` Output "target/calendar-explorer.gif" Set Theme "Aardvark Blue" Set Width 1200 Set Height 800 Hide -Type "cargo run -p calendar-explorer" +Type "cargo run -p ratatui-calendar --example calendar-explorer" Enter Sleep 3s Show diff --git a/vendor/ratatui/ratatui-widgets/examples/vhs/calendar.tape b/vendor/ratatui/ratatui-calendar/examples/vhs/calendar.tape similarity index 57% rename from vendor/ratatui/ratatui-widgets/examples/vhs/calendar.tape rename to vendor/ratatui/ratatui-calendar/examples/vhs/calendar.tape index 4f7bea7..e3fa746 100644 --- a/vendor/ratatui/ratatui-widgets/examples/vhs/calendar.tape +++ b/vendor/ratatui/ratatui-calendar/examples/vhs/calendar.tape @@ -1,11 +1,11 @@ # This is a vhs script. See https://github.com/charmbracelet/vhs for more info. -# To run this script, install vhs and run `vhs ./ratatui-widgets/examples/vhs/calendar.tape` +# To run this script, install vhs and run `vhs ./ratatui-calendar/examples/vhs/calendar.tape` Output "target/calendar.gif" Set Theme "Aardvark Blue" Set Width 1200 Set Height 800 Hide -Type "cargo run -p ratatui-widgets --example calendar" +Type "cargo run -p ratatui-calendar --example calendar" Enter Sleep 3s Show diff --git a/vendor/ratatui/ratatui-calendar/src/lib.rs b/vendor/ratatui/ratatui-calendar/src/lib.rs new file mode 100644 index 0000000..04e0655 --- /dev/null +++ b/vendor/ratatui/ratatui-calendar/src/lib.rs @@ -0,0 +1,868 @@ +#![no_std] +// show the feature flags in the generated documentation +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc( + html_logo_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/logo.png", + html_favicon_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/favicon.ico" +)] +#![warn(missing_docs)] +#![warn(clippy::std_instead_of_core)] +#![warn(clippy::std_instead_of_alloc)] +#![warn(clippy::alloc_instead_of_core)] +//! **ratatui-calendar** provides a monthly calendar widget for [Ratatui] terminal user +//! interfaces. +//! +//! [Ratatui]: https://crates.io/crates/ratatui +//! +//! Most applications use this crate through `ratatui::widgets::calendar` by enabling the +//! `widget-calendar` feature of the `ratatui` crate (on by default via `all-widgets`). Depend on +//! `ratatui-calendar` directly if you are building a widget library, or if you want finer-grained +//! dependencies than the `ratatui` crate gives you. +//! +//! Dates are [`jiff::civil::Date`] values from the [jiff] crate. Use [`jiff::civil::date`] to +//! build one from a year, month and day. +//! +//! The calendar previously lived in the `calendar` module of `ratatui-widgets`. It moved to its +//! own crate because it is the only built-in widget whose public API uses a third-party type (the +//! date type), and a separate crate lets that dependency change without a breaking release of +//! `ratatui-widgets`. +//! +//! [jiff]: https://crates.io/crates/jiff +//! +//! # Installation +//! +//! Run the following command to add this crate to your project: +//! +//! ```sh +//! cargo add ratatui-calendar jiff +//! ``` +//! +//! # Usage +//! +//! [`Monthly`] renders the month that contains its `display_date`, one row per week starting on +//! Sunday. Each day uses the default style unless the [`DateStyler`] returns a style for it, and +//! days outside the month are only drawn when [`Monthly::show_surrounding`] is set. Optional +//! headers show the month name and the weekdays, and a [`Block`] can wrap the calendar. +//! +//! [`CalendarEventStore`] is a ready-made [`DateStyler`] that maps dates to styles. Implement +//! [`DateStyler`] yourself to compute styles on the fly, for example from an events database. +//! +//! [`Monthly::width`] and [`Monthly::height`] report the size the calendar needs, which is useful +//! for laying it out with a fixed-size constraint. +//! +//! ```rust +//! use jiff::civil::date; +//! use ratatui_calendar::{CalendarEventStore, Monthly}; +//! use ratatui_core::buffer::Buffer; +//! use ratatui_core::layout::Rect; +//! use ratatui_core::style::{Color, Modifier, Style}; +//! use ratatui_core::widgets::Widget; +//! use ratatui_widgets::block::Block; +//! +//! let november = date(2026, 11, 1); +//! +//! let mut events = CalendarEventStore::default(); +//! events.add( +//! date(2026, 11, 26), +//! Style::new().fg(Color::Red).add_modifier(Modifier::BOLD), +//! ); +//! +//! let calendar = Monthly::new(november, events) +//! .show_month_header(Style::new().add_modifier(Modifier::BOLD)) +//! .show_weekdays_header(Style::new().fg(Color::Cyan)) +//! .show_surrounding(Style::new().fg(Color::DarkGray)) +//! .block(Block::bordered().title("Calendar")); +//! +//! let area = Rect::new(0, 0, calendar.width(), calendar.height()); +//! let mut buf = Buffer::empty(area); +//! calendar.render(area, &mut buf); +//! ``` +//! +//! # Examples +//! +//! Run these with `cargo run -p ratatui-calendar --example `. +//! +//! The main example is [`calendar-explorer`]. It is intentionally the most complex one, to show +//! off the features: every style option across a whole year, with holidays and recurring events +//! computed using jiff, and keyboard navigation. +//! +//! The smaller examples are easier to start from: +//! +//! - [`minimal`]: the current month in a bordered block. +//! - [`calendar`]: two months side by side with different styles. +//! - [`time`]: an app that keeps its own dates as `time::Date` and converts them at the boundary. +//! - [`chrono`]: the same for an app that uses `chrono::NaiveDate`. +//! +//! [`Block`]: ratatui_widgets::block::Block +//! [`calendar-explorer`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/calendar-explorer.rs +//! [`minimal`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/minimal.rs +//! [`calendar`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/calendar.rs +//! [`time`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/time.rs +//! [`chrono`]: https://github.com/ratatui/ratatui/blob/main/ratatui-calendar/examples/chrono.rs +//! +//! # Crate Organization +//! +//! `ratatui-calendar` is part of the Ratatui workspace. It builds on [`ratatui-core`] for the +//! widget traits and on [`ratatui-widgets`] for [`Block`], and the main [`ratatui`] crate +//! re-exports it as `ratatui::widgets::calendar`. +//! +//! **When to use `ratatui-calendar`:** +//! +//! - Building widget libraries that embed or wrap the calendar +//! - You want finer-grained dependencies than the `ratatui` crate +//! +//! **When to use the main [`ratatui`] crate:** +//! +//! - Building applications (recommended - includes everything you need) +//! +//! For detailed information about the workspace organization, see [ARCHITECTURE.md]. +//! +//! [`ratatui`]: https://crates.io/crates/ratatui +//! [`ratatui-core`]: https://crates.io/crates/ratatui-core +//! [`ratatui-widgets`]: https://crates.io/crates/ratatui-widgets +//! [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md +#![cfg_attr(feature = "document-features", doc = "\n## Features")] +#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] +//! +//! # Contributing +//! +//! Contributions are welcome! Please open an issue or submit a pull request on GitHub. For more +//! details on contributing, please see the [CONTRIBUTING](../CONTRIBUTING.md) document. +//! +//! # License +//! +//! This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. + +extern crate alloc; +#[cfg(feature = "std")] +extern crate std; + +use alloc::format; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; + +use hashbrown::HashMap; +use jiff::ToSpan; +use jiff::civil::{Date, Weekday}; +use ratatui_core::buffer::Buffer; +use ratatui_core::layout::{Alignment, Constraint, Layout, Rect}; +use ratatui_core::style::Style; +use ratatui_core::text::{Line, Span}; +use ratatui_core::widgets::Widget; +use ratatui_widgets::block::{Block, BlockExt}; + +/// Display a month calendar for the month containing `display_date` +#[derive(Debug, Clone, Eq, PartialEq, Hash)] +pub struct Monthly<'a, DS: DateStyler> { + display_date: Date, + events: DS, + show_surrounding: Option