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

Update ratatui version #42

Merged
merged 3 commits into from
Jul 20, 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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ travis-ci = { repository = "gin66/tui-logger" }
log = "0.4"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tui = { version = "0.19", default-features = false, package = "tui", optional = true }
ratatui = { version = "0.21", default-features = false, package = "ratatui", optional = true }
ratatui = { version = "0.22.0", default-features = false, package = "ratatui", optional = true }
tracing = {version = "0.1.37", optional = true}
tracing-subscriber = {version = "0.3", optional = true}
lazy_static = "1.0"
Expand All @@ -33,6 +33,6 @@ env_logger = "0.10.0"
default = ["tui","tui/termion"]
tui-rs = ["tui"]
slog-support = ["slog"]
ratatui-support = ["ratatui"]
ratatui-support = ["ratatui","ratatui/termion"]
tracing-support = ["tracing", "tracing-subscriber"]

16 changes: 14 additions & 2 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ use termion::{
};

#[cfg(feature = "ratatui-support")]
use ratatui as tui;
use ratatui::prelude::*;
#[cfg(feature = "ratatui-support")]
use ratatui::widgets::*;
#[cfg(feature = "ratatui-support")]
use ratatui::backend::TermionBackend;

#[cfg(not(feature = "ratatui-support"))]
use tui::backend::Backend;
#[cfg(not(feature = "ratatui-support"))]
use tui::backend::TermionBackend;
#[cfg(not(feature = "ratatui-support"))]
use tui::layout::{Constraint, Direction, Layout, Rect};
#[cfg(not(feature = "ratatui-support"))]
use tui::style::{Color, Modifier, Style};
#[cfg(not(feature = "ratatui-support"))]
use tui::widgets::{Block, Borders, Gauge, Tabs};
#[cfg(not(feature = "ratatui-support"))]
use tui::Frame;
#[cfg(not(feature = "ratatui-support"))]
use tui::Terminal;

use tui_logger::*;

struct App {
Expand Down Expand Up @@ -178,7 +190,7 @@ fn draw_frame<B: Backend>(t: &mut Frame<B>, size: Rect, app: &mut App) {
#[cfg(not(feature = "ratatui-support"))]
let tabs: Vec<tui::text::Spans> = vec!["V1".into(), "V2".into(), "V3".into(), "V4".into()];
#[cfg(feature = "ratatui-support")]
let tabs: Vec<tui::text::Line> = vec!["V1".into(), "V2".into(), "V3".into(), "V4".into()];
let tabs: Vec<Line> = vec!["V1".into(), "V2".into(), "V3".into(), "V4".into()];
let sel = app.selected_tab;

if app.states.len() <= sel {
Expand Down
22 changes: 13 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,23 @@ use std::mem;
use std::sync::Arc;

#[cfg(feature = "ratatui-support")]
use ratatui as tui;
use ratatui::prelude::*;
#[cfg(feature = "ratatui-support")]
use ratatui::widgets::*;

use chrono::{DateTime, Local};
use log::{Level, LevelFilter, Log, Metadata, Record};
use parking_lot::Mutex;

#[cfg(not(feature = "ratatui-support"))]
use tui::buffer::Buffer;
#[cfg(not(feature = "ratatui-support"))]
use tui::layout::{Constraint, Direction, Layout, Rect};
#[cfg(not(feature = "ratatui-support"))]
use tui::style::{Modifier, Style};
#[cfg(feature = "ratatui-support")]
use tui::text::Line;
#[cfg(not(feature = "ratatui-support"))]
use tui::text::Spans as Line;
#[cfg(not(feature = "ratatui-support"))]
use tui::widgets::{Block, BorderType, Borders, Widget};

mod circular;
Expand Down Expand Up @@ -523,6 +528,7 @@ impl Log for TuiLogger {
}

/// A simple `Drain` to log any event directly.
#[derive(Default)]
pub struct Drain;

impl Drain {
Expand Down Expand Up @@ -859,7 +865,7 @@ impl<'b> Widget for TuiLoggerTargetWidget<'b> {
cell.set_style(cell_style);
cell.symbol = sym.to_string();
}
buf.set_stringn(la_left + 5, la_top + i as u16, &":", la_width, self.style);
buf.set_stringn(la_left + 5, la_top + i as u16, ":", la_width, self.style);
buf.set_stringn(
la_left + 6,
la_top + i as u16,
Expand Down Expand Up @@ -1151,11 +1157,9 @@ impl<'b> Widget for TuiLoggerWidget<'b> {
if *level < evt.level {
continue;
}
} else {
if let Some(level) = state.config.default_display_level {
if level < evt.level {
continue;
}
} else if let Some(level) = state.config.default_display_level {
if level < evt.level {
continue;
}
}
if state.focus_selected {
Expand Down
Loading