Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# woad.Rust - Changes <!-- omit in toc -->


## 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;
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"


# ##########################################################
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# woad.Rust - News <!-- omit in toc -->

| 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) |


<!-- ########################### end of file ########################### -->
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/)

Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

Expand Down
126 changes: 122 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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'));
}
}
}
Loading