Skip to content
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

Merge develop into main for version 0.1.0 #15

Merged
merged 51 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9cf7b1e
feat: initialize new Rust project with cargo init
Syaw0 Oct 29, 2024
8cd25aa
chore: update Cargo.toml project metadata
Syaw0 Oct 29, 2024
d67a238
chore: add Github Actions workflow file
Syaw0 Oct 29, 2024
6367638
feat: Add ANSIEscapeCode struct with accompanying tests
Syaw0 Oct 31, 2024
d63eee2
refactor: move ANSIEscapeCode and tests to own module
Syaw0 Nov 1, 2024
27dc04f
feat: Add basic colors constants
Syaw0 Nov 1, 2024
5adde3c
feat: Add palette color struct with tests
Syaw0 Nov 1, 2024
8b24455
feat: Add RGB struct with tests
Syaw0 Nov 1, 2024
5b24cde
feat: Add Colorify trait with paint_fg and paint_bg
Syaw0 Nov 1, 2024
5c669e6
feat: Add a new trait, `Stylify` that use just `make_styles`
Syaw0 Nov 1, 2024
17609c6
chore: rename package from Vitalux to vitalux for consistency
Syaw0 Nov 2, 2024
68b701e
refactor: remove test.rs file and move tests to a module files
Syaw0 Nov 2, 2024
c41e8d8
feat: Implement the Stylify for PaintType
Syaw0 Nov 2, 2024
ffe74d4
feat: Add StyledText struct and implement the public api for basic co…
Syaw0 Nov 2, 2024
ca0f229
feat: Add Style enum and store style variants with their structs
Syaw0 Nov 3, 2024
be0cbea
feat: Use new implementation for styled_text
Syaw0 Nov 3, 2024
169ac59
feat: Add Clone to Styles variant structs
Syaw0 Nov 3, 2024
363697b
feat : Use default paint type if there is only one or zero pain type …
Syaw0 Nov 3, 2024
c5f297f
fix: Remove the extra \ from ANSIEscapeCode
Syaw0 Nov 3, 2024
bdd27b4
feat: Develop the paint method that merge all styles into String
Syaw0 Nov 3, 2024
d0c6ff5
feat: Using ref PaintType in make_styles trait method
Syaw0 Nov 3, 2024
a322ef4
test: Add test for basic color styles
Syaw0 Nov 3, 2024
4d0647d
feat: Add Formatter struct
Syaw0 Nov 4, 2024
427a129
feat: Add methods to format text
Syaw0 Nov 4, 2024
ad2546d
feat: Add reset method and change txt public api to styled
Syaw0 Nov 4, 2024
874e156
doc: Add basic documantation for styled method
Syaw0 Nov 4, 2024
fb1a1c0
refactor: extract the Stylify trait to traits.rs module and update th…
Syaw0 Nov 4, 2024
a56c441
refactor(colors.rs): just break the file into multiple module
Syaw0 Nov 5, 2024
95fb216
refactor: Move the styled_text module to lib and remove the styled_te…
Syaw0 Nov 5, 2024
d4beec4
refactor: rename the ansi_escape_code to ansi_code
Syaw0 Nov 6, 2024
ff9e504
refactor: Use `Macros` to create basic colors
Syaw0 Nov 6, 2024
4b4126e
test(basic_color.rs): Write test for coverage all of the module
Syaw0 Nov 6, 2024
8cabf4e
doc(basic_color.rs): Write document for module
Syaw0 Nov 6, 2024
fbf1c1b
refactor(formatter.rs): Write `Macro` to reduce code duplication
Syaw0 Nov 6, 2024
860c7a5
fix(basic_color.rs): fix issue with document comment test for color_c…
Syaw0 Nov 6, 2024
df4a75c
test(formatter.rs): Write test for coverage module
Syaw0 Nov 6, 2024
67b873d
doc(formatter.rs): Write document test for a module
Syaw0 Nov 6, 2024
217ce50
doc(paint_type.rs): Add document for a module
Syaw0 Nov 7, 2024
8fe8c70
test(paint_type.rs): Add basic tests for a module
Syaw0 Nov 7, 2024
8b9f3c8
doc(palette.rs): Add document for a module
Syaw0 Nov 7, 2024
d981ce9
test(palette.rs): Add tests for a module
Syaw0 Nov 7, 2024
745d582
doc(rgb.rs): Add test for a module
Syaw0 Nov 7, 2024
fadfff3
test(rgb.rs): Add tests for a module
Syaw0 Nov 7, 2024
1302bcd
doc(ansi_code.rs): add basic document for a module
Syaw0 Nov 7, 2024
f5bb741
doc(styles.rs): Add basic document for a module
Syaw0 Nov 7, 2024
1a67984
feat: Public the field of BasicColor and Formatter struct
Syaw0 Nov 7, 2024
6fbd3b5
test(styles.rs): Add tests for a module
Syaw0 Nov 7, 2024
f57bbf4
doc(lib.rs): Add document for a public api
Syaw0 Nov 7, 2024
01bfd96
chore: rename a package to `term_tools`
Syaw0 Nov 9, 2024
e8a2e64
doc(readme.md): just change the package name inside the file
Syaw0 Nov 9, 2024
8b40d10
doc: Add a document for a package
Syaw0 Nov 12, 2024
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
Prev Previous commit
Next Next commit
doc(palette.rs): Add document for a module
Syaw0 committed Nov 7, 2024

Verified

This commit was signed with the committer’s verified signature.
jalling97 John Alling
commit 8b9f3c84484a679a58951ea66a35bb953d46cd5d
15 changes: 15 additions & 0 deletions src/styles/palette.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
/// A module for creating palette color.
///
/// This module provides an struct `PaletteColor`
/// that represents palette color, index should be between 0 to 255 mean u8.
/// It also implements the `Stylify` trait for `PaletteColor`,
/// which allows for generating styles based on the paint type.

// =======================================================================

use super::{ paint_type::PaintType, Stylify };

// =======================================================================

/// An struct representing index of palette color.
///
/// This struct has 1 field: `index`, which represent 8 bit color code between 0 to 255.
#[derive(Debug, Clone)]
pub struct PaletteColor {
pub index: u8,
}

impl Stylify for PaletteColor {
/// Returns a string representation of the palette index code.
///
/// If `paint_type` is `None`, the foreground color is assumed.
fn make_styles(&self, paint_type: Option<&PaintType>) -> String {
let paint_type = paint_type.unwrap_or(&PaintType::FG);
format!(