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

remove tui-support, upgrade to ratatui 0.24.0 #49

Merged
merged 3 commits into from
Oct 23, 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
10 changes: 2 additions & 8 deletions .github/workflows/build_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build examples with tui and crossterm
- name: Build examples with ratatui and termion
run: cargo build --examples
- name: Build examples with tui and termion
run: cargo build --examples --no-default-features -F examples-tui-termion
- name: Build examples with tui and crossterm
run: cargo build --examples --no-default-features -F examples-tui-crossterm
- name: Build example with ratatui and termion
run: cargo build --examples --no-default-features -F ratatui-support,examples-ratatui-termion
- name: Build example with ratatui and crossterm
run: cargo build --examples --no-default-features -F ratatui-support,examples-ratatui-crossterm
run: cargo build --examples --no-default-features -F examples-ratatui-crossterm
13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.9.6"
authors = ["Jochen Kiemes <jochen@kiemes.de>"]
edition = "2021"
license = "MIT"
description = "Logger with smart widget for the `tui` crate"
description = "Logger with smart widget for the `ratatui` crate"
documentation = "https://docs.rs/tui-logger/latest/tui_logger/"
repository = "https://github.com/gin66/tui-logger"
readme = "README.md"
Expand All @@ -16,31 +16,26 @@ travis-ci = { repository = "gin66/tui-logger" }
[dependencies]
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.23.0", default-features = false, package = "ratatui", optional = true }
ratatui = { version = "0.24.0", default-features = false, package = "ratatui" }
tracing = {version = "0.1.37", optional = true}
tracing-subscriber = {version = "0.3", optional = true}
lazy_static = "1.0"
fxhash = "0.2"
parking_lot = "0.12"
slog = { version = "2.7.0", optional = true }

# Optional features for demo. Unfortunately cannot move to dep-dependencies
# Optional features for demo. Unfortunately cannot move to dev-dependencies
termion = {version = "1.5", optional = true }
crossterm = {version = "0.27", optional = true }

[dev-dependencies]
env_logger = "0.10.0"

[features]
default = ["tui","tui/termion", "examples-tui-termion"]
tui-rs = ["tui"]
default = ["ratatui/termion", "examples-ratatui-termion"]
slog-support = ["slog"]
ratatui-support = ["ratatui"]
tracing-support = ["tracing", "tracing-subscriber"]

# This features are exclusively used by examples/demo.rs
examples-tui-termion = ["termion", "tui/termion"]
examples-tui-crossterm = ["crossterm", "tui/crossterm"]
examples-ratatui-termion = ["termion", "ratatui/termion"]
examples-ratatui-crossterm = ["crossterm", "ratatui/crossterm"]
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Logger with smart widget for the `tui` and `ratatui` crate
# Logger with smart widget for the `ratatui` crate

![Build Status](https://travis-ci.org/gin66/tui-logger.svg?branch=master)
[![dependency status](https://deps.rs/repo/github/gin66/tui-logger/status.svg?service=github&nocache=0_9_1)](https://deps.rs/repo/github/gin66/tui-logger)
Expand Down Expand Up @@ -152,10 +152,6 @@

Enabled by feature "tracing-support"

## `ratatui` support

Enabled by feature "ratatui-support" + disable default-features of tui-logger

## Custom filtering
```rust
#[macro_use]
Expand Down
25 changes: 1 addition & 24 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,9 @@ use termion::{
use ratatui::backend::CrosstermBackend as SelectedBackend;
#[cfg(feature = "examples-ratatui-termion")]
use ratatui::backend::TermionBackend as SelectedBackend;
#[cfg(feature = "ratatui-support")]
use ratatui::prelude::*;
#[cfg(feature = "ratatui-support")]
use ratatui::widgets::*;

#[cfg(not(feature = "ratatui-support"))]
use tui::backend::Backend;
#[cfg(feature = "examples-tui-crossterm")]
use tui::backend::CrosstermBackend as SelectedBackend;
#[cfg(feature = "examples-tui-termion")]
use tui::backend::TermionBackend as SelectedBackend;

#[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 @@ -229,10 +209,7 @@ fn main() -> std::result::Result<(), std::io::Error> {
Ok(())
}

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")]
fn draw_frame(t: &mut Frame, size: Rect, app: &mut App) {
let tabs: Vec<Line> = vec!["V1".into(), "V2".into(), "V3".into(), "V4".into()];
let sel = app.selected_tab;

Expand Down
28 changes: 5 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,31 @@
//!
//! Run demo with tui and termion:
//!
//! ```
//! ```ignore
//! cargo run --example demo --no-default-features -F tui-rs,examples-tui-termion
//! ```
//!
//! or simply:
//!
//! ```
//! ```ignore
//! cargo run --example demo
//! ```
//!
//! Run demo with tui and crossterm:
//!
//! ```
//! ```ignore
//! cargo run --example demo --no-default-features -F tui-rs,examples-tui-crossterm
//! ```
//!
//! Run demo with ratatui and termion:
//!
//! ```
//! ```ignore
//! cargo run --example demo --no-default-features -F ratatui-support,examples-ratatui-termion
//! ```
//!
//! Run demo with ratatui and crossterm:
//!
//! ```
//! ```ignore
//! cargo run --example demo --no-default-features -F ratatui-support,examples-ratatui-crossterm
//! ```
//!
Expand Down Expand Up @@ -213,26 +213,13 @@ use std::io::Write;
use std::mem;
use std::sync::Arc;

#[cfg(feature = "ratatui-support")]
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(not(feature = "ratatui-support"))]
use tui::text::Spans as Line;
#[cfg(not(feature = "ratatui-support"))]
use tui::widgets::{Block, BorderType, Borders, Widget};

mod circular;
#[cfg(feature = "slog-support")]
mod slog;
Expand Down Expand Up @@ -1454,14 +1441,9 @@ impl<'a> Widget for TuiLoggerSmartWidget<'a> {
};

let mut title_log = self.title_log.clone();
#[cfg(feature = "ratatui-support")]
title_log
.spans
.push(format!(" [log={:.1}/s]", entries_s).into());
#[cfg(not(feature = "ratatui-support"))]
title_log
.0
.push(format!(" [log={:.1}/s]", entries_s).into());

let hide_target = self.state.lock().hide_target;
if hide_target {
Expand Down