Hello,
New to odin. Long time pre-standard C dev mostly in deep embedded.
I was interested in understanding the type signature in some example code and grabbed the whole repo to play with locally. It appears that a recent addition has broken the example, so I brute-forced it into working. I understand that this repo is pretty old and things may have changed, but it went from looking pretty slick - to looking pretty ugly.
Is there a better way to construct this example so that it tickles that elegant part of my brain again? or do I need to recalibrate my expectations?
repo: odin-color
original example: readme-image.odin
What I brute forced:
#+feature using-stmt
package main
import color ".."
import "core:fmt"
import "base:runtime"
main :: proc() {
using color
fg_colors := [?]proc(string, runtime.Allocator)->string {
black, red, green, yellow, blue, magenta, cyan, white,
bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white,
}
bg_colors := [?]proc(string, runtime.Allocator)->string {
on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white,
on_bright_black, on_bright_red, on_bright_green, on_bright_yellow, on_bright_blue, on_bright_magenta, on_bright_cyan, on_bright_white,
}
for bg in bg_colors {
for fg in fg_colors {
fmt.printf("%s ", bg(fg("odin", context.allocator), context.allocator))
}
fmt.println()
}
}
Also, is there a way to preview a post before creating?
