|
@@ -39,7 +39,7 @@ func normalizeBlock(block *[][]byte) {
|
|
|
}
|
|
|
}
|
|
|
// fmt.Printf("max = %d\n", max)
|
|
|
- for idx, _ := range *block {
|
|
|
+ for idx := range *block {
|
|
|
// l := len(line)
|
|
|
for len((*block)[idx]) < max {
|
|
|
//(*block)[idx] += byte(0x20) //append((*block)[idx], byte{0x20})
|
|
@@ -78,12 +78,14 @@ func (bf *BlockFont) GetCharacter(c int) [][]byte {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
// expandBlock the number of strings, and make it match the length of [0].
|
|
|
func __expandBlock(block *[]string) {
|
|
|
// l := len((*block)[0])
|
|
|
l := len([]rune((*block)[0]))
|
|
|
*block = append(*block, strings.Repeat(" ", l))
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
func expandBlock(block *[][]byte) {
|
|
|
// l := len((*block)[0])
|
|
@@ -106,9 +108,12 @@ func (bf *BlockFont) Output(input string) ([][]byte, int) {
|
|
|
if l != 0 {
|
|
|
if len(out) == 0 {
|
|
|
// First time
|
|
|
- for _, b := range block {
|
|
|
- out = append(out, b)
|
|
|
- }
|
|
|
+ out = append(out, block...)
|
|
|
+ /*
|
|
|
+ for _, b := range block {
|
|
|
+ out = append(out, b)
|
|
|
+ }
|
|
|
+ */
|
|
|
} else {
|
|
|
if len(out) != 0 {
|
|
|
for l > len(out) {
|
|
@@ -122,11 +127,14 @@ func (bf *BlockFont) Output(input string) ([][]byte, int) {
|
|
|
// Ok, we have something!
|
|
|
for idx, b := range block {
|
|
|
out[idx] = append(out[idx], byte(0x20))
|
|
|
- // out[idx] = append(out[idx], b)
|
|
|
+ out[idx] = append(out[idx], b...)
|
|
|
+
|
|
|
+ /*
|
|
|
+ for _, inner := range b {
|
|
|
+ out[idx] = append(out[idx], inner)
|
|
|
+ }
|
|
|
+ */
|
|
|
|
|
|
- for _, inner := range b {
|
|
|
- out[idx] = append(out[idx], inner)
|
|
|
- }
|
|
|
// out[idx] += byte(0x20) + b
|
|
|
// fmt.Printf("%s\n", CP437_to_Unicode(b))
|
|
|
}
|
|
@@ -144,6 +152,7 @@ type ColorFont struct {
|
|
|
data [][][]byte
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
// Make []strings all the same length
|
|
|
func ___normalizeColor(block *[]string) int {
|
|
|
var max int
|
|
@@ -161,6 +170,7 @@ func ___normalizeColor(block *[]string) int {
|
|
|
}
|
|
|
return max
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
func normalizeColor(block *[][]byte) int {
|
|
|
var max int
|
|
@@ -170,7 +180,7 @@ func normalizeColor(block *[][]byte) int {
|
|
|
max = l
|
|
|
}
|
|
|
}
|
|
|
- for idx, _ := range *block {
|
|
|
+ for idx := range *block {
|
|
|
// l := len(line)
|
|
|
blank := []byte{0x20, 0x0f}
|
|
|
for len((*block)[idx]) < max {
|
|
@@ -227,6 +237,8 @@ func thedraw_to_ansi(c int) int {
|
|
|
return trans[c]
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+// Before color output was optimized
|
|
|
func colorout(c int) string {
|
|
|
bg := thedraw_to_ansi(c / 16)
|
|
|
fg := c % 16
|
|
@@ -238,6 +250,7 @@ func colorout(c int) string {
|
|
|
return fmt.Sprintf("\x1b[0;%d;%dm", fg+30, bg+40)
|
|
|
}
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
type ColorParts struct {
|
|
|
Background int
|
|
@@ -304,9 +317,12 @@ func Colorize(input []byte) []byte {
|
|
|
color := int(input[pos+1])
|
|
|
// fmt.Printf("%d : CH %d / %x, Color %d / %x\n", pos, ch, ch, color, color)
|
|
|
colorstring := ColorOutput(previous, color)
|
|
|
- for _, c := range []byte(colorstring) {
|
|
|
- result = append(result, c)
|
|
|
- }
|
|
|
+ result = append(result, []byte(colorstring)...)
|
|
|
+ /*
|
|
|
+ for _, c := range []byte(colorstring) {
|
|
|
+ result = append(result, c)
|
|
|
+ }
|
|
|
+ */
|
|
|
|
|
|
// result = append(result, []byte(colorstring))
|
|
|
|
|
@@ -320,9 +336,11 @@ func Colorize(input []byte) []byte {
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
func __expandColor(block *[]string, need int) {
|
|
|
*block = append(*block, strings.Repeat(" \x0f", need))
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
func expandColor(block *[][]byte, need int) {
|
|
|
blank := []byte{0x20, 0x0f}
|
|
@@ -346,9 +364,13 @@ func (bf *ColorFont) Output(input string) ([][]byte, int) {
|
|
|
if l != 0 {
|
|
|
if len(out) == 0 {
|
|
|
// First time
|
|
|
- for _, b := range block {
|
|
|
- out = append(out, b)
|
|
|
- }
|
|
|
+ out = append(out, block...)
|
|
|
+ /*
|
|
|
+ for _, b := range block {
|
|
|
+ out = append(out, b)
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
} else {
|
|
|
if len(out) != 0 {
|
|
|
for l > len(out) {
|
|
@@ -370,14 +392,20 @@ func (bf *ColorFont) Output(input string) ([][]byte, int) {
|
|
|
panic(fmt.Sprintf("len(out) %d != len(block) %d", len(out), len(block)))
|
|
|
}
|
|
|
|
|
|
+ blank := []byte{0x20, 0x0f}
|
|
|
// Ok, we have something!
|
|
|
for idx, b := range block {
|
|
|
- // blank := []byte{0x20, 0x0f}
|
|
|
- out[idx] = append(out[idx], byte(0x20))
|
|
|
- out[idx] = append(out[idx], byte(0x0f))
|
|
|
- for _, inner := range b {
|
|
|
- out[idx] = append(out[idx], inner)
|
|
|
- }
|
|
|
+ /*
|
|
|
+ out[idx] = append(out[idx], byte(0x20))
|
|
|
+ out[idx] = append(out[idx], byte(0x0f))
|
|
|
+ */
|
|
|
+ out[idx] = append(out[idx], blank...)
|
|
|
+ out[idx] = append(out[idx], b...)
|
|
|
+ /*
|
|
|
+ for _, inner := range b {
|
|
|
+ out[idx] = append(out[idx], inner)
|
|
|
+ }
|
|
|
+ */
|
|
|
//out[idx] += " \x0f" + b
|
|
|
// fmt.Printf("%s\n", CP437_to_Unicode(b))
|
|
|
}
|
|
@@ -394,7 +422,7 @@ func (bf *ColorFont) Output(input string) ([][]byte, int) {
|
|
|
// StringHexO(&out)
|
|
|
max = len(out[0]) / 2
|
|
|
|
|
|
- for idx, _ := range out {
|
|
|
+ for idx := range out {
|
|
|
out[idx] = Colorize(out[idx])
|
|
|
}
|
|
|
return out, max
|