Skip to content

Commit b48bfae

Browse files
Evalirmikelodder7
authored andcommitted
chore(deps): remove tui for ratatui (foundry-rs#5700)
* fix: remove tui from cargo * fix: switch to ratatui * chore: clippy
1 parent 9ed7f1c commit b48bfae

File tree

3 files changed

+51
-59
lines changed

3 files changed

+51
-59
lines changed

Cargo.lock

Lines changed: 24 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ethers.workspace = true
1818
crossterm = "0.26"
1919
eyre = "0.6"
2020
revm = { version = "3", features = ["std", "serde"] }
21-
tui = { version = "0.19", default-features = false, features = ["crossterm"] }
21+
ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]}

crates/ui/src/lib.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ use foundry_evm::{
1616
utils::{build_pc_ic_map, PCICMap},
1717
CallKind,
1818
};
19+
use ratatui::{
20+
backend::{Backend, CrosstermBackend},
21+
layout::{Alignment, Constraint, Direction, Layout, Rect},
22+
style::{Color, Modifier, Style},
23+
terminal::Frame,
24+
text::{Line, Span, Text},
25+
widgets::{Block, Borders, Paragraph, Wrap},
26+
Terminal,
27+
};
1928
use revm::{interpreter::opcode, primitives::SpecId};
2029
use std::{
2130
cmp::{max, min},
@@ -25,15 +34,6 @@ use std::{
2534
thread,
2635
time::{Duration, Instant},
2736
};
28-
use tui::{
29-
backend::{Backend, CrosstermBackend},
30-
layout::{Alignment, Constraint, Direction, Layout, Rect},
31-
style::{Color, Modifier, Style},
32-
terminal::Frame,
33-
text::{Span, Spans, Text},
34-
widgets::{Block, Borders, Paragraph, Wrap},
35-
Terminal,
36-
};
3737

3838
/// Trait for starting the UI
3939
pub trait Ui {
@@ -367,9 +367,9 @@ impl Tui {
367367
fn draw_footer<B: Backend>(f: &mut Frame<B>, area: Rect) {
368368
let block_controls = Block::default();
369369

370-
let text_output = vec![Spans::from(Span::styled(
370+
let text_output = vec![Line::from(Span::styled(
371371
"[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end", Style::default().add_modifier(Modifier::DIM))),
372-
Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | ['<char>]: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))];
372+
Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | ['<char>]: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))];
373373

374374
let paragraph = Paragraph::new(text_output)
375375
.block(block_controls)
@@ -486,7 +486,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
486486
if let Some(last) = before.pop() {
487487
if !last.ends_with('\n') {
488488
before.iter().skip(start_line).for_each(|line| {
489-
text_output.lines.push(Spans::from(vec![
489+
text_output.lines.push(Line::from(vec![
490490
Span::styled(
491491
format!(
492492
"{: >max_line_num$}",
@@ -506,7 +506,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
506506
line_number += 1;
507507
});
508508

509-
text_output.lines.push(Spans::from(vec![
509+
text_output.lines.push(Line::from(vec![
510510
Span::styled(
511511
format!(
512512
"{: >max_line_num$}",
@@ -530,7 +530,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
530530
line_number += 1;
531531

532532
actual.iter().skip(1).for_each(|s| {
533-
text_output.lines.push(Spans::from(vec![
533+
text_output.lines.push(Line::from(vec![
534534
Span::styled(
535535
format!(
536536
"{: >max_line_num$}",
@@ -561,7 +561,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
561561
} else {
562562
before.push(last);
563563
before.iter().skip(start_line).for_each(|line| {
564-
text_output.lines.push(Spans::from(vec![
564+
text_output.lines.push(Line::from(vec![
565565
Span::styled(
566566
format!(
567567
"{: >max_line_num$}",
@@ -582,7 +582,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
582582
line_number += 1;
583583
});
584584
actual.iter().for_each(|s| {
585-
text_output.lines.push(Spans::from(vec![
585+
text_output.lines.push(Line::from(vec![
586586
Span::styled(
587587
format!(
588588
"{: >max_line_num$}",
@@ -611,7 +611,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
611611
}
612612
} else {
613613
actual.iter().for_each(|s| {
614-
text_output.lines.push(Spans::from(vec![
614+
text_output.lines.push(Line::from(vec![
615615
Span::styled(
616616
format!(
617617
"{: >max_line_num$}",
@@ -644,7 +644,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
644644
if !last.ends_with('\n') {
645645
if let Some(post) = after.pop_front() {
646646
if let Some(last) = text_output.lines.last_mut() {
647-
last.0.push(Span::raw(post));
647+
last.spans.push(Span::raw(post));
648648
}
649649
}
650650
}
@@ -655,7 +655,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
655655
after.pop_back();
656656
}
657657
after.iter().for_each(|line| {
658-
text_output.lines.push(Spans::from(vec![
658+
text_output.lines.push(Line::from(vec![
659659
Span::styled(
660660
format!(
661661
"{: >max_line_num$}",
@@ -721,7 +721,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
721721
debug_steps[current_step].total_gas_used,
722722
))
723723
.borders(Borders::ALL);
724-
let mut text_output: Vec<Spans> = Vec::new();
724+
let mut text_output: Vec<Line> = Vec::new();
725725

726726
// Scroll:
727727
// Focused line is line that should always be at the center of the screen.
@@ -776,12 +776,12 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
776776
};
777777

778778
if let Some(op) = opcode_list.get(line_number) {
779-
text_output.push(Spans::from(Span::styled(
779+
text_output.push(Line::from(Span::styled(
780780
format!("{line_number_format}{op}"),
781781
Style::default().fg(Color::White).bg(bg_color),
782782
)));
783783
} else {
784-
text_output.push(Spans::from(Span::styled(
784+
text_output.push(Line::from(Span::styled(
785785
line_number_format,
786786
Style::default().fg(Color::White).bg(bg_color),
787787
)));
@@ -818,7 +818,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
818818
vec![]
819819
};
820820

821-
let text: Vec<Spans> = stack
821+
let text: Vec<Line> = stack
822822
.iter()
823823
.rev()
824824
.enumerate()
@@ -861,7 +861,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
861861
spans.extend(words);
862862
spans.push(Span::raw("\n"));
863863

864-
Spans::from(spans)
864+
Line::from(spans)
865865
})
866866
.collect();
867867

@@ -923,7 +923,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
923923
let height = area.height as usize;
924924
let end_line = draw_mem.current_mem_startline + height;
925925

926-
let text: Vec<Spans> = memory
926+
let text: Vec<Line> = memory
927927
.chunks(32)
928928
.enumerate()
929929
.skip(draw_mem.current_mem_startline)
@@ -975,7 +975,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/
975975

976976
spans.push(Span::raw("\n"));
977977

978-
Spans::from(spans)
978+
Line::from(spans)
979979
})
980980
.collect();
981981
let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true });

0 commit comments

Comments
 (0)