From 176b19d6925050d1e9a34edc3e5d576040afa358 Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Thu, 7 Nov 2024 03:59:52 +0530 Subject: [PATCH] Use ratatui bundled crossterm (#805) --- 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 e6f5151f..094a02ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -435,7 +435,6 @@ dependencies = [ "ansi-to-tui", "anstyle", "clap", - "crossterm", "ego-tree", "linutil_core", "oneshot", diff --git a/tui/Cargo.toml b/tui/Cargo.toml index b411fb2d..baa0d995 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -15,7 +15,6 @@ tips = ["rand"] [dependencies] clap = { version = "4.5.20", 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 91d86c28..96ab06ca 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 0d9920de..cc93ecee 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, KeyModifiers}; use ego_tree::NodeId; use linutil_core::Tab; use ratatui::{ + crossterm::event::{KeyCode, KeyEvent, KeyModifiers}, layout::{Position, Rect}, style::{Color, 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 a43361af..50655df1 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 df20e733..428e6b5b 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 e55690fe..af642d0f 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 ac584070..ea598d05 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, TabList}; #[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},