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

chore: migrate to ratatui and update crossterm #425

Merged
merged 2 commits into from
May 31, 2023
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
112 changes: 28 additions & 84 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions tokio-console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ clap = { version = "3", features = ["cargo", "derive", "env"] }
tokio = { version = "1", features = ["full", "rt-multi-thread"] }
tonic = { version = "0.9", features = ["transport"] }
futures = "0.3"
tui = { version = "0.16.0", default-features = false, features = ["crossterm"] }
ratatui = { version = "0.20.1", default-features = false, features = ["crossterm"] }
tower = "0.4.12"
tracing = "0.1"
tracing-subscriber = { version = "0.3.0", features = ["env-filter"] }
tracing-journald = { version = "0.2", optional = true }
prost-types = "0.11"
crossterm = { version = "0.20", features = ["event-stream"] }
crossterm = { version = "0.26.1", features = ["event-stream"] }
color-eyre = { version = "0.6", features = ["issue-url"] }
hdrhistogram = { version = "7.3.0", default-features = false, features = ["serialization"] }
h2 = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions tokio-console/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ impl Connection {
}
}

pub fn render(&self, styles: &crate::view::Styles) -> tui::text::Spans {
use tui::{
pub fn render(&self, styles: &crate::view::Styles) -> ratatui::text::Spans {
use ratatui::{
style::{Color, Modifier},
text::{Span, Spans},
};
Expand Down
4 changes: 3 additions & 1 deletion tokio-console/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO(eliza): support TUI backends other than crossterm?
// TODO(eliza): support Ratatui backends other than crossterm?
// This would probably involve using `spawn_blocking` to drive their blocking
// input-handling mechanisms in the background...
pub use crossterm::event::*;
Expand All @@ -13,10 +13,12 @@ pub fn should_quit(input: &Event) -> bool {
Key(KeyEvent {
code: Char('c'),
modifiers,
..
})
| Key(KeyEvent {
code: Char('d'),
modifiers,
..
}) if modifiers.contains(KeyModifiers::CONTROL) => true,
_ => false,
}
Expand Down
4 changes: 2 additions & 2 deletions tokio-console/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use console_api::tasks::TaskDetails;
use state::State;

use futures::stream::StreamExt;
use tokio::sync::{mpsc, watch};
use tui::{
use ratatui::{
layout::{Constraint, Direction, Layout},
style::Color,
text::{Span, Spans},
widgets::{Paragraph, Wrap},
};
use tokio::sync::{mpsc, watch};

use crate::view::{bold, UpdateKind};

Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/state/async_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use crate::{
view,
};
use console_api as proto;
use ratatui::text::Span;
use std::{
cell::RefCell,
collections::HashMap,
convert::{TryFrom, TryInto},
rc::{Rc, Weak},
time::{Duration, SystemTime},
};
use tui::text::Span;

#[derive(Default, Debug)]
pub(crate) struct AsyncOpsState {
Expand Down
8 changes: 4 additions & 4 deletions tokio-console/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use crate::{
warnings::Linter,
};
use console_api as proto;
use ratatui::{
style::{Color, Modifier},
text::Span,
};
use std::{
cell::RefCell,
cmp::Ordering,
Expand All @@ -15,10 +19,6 @@ use std::{
time::{Duration, SystemTime},
};
use tasks::{Details, Task, TasksState};
use tui::{
style::{Color, Modifier},
text::Span,
};

pub mod async_ops;
pub mod histogram;
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/state/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::state::{
};
use crate::view;
use console_api as proto;
use ratatui::{style::Color, text::Span};
use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
rc::Rc,
time::{Duration, SystemTime},
};
use tui::{style::Color, text::Span};

#[derive(Default, Debug)]
pub(crate) struct ResourcesState {
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/state/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use crate::{
warnings::Linter,
};
use console_api as proto;
use ratatui::{style::Color, text::Span};
use std::{
cell::RefCell,
collections::HashMap,
convert::{TryFrom, TryInto},
rc::{Rc, Weak},
time::{Duration, SystemTime},
};
use tui::{style::Color, text::Span};

#[derive(Default, Debug)]
pub(crate) struct TasksState {
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/term.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use color_eyre::eyre::WrapErr;
pub use ratatui::{backend::CrosstermBackend, Terminal};
use std::io;
pub use tui::{backend::CrosstermBackend, Terminal};

pub fn init_crossterm() -> color_eyre::Result<(Terminal<CrosstermBackend<io::Stdout>>, OnShutdown)>
{
Expand Down
6 changes: 3 additions & 3 deletions tokio-console/src/view/async_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
},
};

use tui::{
use ratatui::{
layout,
style::{self, Color, Style},
text::Spans,
Expand Down Expand Up @@ -55,10 +55,10 @@ impl TableList<9> for AsyncOpsTable {
Self::HEADER[8].len() + 1,
];

fn render<B: tui::backend::Backend>(
fn render<B: ratatui::backend::Backend>(
table_list_state: &mut TableListState<Self, 9>,
styles: &view::Styles,
frame: &mut tui::terminal::Frame<B>,
frame: &mut ratatui::terminal::Frame<B>,
area: layout::Rect,
state: &mut State,
ctx: Self::Context,
Expand Down
Loading