Skip to content
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

Allow creating a Buffer with no FontSystem #127

Merged
merged 2 commits into from
Jun 9, 2023

Conversation

tigregalis
Copy link
Contributor

Changes

This introduces a new constructor Buffer::new_empty which has zero BufferLines and is unshaped.

Buffer::new calls Buffer::new_empty.

Context

#97 untangled the Buffer from the FontSystem, but didn't remove the need to pass a FontSystem into Buffer::new.

It is useful to be able to initialise a Buffer when you don't have a FontSystem in scope, for example if you want to impl Default for some type that contains a Buffer, since it is otherwise constructable without a FontSystem:

let buffer = Buffer::new_empty(Metrics::new(MY_DEFAULT_FONT_SIZE, MY_DEFAULT_LINE_HEIGHT));

Future work

Any of the examples where Buffer::new is called and then immediately overwritten through Buffer::set_text or overwriting the BufferLines could be rewritten in terms of Buffer::new_empty but I have not done this.

jackpot51
jackpot51 previously approved these changes Jun 8, 2023
@jackpot51
Copy link
Member

This now has conflicts after #122

@tigregalis
Copy link
Contributor Author

I've resolved the conflict.

@jackpot51 jackpot51 merged commit b6b0358 into pop-os:main Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants