Skip to content

Commit

Permalink
upgrade tui to 0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmaco committed Jun 6, 2020
1 parent 42a3846 commit 3940f95
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
18 changes: 4 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -15,7 +15,7 @@ default = []
nvidia = ["nvml-wrapper"]

[dependencies]
tui = "0.6.*"
tui = "0.9.*"
termion = "1.5"
byte-unit = "3.0.3"
users = "0.9.1"
Expand Down
26 changes: 23 additions & 3 deletions src/render.rs
Expand Up @@ -26,18 +26,37 @@ use termion::screen::AlternateScreen;
use tui::backend::TermionBackend;

use std::ops::Mul;
use tui::backend::Backend;
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use tui::style::{Color, Modifier, Style};
use tui::widgets::{
BarChart, Block, Borders, List, Paragraph, Row, Sparkline, Table, Text, Widget,
};
use tui::widgets::{BarChart, Block, Borders, List, Paragraph, Row, Sparkline, Table, Text};
use tui::Frame;
use tui::Terminal;

const PROCESS_SELECTION_GRACE: Duration = Duration::from_millis(2000);

type ZBackend = TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<Stdout>>>>;

/// Compatibility trait, that preserves an older method from tui 0.6.5
/// Exists mostly to keep the caller code idiomatic for the use cases in this file
/// May be refactored out later if the widget usage patterns change
trait Render<B>
where
B: Backend,
{
fn render(self, f: &mut Frame<B>, area: Rect);
}

impl<T, B> Render<B> for T
where
T: tui::widgets::Widget,
B: Backend,
{
fn render(self, f: &mut Frame<B>, area: Rect) {
f.render_widget(self, area)
}
}

macro_rules! float_to_byte_string {
($x:expr, $unit:expr) => {
match Byte::from_unit($x, $unit) {
Expand Down Expand Up @@ -260,6 +279,7 @@ fn render_process_table(
app.threads_total
)
};
let widths: Vec<_> = widths.iter().map(|w| Constraint::Length(*w)).collect();

Table::new(header.into_iter(), rows)
.block(
Expand Down

0 comments on commit 3940f95

Please sign in to comment.