Exemplo n.º 1
0
func doprint(s string) {
	var i int
	for {
		if i >= len(s) {
			break
		}
		if i > 2 {
			if s[i] == '[' && s[i+1] == '%' && s[i+2] == '^' {
				i += 3
				color := string(s[i])
				i++
				var ns string
				for {
					if i >= len(s) {
						panic("Unescaped color code")
					}

					if s[i] == '^' && s[i+1] == '%' && s[i+2] == ']' {
						i += 3
						break
					}

					ns += string(s[i])

					i++
				}

				switch color {
				case "1":
					term.Red(os.Stdout, ns)
				case "2":
					term.DarkYellow(os.Stdout, ns)
				default:
					fmt.Print(ns)
				}
			}
		}

		fmt.Print(string(s[i]))
		i++
	}
}
Exemplo n.º 2
0
func (l *FModLog) Error(format string, args ...interface{}) {
	term.Red(os.Stdout, " >> ")
	s := fmt.Sprintf(format, args...)
	doprint(s)
}