~blainsmith/public-inbox

Use tabs instead of spaces v2 PROPOSED

iamthenoname: 2
 Use tabs instead of spaces
 Implement NO_COLOR

 3 files changed, 47 insertions(+), 39 deletions(-)
Damn it, I forgot to add the project name in the subject again. Sorry 
about that, I'm new to patching and emails...
No worries. I will try them tomorrow when I get a chance. Thanks for 
sending them again!
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~blainsmith/public-inbox/patches/37513/mbox | git am -3
Learn more about email & git

[PATCH v2 1/2] Use tabs instead of spaces Export this patch

---
I'm not quite sure what causes the formatting issues, but I 
tried using a different editor instead.

 clrfmt/clrfmt.ha | 40 ++++++++++++++++++++--------------------
 main.ha          | 34 +++++++++++++++++-----------------
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/clrfmt/clrfmt.ha b/clrfmt/clrfmt.ha
index 5711e81..fd99c97 100644
--- a/clrfmt/clrfmt.ha
+++ b/clrfmt/clrfmt.ha
@@ -58,37 +58,37 @@ export def BG_HI_CYAN: color = 106;
export def BG_HI_WHITE: color = 107;

export fn printf(s: style, c: color, fmt: str, args: fmt::field...) (io::error | size) =
    fprintf(s: style, c: color, os::stdout, fmt, args...);
	fprintf(s: style, c: color, os::stdout, fmt, args...);

export fn printfln(s: style, c: color, fmt: str, args: fmt::field...) (io::error | size) =
    fprintf(s: style, c: color, os::stdout, fmt, args...);
	fprintf(s: style, c: color, os::stdout, fmt, args...);

export fn errorf(s: style, c: color, fmt: str, args: fmt::field...) (io::error | size) =
    fprintf(s: style, c: color, os::stderr, fmt, args...);
	fprintf(s: style, c: color, os::stderr, fmt, args...);

export fn errorfln(s: style, c: color, fmt: str, args: fmt::field...) (io::error | size) =
    fprintf(s: style, c: color, os::stderr, fmt, args...);
	fprintf(s: style, c: color, os::stderr, fmt, args...);

export fn asprintf(s: style, c: color, fmt: str, args: fmt::field...) str = {
    let buf = bufio::dynamic(io::mode::WRITE);
    assert(fprintf(s: style, c: color, &buf, fmt, args...) is size);
    return strings::fromutf8_unsafe(bufio::buffer(&buf));
	let buf = bufio::dynamic(io::mode::WRITE);
	assert(fprintf(s: style, c: color, &buf, fmt, args...) is size);
	return strings::fromutf8_unsafe(bufio::buffer(&buf));
};

export fn bsprintf(s: style, c: color, buf: []u8, fmt: str, args: fmt::field...) str = {
	let sink = bufio::fixed(buf, io::mode::WRITE);
    let l = fprintf(s: style, c: color, &sink, fmt, args...)!;
	let l = fprintf(s: style, c: color, &sink, fmt, args...)!;
	return strings::fromutf8_unsafe(buf[..l]);
};

export @noreturn fn fatalf(s: style, c: color, fmt: str, args: fmt::field...) void = {
    fprintfln(s, c, os::stderr, fmt, args...)!;
    os::exit(255);
	fprintfln(s, c, os::stderr, fmt, args...)!;
	os::exit(255);
};

export @noreturn fn fatal(s: style, c: color, args: fmt::formattable...) void = {
    fprintln(s, c, os::stderr, args...)!;
    os::exit(255);
	fprintln(s, c, os::stderr, args...)!;
	os::exit(255);
};

export fn fprintfln(s: style, c: color, h: io::handle, fmt: str, args: fmt::field...) (io::error | size) = {
@@ -124,15 +124,15 @@ export fn fprintln(s: style, c: color, h: io::handle, args: fmt::formattable...)
};

export fn fprint(s: style, c: color, h: io::handle, args: fmt::formattable...) (io::error | size) = {
    let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
    s += fmt::fprint(h, args...)?;
    s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
    return s;
	let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
	s += fmt::fprint(h, args...)?;
	s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
	return s;
};

export fn fprintf(s: style, c: color, h: io::handle, fmt: str, args: fmt::field...) (io::error | size) = {
    let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
    s += fmt::fprintf(h, fmt, args...)?;
    s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
    return s;
	let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
	s += fmt::fprintf(h, fmt, args...)?;
	s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
	return s;
};
\ No newline at end of file
diff --git a/main.ha b/main.ha
index 5ba62b0..8f4c93c 100644
--- a/main.ha
+++ b/main.ha
@@ -3,24 +3,24 @@ use clrfmt;
use log;

export fn main() void = {
    let cf = clrfmt::asprint(clrfmt::UNDERLINE, clrfmt::FG_GREEN, "clrfmt:");
    let an = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_BLUE, "an");
    let ansi = clrfmt::asprint(clrfmt::BOLD, clrfmt::BG_RED, "ANSI");
    let color = clrfmt::asprint(clrfmt::BOLD, clrfmt::BG_BLUE, "color");
    let module = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_HI_YELLOW, "module");
    let fr = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_RED, "for");
    let go = clrfmt::asprint(clrfmt::CROSSED_OUT, clrfmt::FG_CYAN, "Go");
    let hare = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_HI_MAGENTA, "Hare");
	let cf = clrfmt::asprint(clrfmt::UNDERLINE, clrfmt::FG_GREEN, "clrfmt:");
	let an = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_BLUE, "an");
	let ansi = clrfmt::asprint(clrfmt::BOLD, clrfmt::BG_RED, "ANSI");
	let color = clrfmt::asprint(clrfmt::BOLD, clrfmt::BG_BLUE, "color");
	let module = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_HI_YELLOW, "module");
	let fr = clrfmt::asprint(clrfmt::NORMAL, clrfmt::FG_RED, "for");
	let go = clrfmt::asprint(clrfmt::CROSSED_OUT, clrfmt::FG_CYAN, "Go");
	let hare = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_HI_MAGENTA, "Hare");

    fmt::printfln("{} {} {} {} {} {} {} {}", cf, an, ansi, color, module, fr, go, hare)!;
	fmt::printfln("{} {} {} {} {} {} {} {}", cf, an, ansi, color, module, fr, go, hare)!;

    let info = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_GREEN, "[INFO]");
    let warn = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_YELLOW, "[WARN]");
    let error = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_RED, "[ERROR]");
    let debug = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_BLUE, "[DEBUG]");
	let info = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_GREEN, "[INFO]");
	let warn = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_YELLOW, "[WARN]");
	let error = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_RED, "[ERROR]");
	let debug = clrfmt::asprint(clrfmt::BOLD, clrfmt::FG_BLUE, "[DEBUG]");

    log::printfln("{} - this is some info", info);
    log::printfln("{} - warning warning warning", warn);
    log::printfln("{} - something is very wrong", error);
    log::printfln("{} - testing out something", debug);
	log::printfln("{} - this is some info", info);
	log::printfln("{} - warning warning warning", warn);
	log::printfln("{} - something is very wrong", error);
	log::printfln("{} - testing out something", debug);
};
\ No newline at end of file
-- 
2.39.0

[PATCH v2 2/2] Implement NO_COLOR Export this patch

---
 clrfmt/clrfmt.ha | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/clrfmt/clrfmt.ha b/clrfmt/clrfmt.ha
index fd99c97..533a597 100644
--- a/clrfmt/clrfmt.ha
+++ b/clrfmt/clrfmt.ha
@@ -124,14 +124,22 @@ export fn fprintln(s: style, c: color, h: io::handle, args: fmt::formattable...)
};

export fn fprint(s: style, c: color, h: io::handle, args: fmt::formattable...) (io::error | size) = {
	let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
	let s = fmt::fprintf(h, "{}[{}", escape, s: int)?;
	if (os::getenv("NO_COLOR"): str != "1") {
		s += fmt::fprintf(h, ";{}", c: int)?;
	};
	s += fmt::fprintf(h, "m")?;
	s += fmt::fprint(h, args...)?;
	s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
	return s;
};

export fn fprintf(s: style, c: color, h: io::handle, fmt: str, args: fmt::field...) (io::error | size) = {
	let s = fmt::fprintf(h, "{}[{};{}m", escape, s: int, c: int)?;
	let s = fmt::fprintf(h, "{}[{}", escape, s: int)?;
	if (os::getenv("NO_COLOR"): str != "1") {
		s += fmt::fprintf(h, ";{}", c: int)?;
	};
	s += fmt::fprintf(h, "m")?;
	s += fmt::fprintf(h, fmt, args...)?;
	s += fmt::fprintf(h, "{}[{}m", escape, NORMAL: int)?;
	return s;
-- 
2.39.0
Damn it, I forgot to add the project name in the subject again. Sorry 
about that, I'm new to patching and emails...