Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump ratatui to 0.28 and simplify imports #143

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 39 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ categories = ["command-line-utilities", "text-editors"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ratatui = "0.27.0"
crossterm = "0.27.0"
ratatui = "0.28.0"
clap = { version = "4.5.13", features = ["derive"] }
arboard = { version = "3.4.0", default-features = false }
memmap2 = "0.9.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ terminal.draw(|frame| {
To handle key events:

```rust
heh.handle_input(&crossterm::event::Event::Key(/* */)).unwrap();
heh.handle_input(&ratatui::crossterm::event::Event::Key(/* */)).unwrap();
```

See the [binsider](https://github.com/orhun/binsider) project for an example use case.
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use std::{error::Error, fs::File, process};

use arboard::Clipboard;
use crossterm::event::{self, Event, KeyEventKind};
use ratatui::crossterm::event::{self, Event, KeyEventKind};
use ratatui::layout::Rect;
use ratatui::Frame;

Expand Down
4 changes: 3 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use std::{
io::{Seek, Write},
};

use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind};
use ratatui::crossterm::event::{
KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind,
};

use crate::{
app::{Action, Application, Nibble},
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::{error::Error, fs::OpenOptions, io, process};

use clap::{Parser, ValueEnum};
use crossterm::tty::IsTty;
use ratatui::crossterm::tty::IsTty;

use heh::app::Application;
use heh::decoder::Encoding;
Expand Down
15 changes: 8 additions & 7 deletions src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
rc::Rc,
};

use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use ratatui::{
backend::CrosstermBackend,
crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
},
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Style},
text::{Line, Span, Text},
Expand Down Expand Up @@ -55,7 +55,8 @@
/// This errors when constructing the terminal or retrieving the terminal size fails.
pub fn new() -> Result<Self, Box<dyn Error>> {
let terminal = Terminal::new(CrosstermBackend::new(io::stdout()))?;
let terminal_size = terminal.size()?;
let size = terminal.size()?;
let terminal_size = Rect::new(0, 0, size.width, size.height);

Check warning on line 59 in src/screen.rs

View check run for this annotation

Codecov / codecov/patch

src/screen.rs#L58-L59

Added lines #L58 - L59 were not covered by tests
Ok(Self {
terminal,
terminal_size,
Expand Down Expand Up @@ -215,7 +216,7 @@
// We check if we need to recompute the terminal size in the case that the saved off
// variable differs from the current frame, which can occur when a terminal is resized
// between an event handling and a rendering.
let size = frame.size();
let size = frame.area();

Check warning on line 219 in src/screen.rs

View check run for this annotation

Codecov / codecov/patch

src/screen.rs#L219

Added line #L219 was not covered by tests
if size != self.terminal_size {
self.terminal_size = size;
self.comp_layouts = Self::calculate_dimensions(self.terminal_size, window);
Expand Down
Loading