-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Godzie44/run as widget #73
base: main
Are you sure you want to change the base?
Conversation
7a1623f
to
c224619
Compare
Can you go through your changes a bit and tell me about the rationales? Comparing |
Codecov ReportAttention: 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. |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to remove the lifetimes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
examples/widget.rs
Outdated
crossterm::event::{KeyCode}, | ||
Frame, | ||
}; | ||
use binsider::prelude::Event; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
examples/widget.rs
Outdated
binsider::app::Analyzer::new(file_info, 15, vec![]).unwrap(); | ||
|
||
state.change_analyzer(analyzer); | ||
state.handle_tab().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid unwraps in the example. I think we can return the error type from the library instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/tui/mod.rs
Outdated
.store(self.paused, Ordering::Relaxed); | ||
Ok(()) | ||
} | ||
pub fn tui_toggle_pause(paused: &mut bool, events: &EventHandler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we can remove paused
variable and simply lock user input at Event::Trace
event, and unlock at Event::TraceResult
.
src/tui/state.rs
Outdated
@@ -91,6 +91,10 @@ impl<'a> State<'a> { | |||
state.handle_tab()?; | |||
Ok(state) | |||
} | |||
|
|||
pub fn change_analyzer(&mut self, analyzer: Analyzer<'a>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
Description of change
Tui
component has been removed. Integration with third-party applications has been simplified.