From b51ebb0560a01c9eb6a4a86e67c0d36db4dca8c9 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Thu, 14 Mar 2024 00:25:29 +0200 Subject: [PATCH] Adding title to creating notification and moving title to CONST_ERROR_N_TITLE const under consts.go --- tui/consts.go | 5 +++++ tui/notification.go | 3 +-- tui/ui.go | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tui/consts.go b/tui/consts.go index c7f8c52..e2a45cd 100644 --- a/tui/consts.go +++ b/tui/consts.go @@ -12,6 +12,11 @@ const ( cursorPosGeneralRight cursorPosConfigValue = -3 ) +const ( + CONST_MESSAGE_LEN = 1024 + CONST_ERROR_N_TITLE = "ERROR" +) + const ( footerStart = "State: " ) diff --git a/tui/notification.go b/tui/notification.go index b109740..c7860c2 100644 --- a/tui/notification.go +++ b/tui/notification.go @@ -18,8 +18,7 @@ func centerText(width int, text string) string { ) } -func createNotification(message string) (notifier, error) { - title := "ERROR" +func createNotification(message, title string) (notifier, error) { var buf string width, height := UI.getSizes() if width == 0 { diff --git a/tui/ui.go b/tui/ui.go index ceec6d5..de5d438 100644 --- a/tui/ui.go +++ b/tui/ui.go @@ -144,8 +144,8 @@ func (t *TUI) Run() error { return nil } -func (t *TUI) createNotification(text string) { - notifier, err := createNotification(text) +func (t *TUI) createNotification(text, title string) { + notifier, err := createNotification(text, title) t.selectedNotifier = ¬ifier t.errors <- err t.errors <- t.write(notifier.Buf) @@ -159,7 +159,7 @@ func (t *TUI) setRoutines() error { go func() { for err := range t.errors { if err != nil { - t.createNotification(err.Error()) + t.createNotification(err.Error(), CONST_ERROR_N_TITLE) } } }() @@ -183,6 +183,7 @@ func (t *TUI) setRoutines() error { } go func() { for message := range t.messageChannel { + t.createNotification(string(message), "Message!") } }() go func() {