From 5acfb29c3a59933125ee66afe073bcd76b286405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sun, 1 Jan 2023 22:05:50 -0500 Subject: [PATCH] Fixed formatting --- system/discourse/connect.go | 10 ++++-- ui/helpers/overlay.go | 6 +++- ui/theme/theme.go | 61 +++++++++++++++++++++++-------------- ui/views/posts/view.go | 5 ++- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/system/discourse/connect.go b/system/discourse/connect.go index 33a1a8f..3efa2e1 100644 --- a/system/discourse/connect.go +++ b/system/discourse/connect.go @@ -47,14 +47,20 @@ func (sys *System) Connect(sysURL string) error { return err } privateKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey) - privateKeyPEM := string(pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: privateKeyBytes})) + privateKeyPEM := string(pem.EncodeToMemory(&pem.Block{ + Type: "PRIVATE KEY", + Bytes: privateKeyBytes, + })) // Public key publicKeyBytes, err := x509.MarshalPKIXPublicKey(&privateKey.PublicKey) if err != nil { return err } - publicKeyPEM := string(pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: publicKeyBytes})) + publicKeyPEM := string(pem.EncodeToMemory(&pem.Block{ + Type: "PUBLIC KEY", + Bytes: publicKeyBytes, + })) // Client ID uuidV4, err := uuid.NewRandom() diff --git a/ui/helpers/overlay.go b/ui/helpers/overlay.go index 2d96894..5a4018f 100644 --- a/ui/helpers/overlay.go +++ b/ui/helpers/overlay.go @@ -31,7 +31,11 @@ func getLines(s string) (lines []string, widest int) { } // PlaceOverlay places fg on top of bg. -func PlaceOverlay(x, y int, fg, bg string, shadow bool, opts ...WhitespaceOption) string { +func PlaceOverlay( + x, y int, + fg, bg string, + shadow bool, opts ...WhitespaceOption, +) string { fgLines, fgWidth := getLines(fg) bgLines, bgWidth := getLines(bg) bgHeight := len(bgLines) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 600c22f..888f8c0 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -24,19 +24,19 @@ type Theme struct { Blurred lipgloss.Style } Item struct { - Focused lipgloss.Style - Blurred lipgloss.Style + Focused lipgloss.Style + Blurred lipgloss.Style Selected lipgloss.Style } ItemDetail struct { - Focused lipgloss.Style - Blurred lipgloss.Style + Focused lipgloss.Style + Blurred lipgloss.Style Selected lipgloss.Style } } Post struct { - Author lipgloss.Style + Author lipgloss.Style Subject lipgloss.Style } @@ -45,25 +45,41 @@ type Theme struct { } } -func New(cfg *config.Config) (*Theme) { +func New(cfg *config.Config) *Theme { t := new(Theme) - t.PostsList.List.Focused = t.fromConfig(&cfg.Theme.PostsList.List.Focused) - t.PostsList.List.Blurred = t.fromConfig(&cfg.Theme.PostsList.List.Blurred) - t.PostsList.Item.Focused = t.fromConfig(&cfg.Theme.PostsList.Item.Focused) - t.PostsList.Item.Blurred = t.fromConfig(&cfg.Theme.PostsList.Item.Blurred) - t.PostsList.Item.Selected = t.fromConfig(&cfg.Theme.PostsList.Item.Selected) - t.PostsList.ItemDetail.Focused = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Focused) - t.PostsList.ItemDetail.Blurred = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Blurred) - t.PostsList.ItemDetail.Selected = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Selected) - t.DialogBox.Window.Focused = t.fromConfig(&cfg.Theme.DialogBox.Window.Focused) - t.DialogBox.Window.Blurred = t.fromConfig(&cfg.Theme.DialogBox.Window.Blurred) - t.DialogBox.Titlebar.Focused = t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Focused) - t.DialogBox.Titlebar.Blurred = t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Blurred) - t.DialogBox.Bottombar = t.fromConfig(&cfg.Theme.DialogBox.Bottombar) - t.Post.Author = t.fromConfig(&cfg.Theme.Post.Author) - t.Post.Subject = t.fromConfig(&cfg.Theme.Post.Subject) - t.Reply.Author = t.fromConfig(&cfg.Theme.Reply.Author) + t.PostsList.List.Focused = + t.fromConfig(&cfg.Theme.PostsList.List.Focused) + t.PostsList.List.Blurred = + t.fromConfig(&cfg.Theme.PostsList.List.Blurred) + t.PostsList.Item.Focused = + t.fromConfig(&cfg.Theme.PostsList.Item.Focused) + t.PostsList.Item.Blurred = + t.fromConfig(&cfg.Theme.PostsList.Item.Blurred) + t.PostsList.Item.Selected = + t.fromConfig(&cfg.Theme.PostsList.Item.Selected) + t.PostsList.ItemDetail.Focused = + t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Focused) + t.PostsList.ItemDetail.Blurred = + t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Blurred) + t.PostsList.ItemDetail.Selected = + t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Selected) + t.DialogBox.Window.Focused = + t.fromConfig(&cfg.Theme.DialogBox.Window.Focused) + t.DialogBox.Window.Blurred = + t.fromConfig(&cfg.Theme.DialogBox.Window.Blurred) + t.DialogBox.Titlebar.Focused = + t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Focused) + t.DialogBox.Titlebar.Blurred = + t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Blurred) + t.DialogBox.Bottombar = + t.fromConfig(&cfg.Theme.DialogBox.Bottombar) + t.Post.Author = + t.fromConfig(&cfg.Theme.Post.Author) + t.Post.Subject = + t.fromConfig(&cfg.Theme.Post.Subject) + t.Reply.Author = + t.fromConfig(&cfg.Theme.Reply.Author) return t } @@ -77,4 +93,3 @@ func (t *Theme) fromConfig(itemCfg *config.ThemeItemConfig) lipgloss.Style { Foreground(itemCfg.Foreground). Background(itemCfg.Background) } - diff --git a/ui/views/posts/view.go b/ui/views/posts/view.go index b4f0948..a3f5df6 100644 --- a/ui/views/posts/view.go +++ b/ui/views/posts/view.go @@ -24,7 +24,10 @@ func (m Model) buildView(cached bool) string { m.textarea.SetWidth(m.viewcacheTextareaXY[2]) m.textarea.SetHeight(m.viewcacheTextareaXY[3]) - return helpers.PlaceOverlay(m.viewcacheTextareaXY[0], m.viewcacheTextareaXY[1], m.textarea.View(), m.viewcache, false) + return helpers.PlaceOverlay( + m.viewcacheTextareaXY[0], m.viewcacheTextareaXY[1], + m.textarea.View(), m.viewcache, + false) } m.ctx.Logger.Debugln("View()")