start removing newNumber and number types from the code.

This commit is contained in:
2024-07-11 03:55:19 +01:00
parent 70f2c47e4f
commit bfdb7b6e6a
10 changed files with 150 additions and 128 deletions

View File

@@ -19,8 +19,16 @@ var ArColour = Map(
}
var c *color.Color
var s string
if x, ok := a[0].(number); ok {
c = color.Set(color.Attribute(x.Num().Int64()))
if x, ok := a[0].(ArObject); ok {
colour_int64, err := numberToInt64(x)
if err != nil {
return nil, ArErr{
TYPE: "Type Error",
message: err.Error(),
EXISTS: true,
}
}
c = color.New(color.Attribute(colour_int64))
} else {
return nil, ArErr{
TYPE: "Type Error",
@@ -45,52 +53,52 @@ var ArColour = Map(
}},
"bg": Map(
anymap{
"black": newNumber().SetInt64(int64(color.BgBlack)),
"red": newNumber().SetInt64(int64(color.BgRed)),
"green": newNumber().SetInt64(int64(color.BgGreen)),
"yellow": newNumber().SetInt64(int64(color.BgYellow)),
"blue": newNumber().SetInt64(int64(color.BgBlue)),
"magenta": newNumber().SetInt64(int64(color.BgMagenta)),
"cyan": newNumber().SetInt64(int64(color.BgCyan)),
"white": newNumber().SetInt64(int64(color.BgWhite)),
"hiBlack": newNumber().SetInt64(int64(color.BgHiBlack)),
"hiRed": newNumber().SetInt64(int64(color.BgHiRed)),
"hiGreen": newNumber().SetInt64(int64(color.BgHiGreen)),
"hiYellow": newNumber().SetInt64(int64(color.BgHiYellow)),
"hiBlue": newNumber().SetInt64(int64(color.BgHiBlue)),
"hiMagenta": newNumber().SetInt64(int64(color.BgHiMagenta)),
"hiCyan": newNumber().SetInt64(int64(color.BgHiCyan)),
"hiWhite": newNumber().SetInt64(int64(color.BgHiWhite)),
"black": Number(int64(color.BgBlack)),
"red": Number(int64(color.BgRed)),
"green": Number(int64(color.BgGreen)),
"yellow": Number(int64(color.BgYellow)),
"blue": Number(int64(color.BgBlue)),
"magenta": Number(int64(color.BgMagenta)),
"cyan": Number(int64(color.BgCyan)),
"white": Number(int64(color.BgWhite)),
"hiBlack": Number(int64(color.BgHiBlack)),
"hiRed": Number(int64(color.BgHiRed)),
"hiGreen": Number(int64(color.BgHiGreen)),
"hiYellow": Number(int64(color.BgHiYellow)),
"hiBlue": Number(int64(color.BgHiBlue)),
"hiMagenta": Number(int64(color.BgHiMagenta)),
"hiCyan": Number(int64(color.BgHiCyan)),
"hiWhite": Number(int64(color.BgHiWhite)),
},
),
"fg": Map(
anymap{
"black": newNumber().SetInt64(int64(color.FgBlack)),
"red": newNumber().SetInt64(int64(color.FgRed)),
"green": newNumber().SetInt64(int64(color.FgGreen)),
"yellow": newNumber().SetInt64(int64(color.FgYellow)),
"blue": newNumber().SetInt64(int64(color.FgBlue)),
"magenta": newNumber().SetInt64(int64(color.FgMagenta)),
"cyan": newNumber().SetInt64(int64(color.FgCyan)),
"white": newNumber().SetInt64(int64(color.FgWhite)),
"hiBlack": newNumber().SetInt64(int64(color.FgHiBlack)),
"hiRed": newNumber().SetInt64(int64(color.FgHiRed)),
"hiGreen": newNumber().SetInt64(int64(color.FgHiGreen)),
"hiYellow": newNumber().SetInt64(int64(color.FgHiYellow)),
"hiBlue": newNumber().SetInt64(int64(color.FgHiBlue)),
"hiMagenta": newNumber().SetInt64(int64(color.FgHiMagenta)),
"hiCyan": newNumber().SetInt64(int64(color.FgHiCyan)),
"hiWhite": newNumber().SetInt64(int64(color.FgHiWhite)),
"black": Number(int64(color.FgBlack)),
"red": Number(int64(color.FgRed)),
"green": Number(int64(color.FgGreen)),
"yellow": Number(int64(color.FgYellow)),
"blue": Number(int64(color.FgBlue)),
"magenta": Number(int64(color.FgMagenta)),
"cyan": Number(int64(color.FgCyan)),
"white": Number(int64(color.FgWhite)),
"hiBlack": Number(int64(color.FgHiBlack)),
"hiRed": Number(int64(color.FgHiRed)),
"hiGreen": Number(int64(color.FgHiGreen)),
"hiYellow": Number(int64(color.FgHiYellow)),
"hiBlue": Number(int64(color.FgHiBlue)),
"hiMagenta": Number(int64(color.FgHiMagenta)),
"hiCyan": Number(int64(color.FgHiCyan)),
"hiWhite": Number(int64(color.FgHiWhite)),
},
),
"reset": newNumber().SetInt64(int64(color.Reset)),
"bold": newNumber().SetInt64(int64(color.Bold)),
"faint": newNumber().SetInt64(int64(color.Faint)),
"italic": newNumber().SetInt64(int64(color.Italic)),
"underline": newNumber().SetInt64(int64(color.Underline)),
"blinkSlow": newNumber().SetInt64(int64(color.BlinkSlow)),
"blinkRapid": newNumber().SetInt64(int64(color.BlinkRapid)),
"reverseVideo": newNumber().SetInt64(int64(color.ReverseVideo)),
"concealed": newNumber().SetInt64(int64(color.Concealed)),
"crossedOut": newNumber().SetInt64(int64(color.CrossedOut)),
"reset": Number(int64(color.Reset)),
"bold": Number(int64(color.Bold)),
"faint": Number(int64(color.Faint)),
"italic": Number(int64(color.Italic)),
"underline": Number(int64(color.Underline)),
"blinkSlow": Number(int64(color.BlinkSlow)),
"blinkRapid": Number(int64(color.BlinkRapid)),
"reverseVideo": Number(int64(color.ReverseVideo)),
"concealed": Number(int64(color.Concealed)),
"crossedOut": Number(int64(color.CrossedOut)),
})