From c7b99d9903c5cf36e1f22b70c78c579ac92a33b0 Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Sat, 12 Oct 2024 11:28:42 +0530 Subject: [PATCH] Use ratatui bundled crossterm --- Cargo.lock | 1 - tui/Cargo.toml | 1 - tui/src/confirmation.rs | 2 +- tui/src/filter.rs | 2 +- tui/src/float.rs | 2 +- tui/src/floating_text.rs | 3 +-- tui/src/main.rs | 16 ++++++++++------ tui/src/running_command.rs | 2 +- tui/src/state.rs | 2 +- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 266ed837..dd6afedb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,7 +503,6 @@ dependencies = [ "anstyle", "chrono", "clap", - "crossterm", "ego-tree", "linutil_core", "oneshot", diff --git a/tui/Cargo.toml b/tui/Cargo.toml index 40d3c357..523828ab 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -16,7 +16,6 @@ tips = ["rand"] [dependencies] clap = { version = "4.5.19", features = ["derive"] } -crossterm = "0.28.1" ego-tree = { workspace = true } oneshot = "0.1.8" portable-pty = "0.8.1" diff --git a/tui/src/confirmation.rs b/tui/src/confirmation.rs index 28732e35..5583e1a9 100644 --- a/tui/src/confirmation.rs +++ b/tui/src/confirmation.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use crate::{float::FloatContent, hint::Shortcut}; -use crossterm::event::{KeyCode, KeyEvent}; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent}, layout::Alignment, prelude::*, widgets::{Block, Borders, Clear, List}, diff --git a/tui/src/filter.rs b/tui/src/filter.rs index e6ff2cc2..46c35a00 100644 --- a/tui/src/filter.rs +++ b/tui/src/filter.rs @@ -1,8 +1,8 @@ use crate::{state::ListEntry, theme::Theme}; -use crossterm::event::{KeyCode, KeyEvent}; use ego_tree::NodeId; use linutil_core::Tab; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent}, layout::{Position, Rect}, style::Style, text::Span, diff --git a/tui/src/float.rs b/tui/src/float.rs index 7b569752..993684b0 100644 --- a/tui/src/float.rs +++ b/tui/src/float.rs @@ -1,5 +1,5 @@ -use crossterm::event::{KeyCode, KeyEvent}; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent}, layout::{Constraint, Direction, Layout, Rect}, Frame, }; diff --git a/tui/src/floating_text.rs b/tui/src/floating_text.rs index 879fcbc5..2fa53f98 100644 --- a/tui/src/floating_text.rs +++ b/tui/src/floating_text.rs @@ -8,9 +8,8 @@ use crate::{float::FloatContent, hint::Shortcut}; use linutil_core::Command; -use crossterm::event::{KeyCode, KeyEvent}; - use ratatui::{ + crossterm::event::{KeyCode, KeyEvent}, layout::Rect, style::{Style, Stylize}, text::Line, diff --git a/tui/src/main.rs b/tui/src/main.rs index 801e3b1d..47a3c103 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -14,13 +14,17 @@ use std::{ use crate::theme::Theme; use clap::Parser; -use crossterm::{ - event::{self, DisableMouseCapture, Event, KeyEventKind}, - style::ResetColor, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, - ExecutableCommand, + +use ratatui::{ + backend::CrosstermBackend, + crossterm::{ + event::{self, DisableMouseCapture, Event, KeyEventKind}, + style::ResetColor, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, + ExecutableCommand, + }, + Terminal, }; -use ratatui::{backend::CrosstermBackend, Terminal}; use state::AppState; // Linux utility toolbox diff --git a/tui/src/running_command.rs b/tui/src/running_command.rs index 89daa755..a7d069ae 100644 --- a/tui/src/running_command.rs +++ b/tui/src/running_command.rs @@ -1,11 +1,11 @@ use crate::{float::FloatContent, hint::Shortcut}; -use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; use linutil_core::Command; use oneshot::{channel, Receiver}; use portable_pty::{ ChildKiller, CommandBuilder, ExitStatus, MasterPty, NativePtySystem, PtySize, PtySystem, }; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent, KeyModifiers}, layout::{Rect, Size}, style::{Color, Style, Stylize}, text::{Line, Span}, diff --git a/tui/src/state.rs b/tui/src/state.rs index 9ed61771..a3bc3869 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -7,12 +7,12 @@ use crate::{ running_command::RunningCommand, theme::Theme, }; -use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use ego_tree::NodeId; use linutil_core::{ListNode, Tab}; #[cfg(feature = "tips")] use rand::Rng; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers}, layout::{Alignment, Constraint, Direction, Flex, Layout}, style::{Style, Stylize}, text::{Line, Span, Text},