-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bold pixels #21
Comments
I have a quick-and-dirty proof-of-concept implementation in my fork. |
I won't mind a change with the Such change could make into a 3.0 release, including deprecation notice in the current major version. EDIT: about your PoC implementation, is it possible to mix the styles ? (e.g. bold + underline) |
Yes, of course. Each pixel contains a new // we check if the last pixel is the same as the current one.
// if the color/attribute is the same, only print the character
// the less we write on the output the faster we'll get
// and additional characters for colors we already have set is
// time consuming
if current_bold != pixel.style.bold || first {
current_bold = pixel.style.bold;
if pixel.style.bold {
queue!(self.stdout, style::SetAttribute(style::Attribute::Bold)).unwrap();
} else {
// style::Attribute::NoBold is unreliable across terminals
// Use style::Attribute::Reset instead, process italics and underline
// afterwards to avoid resetting those attributes.
queue!(self.stdout, style::SetAttribute(style::Attribute::Reset)).unwrap();
}
}
if current_italic != pixel.style.italic || first {
current_italic = pixel.style.italic;
if pixel.style.italic {
queue!(self.stdout, style::SetAttribute(style::Attribute::Italic)).unwrap();
} else {
queue!(self.stdout, style::SetAttribute(style::Attribute::NoItalic)).unwrap();
}
}
if current_underline != pixel.style.underlined || first {
current_underline = pixel.style.underlined;
if pixel.style.underlined {
queue!(self.stdout, style::SetAttribute(style::Attribute::Underlined)).unwrap();
} else {
queue!(self.stdout, style::SetAttribute(style::Attribute::NoUnderline)).unwrap();
}
}
if current_colors != pixel.get_colors() || first {
current_colors = pixel.get_colors();
queue!(
self.stdout,
style::SetForegroundColor(pixel.fg),
style::SetBackgroundColor(pixel.bg),
).unwrap();
}
first = false;
queue!(self.stdout, style::Print(pixel.chr)).unwrap(); Note that using Reset instead of NoBold is necessary for some terminals. At the current moment, I think there's a risk of accidentally clearing italics and underline for Pixels immediately after the last bold Pixel in a row. |
Is your feature request related to a problem? Please describe.
I would like to add more depth to what is rendered, by using bold characters
Describe the solution you'd like
I would like to set some "pixel" to be rendered as bold. Maybe something like:
But I don't have much opinion on the API.
Describe alternatives you've considered
Aside using crosstem directly, I don't see how to achieve that via
console_engine
Additional context
There might be other desirable styles such as italic, underline, etc.
The text was updated successfully, but these errors were encountered: