clx-browser

[ACTIVE] a smol browser based off of circumflex
git clone git://git.figbert.com/clx-browser.git
Log | Files | Refs | README | LICENSE

commit fead57edfcb8430d05856a845b64ea60a505ee88
parent 529aa23303368e6838d13df69a75e913d4cbb09c
Author: FIGBERT <figbert@figbert.com>
Date:   Fri, 29 Jul 2022 21:01:10 -0700

Move meta block to its own file

Diffstat:
Mmain.go | 30------------------------------
Ameta.go | 34++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/main.go b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "os/exec" "strings" @@ -9,7 +8,6 @@ import ( "git.figbert.com/clx-browser/reader" "github.com/charmbracelet/glamour" - "github.com/charmbracelet/lipgloss" ) func main() { @@ -44,31 +42,3 @@ func main() { panic(err) } } - -func getReaderModeMetaBlock(title string, url string, lineWidth int) string { - style := lipgloss.NewStyle(). - BorderStyle(lipgloss.RoundedBorder()). - PaddingLeft(1). - PaddingRight(1). - MarginLeft(1). - MarginTop(1). - MarginBottom(1). - Width(lineWidth) - bold := lipgloss.NewStyle().Bold(true) - blue := lipgloss.NewStyle().Foreground(lipgloss.Color("32")) - green := lipgloss.NewStyle().Foreground(lipgloss.Color("34")) - - urlRunes := []rune(url) - if len(urlRunes) > lineWidth-2 { - url = string(append(urlRunes[:lineWidth-3], '…')) - } - - return style.Render( - fmt.Sprintf( - "%s\n%s\n%s", - bold.Render(title), - blue.Render(url), - green.Render("Reader Mode"), - ), - ) -} diff --git a/meta.go b/meta.go @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + "github.com/charmbracelet/lipgloss" +) + +func getReaderModeMetaBlock(title string, url string, lineWidth int) string { + style := lipgloss.NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + PaddingLeft(1). + PaddingRight(1). + MarginLeft(1). + MarginTop(1). + MarginBottom(1). + Width(lineWidth) + bold := lipgloss.NewStyle().Bold(true) + blue := lipgloss.NewStyle().Foreground(lipgloss.Color("32")) + green := lipgloss.NewStyle().Foreground(lipgloss.Color("34")) + + urlRunes := []rune(url) + if len(urlRunes) > lineWidth-2 { + url = string(append(urlRunes[:lineWidth-3], '…')) + } + + return style.Render( + fmt.Sprintf( + "%s\n%s\n%s", + bold.Render(title), + blue.Render(url), + green.Render("Reader Mode"), + ), + ) +}