-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bitfield): add
display_ascii
to generated bitfields (#420)
The `fmt::Display` implementation for bitfields uses Unicode box-drawing characters. In some contexts, where Unicode is not supported or box-drawing characters are not rendered nicely, it may be desirable to use an ASCII-only version of the multi-line format, instead. Therefore, in addition to the `Display` implementation, this commit adds a new generated `display_ascii` method to bitfield types. `display_ascii` returns an `impl fmt::Display` value that renders the bitfield in an ASCII-only version of the multi-line format. The ASCII-only format also uses slightly fewer horizontal characters than the Unicode box-drawing format, so it may also be useful in cases where text fields have limited width. For example: ``` 00000000000000000011010110011110 ..............................10 ENUM_VALUE: Baz ........................100111.. SOME_BITS: 39 .......................1........ FLAG_1: true ......................0......... FLAG_2: false ..............00001101.......... A_BYTE: 13 ``` This was added primarily in order to allow displaying page fault error codes nicely in mycelium's oops screen, because the `embedded_graphics` crate doesn't render Unicode box-drawing characters.
- Loading branch information
Showing
1 changed file
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters