-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Implement various --border styles #54
Conversation
Thank you very much for your contribution! I didn't have time to look at the code changes, but I have to say that I really like the style without any border. I tend to think that we should make this the default. What do others think? |
Currently, without a border, this puts both a leading and a trailing space character on each line. I will try to eliminate that, but I might need some guidance later. Let me come up with the implementation first :-) |
I've now spend a good amount of time trying to understand the borrow checker. My initial plan was to move some details into something like impl BorderStyle {
// Returns left corner, colum separator, horizontal line and right corner.
fn header_elems(self) -> Option<(char, char, char, char)> {
match self {
BorderStyle::Unicode => Some(('┌', '┬', '─', '┐')),
BorderStyle::Ascii => Some(('+', '+', '-', '+')),
BorderStyle::None => None,
}
}
} and condense fn header(&mut self) {
if let Some((l,c,h,r)) = self.border_style.header_elems() {
writeln!(self.stdout, "...", ...).ok()
}
} but Another approach would be to move the Do you have suggestions, on how to make this a bit more DRY? |
I can try to look into this, if you could provide the full code of what you are trying to do. Would this work? fn header(&mut self) {
let header_elems = self.border_style.header_elems();
if let Some((l,c,h,r)) = header_elems {
writeln!(self.stdout, "...", ...).ok()
}
} |
No, that was not it. I've found a solution, though, by allowing -fn header_elems(self) -> Option<(char, char, char, char)> {
+fn header_elems(&self) -> Option<(char, char, char, char)> { I've updated the commit (again). |
Just chiming in. The border none is neat for sure 👍 |
@dmke Sorry for the delay. I have a few suggestions, but I think it's easier if I just merge this as is and integrate a changes myself. Thank you very much! |
This might help to remedy display issues described in #17.
Please note, I'm not a Rust developer, so there might be better ways to solve this. In particular, I'm not a fan of the various
match
es on theborder_style
field.Here's a screenshot of how this looks in my terminal: