summaryrefslogtreecommitdiff
path: root/internal/ui/termstatus/status.go
diff options
context:
space:
mode:
authorMichaelEischer <michael.eischer@fau.de>2020-10-25 17:51:39 +0100
committerGitHub <noreply@github.com>2020-10-25 17:51:39 +0100
commitad3a52e6f007107185f96d8d89f33847fc074da0 (patch)
treecb85f6bb8390a7df766b6b577d9517495bc3948e /internal/ui/termstatus/status.go
parente8b4d8d8bcdb6100081ba7fc9f690d1ec7b70f98 (diff)
parent35419de232f89b02645a8844ae0f4853ba46be2e (diff)
Merge pull request #3026 from greatroar/refactor-ui
internal/ui refactoring
Diffstat (limited to 'internal/ui/termstatus/status.go')
-rw-r--r--internal/ui/termstatus/status.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go
index 87cf1a232..b577f2f32 100644
--- a/internal/ui/termstatus/status.go
+++ b/internal/ui/termstatus/status.go
@@ -234,19 +234,23 @@ func (t *Terminal) undoStatus(lines int) {
}
}
-// Print writes a line to the terminal.
-func (t *Terminal) Print(line string) {
+func (t *Terminal) print(line string, isErr bool) {
// make sure the line ends with a line break
if line[len(line)-1] != '\n' {
line += "\n"
}
select {
- case t.msg <- message{line: line}:
+ case t.msg <- message{line: line, err: isErr}:
case <-t.closed:
}
}
+// Print writes a line to the terminal.
+func (t *Terminal) Print(line string) {
+ t.print(line, false)
+}
+
// Printf uses fmt.Sprintf to write a line to the terminal.
func (t *Terminal) Printf(msg string, args ...interface{}) {
s := fmt.Sprintf(msg, args...)
@@ -255,15 +259,7 @@ func (t *Terminal) Printf(msg string, args ...interface{}) {
// Error writes an error to the terminal.
func (t *Terminal) Error(line string) {
- // make sure the line ends with a line break
- if line[len(line)-1] != '\n' {
- line += "\n"
- }
-
- select {
- case t.msg <- message{line: line, err: true}:
- case <-t.closed:
- }
+ t.print(line, true)
}
// Errorf uses fmt.Sprintf to write an error line to the terminal.