Skip to content

Commit

Permalink
chore!: upgrade ratatui and crosstermion to latest versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 29, 2023
1 parent 967e99a commit 18686db
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/render/tui/draw/information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
36 changes: 22 additions & 14 deletions src/render/tui/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 18686db

Please sign in to comment.