|
@@ -31,9 +31,12 @@ func (l *Line) Output() string {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+// The old example of a render function (before Render struct)
|
|
|
+//
|
|
|
// Sample RenderF function
|
|
|
// Upcase is BOLD Blue, everything else is Yellow
|
|
|
-func RenderBlueYellow(text string) string {
|
|
|
+func Render_BlueYellow(text string) string {
|
|
|
var output string
|
|
|
var lastColor string
|
|
|
|
|
@@ -73,3 +76,21 @@ func (r *Render) Append(color string, len int) {
|
|
|
r.Result += r.Line[r.Pos : r.Pos+len]
|
|
|
r.Pos += len
|
|
|
}
|
|
|
+
|
|
|
+// Sample RenderF function
|
|
|
+// Upcase is BOLD Blue, everything else is Yellow
|
|
|
+func RenderBlueYellow(text string) string {
|
|
|
+ var r Render = Render{Line: text}
|
|
|
+
|
|
|
+ blue := ColorText("BOLD BLUE")
|
|
|
+ yellow := ColorText("BOLD YELLOW")
|
|
|
+
|
|
|
+ for _, letter := range text {
|
|
|
+ if unicode.IsUpper(letter) {
|
|
|
+ r.Append(blue, 1)
|
|
|
+ } else {
|
|
|
+ r.Append(yellow, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return r.Result
|
|
|
+}
|