cpjreynolds / rustty

A terminal UI library
https://docs.rs/rustty
MIT License
152 stars 14 forks source link

Flatten Cell's structure #16

Closed ghost closed 9 years ago

ghost commented 9 years ago

Remove Style in order to flatten Cell structure. Rather than fg and bg each having both a Color and a Attr, they both become straight up Color and we add a new attrs attribute to the Cell.

This is more in line with the underlying driver (the term module) which doesn't apply its attribute to foreground or background. It's always the whole cell that it affected.

It also makes working with the API a bit lighter. It could become cumbersome to have to involve both Style and Color in order to change foreground or background colors.

@cpjreynolds what do you think about this change? I wanted to try it out (hence this PR) because the more I work with rustty, the more I find the Style API needlessly heavy. So the other day, I dig in the code and see that Attr isn't really tied to either fg or bg in the underlying driver, so I think "why give us this trouble"? So here's a PR giving an idea of what it looks like without Style.

cpjreynolds commented 9 years ago

This looks great! I definitely share your sentiments regarding the heaviness of the API, when I was writing this I wasn't happy with it either but didn't have many ideas on how to implement it in a more lightweight fashion.

I've also been thinking of taking out a lot of the with_xxx() methods, and replacing them with easily chained methods. This is a great help on the road to completing that, thanks again!

This looks good to me, and the tests have passed, so lets get this merged!