diff --git a/CHANGES.md b/CHANGES.md index be8fc3e..8dcc61a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,11 @@ # woad.Rust - Changes +## 0.0.1 - 15th August 2026 + +* SGR colour and reset codes (`RESET`, `FG_*`, `BG_*`, including bright variants); + + ## 0.0.0 - 15th August 2026 * initial project scaffolding; diff --git a/Cargo.lock b/Cargo.lock index 9252f09..970b653 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 4 [[package]] name = "woad" -version = "0.0.0" +version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index f578aca..61e3b1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ license = "BSD-3-Clause" name = "woad" readme = "README.md" repository = "https://github.com/synesissoftware/woad.Rust" -version = "0.0.0" +version = "0.0.1" # ########################################################## diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..3d12ebd --- /dev/null +++ b/NEWS.md @@ -0,0 +1,9 @@ +# woad.Rust - News + +| Date | News Item | +| ---------------- | -------------------------------------------------------------------------------------- | +| 15th August 2026 | [**woad.Rust** 0.0.1](https://github.com/synesissoftware/woad.Rust/releases/tag/0.0.1) | +| 15th August 2026 | [**woad.Rust** 0.0.0](https://github.com/synesissoftware/woad.Rust/releases/tag/0.0.0) | + + + diff --git a/README.md b/README.md index 62f6a84..9660726 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,15 @@ woad = { version = "0" } ## Components -**woad.Rust** currently ships version metadata (`woad::VERSION`). Colour codes, TTY/stream gating, and Windows virtual-terminal opt-in are not implemented in this 0.0.0 skeleton. +**woad.Rust** ships SGR string constants (`RESET`, `FG_*`, `BG_*`, including bright variants) and `VERSION`. TTY/stream gating and Windows virtual-terminal opt-in are not implemented yet. + +```rust +use woad::{FG_GREEN, RESET}; + +fn main() { + println!("{FG_GREEN}ok{RESET}"); +} +``` ## Project Information @@ -80,6 +88,7 @@ None (currently). ### Related projects +* [**woad**](https://github.com/synesissoftware/woad/) * [**woad.Python**](https://github.com/synesissoftware/woad.Python/) * [**woad.Ruby**](https://github.com/synesissoftware/woad.Ruby/) diff --git a/TODO.md b/TODO.md index 0918e7a..f4ca40b 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ ## Functional improvements -* [ ] SGR colour and reset codes; +* [x] ~~~SGR colour and reset codes~~~ ✅; * [ ] TTY-conditional colour codes (process and per-stream); * [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode`); diff --git a/src/lib.rs b/src/lib.rs index 0fcdf25..0da927b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,96 @@ -//! Placeholder crate for **woad**.Rust. +//! Minimal ANSI terminal colour codes, for Rust. //! -//! Colour facilities are not implemented in this 0.0.0 skeleton. +//! **woad** provides the smallest useful set of fixed SGR sequences for +//! library authors. It is not a console or TUI framework. /// Crate version. -pub const VERSION : &str = "0.0.0"; +pub const VERSION : &str = "0.0.1"; + + +// Reset + +/// Reset all attributes. +pub const RESET : &str = "\x1b[0m"; + + +// Foreground (standard) + +/// Foreground black. +pub const FG_BLACK : &str = "\x1b[30m"; +/// Foreground red. +pub const FG_RED : &str = "\x1b[31m"; +/// Foreground green. +pub const FG_GREEN : &str = "\x1b[32m"; +/// Foreground yellow. +pub const FG_YELLOW : &str = "\x1b[33m"; +/// Foreground blue. +pub const FG_BLUE : &str = "\x1b[34m"; +/// Foreground magenta. +pub const FG_MAGENTA : &str = "\x1b[35m"; +/// Foreground cyan. +pub const FG_CYAN : &str = "\x1b[36m"; +/// Foreground white. +pub const FG_WHITE : &str = "\x1b[37m"; + + +// Foreground (bright) + +/// Foreground bright black. +pub const FG_BRIGHT_BLACK : &str = "\x1b[90m"; +/// Foreground bright red. +pub const FG_BRIGHT_RED : &str = "\x1b[91m"; +/// Foreground bright green. +pub const FG_BRIGHT_GREEN : &str = "\x1b[92m"; +/// Foreground bright yellow. +pub const FG_BRIGHT_YELLOW : &str = "\x1b[93m"; +/// Foreground bright blue. +pub const FG_BRIGHT_BLUE : &str = "\x1b[94m"; +/// Foreground bright magenta. +pub const FG_BRIGHT_MAGENTA : &str = "\x1b[95m"; +/// Foreground bright cyan. +pub const FG_BRIGHT_CYAN : &str = "\x1b[96m"; +/// Foreground bright white. +pub const FG_BRIGHT_WHITE : &str = "\x1b[97m"; + + +// Background (standard) + +/// Background black. +pub const BG_BLACK : &str = "\x1b[40m"; +/// Background red. +pub const BG_RED : &str = "\x1b[41m"; +/// Background green. +pub const BG_GREEN : &str = "\x1b[42m"; +/// Background yellow. +pub const BG_YELLOW : &str = "\x1b[43m"; +/// Background blue. +pub const BG_BLUE : &str = "\x1b[44m"; +/// Background magenta. +pub const BG_MAGENTA : &str = "\x1b[45m"; +/// Background cyan. +pub const BG_CYAN : &str = "\x1b[46m"; +/// Background white. +pub const BG_WHITE : &str = "\x1b[47m"; + + +// Background (bright) + +/// Background bright black. +pub const BG_BRIGHT_BLACK : &str = "\x1b[100m"; +/// Background bright red. +pub const BG_BRIGHT_RED : &str = "\x1b[101m"; +/// Background bright green. +pub const BG_BRIGHT_GREEN : &str = "\x1b[102m"; +/// Background bright yellow. +pub const BG_BRIGHT_YELLOW : &str = "\x1b[103m"; +/// Background bright blue. +pub const BG_BRIGHT_BLUE : &str = "\x1b[104m"; +/// Background bright magenta. +pub const BG_BRIGHT_MAGENTA : &str = "\x1b[105m"; +/// Background bright cyan. +pub const BG_BRIGHT_CYAN : &str = "\x1b[106m"; +/// Background bright white. +pub const BG_BRIGHT_WHITE : &str = "\x1b[107m"; #[cfg(test)] @@ -13,6 +100,37 @@ mod tests { #[test] fn TEST_VERSION() { - assert_eq!(crate::VERSION, "0.0.0"); + assert_eq!(crate::VERSION, "0.0.1"); + } + + #[test] + fn TEST_RESET() { + assert_eq!(crate::RESET, "\x1b[0m"); + } + + #[test] + fn TEST_FG_RED() { + assert_eq!(crate::FG_RED, "\x1b[31m"); + } + + #[test] + fn TEST_BG_BLUE() { + assert_eq!(crate::BG_BLUE, "\x1b[44m"); + } + + #[test] + fn TEST_CODES_ARE_CSI_SGR() { + let codes = [ + crate::RESET, + crate::FG_BLACK, + crate::FG_BRIGHT_WHITE, + crate::BG_BLACK, + crate::BG_BRIGHT_WHITE, + ]; + + for code in codes { + assert!(code.starts_with("\x1b[")); + assert!(code.ends_with('m')); + } } }