-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
feat(frame)!: Remove generic Backend parameter #530
Conversation
The purpose of this change is to simplify UI code that uses the Frame type. E.g.: ``` fn draw<B: Backend>(frame: &mut Frame<B>) { // ... } ``` Frame was generic over Backend because it stored a reference to the terminal in the field. Instead it now directly stores the viewport area and current buffer. These are provided at creation time and are valid for the duration of the frame. BREAKING CHANGE: Frame is no longer generic over Backend. Code that accepted a Frame<Backend> will now need to accept a Frame.
Codecov Report
@@ Coverage Diff @@
## main #530 +/- ##
=======================================
Coverage 90.06% 90.06%
=======================================
Files 40 40
Lines 11267 11268 +1
=======================================
+ Hits 10148 10149 +1
Misses 1119 1119
|
I haven't checked all the tests but what happens if a terminal resize occurs? Does this handle that? |
Frames are only created by let backend = TestBackend::new(10, 10);
let mut terminal = Terminal::new(backend).unwrap();
let frame = terminal.get_frame();
terminal.resize(Rect::new(0, 0, 5, 5)).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.
Breaking but good. We should add "migration" instructions to the final commit message.
Will do |
This change simplifys UI code that uses the Frame type. E.g.: ```rust fn draw<B: Backend>(frame: &mut Frame<B>) { // ... } ``` Frame was generic over Backend because it stored a reference to the terminal in the field. Instead it now directly stores the viewport area and current buffer. These are provided at creation time and are valid for the duration of the frame. BREAKING CHANGE: Frame is no longer generic over Backend. Code that accepted `Frame<Backend>` will now need to accept `Frame`. To migrate existing code, remove any generic parameters from code that uses an instance of a Frame. E.g. the above code becomes: ```rust fn draw(frame: &mut Frame) { // ... } ```
The purpose of this change is to simplify UI code that uses the Frame
type. E.g.:
Frame was generic over Backend because it stored a reference to the
terminal in the field. Instead it now directly stores the viewport area
and current buffer. These are provided at creation time and are valid
for the duration of the frame.
BREAKING CHANGE: Frame is no longer generic over Backend. Code that
accepted a Frame will now need to accept a Frame.