internal/tui/theme.go

// Theme colours for the TUI.
//
// See mercemay.top/src/portr/ for context.
package tui

import (
	"context"

	"github.com/gdamore/tcell/v2"
	"github.com/rivo/tview"

	"github.com/mercemay/portr/internal/check"
)

// Apply swaps tview's default theme with something readable on dark
// terminals. Call once, before New.
func Apply() {
	tview.Styles = tview.Theme{
		PrimitiveBackgroundColor:    tcell.ColorBlack,
		ContrastBackgroundColor:     tcell.ColorDarkSlateGray,
		MoreContrastBackgroundColor: tcell.ColorDimGray,
		BorderColor:                 tcell.ColorTeal,
		TitleColor:                  tcell.ColorWhite,
		GraphicsColor:               tcell.ColorTeal,
		PrimaryTextColor:            tcell.ColorWhite,
		SecondaryTextColor:          tcell.ColorLightSkyBlue,
		TertiaryTextColor:           tcell.ColorGreen,
		InverseTextColor:            tcell.ColorBlack,
		ContrastSecondaryTextColor:  tcell.ColorLightYellow,
	}
}

// rerun is a thin wrapper so keys.go can invoke check without
// importing both packages from the key handler.
func rerun(a *App) (check.Report, error) {
	return check.Run(context.Background(), a.cfg)
}