diff options
author | Noah Too <krivahtoo@gmail.com> | 2022-06-22 18:05:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-22 11:05:51 -0400 |
commit | 05d16b4083d07fe00ae7c0da23aa19d1d4321f56 (patch) | |
tree | 0f6c0b32d5a0692cbaa528b934b9f8c90973a3d3 /src/ui | |
parent | ba9a5726ab31071c83e83fc808a910fccdbd86f7 (diff) |
Bump `ansi-to-tui` to `0.6` and remove `tui_old` (#179)
`ansi-to-tui` 0.6 uses the latest `tui`
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_file_preview.rs | 51 |
1 files changed, 1 insertions, 50 deletions
diff --git a/src/ui/widgets/tui_file_preview.rs b/src/ui/widgets/tui_file_preview.rs index a471a64..402d6df 100644 --- a/src/ui/widgets/tui_file_preview.rs +++ b/src/ui/widgets/tui_file_preview.rs @@ -1,46 +1,10 @@ use tui::buffer::Buffer; use tui::layout::Rect; -use tui::style::{Color, Style}; -use tui::text::{Span, Spans}; +use tui::text::Span; use tui::widgets::Widget; use crate::preview::preview_file::FilePreview; -fn color_to_color(color: tui_old::style::Color) -> Color { - match color { - tui_old::style::Color::Reset => Color::Reset, - tui_old::style::Color::Black => Color::Black, - tui_old::style::Color::Red => Color::Red, - tui_old::style::Color::Green => Color::Green, - tui_old::style::Color::Yellow => Color::Yellow, - tui_old::style::Color::Blue => Color::Blue, - tui_old::style::Color::Magenta => Color::Magenta, - tui_old::style::Color::Cyan => Color::Cyan, - tui_old::style::Color::Gray => Color::Gray, - tui_old::style::Color::DarkGray => Color::DarkGray, - tui_old::style::Color::LightRed => Color::LightRed, - tui_old::style::Color::LightGreen => Color::LightGreen, - tui_old::style::Color::LightYellow => Color::LightYellow, - tui_old::style::Color::LightBlue => Color::LightBlue, - tui_old::style::Color::LightMagenta => Color::LightMagenta, - tui_old::style::Color::LightCyan => Color::LightCyan, - tui_old::style::Color::White => Color::White, - tui_old::style::Color::Rgb(r, g, b) => Color::Rgb(r, g, b), - tui_old::style::Color::Indexed(i) => Color::Indexed(i), - } -} - -fn style_to_style(style: tui_old::style::Style) -> Style { - let mut new_style = Style::default(); - if let Some(fg) = style.fg { - new_style = new_style.fg(color_to_color(fg)); - } - if let Some(bg) = style.bg { - new_style = new_style.fg(color_to_color(bg)); - } - new_style -} - pub struct TuiFilePreview<'a> { preview: &'a FilePreview, } @@ -77,19 +41,6 @@ impl<'a> TuiFilePreview<'a> { .skip(self.preview.index) .zip(area.y..area.y + area.height) { - // required to convert between different tui-rs versions. - // remove once ansi-to-tui depends on latest tui-rs - let span_vec: Vec<Span> = line - .0 - .iter() - .map(|s| Span { - content: s.content.clone(), - style: style_to_style(s.style), - }) - .collect(); - let spans = Spans(span_vec); - let line = &spans; - buf.set_spans(area.x, y, line, area.width); } } |