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

Fix `tapasco-debug` for `snafu` crate version bump to 0.7.0

parent d5379853
......@@ -65,11 +65,11 @@ impl<'a> App<'a> {
trace!("Creating new App for Tapasco state");
// Get Tapasco Loadable Linux Kernel Module
let tlkm = TLKM::new().context(TLKMInit {})?;
let tlkm = TLKM::new().context(TLKMInitSnafu {})?;
// Allocate the device with the given ID
let tlkm_device = tlkm
.device_alloc(device_id, &HashMap::new())
.context(TLKMInit {})?;
.context(TLKMInitSnafu {})?;
// For some access modes we need to take some special care to use them
let access_mode_str = match access_mode {
......@@ -84,7 +84,7 @@ impl<'a> App<'a> {
// // Change device access to exclusive to be able to acquire PEs
// tlkm_device
// .change_access(tapasco::tlkm::tlkm_access::TlkmAccessExclusive)
// .context(DeviceInit {})?;
// .context(DeviceInitSnafu {})?;
// "Debug"
//}
AccessMode::Unsafe {} => {
......@@ -109,7 +109,7 @@ impl<'a> App<'a> {
]);
let title = format!("TaPaSCo Debugger - {} Mode", access_mode_str);
let tlkm_version = tlkm.version().context(TLKMInit {})?;
let tlkm_version = tlkm.version().context(TLKMInitSnafu {})?;
let platform_base = tlkm_device
.status()
.platform_base
......@@ -137,7 +137,7 @@ impl<'a> App<'a> {
// Warning: casting to usize can panic! On a <32-bit system..
let pe = tlkm_device
.acquire_pe_without_job(pe.id as usize)
.context(DeviceInit {})?;
.context(DeviceInitSnafu {})?;
// TODO: There is no way to check that you really got the PE that you wanted
// so I have to use this workaround to set it at the ID of the PE struct which
// confusingly is NOT the pe.id from above which is stored at type_id inside the PE.
......
......@@ -63,7 +63,7 @@ fn init() -> Result<()> {
} = Opt::from_args();
// Specify the Access Mode as subcommand and setup the App and UI
ui::setup(&mut app::App::new(device_id, subcommand).context(App {})?).context(UI {})
ui::setup(&mut app::App::new(device_id, subcommand).context(AppSnafu {})?).context(UISnafu {})
}
fn main() {
......
......@@ -47,26 +47,26 @@ enum Event<I, H> {
pub fn setup(app: &mut App) -> Result<()> {
// Raw mode disables some common terminal functions that are unnecessary in the TUI environment
enable_raw_mode().context(Crossterm {})?;
enable_raw_mode().context(CrosstermSnafu {})?;
// Enter the Alternate Screen, so we don't break terminal history (it's like opening vim)
let mut stdout = stdout();
execute!(stdout, EnterAlternateScreen).context(Crossterm {})?;
execute!(stdout, EnterAlternateScreen).context(CrosstermSnafu {})?;
// Initialize Crossterm backend
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend).context(Crossterm {})?;
let mut terminal = Terminal::new(backend).context(CrosstermSnafu {})?;
// Clear the Alternate Screen if someone left it dirty
terminal.clear().context(Crossterm {})?;
terminal.clear().context(CrosstermSnafu {})?;
// Save the result of the main loop to return it after tearing down the backend
let result = run_event_loop(app, &mut terminal);
// Leave Alternate Screen to shut down cleanly regardless of the result
disable_raw_mode().context(Crossterm {})?;
execute!(terminal.backend_mut(), LeaveAlternateScreen).context(Crossterm {})?;
terminal.show_cursor().context(Crossterm {})?;
disable_raw_mode().context(CrosstermSnafu {})?;
execute!(terminal.backend_mut(), LeaveAlternateScreen).context(CrosstermSnafu {})?;
terminal.show_cursor().context(CrosstermSnafu {})?;
// Return the result of the main loop after restoring the previous terminal state in order to
// not be stuck in the Alternate Screen / or Raw Mode which would make a `reset` of the shell
......@@ -100,7 +100,7 @@ fn run_event_loop<B: Backend>(app: &mut App, terminal: &mut Terminal<B>) -> Resu
draw(app, terminal)?;
// Handle events
match rx.recv().context(ReceiveInput {})? {
match rx.recv().context(ReceiveInputSnafu {})? {
// Match key pressed events
Event::Input(event) => {
trace!("Input event: {:?}", event);
......@@ -216,7 +216,7 @@ fn draw<B: Backend>(app: &mut App, terminal: &mut Terminal<B>) -> Result<()> {
2 => draw_tab_bitstream_and_device_info(f, app, tabs_chunks[2]),
_ => {},
}
}).context(Crossterm {})?;
}).context(CrosstermSnafu {})?;
Ok(())
}
......
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