Skip to content

Commit

Permalink
Refactor termbox attribute values and make it clear that they can be …
Browse files Browse the repository at this point in the history
…manipulated w bit sets
  • Loading branch information
osa1 committed Sep 23, 2024
1 parent 21423d4 commit a0f3798
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/termbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ use unicode_width::UnicodeWidthChar;
// FIXME: Use enter_ca_mode(smcup)/exit_ca_mode(rmcup) from terminfo

pub const TB_DEFAULT: u16 = 0x0000;
pub const TB_BOLD: u16 = 0x0100;
pub const TB_UNDERLINE: u16 = 0x0200;
pub const TB_ITALIC: u16 = 0x0400;
pub const TB_STRIKETHROUGH: u16 = 0x0800;

// Each attribute is a distinct bit after the low byte, so attributes can be manipulated with
// bitwise operations.
pub const TB_BOLD: u16 = 1 << 8;
pub const TB_UNDERLINE: u16 = 1 << 9;
pub const TB_ITALIC: u16 = 1 << 10;
pub const TB_STRIKETHROUGH: u16 = 1 << 11;

pub struct Termbox {
// Not available in test instances
Expand Down

0 comments on commit a0f3798

Please sign in to comment.