Example #1
0
func updateTerminalSize(term terminal.Terminal, tc terminal.Control) {
	width, height, err := tc.GetSize(0)
	if err != nil {
		return
	}
	term.SetSize(width, height)
}
Example #2
0
func terminalMessage(term terminal.Terminal, tc terminal.Control, color []byte, msg string, critical bool) {
	line := make([]byte, 0, len(msg)+16)

	line = append(line, ' ')
	line = append(line, color...)
	line = append(line, '*')
	line = append(line, tc.Escape(term).Reset...)
	line = append(line, []byte(fmt.Sprintf(" (%s) ", time.Now().Format(time.Kitchen)))...)
	if critical {
		line = append(line, tc.Escape(term).Red...)
	}
	line = appendTerminalEscaped(line, []byte(msg))
	if critical {
		line = append(line, tc.Escape(term).Reset...)
	}
	line = append(line, '\n')
	term.Write(line)
}
Example #3
0
func critical(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Red, msg, true)
}
Example #4
0
func alert(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Red, msg, false)
}
Example #5
0
func warn(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Magenta, msg, false)
}
Example #6
0
func info(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Blue, msg, false)
}