Skip to content

Commit 03f0a73

Browse files
committed
taco bell'ize
1 parent c05cf70 commit 03f0a73

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

src/main.rs

+39-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
use clap::Parser;
2-
use mi::{
3-
data_disassemble, data_read_memory_bytes, parse_asm_insns_values, parse_key_value_pairs,
4-
parse_register_values, register_x86_64, Asm, MIResponse, Register,
5-
};
6-
use ratatui::widgets::block::Title;
7-
use ratatui::widgets::{Cell, Row, Table, TableState};
81
use std::fs::File;
92
use std::io::{BufRead, BufReader, Read, Write};
103
use std::net::{SocketAddr, TcpStream};
@@ -13,13 +6,15 @@ use std::sync::{Arc, Mutex};
136
use std::thread;
147
use std::time::Duration;
158
use std::{error::Error, io};
16-
use tui_input::backend::crossterm::EventHandler;
17-
use tui_input::Input;
189

10+
use clap::Parser;
1911
use env_logger::{Builder, Env};
2012
use log::debug;
2113
use ratatui::layout::{Constraint, Layout};
2214
use ratatui::prelude::*;
15+
use ratatui::style::Styled;
16+
use ratatui::widgets::block::Title;
17+
use ratatui::widgets::{Cell, Row, Table, TableState};
2318
use ratatui::{
2419
crossterm::{
2520
event::{self, DisableMouseCapture, Event, KeyCode},
@@ -28,15 +23,27 @@ use ratatui::{
2823
},
2924
widgets::{Block, Borders, List, ListItem, Paragraph},
3025
};
26+
use tui_input::backend::crossterm::EventHandler;
27+
use tui_input::Input;
3128
use Constraint::{Fill, Length, Max, Min};
3229

3330
mod mi;
31+
use mi::{
32+
data_disassemble, data_read_memory_bytes, parse_asm_insns_values, parse_key_value_pairs,
33+
parse_register_values, register_x86_64, Asm, MIResponse, Register,
34+
};
3435

3536
enum InputMode {
3637
Normal,
3738
Editing,
3839
}
3940

41+
// Taco bell colors
42+
const BLUE: Color = Color::Rgb(54, 57, 154);
43+
const PURPLE: Color = Color::Rgb(167, 123, 202);
44+
const PINK: Color = Color::Rgb(239, 24, 151);
45+
const YELLOW: Color = Color::Rgb(254, 224, 18);
46+
4047
use std::collections::{HashMap, VecDeque};
4148

4249
struct LimitedBuffer<T> {
@@ -484,8 +491,8 @@ fn ui(f: &mut Frame, app: &App) {
484491
Ok(regs) => {
485492
for (name, register) in regs.iter() {
486493
rows.push(Row::new(vec![
487-
name.to_string(),
488-
register.value.clone().unwrap(),
494+
Cell::from(name.to_string()).style(Style::new().fg(PURPLE)),
495+
Cell::from(register.value.clone().unwrap()),
489496
]));
490497
}
491498
}
@@ -495,8 +502,8 @@ fn ui(f: &mut Frame, app: &App) {
495502
let widths = [Constraint::Length(5), Constraint::Length(20)];
496503
let table = Table::new(rows, widths).block(
497504
Block::default()
498-
.borders(Borders::ALL)
499-
.title("Registers".blue()),
505+
.borders(Borders::TOP)
506+
.title("Registers".fg(PINK)),
500507
);
501508

502509
f.render_widget(table, register);
@@ -509,7 +516,7 @@ fn ui(f: &mut Frame, app: &App) {
509516
entries.sort_by(|a, b| a.0.cmp(&b.0));
510517
for (addr, value) in entries.iter() {
511518
rows.push(Row::new(vec![
512-
Cell::from(format!("0x{:02x}", addr)).yellow(),
519+
Cell::from(format!("0x{:02x}", addr)).style(Style::new().fg(PURPLE)),
513520
Cell::from(format!("0x{:02x}", value)),
514521
]));
515522
}
@@ -518,8 +525,11 @@ fn ui(f: &mut Frame, app: &App) {
518525
}
519526

520527
let widths = [Constraint::Length(16), Fill(1)];
521-
let table = Table::new(rows, widths)
522-
.block(Block::default().borders(Borders::ALL).title("Stack".blue()));
528+
let table = Table::new(rows, widths).block(
529+
Block::default()
530+
.borders(Borders::TOP)
531+
.title("Stack".fg(PINK)),
532+
);
523533

524534
f.render_widget(table, stack);
525535

@@ -552,7 +562,8 @@ fn ui(f: &mut Frame, app: &App) {
552562
function_name = Some(func_name.clone());
553563
}
554564
}
555-
let addr_cell = Cell::from(format!("0x{:02x}", a.address)).yellow();
565+
let addr_cell =
566+
Cell::from(format!("0x{:02x}", a.address)).style(Style::default().fg(PURPLE));
556567
let inst_cell = if let Some(pc_index) = pc_index {
557568
if pc_index == index {
558569
Cell::from(format!("{}", a.inst)).green()
@@ -570,14 +581,14 @@ fn ui(f: &mut Frame, app: &App) {
570581
}
571582

572583
let tital = if let Some(function_name) = function_name {
573-
Title::from(format!("Instructions ({})", function_name).blue())
584+
Title::from(format!("Instructions ({})", function_name).fg(PINK))
574585
} else {
575-
Title::from("Instructions".blue())
586+
Title::from("Instructions".fg(PINK))
576587
};
577588
if let Some(pc_index) = pc_index {
578589
let widths = [Constraint::Length(16), Fill(1)];
579590
let table = Table::new(rows, widths)
580-
.block(Block::default().borders(Borders::ALL).title(tital))
591+
.block(Block::default().borders(Borders::TOP).title(tital))
581592
.row_highlight_style(Style::new().green())
582593
.highlight_symbol(">>");
583594
let start_offset = if pc_index < 5 { 0 } else { pc_index - 5 };
@@ -586,7 +597,7 @@ fn ui(f: &mut Frame, app: &App) {
586597
.with_selected(pc_index);
587598
f.render_stateful_widget(table, asm, &mut table_state);
588599
} else {
589-
let block = Block::default().borders(Borders::ALL).title(tital);
600+
let block = Block::default().borders(Borders::TOP).title(tital);
590601
f.render_widget(block, asm);
591602
}
592603

@@ -603,13 +614,13 @@ fn ui(f: &mut Frame, app: &App) {
603614
let messages = List::new(messages).block(
604615
Block::default()
605616
.borders(Borders::ALL)
606-
.title("Messages".blue()),
617+
.title("Messages".fg(BLUE)),
607618
);
608619
f.render_widget(messages, other);
609620

610621
let response_widget = Paragraph::new(response_text).block(
611622
Block::default()
612-
.title("Parsed Responses".blue())
623+
.title("Parsed Responses".fg(BLUE))
613624
.borders(Borders::ALL),
614625
);
615626
f.render_widget(response_widget, parsed);
@@ -624,7 +635,11 @@ fn ui(f: &mut Frame, app: &App) {
624635
InputMode::Editing => Style::default().fg(Color::Green),
625636
})
626637
.scroll((0, scroll as u16))
627-
.block(Block::default().borders(Borders::ALL).title("Input"));
638+
.block(
639+
Block::default()
640+
.borders(Borders::ALL)
641+
.title("Input".fg(YELLOW)),
642+
);
628643
f.render_widget(txt_input, input);
629644
match app.input_mode {
630645
InputMode::Normal =>

0 commit comments

Comments
 (0)