From c4fb002ae0b48aed1a0d2b8fa84b6be795f83e2d Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sun, 24 Nov 2024 14:26:28 -0500 Subject: feat: Update master (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Attemp at using goreleaser * Fix syntax error in .goreleaser.yml * fix: Check roadmap feature for clipboard (README) * feat: add help menu at the bottom (#4) * MVP for a help menu * fix: commented code is evil * feat: box-drawing UI (#6) * feat: add help at the bottom (#5) * Attemp at using goreleaser * Fix syntax error in .goreleaser.yml * fix: Check roadmap feature for clipboard (README) * feat: add help menu at the bottom (#4) * MVP for a help menu * fix: commented code is evil * Update generated VHS GIF * feat: Rounded corner box UI * Update roadmap checkmarks in README --------- Co-authored-by: vhs-action 📼 --------- Co-authored-by: vhs-action 📼 --- internal/preview/preview.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'internal/preview') diff --git a/internal/preview/preview.go b/internal/preview/preview.go index eb7d344..1ab86be 100644 --- a/internal/preview/preview.go +++ b/internal/preview/preview.go @@ -7,19 +7,29 @@ import ( "github.com/charmbracelet/lipgloss" ) -const runeBlock = "█" +const ( + runeBlock = "█" + defaultHeight = 5 + defaultWidth = 78 +) type Model struct { - size int // height of the square in rows - hex string + height int + width int + hex string } -func (m *Model) Color(hex string) { m.hex = hex } +func (m *Model) SetColor(hex string) { m.hex = hex } + +func (m *Model) SetHeight(size int) { m.height = size } + +func (m *Model) SetWidth(size int) { m.width = size } func New(hex string) *Model { return &Model{ - size: 5, - hex: hex, + height: defaultHeight, + width: defaultWidth, + hex: hex, } } @@ -29,8 +39,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } func (m Model) View() string { style := lipgloss.NewStyle().Foreground(lipgloss.Color(m.hex)) - // size is doubled since terminal cells are 2:1 (h:w) - oneRow := strings.Repeat(runeBlock, m.size*2) - block := strings.Repeat(oneRow+"\n", m.size) + oneRow := strings.Repeat(runeBlock, m.width) + block := strings.Repeat(oneRow+"\n", m.height) return style.Render(block) } -- cgit v1.2.3