From 18686dbd32e6920ab5d7271c32481f7f41eae4de Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 29 Dec 2023 09:15:15 +0100 Subject: [PATCH] chore!: upgrade `ratatui` and `crosstermion` to latest versions. --- Cargo.toml | 6 ++--- src/render/tui/draw/information.rs | 2 +- src/render/tui/engine.rs | 36 ++++++++++++++++++------------ 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e90f764..09f4452 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,14 +65,14 @@ parking_lot = { version = "0.12.1", optional = true, default-features = false } log = { version = "0.4.8", optional = true } # render-tui -tui = { package = "ratatui", version = "0.24.0", optional = true, default-features = false } -tui-react = { version = "0.21.0", optional = true } +tui = { package = "ratatui", version = "0.25.0", optional = true, default-features = false } +tui-react = { version = "0.22.0", optional = true } futures-core = { version = "0.3.4", optional = true, default-features = false } futures-lite = { version = "2.1.0", optional = true } humantime = { version = "2.1.0", optional = true } unicode-segmentation = { version = "1.6.0", optional = true } unicode-width = { version = "0.1.7", optional = true } -crosstermion = { version = "0.12.1", optional = true, default-features = false } +crosstermion = { version = "0.13.0", optional = true, default-features = false } async-io = { version = "2.2.1", optional = true } # localtime support for render-tui diff --git a/src/render/tui/draw/information.rs b/src/render/tui/draw/information.rs index 0d5f7a7..d692e4e 100644 --- a/src/render/tui/draw/information.rs +++ b/src/render/tui/draw/information.rs @@ -39,7 +39,7 @@ pub fn pane(lines: &[Line], bound: Rect, buf: &mut Buffer) { let blocks_drawn = draw_text_with_ellipsis_nowrap(line_bound, buf, text, bold); let lines_rect = rect::offset_x(line_bound, blocks_drawn + 1); for x in lines_rect.left()..lines_rect.right() { - buf.get_mut(x, lines_rect.y).symbol = "─".into(); + buf.get_mut(x, lines_rect.y).set_symbol("─"); } offset += 1; } diff --git a/src/render/tui/engine.rs b/src/render/tui/engine.rs index 9658d02..2503d6c 100644 --- a/src/render/tui/engine.rs +++ b/src/render/tui/engine.rs @@ -94,6 +94,7 @@ compile_error!( "Please set either the 'render-tui-crossterm' or 'render-tui-termion' feature whne using the 'render-tui'" ); +use crosstermion::crossterm::event::{KeyCode, KeyEventKind, KeyModifiers}; use crosstermion::{ input::{key_input_stream, Key}, terminal::{tui::new_terminal, AlternateRawScreen}, @@ -175,25 +176,32 @@ pub fn render_with_input( let mut skip_redraw = false; match event { Event::Tick => {} - Event::Input(key) => match key { - Key::Esc | Key::Char('q') | Key::Ctrl('c') | Key::Ctrl('[') => match interrupt_mode { + Event::Input(key) if key.kind != KeyEventKind::Release => match key.code { + KeyCode::Char('c') | KeyCode::Char('[') if key.modifiers.contains(KeyModifiers::CONTROL) => { + match interrupt_mode { + InterruptDrawInfo::Instantly => break, + InterruptDrawInfo::Deferred(_) => interrupt_mode = InterruptDrawInfo::Deferred(true), + } + } + KeyCode::Esc | KeyCode::Char('q') => match interrupt_mode { InterruptDrawInfo::Instantly => break, InterruptDrawInfo::Deferred(_) => interrupt_mode = InterruptDrawInfo::Deferred(true), }, - Key::Char('`') => state.hide_messages = !state.hide_messages, - Key::Char('~') => state.messages_fullscreen = !state.messages_fullscreen, - Key::Char('J') => state.message_offset = state.message_offset.saturating_add(1), - Key::Char('D') => state.message_offset = state.message_offset.saturating_add(10), - Key::Char('j') => state.task_offset = state.task_offset.saturating_add(1), - Key::Char('d') => state.task_offset = state.task_offset.saturating_add(10), - Key::Char('K') => state.message_offset = state.message_offset.saturating_sub(1), - Key::Char('U') => state.message_offset = state.message_offset.saturating_sub(10), - Key::Char('k') => state.task_offset = state.task_offset.saturating_sub(1), - Key::Char('u') => state.task_offset = state.task_offset.saturating_sub(10), - Key::Char('[') => state.hide_info = !state.hide_info, - Key::Char('{') => state.maximize_info = !state.maximize_info, + KeyCode::Char('`') => state.hide_messages = !state.hide_messages, + KeyCode::Char('~') => state.messages_fullscreen = !state.messages_fullscreen, + KeyCode::Char('J') => state.message_offset = state.message_offset.saturating_add(1), + KeyCode::Char('D') => state.message_offset = state.message_offset.saturating_add(10), + KeyCode::Char('j') => state.task_offset = state.task_offset.saturating_add(1), + KeyCode::Char('d') => state.task_offset = state.task_offset.saturating_add(10), + KeyCode::Char('K') => state.message_offset = state.message_offset.saturating_sub(1), + KeyCode::Char('U') => state.message_offset = state.message_offset.saturating_sub(10), + KeyCode::Char('k') => state.task_offset = state.task_offset.saturating_sub(1), + KeyCode::Char('u') => state.task_offset = state.task_offset.saturating_sub(10), + KeyCode::Char('[') => state.hide_info = !state.hide_info, + KeyCode::Char('{') => state.maximize_info = !state.maximize_info, _ => skip_redraw = true, }, + Event::Input(_) => skip_redraw = true, Event::SetWindowSize(bound) => state.user_provided_window_size = Some(bound), Event::SetTitle(title) => state.title = title, Event::SetInformation(info) => state.information = info,