diff options
Diffstat (limited to 'state.go')
| -rw-r--r-- | state.go | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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 +} |
