From b787ef92df3f859b033aa8cded6b1f6dbc7c2be0 Mon Sep 17 00:00:00 2001 From: tjp Date: Fri, 16 Feb 2024 09:44:52 -0700 Subject: lipgloss styles --- state.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'state.go') diff --git a/state.go b/state.go index 918346f..5c3aa5c 100644 --- a/state.go +++ b/state.go @@ -3,10 +3,12 @@ package main import ( "bytes" "errors" + "fmt" "net/url" "os" "os/exec" + "github.com/charmbracelet/lipgloss" "github.com/chzyer/readline" ) @@ -69,16 +71,17 @@ func NewBrowserState(conf *Config) *BrowserState { type Printer interface { PrintModal(*BrowserState, []byte) error PrintPage(*BrowserState, string) error + PrintError(string) error } type PromptPrinter struct{} -func (_ PromptPrinter) PrintModal(state *BrowserState, contents []byte) error { +func (PromptPrinter) PrintModal(state *BrowserState, contents []byte) error { _, err := os.Stdout.Write(contents) return err } -func (_ PromptPrinter) PrintPage(state *BrowserState, body string) error { +func (PromptPrinter) PrintPage(state *BrowserState, body string) error { if state.Quiet { return nil } @@ -105,3 +108,10 @@ func (_ PromptPrinter) PrintPage(state *BrowserState, body string) error { return errors.New("invalid 'pager' value in configuration") } } + +var promptErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("196")).Bold(true) + +func (PromptPrinter) PrintError(msg string) error { + _, err := fmt.Println(promptErrorStyle.Render(msg)) + return err +} -- cgit v1.2.3