Color encode OVERLAPPED sections and set version to 1.0
This commit is contained in:
parent
5b82dba5ec
commit
e07d144da3
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "psxreadmap"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -413,10 +413,15 @@ impl ConsoleUI {
|
|||
|
||||
let section_list = List::new(data.section_info.iter().map(
|
||||
|section| {
|
||||
ListItem::new(section.name.clone())
|
||||
let mut new_item = ListItem::new(section.name.clone());
|
||||
|
||||
if let Some(color) = section.color_share {
|
||||
new_item = new_item.style(Style::default().fg(color));
|
||||
}
|
||||
new_item
|
||||
}).collect::<Vec<_>>()).style(Style::default().fg(Color::White))
|
||||
.block(Self::create_default_border("Section"))
|
||||
.highlight_style(Style::default().bg(Color::White));
|
||||
.highlight_style(Style::default().add_modifier(Modifier::REVERSED|Modifier::BOLD));
|
||||
|
||||
let top_section = Self::get_selected_top_section(section_selection, data);
|
||||
let mut info_data: &dyn NamedMemoryArea = top_section;
|
||||
|
@ -522,6 +527,7 @@ impl ConsoleUIData {
|
|||
pub const RAM_SIZE:usize = 2*1024*1024;
|
||||
|
||||
pub fn from(memory_map: MemoryMap) -> Result<Self, Error> {
|
||||
const COLORS:[Color;4] = [Color::Red, Color::Green, Color::Blue, Color::Yellow];
|
||||
fn get_last_section_end_adr(memory_map: &MemoryMap) -> u64 {
|
||||
if let Some(section) = memory_map.sections.last() {
|
||||
return section.adr + section.size as u64;
|
||||
|
@ -530,38 +536,65 @@ impl ConsoleUIData {
|
|||
}
|
||||
|
||||
let mut new_self = ConsoleUIData::default();
|
||||
let mut color_idx = 0;
|
||||
let highest_adr = get_last_section_end_adr(&memory_map);
|
||||
let program_size = (highest_adr - Self::RAM_BASE_ADDRESS) as usize;
|
||||
|
||||
new_self.section_info.push(SectionInfo{
|
||||
name: String::from("<overall usage>"),
|
||||
symbols: memory_map.global,
|
||||
start_adr: Self::RAM_BASE_ADDRESS,
|
||||
size: program_size,
|
||||
max_size: Self::RAM_SIZE
|
||||
name: String::from("<overall usage>"),
|
||||
symbols: memory_map.global,
|
||||
start_adr: Self::RAM_BASE_ADDRESS,
|
||||
size: program_size,
|
||||
max_size: Self::RAM_SIZE,
|
||||
color_share: None,
|
||||
});
|
||||
|
||||
for section in memory_map.sections {
|
||||
new_self.section_info.push(SectionInfo{
|
||||
name: section.name,
|
||||
symbols: section.symbols,
|
||||
start_adr: section.adr,
|
||||
size: section.size,
|
||||
max_size: program_size
|
||||
name: section.name,
|
||||
symbols: section.symbols,
|
||||
start_adr: section.adr,
|
||||
size: section.size,
|
||||
max_size: program_size,
|
||||
color_share: None,
|
||||
});
|
||||
}
|
||||
|
||||
let mut iter = new_self.section_info.iter_mut().peekable();
|
||||
while let Some(section) = iter.next() {
|
||||
if let Some(next_section) = iter.peek_mut() {
|
||||
if section.start_adr == next_section.start_adr {
|
||||
let color = {
|
||||
if let Some(color) = section.color_share {
|
||||
color
|
||||
}
|
||||
|
||||
else {
|
||||
// next color
|
||||
let color = COLORS[color_idx];
|
||||
|
||||
color_idx = (color_idx + 1)%COLORS.len();
|
||||
color
|
||||
}
|
||||
};
|
||||
|
||||
section.color_share = Some(color);
|
||||
next_section.color_share = Some(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(new_self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct SectionInfo {
|
||||
pub name: String,
|
||||
pub symbols: Vec<Symbol>,
|
||||
pub start_adr: u64,
|
||||
pub size: usize,
|
||||
pub max_size: usize,
|
||||
pub name: String,
|
||||
pub symbols: Vec<Symbol>,
|
||||
pub start_adr: u64,
|
||||
pub size: usize,
|
||||
pub max_size: usize,
|
||||
pub color_share: Option<Color>
|
||||
}
|
||||
|
||||
impl SectionInfo {
|
||||
|
|
Loading…
Reference in New Issue