Unverified Commit ba0a3e6e authored by zyno42's avatar zyno42
Browse files

Apply `rustfmt` formatting

parent a54c48ab
......@@ -310,15 +310,16 @@ impl<'a> App<'a> {
InputMode::Edit => {
// If the input cannot be parsed correctly, simply do nothing until
// we either hit Escape or enter a valid decimal integer.
let new_value: Option<u64> = if let Some(hex_string) = self.input.strip_prefix("0x") {
u64::from_str_radix(hex_string, 16).ok()
} else if let Ok(new_value) = self.input.parse::<u64>() {
Some(new_value)
} else if let Ok(new_value) = self.input.parse::<i64>() {
Some(new_value as u64) // explicitly use as casting
} else {
None
};
let new_value: Option<u64> =
if let Some(hex_string) = self.input.strip_prefix("0x") {
u64::from_str_radix(hex_string, 16).ok()
} else if let Ok(new_value) = self.input.parse::<u64>() {
Some(new_value)
} else if let Ok(new_value) = self.input.parse::<i64>() {
Some(new_value as u64) // explicitly use as casting
} else {
None
};
if let Some(new_value) = new_value {
self.input.clear();
......@@ -338,10 +339,12 @@ impl<'a> App<'a> {
important. You should fix this app.", e);
}
self.messages.push(format!("In slot {} set argument register {} to new value: {}.",
self.pe_infos.state.selected().unwrap(),
self.register_list.selected().unwrap(),
new_value));
self.messages.push(format!(
"In slot {} set argument register {} to new value: {}.",
self.pe_infos.state.selected().unwrap(),
self.register_list.selected().unwrap(),
new_value
));
self.input_mode = InputMode::Navigation;
}
......@@ -403,7 +406,9 @@ impl<'a> App<'a> {
//
trace!("Starting PE with ID: {}.", pe.id());
let offset = (*pe.offset()).try_into().expect("Expected to be able to cast the PE offset.");
let offset = (*pe.offset())
.try_into()
.expect("Expected to be able to cast the PE offset.");
unsafe {
// Access PE memory just like in `libtapasco`:
......@@ -417,7 +422,13 @@ impl<'a> App<'a> {
(ptr as *mut u32).write_volatile(1);
}
return format!("Send start signal to PE in slot: {}.", self.pe_infos.state.selected().expect("There needs to be a selected PE. This is a bug."))
return format!(
"Send start signal to PE in slot: {}.",
self.pe_infos
.state
.selected()
.expect("There needs to be a selected PE. This is a bug.")
);
}
"No PE selected.".to_string()
......@@ -441,10 +452,11 @@ impl<'a> App<'a> {
//result += &format!("Interrupt pending: {}", interrupt_pending);
result += &format!(
"Return: 0x{:16x} (i32: {:10})\n",
return_value, return_value as i32 // explicitly use as casting
return_value,
return_value as i32 // explicitly use as casting
);
return result
return result;
}
"No PE selected.".to_string()
......@@ -471,7 +483,7 @@ impl<'a> App<'a> {
result.push(format!("Arg#{:02}: 0x{:16x} ({:20})\n", i, a, a));
}
return result
return result;
}
vec!["No PE selected.".to_string()]
......
......@@ -235,7 +235,12 @@ fn draw_tab_peek_and_poke_pes<B: Backend>(f: &mut Frame<B>, app: &mut App, chunk
Constraint::Length(3),
]
.as_ref(),
InputMode::Navigation => [Constraint::Length(15), Constraint::Min(30), Constraint::Length(15)].as_ref(),
InputMode::Navigation => [
Constraint::Length(15),
Constraint::Min(30),
Constraint::Length(15),
]
.as_ref(),
})
.split(chunk);
......@@ -305,7 +310,8 @@ fn draw_tab_peek_and_poke_pes<B: Backend>(f: &mut Frame<B>, app: &mut App, chunk
f.render_stateful_widget(registers, register_chunks[1], &mut app.register_list);
// TODO: Should local memory also be editable?
let local_memory = app.dump_current_pe_local_memory(horizontal_chunks[1].height.saturating_sub(2).into());
let local_memory =
app.dump_current_pe_local_memory(horizontal_chunks[1].height.saturating_sub(2).into());
let local_memory: Vec<ListItem> = local_memory
.iter()
.map(|i| ListItem::new(vec![Spans::from(Span::raw(i))]))
......@@ -343,7 +349,14 @@ fn draw_tab_peek_and_poke_pes<B: Backend>(f: &mut Frame<B>, app: &mut App, chunk
draw_block_with_paragraph(
f,
"Messages",
app.messages.iter().rev().take(vertical_chunks[2].height.saturating_sub(2).into()).rev().cloned().collect::<Vec<String>>().join("\n"),
app.messages
.iter()
.rev()
.take(vertical_chunks[2].height.saturating_sub(2).into())
.rev()
.cloned()
.collect::<Vec<String>>()
.join("\n"),
vertical_chunks[2],
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment