Godzie44/run as widget - #73
Conversation
7a1623f to
c224619
Compare
|
Can you go through your changes a bit and tell me about the rationales? Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #73 +/- ##
========================================
- Coverage 3.31% 3.31% -0.00%
========================================
Files 19 19
Lines 2419 2422 +3
========================================
Hits 80 80
- Misses 2339 2342 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Currently it's make possible to handle restart event correctly - because now, only this event requires user implementation. About simplification - if you compare with demo.rs, then all event processing is now hidden in the |
|
I see. I think it would be easier to review this after seeing the usage in action. So if you can incorporate these changes in #45, I can take a look again :) |
|
You can check this out now |
orhun
left a comment
There was a problem hiding this comment.
I was traveling - sorry for the delay. Just got a chance to look at this again :)
| pub struct FileInfo<'a> { | ||
| pub struct FileInfo { | ||
| /// Path of the file. | ||
| pub path: &'a str, | ||
| pub path: String, | ||
| /// Arguments of the file. | ||
| pub arguments: Option<Vec<&'a str>>, | ||
| pub arguments: Option<Vec<String>>, | ||
| /// Bytes of the file. | ||
| pub bytes: &'a [u8], | ||
| pub bytes: Box<[u8]>, |
There was a problem hiding this comment.
Why do we need to remove the lifetimes here?
There was a problem hiding this comment.
Short answer - beacause now all application live in one loop in lib.rs (without recreating it with run function).
More detailed. Reference path: &'a str removed because when wee create a new analyzer in Event::Restart handler live time of analizer (and FileInfo in it) is greater than the lifetime of the variable path from the event. &'a [u8] changed to Box<[u8]> with same reason, file data will be freed but we still need it in an analyzer. I dont think that this is a big problem at all, Box<[u8]> still protects us from copy of the file data, and own file path instead of reference to it - not a big overhead.
| crossterm::event::{KeyCode}, | ||
| Frame, | ||
| }; | ||
| use binsider::prelude::Event; |
There was a problem hiding this comment.
Can you remove the other implicit imports (e.g. binsider::file and so on) and use the prelude module? Feel free to update the prelude if we are not already covering some of the types.
| binsider::app::Analyzer::new(file_info, 15, vec![]).unwrap(); | ||
|
|
||
| state.change_analyzer(analyzer); | ||
| state.handle_tab().unwrap(); |
There was a problem hiding this comment.
Let's avoid unwraps in the example. I think we can return the error type from the library instead.
| .store(self.paused, Ordering::Relaxed); | ||
| Ok(()) | ||
| } | ||
| pub fn tui_toggle_pause(paused: &mut bool, events: &EventHandler) { |
There was a problem hiding this comment.
Can you expand on this change a bit and explain the rationale?
I honestly don't like the way that this currently works. Instead of taking a mutable reference to a bool, we should handle this in a more stateful way - that's why I had the Tui struct before.
There was a problem hiding this comment.
Looks like we can remove paused variable and simply lock user input at Event::Trace event, and unlock at Event::TraceResult.
| Ok(state) | ||
| } | ||
|
|
||
| pub fn change_analyzer(&mut self, analyzer: Analyzer<'a>) { |
There was a problem hiding this comment.
analyzer is a public field, do we need this function? (if so, let's rename it to update_analyzer)
There was a problem hiding this comment.
Agreed, i think more consistently will be remove this
c224619 to
803731d
Compare
f0fe341 to
dc54752
Compare
dc54752 to
3d912dc
Compare
This will help to embedding binsider into another TUI applications.
3d912dc to
8395b85
Compare
|
@orhun please check this now |
|
I got sidetracked for a couple of months and lost interest, sorry. I'll probably get back to this when I start working on |
|
Hi! No problem. Yep this change need for integration. Integration already done too godzie44/BugStalker#45 (however, this PR is somewhat outdated). |
Description of change
Tuicomponent has been removed. Integration with third-party applications has been simplified.