Adding title to creating notification and moving title to CONST_ERROR_N_TITLE const under consts.go

This commit is contained in:
qowevisa 2024-03-14 00:25:29 +02:00
parent 715a25a6d4
commit b51ebb0560
3 changed files with 10 additions and 5 deletions

View File

@ -12,6 +12,11 @@ const (
cursorPosGeneralRight cursorPosConfigValue = -3 cursorPosGeneralRight cursorPosConfigValue = -3
) )
const (
CONST_MESSAGE_LEN = 1024
CONST_ERROR_N_TITLE = "ERROR"
)
const ( const (
footerStart = "State: " footerStart = "State: "
) )

View File

@ -18,8 +18,7 @@ func centerText(width int, text string) string {
) )
} }
func createNotification(message string) (notifier, error) { func createNotification(message, title string) (notifier, error) {
title := "ERROR"
var buf string var buf string
width, height := UI.getSizes() width, height := UI.getSizes()
if width == 0 { if width == 0 {

View File

@ -144,8 +144,8 @@ func (t *TUI) Run() error {
return nil return nil
} }
func (t *TUI) createNotification(text string) { func (t *TUI) createNotification(text, title string) {
notifier, err := createNotification(text) notifier, err := createNotification(text, title)
t.selectedNotifier = &notifier t.selectedNotifier = &notifier
t.errors <- err t.errors <- err
t.errors <- t.write(notifier.Buf) t.errors <- t.write(notifier.Buf)
@ -159,7 +159,7 @@ func (t *TUI) setRoutines() error {
go func() { go func() {
for err := range t.errors { for err := range t.errors {
if err != nil { 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() { go func() {
for message := range t.messageChannel { for message := range t.messageChannel {
t.createNotification(string(message), "Message!")
} }
}() }()
go func() { go func() {