From deaa779a9478bcc4be99d8bddc636a9710045cb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 26 Oct 2024 07:26:28 +0000 Subject: [PATCH 1/2] build(deps): bump the minor-patch group across 1 directory with 6 updates Bumps the minor-patch group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [crossterm](https://github.com/crossterm-rs/crossterm) | `0.27.0` | `0.28.1` | | [ratatui](https://github.com/ratatui/ratatui) | `0.27.0` | `0.28.1` | | [serde](https://github.com/serde-rs/serde) | `1.0.210` | `1.0.213` | | [tui-prompts](https://github.com/joshka/tui-widgets) | `0.3.20` | `0.5.0` | | [regex](https://github.com/rust-lang/regex) | `1.11.0` | `1.11.1` | | [unicode-width](https://github.com/unicode-rs/unicode-width) | `0.1.14` | `0.2.0` | Updates `crossterm` from 0.27.0 to 0.28.1 - [Release notes](https://github.com/crossterm-rs/crossterm/releases) - [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md) - [Commits](https://github.com/crossterm-rs/crossterm/commits) Updates `ratatui` from 0.27.0 to 0.28.1 - [Release notes](https://github.com/ratatui/ratatui/releases) - [Changelog](https://github.com/ratatui/ratatui/blob/main/CHANGELOG.md) - [Commits](https://github.com/ratatui/ratatui/compare/v0.27.0...v0.28.1) Updates `serde` from 1.0.210 to 1.0.213 - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.210...v1.0.213) Updates `tui-prompts` from 0.3.20 to 0.5.0 - [Release notes](https://github.com/joshka/tui-widgets/releases) - [Changelog](https://github.com/joshka/tui-widgets/blob/main/CHANGELOG.md) - [Commits](https://github.com/joshka/tui-widgets/compare/tui-prompts-v0.3.20...tui-prompts-v0.5.0) Updates `regex` from 1.11.0 to 1.11.1 - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.11.0...1.11.1) Updates `unicode-width` from 0.1.14 to 0.2.0 - [Commits](https://github.com/unicode-rs/unicode-width/commits) --- updated-dependencies: - dependency-name: crossterm dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-patch - dependency-name: ratatui dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-patch - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-patch - dependency-name: tui-prompts dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-patch - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-patch - dependency-name: unicode-width dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 138 +++++++++++++++++++---------------------------------- Cargo.toml | 12 ++--- 2 files changed, 55 insertions(+), 95 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfead32c97..1db2b39190 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,20 +293,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" -[[package]] -name = "compact_str" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" -dependencies = [ - "castaway", - "cfg-if", - "itoa", - "ryu", - "serde", - "static_assertions", -] - [[package]] name = "compact_str" version = "0.8.0" @@ -318,6 +304,7 @@ dependencies = [ "itoa", "rustversion", "ryu", + "serde", "static_assertions", ] @@ -400,22 +387,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crossterm" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" -dependencies = [ - "bitflags", - "crossterm_winapi", - "libc", - "mio 0.8.11", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - [[package]] name = "crossterm" version = "0.28.1" @@ -424,7 +395,7 @@ checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ "bitflags", "crossterm_winapi", - "mio 1.0.2", + "mio", "parking_lot", "rustix", "signal-hook", @@ -672,7 +643,7 @@ dependencies = [ "chrono", "clap", "criterion", - "crossterm 0.27.0", + "crossterm", "etcetera", "figment", "git-version", @@ -682,7 +653,7 @@ dependencies = [ "log", "nom", "pretty_assertions", - "ratatui 0.27.0", + "ratatui 0.28.1", "regex", "serde", "similar", @@ -711,7 +682,7 @@ dependencies = [ "tree-sitter-toml", "tree-sitter-typescript", "tui-prompts", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -811,6 +782,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "insta" version = "1.40.0" @@ -977,18 +954,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.2" @@ -1252,54 +1217,54 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.27.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16546c5b5962abf8ce6e2881e722b4e0ae3b6f1a08a26ae3573c55853ca68d3" +checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" dependencies = [ "bitflags", "cassowary", - "compact_str 0.7.1", - "crossterm 0.27.0", + "compact_str", + "crossterm", + "instability", "itertools 0.13.0", "lru", "paste", "serde", - "stability", "strum", "strum_macros", "unicode-segmentation", "unicode-truncate", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "ratatui" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ "bitflags", "cassowary", - "compact_str 0.8.0", - "crossterm 0.28.1", + "compact_str", + "crossterm", + "indoc", "instability", "itertools 0.13.0", "lru", "paste", "strum", - "strum_macros", "unicode-segmentation", "unicode-truncate", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] name = "ratatui-macros" -version = "0.4.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4a88a1767c49fc279878ee4384117a03ae99377b5262da937d66a7d5eea240" +checksum = "6fef540f80dbe8a0773266fa6077788ceb65ef624cdbf36e131aaf90b4a52df4" dependencies = [ - "ratatui 0.28.1", + "ratatui 0.29.0", ] [[package]] @@ -1339,9 +1304,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -1374,9 +1339,9 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "rstest" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afd55a67069d6e434a95161415f5beeada95a01c7b815508a82dcb0e1593682" +checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" dependencies = [ "futures", "futures-timer", @@ -1386,9 +1351,9 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4165dfae59a39dd41d8dec720d3cbfbc71f69744efb480a3920f5d4e0cc6798d" +checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a" dependencies = [ "cfg-if", "glob", @@ -1459,18 +1424,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -1515,8 +1480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio 0.8.11", - "mio 1.0.2", + "mio", "signal-hook", ] @@ -1565,16 +1529,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "stability" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -1611,9 +1565,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -1929,12 +1883,12 @@ dependencies = [ [[package]] name = "tui-prompts" -version = "0.3.20" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b552384d04152fa742c92973ceb8c9f2b9b0e59e7326e6ab2348a9b9d6989010" +checksum = "eb6e0d8a972545cc209b933a1c06dab8932674b54ae19947834ec854fec2364f" dependencies = [ "itertools 0.13.0", - "ratatui 0.27.0", + "ratatui 0.29.0", "ratatui-macros", "rstest", ] @@ -1983,7 +1937,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" dependencies = [ "itertools 0.13.0", "unicode-segmentation", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -1992,6 +1946,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "url" version = "2.5.2" diff --git a/Cargo.toml b/Cargo.toml index 976f7d7ec7..f508414e5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ pretty_assertions = "1.4.0" temp-dir = "0.1.13" criterion = "0.5.1" insta = "1.39.0" -unicode-width = "0.1.12" +unicode-width = "0.2.0" [profile.release] strip = true @@ -25,7 +25,7 @@ arboard = { version = "3.4.0", default-features = false, features = [ ] } chrono = "0.4.38" clap = { version = "4.5.16", features = ["derive"] } -crossterm = "0.27.0" +crossterm = "0.28.1" etcetera = "0.8.0" figment = { version = "0.10.19", features = ["toml"] } git-version = "0.3.9" @@ -33,12 +33,12 @@ git2 = { version = "0.19.0", default-features = false } itertools = "0.13.0" log = "0.4.22" nom = "7.1.3" -ratatui = { version = "0.27.0", features = ["serde"] } -serde = { version = "1.0.209", features = ["derive"] } +ratatui = { version = "0.28.1", features = ["serde"] } +serde = { version = "1.0.213", features = ["derive"] } similar = { version = "2.6.0", features = ["unicode", "inline"] } simple-logging = "2.0.2" toml = "0.8.15" -tui-prompts = "0.3.20" +tui-prompts = "0.5.0" tree-sitter = "=0.20.10" tree-sitter-highlight = "=0.20.1" tree-sitter-rust = "=0.20.4" @@ -60,4 +60,4 @@ tree-sitter-scala = "=0.20.3" tree-sitter-ocaml = "=0.20.4" tree-sitter-html = "=0.20.0" tree-sitter-elixir = "=0.1.1" -regex = "1.10.6" +regex = "1.11.1" From 0d2ce15cadd9130770bfa8be47b5ad6566c1ec69 Mon Sep 17 00:00:00 2001 From: altsem Date: Sun, 27 Oct 2024 10:42:57 +0100 Subject: [PATCH 2/2] chore: update ratatui to 0.29.0 --- Cargo.lock | 29 ++++----------------------- Cargo.toml | 2 +- src/screen/log.rs | 4 ++-- src/screen/mod.rs | 14 ++++++------- src/screen/show.rs | 4 ++-- src/screen/show_refs.rs | 4 ++-- src/screen/status.rs | 4 ++-- src/state.rs | 6 +++--- src/term.rs | 44 ++++++++++++++++++++--------------------- src/tests/helpers/ui.rs | 20 +++++++++---------- src/ui.rs | 6 +++--- 11 files changed, 57 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1db2b39190..689dce90ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -653,7 +653,7 @@ dependencies = [ "log", "nom", "pretty_assertions", - "ratatui 0.28.1", + "ratatui", "regex", "serde", "similar", @@ -1215,28 +1215,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "ratatui" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" -dependencies = [ - "bitflags", - "cassowary", - "compact_str", - "crossterm", - "instability", - "itertools 0.13.0", - "lru", - "paste", - "serde", - "strum", - "strum_macros", - "unicode-segmentation", - "unicode-truncate", - "unicode-width 0.1.14", -] - [[package]] name = "ratatui" version = "0.29.0" @@ -1252,6 +1230,7 @@ dependencies = [ "itertools 0.13.0", "lru", "paste", + "serde", "strum", "unicode-segmentation", "unicode-truncate", @@ -1264,7 +1243,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fef540f80dbe8a0773266fa6077788ceb65ef624cdbf36e131aaf90b4a52df4" dependencies = [ - "ratatui 0.29.0", + "ratatui", ] [[package]] @@ -1888,7 +1867,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb6e0d8a972545cc209b933a1c06dab8932674b54ae19947834ec854fec2364f" dependencies = [ "itertools 0.13.0", - "ratatui 0.29.0", + "ratatui", "ratatui-macros", "rstest", ] diff --git a/Cargo.toml b/Cargo.toml index f508414e5d..50191d9ea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ git2 = { version = "0.19.0", default-features = false } itertools = "0.13.0" log = "0.4.22" nom = "7.1.3" -ratatui = { version = "0.28.1", features = ["serde"] } +ratatui = { version = "0.29.0", features = ["serde"] } serde = { version = "1.0.213", features = ["derive"] } similar = { version = "2.6.0", features = ["unicode", "inline"] } simple-logging = "2.0.2" diff --git a/src/screen/log.rs b/src/screen/log.rs index ee5df1ed2c..60bcd66c54 100644 --- a/src/screen/log.rs +++ b/src/screen/log.rs @@ -1,14 +1,14 @@ use super::Screen; use crate::{config::Config, items::log, Res}; use git2::{Oid, Repository}; -use ratatui::prelude::Rect; +use ratatui::layout::Size; use regex::Regex; use std::rc::Rc; pub(crate) fn create( config: Rc, repo: Rc, - size: Rect, + size: Size, limit: usize, rev: Option, msg_regex: Option, diff --git a/src/screen/mod.rs b/src/screen/mod.rs index 8aecc4adad..76b7e153fc 100644 --- a/src/screen/mod.rs +++ b/src/screen/mod.rs @@ -20,7 +20,7 @@ pub(crate) enum NavMode { } pub(crate) struct Screen { - pub(crate) size: Rect, + pub(crate) size: Size, cursor: usize, scroll: usize, config: Rc, @@ -33,7 +33,7 @@ pub(crate) struct Screen { impl Screen { pub(crate) fn new( config: Rc, - size: Rect, + size: Size, refresh_items: Box Res>>, ) -> Res { let mut screen = Self { @@ -276,7 +276,7 @@ impl Screen { &self.items[self.line_index[self.cursor]] } - fn line_views(&self, area: Rect) -> impl Iterator { + fn line_views(&self, area: Size) -> impl Iterator { let scan_start = self.scroll.min(self.cursor); let scan_end = (self.scroll + area.height as usize).min(self.line_index.len()); let scan_highlight_range = scan_start..(scan_end); @@ -314,7 +314,7 @@ impl Widget for &Screen { fn render(self, area: Rect, buf: &mut Buffer) { let style = &self.config.style; - for (line_index, line) in self.line_views(area).enumerate() { + for (line_index, line) in self.line_views(area.as_size()).enumerate() { let line_area = Rect { x: 0, y: line_index as u16, @@ -330,7 +330,7 @@ impl Widget for &Screen { if self.line_index[self.cursor] == line.item_index { buf.set_style(line_area, &style.selection_line); } else { - buf.get_mut(0, line_index as u16) + buf[(0, line_index as u16)] .set_char(style.selection_bar.symbol) .set_style(&style.selection_bar); } @@ -342,11 +342,11 @@ impl Widget for &Screen { if self.is_collapsed(line.item) && line.display.width() > 0 || overflow { let line_end = (indented_line_area.x + line.display.width() as u16).min(area.width - 1); - buf.get_mut(line_end, line_index as u16).set_char('…'); + buf[(line_end, line_index as u16)].set_char('…'); } if self.line_index[self.cursor] == line.item_index { - buf.get_mut(0, line_index as u16) + buf[(0, line_index as u16)] .set_char(style.cursor.symbol) .set_style(&style.cursor); } diff --git a/src/screen/show.rs b/src/screen/show.rs index 99554783fb..700cadb3ad 100644 --- a/src/screen/show.rs +++ b/src/screen/show.rs @@ -8,7 +8,7 @@ use crate::{ }; use git2::Repository; use ratatui::{ - prelude::Rect, + layout::Size, text::{Line, Text}, }; @@ -17,7 +17,7 @@ use super::Screen; pub(crate) fn create( config: Rc, repo: Rc, - size: Rect, + size: Size, reference: String, ) -> Res { Screen::new( diff --git a/src/screen/show_refs.rs b/src/screen/show_refs.rs index 70ab530387..c66d2e4b17 100644 --- a/src/screen/show_refs.rs +++ b/src/screen/show_refs.rs @@ -12,11 +12,11 @@ use crate::{ }; use git2::{Reference, Repository}; use ratatui::{ - prelude::Rect, + layout::Size, text::{Line, Span}, }; -pub(crate) fn create(config: Rc, repo: Rc, size: Rect) -> Res { +pub(crate) fn create(config: Rc, repo: Rc, size: Size) -> Res { Screen::new( Rc::clone(&config), size, diff --git a/src/screen/status.rs b/src/screen/status.rs index e504bde6ea..7f0dcafcbd 100644 --- a/src/screen/status.rs +++ b/src/screen/status.rs @@ -8,12 +8,12 @@ use crate::{ }; use git2::Repository; use ratatui::{ - prelude::Rect, + prelude::Size, text::{Line, Span}, }; use std::{path::PathBuf, rc::Rc}; -pub(crate) fn create(config: Rc, repo: Rc, size: Rect) -> Res { +pub(crate) fn create(config: Rc, repo: Rc, size: Size) -> Res { Screen::new( Rc::clone(&config), size, diff --git a/src/state.rs b/src/state.rs index 788cba1dcb..cf71aa7273 100644 --- a/src/state.rs +++ b/src/state.rs @@ -15,7 +15,7 @@ use crossterm::event::KeyCode; use crossterm::event::KeyEventKind; use crossterm::event::KeyModifiers; use git2::Repository; -use ratatui::layout::Rect; +use ratatui::layout::Size; use tui_prompts::State as _; use tui_prompts::Status; @@ -53,7 +53,7 @@ pub(crate) struct State { impl State { pub fn create( repo: Rc, - size: Rect, + size: Size, args: &cli::Args, config: Rc, enable_async_cmds: bool, @@ -102,7 +102,7 @@ impl State { match *event { Event::Resize(w, h) => { for screen in self.screens.iter_mut() { - screen.size = Rect::new(0, 0, w, h); + screen.size = Size::new(w, h); } } Event::Key(key) => { diff --git a/src/term.rs b/src/term.rs index d28899e574..f4dea14f5e 100644 --- a/src/term.rs +++ b/src/term.rs @@ -1,21 +1,19 @@ use crate::Res; -use crossterm::terminal::disable_raw_mode; -use crossterm::terminal::enable_raw_mode; -use crossterm::terminal::is_raw_mode_enabled; -use crossterm::terminal::EnterAlternateScreen; -use crossterm::terminal::LeaveAlternateScreen; -use crossterm::ExecutableCommand; -use ratatui::backend::Backend; -use ratatui::backend::CrosstermBackend; -use ratatui::backend::TestBackend; -use ratatui::prelude::backend::WindowSize; -use ratatui::prelude::buffer::Cell; -use ratatui::prelude::Rect; -use ratatui::Terminal; +use crossterm::{ + terminal::{ + disable_raw_mode, enable_raw_mode, is_raw_mode_enabled, EnterAlternateScreen, + LeaveAlternateScreen, + }, + ExecutableCommand, +}; +use ratatui::{ + backend::{Backend, CrosstermBackend, TestBackend}, + layout::Size, + prelude::{backend::WindowSize, buffer::Cell, Position}, + Terminal, +}; use std::fmt::Display; -use std::io; -use std::io::stderr; -use std::io::Stderr; +use std::io::{self, stderr, Stderr}; pub type Term = Terminal; @@ -95,17 +93,17 @@ impl Backend for TermBackend { } } - fn get_cursor(&mut self) -> io::Result<(u16, u16)> { + fn get_cursor_position(&mut self) -> io::Result { match self { - TermBackend::Crossterm(t) => t.get_cursor(), - TermBackend::Test(t) => t.get_cursor(), + TermBackend::Crossterm(t) => t.get_cursor_position(), + TermBackend::Test(t) => t.get_cursor_position(), } } - fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> { + fn set_cursor_position>(&mut self, position: P) -> io::Result<()> { match self { - TermBackend::Crossterm(t) => t.set_cursor(x, y), - TermBackend::Test(t) => t.set_cursor(x, y), + TermBackend::Crossterm(t) => t.set_cursor_position(position), + TermBackend::Test(t) => t.set_cursor_position(position), } } @@ -116,7 +114,7 @@ impl Backend for TermBackend { } } - fn size(&self) -> io::Result { + fn size(&self) -> io::Result { match self { TermBackend::Crossterm(t) => t.size(), TermBackend::Test(t) => t.size(), diff --git a/src/tests/helpers/ui.rs b/src/tests/helpers/ui.rs index a97870b1bf..c1e287ea57 100644 --- a/src/tests/helpers/ui.rs +++ b/src/tests/helpers/ui.rs @@ -8,7 +8,7 @@ use crate::{ }; use crossterm::event::{Event, KeyEvent}; use git2::Repository; -use ratatui::{backend::TestBackend, prelude::Rect, Terminal}; +use ratatui::{backend::TestBackend, layout::Size, Terminal}; use std::{path::PathBuf, rc::Rc}; use temp_dir::TempDir; @@ -31,35 +31,35 @@ pub struct TestContext { pub term: Term, pub dir: TempDir, pub remote_dir: TempDir, - pub size: Rect, + pub size: Size, config: Rc, } impl TestContext { pub fn setup_init() -> Self { - let width = 80; - let height = 20; - let term = Terminal::new(TermBackend::Test(TestBackend::new(width, height))).unwrap(); + let size = Size::new(80, 20); + let term = + Terminal::new(TermBackend::Test(TestBackend::new(size.width, size.height))).unwrap(); let repo_ctx = RepoTestContext::setup_init(); Self { term, dir: repo_ctx.dir, remote_dir: repo_ctx.remote_dir, - size: Rect::new(0, 0, width, height), + size, config: Rc::new(config::init_test_config().unwrap()), } } pub fn setup_clone() -> Self { - let width = 80; - let height = 20; - let term = Terminal::new(TermBackend::Test(TestBackend::new(width, height))).unwrap(); + let size = Size::new(80, 20); + let term = + Terminal::new(TermBackend::Test(TestBackend::new(size.width, size.height))).unwrap(); let repo_ctx = RepoTestContext::setup_clone(); Self { term, dir: repo_ctx.dir, remote_dir: repo_ctx.remote_dir, - size: Rect::new(0, 0, width, height), + size, config: Rc::new(config::init_test_config().unwrap()), } } diff --git a/src/ui.rs b/src/ui.rs index 33f1cb318d..5a84ddde2e 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -67,7 +67,7 @@ pub(crate) fn ui(frame: &mut Frame, state: &mut State) { widget_height(&maybe_log), ], ) - .split(frame.size()); + .split(frame.area()); frame.render_widget(state.screens.last().unwrap(), layout[0]); @@ -77,10 +77,10 @@ pub(crate) fn ui(frame: &mut Frame, state: &mut State) { if let Some(prompt) = maybe_prompt { frame.render_stateful_widget(prompt, layout[1], &mut state.prompt.state); let (cx, cy) = state.prompt.state.cursor(); - frame.set_cursor(cx, cy); + frame.set_cursor_position((cx, cy)); } - state.screens.last_mut().unwrap().size = layout[0]; + state.screens.last_mut().unwrap().size = layout[0].as_size(); } fn popup_block() -> Block<'static> {