Shows text in a Toast (a transient popup notification).

Usage #

package main

import (
    "log"
    t "github.com/hugmouse/gotermux"
)

func main() {
    toast := t.TToast{
        Text:            "Hello from GoTermux!",
        BackgroundColor: t.Blue,
        TextColor:       t.White,
        ToastPosition:   t.Top,
        Short:           true,
    }
    
    err := t.TermuxToast(toast)
    if err != nil {
        log.Println("Toast error:", err)
    }
}

Parameters #

  • t TToast - Toast configuration structure

Struct TToast #

FieldTypeDescription
TextstringText to display in the toast
BackgroundColorColorBackground color using predefined colors
BackgroundColorAARRGGBBstringBackground color using hex format (#AARRGGBB)
TextColorColorText color using predefined colors
TextColorAARRGGBBstringText color using hex format (#AARRGGBB)
ToastPositionPositionPosition on screen (Top, Middle, Bottom)
ShortboolShow toast for a short duration if true

Color Constants #

Available predefined colors:

  • Black, Blue, Cyan, DarkGray, Gray, Green
  • LightGray, Magenta, Red, Transparent, White, Yellow

Position Constants #

  • Top - Display at top of screen
  • Middle - Display in middle of screen (default)
  • Bottom - Display at bottom of screen

Return Value #

Returns error - nil on success, error message on failure.

You can use either predefined colors (BackgroundColor/TextColor) or hex colors (BackgroundColorAARRGGBB/TextColorAARRGGBB), but not both for the same color type.