From 6e2ae280251991bf838ae73544d7ad5b714a5646 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 15 Jul 2025 16:03:25 +0300 Subject: Added toggleable borders (not fully fleshed) --- internal/client/ui/core/banlist/banlist.go | 34 +++++++++-- internal/client/ui/core/chat/chat.go | 22 +++++-- internal/client/ui/core/core.go | 43 ++++++++++++-- .../client/ui/core/frequencylist/frequencylist.go | 56 ++++++++++++------ internal/client/ui/core/memberlist/memberlist.go | 36 +++++++++--- internal/client/ui/core/networklist/networklist.go | 67 ++++++++++++++++++---- internal/client/ui/core/signallist/signallist.go | 37 +++++++++--- internal/client/ui/ui.go | 2 +- 8 files changed, 230 insertions(+), 67 deletions(-) (limited to 'internal/client/ui') diff --git a/internal/client/ui/core/banlist/banlist.go b/internal/client/ui/core/banlist/banlist.go index 7daff55..dc65d19 100644 --- a/internal/client/ui/core/banlist/banlist.go +++ b/internal/client/ui/core/banlist/banlist.go @@ -7,6 +7,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -23,7 +24,9 @@ var ( symbolWidth = 2 widthWithoutMember = ((margin + padding) * 2) + symbolWidth - ellipsis = "…" + ellipsis = "…" + HorizontalSep = "━" + VerticalSep = "┃" ) type Model struct { @@ -46,6 +49,9 @@ func New(networkId snowflake.ID) Model { m.height = ui.Height m.height -= lipgloss.Height(m.renderHeader()) m.height -= 1 + if config.ReadConfig().ScreenBorders { + m.height -= 1 // Only bottom, top is calculated in renderHeader + } return m } @@ -125,12 +131,25 @@ func (m Model) View() string { builder.WriteString("\n") } + focusStyle := lipgloss.NewStyle().Background(colors.BackgroundDim).Foreground(colors.Focus) + + if config.ReadConfig().ScreenBorders { + builder.WriteString(strings.Repeat("\n", m.height-len(members)+1)) + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, m.width))) + } + sidebar := backgroundStyle.Height(ui.Height).Render(builder.String()) - sep := lipgloss.NewStyle().Width(0).Height(ui.Height). - BorderBackground(colors.BackgroundDim).BorderForeground(colors.Focus). - Border(lipgloss.ThickBorder(), false, true, false, false) - result := lipgloss.JoinHorizontal(lipgloss.Top, sep.String(), sidebar) + sep := "" + if config.ReadConfig().ScreenBorders { + sep = HorizontalSep + strings.Repeat("\n"+VerticalSep, ui.Height-2) + "\n" + HorizontalSep + } else { + sep = strings.Repeat(VerticalSep+"\n", ui.Height) + sep = sep[:len(sep)-1] + } + sep = focusStyle.Render(sep) + + result := lipgloss.JoinHorizontal(lipgloss.Top, sep, sidebar) return result } @@ -140,6 +159,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.height = ui.Height m.height -= lipgloss.Height(m.renderHeader()) m.height -= 1 + if config.ReadConfig().ScreenBorders { + m.height -= 1 // Only bottom, top is calculated in renderHeader + } members := m.Members() @@ -258,7 +280,7 @@ func (m Model) renderHeader() string { headerStyle := lipgloss.NewStyle().Width(m.width). Background(colors.BackgroundDim).Foreground(colors.White). Margin(0, 0, 1).Padding(1).Align(lipgloss.Center). - Border(lipgloss.ThickBorder(), false, false, true). + Border(lipgloss.ThickBorder(), config.ReadConfig().ScreenBorders, false, true). BorderForeground(colors.Focus) return headerStyle.Render("Ban List") } diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 0da463b..fb6a53e 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -11,6 +11,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/google/btree" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -95,8 +96,9 @@ var ( PingedEveryone = func() string { return lipgloss.NewStyle().Foreground(colors.Purple).Render("@everyone ") } PingedUserStyle = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(colors.Gold) } - NewText = "━━ NEW ━━" - NewSymbol = "━" + NewText = "━━ NEW ━━" + HorizontalSep = "━" + VerticalSep = "┃" ) const ( @@ -177,6 +179,9 @@ func (m *Model) Prerender() { messageBoxHeight := lipgloss.Height(messagebox) - 1 messagesHeight := ui.Height - messageBoxHeight - frequencyHeight + if config.ReadConfig().ScreenBorders { + messagesHeight -= 1 // Bottom border, top border is inside freq name + } // if m.messagesCache == nil || messagesHeight != m.messagesHeight { // // Re-render @@ -186,8 +191,15 @@ func (m *Model) Prerender() { m.messagesCache = &messages m.messagesHeight = messagesHeight + focusColor := colors.White + if m.focus { + focusColor = colors.Focus + } + m.prerender = lipgloss.NewStyle(). Background(colors.Background). + Border(lipgloss.ThickBorder(), false, false, config.ReadConfig().ScreenBorders). + BorderBackground(colors.Background).BorderForeground(focusColor). Render(frequencyName + *m.messagesCache + messagebox) } @@ -1593,13 +1605,13 @@ func (m *Model) renderFrequencyName() string { name = user.Name } else { - return "" + name = "" } nameStyle := lipgloss.NewStyle().Width(m.width). Background(colors.Background).Foreground(color). AlignHorizontal(lipgloss.Center). - Border(lipgloss.ThickBorder(), false, false, true). + Border(lipgloss.ThickBorder(), config.ReadConfig().ScreenBorders, false, name != ""). BorderForeground(colors.White) if m.focus { nameStyle = nameStyle.BorderForeground(colors.Focus) @@ -1614,7 +1626,7 @@ func (m *Model) Mode() int { func (m *Model) NewMsgSep(height, remainingHeight int) string { lineWidth := m.width - lipgloss.Width(NewText) - line := strings.Repeat(NewSymbol, lineWidth) + line := strings.Repeat(HorizontalSep, lineWidth) newMsgStyle := lipgloss.NewStyle().Foreground(colors.Red).Width(m.width) if m.index == height-remainingHeight { diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 8b45cde..4c64c75 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -8,6 +8,7 @@ import ( "os" "runtime" "slices" + "strings" "time" "github.com/atotto/clipboard" @@ -76,6 +77,14 @@ const ( Authenticated ) +const ( + VerticalBorder = "┃" + TopLeftCorner = "┏" + BottomLeftCorner = "┗" + TopRightCorner = "┓" + BottomRightCorner = "┛" +) + type Model struct { name string privKey ed25519.PrivateKey @@ -178,13 +187,32 @@ func (m Model) View() string { } chat := m.chat.View() rightSidebar := m.memberList.View() - result := lipgloss.JoinHorizontal(lipgloss.Top, networkList, leftSidebar, chat, rightSidebar) - result = lipgloss.Place( - ui.Width, ui.Height, - lipgloss.Left, lipgloss.Top, - result, - ) + leftBorder := "" + rightBorder := "" + if config.ReadConfig().ScreenBorders { + leftBorder = TopLeftCorner + strings.Repeat("\n"+VerticalBorder, ui.Height-2) + "\n" + BottomLeftCorner + if m.focus == FocusNetworkList { + leftBorder = lipgloss.NewStyle().Background(colors.BackgroundDimmer).Foreground(colors.Focus).Render(leftBorder) + } else { + leftBorder = lipgloss.NewStyle().Background(colors.BackgroundDimmer).Foreground(colors.White).Render(leftBorder) + } + + rightBorder = TopRightCorner + strings.Repeat("\n"+VerticalBorder, ui.Height-2) + "\n" + BottomRightCorner + if m.focus == FocusRightSidebar { + rightBorder = lipgloss.NewStyle().Background(colors.BackgroundDimmer).Foreground(colors.Focus).Render(rightBorder) + } else { + rightBorder = lipgloss.NewStyle().Background(colors.BackgroundDimmer).Foreground(colors.White).Render(rightBorder) + } + } + + result := lipgloss.JoinHorizontal(lipgloss.Top, leftBorder, networkList, leftSidebar, chat, rightSidebar, rightBorder) + + // result = lipgloss.Place( + // ui.Width, ui.Height, + // lipgloss.Left, lipgloss.Top, + // result, + // ) if m.HasPopup() { colors.Restore() @@ -390,6 +418,9 @@ func (m *Model) updateConnected(message tea.Msg) tea.Cmd { func (m *Model) updateAuthenticated(message tea.Msg) tea.Cmd { totalWidth := max(ui.Width, ui.MinWidth) totalWidth -= NetworkWidth + if config.ReadConfig().ScreenBorders { + totalWidth -= 2 // Left/right borders + } sidebarWidth := int(math.Round(float64(totalWidth) * SidebarPercentage)) sidebarWidth = max(sidebarWidth, MinSidebarWidth) chatWidth := totalWidth - (2 * (sidebarWidth + 1)) diff --git a/internal/client/ui/core/frequencylist/frequencylist.go b/internal/client/ui/core/frequencylist/frequencylist.go index 28aa8fc..c2e9a31 100644 --- a/internal/client/ui/core/frequencylist/frequencylist.go +++ b/internal/client/ui/core/frequencylist/frequencylist.go @@ -7,6 +7,7 @@ import ( "github.com/atotto/clipboard" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -35,6 +36,9 @@ var ( notifs = []string{ " 󰲠", " 󰲢", " 󰲤", " 󰲦", " 󰲨", " 󰲪", " 󰲬", " 󰲮", " 󰲰", " 󰲲", } + + HorizontalSep = "━" + VerticalSep = "┃" ) type Model struct { @@ -79,7 +83,7 @@ func (m Model) View() string { var builder strings.Builder - builder.WriteString(m.renderNetworkName()) + builder.WriteString(m.renderHeader()) builder.WriteString("\n") frequencies := m.Frequencies() @@ -146,16 +150,28 @@ func (m Model) View() string { builder.WriteString("\n") } + focusStyle := lipgloss.NewStyle().Background(colors.BackgroundDim).Foreground(colors.White) + if m.focus { + focusStyle = focusStyle.Foreground(colors.Focus) + } + + if config.ReadConfig().ScreenBorders { + builder.WriteString(strings.Repeat("\n", m.height-len(frequencies)+1)) + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, m.width))) + } + sidebar := builder.String() - sep := lipgloss.NewStyle().Width(0).Height(ui.Height). - BorderBackground(colors.BackgroundDim).BorderForeground(colors.White). - Border(lipgloss.ThickBorder(), false, true, false, false) - if m.focus { - sep = sep.BorderForeground(colors.Focus) + sep := "" + if config.ReadConfig().ScreenBorders { + sep = HorizontalSep + strings.Repeat("\n"+VerticalSep, ui.Height-2) + "\n" + HorizontalSep + } else { + sep = strings.Repeat(VerticalSep+"\n", ui.Height) + sep = sep[:len(sep)-1] // Strip last \n } + sep = focusStyle.Render(sep) - result := lipgloss.JoinHorizontal(lipgloss.Top, sidebar, sep.String()) + result := lipgloss.JoinHorizontal(lipgloss.Top, sidebar, sep) return backgroundStyle.Render(result) } @@ -164,8 +180,11 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { if state.NetworkId(m.networkIndex) != nil { // Calculate height for frequencies m.height = ui.Height - m.height -= lipgloss.Height(m.renderNetworkName()) - m.height -= 1 + m.height -= lipgloss.Height(m.renderHeader()) + m.height -= 1 // For bottom margin + if config.ReadConfig().ScreenBorders { + m.height -= 1 // Only bottom, top is calculated in renderHeader + } m.SetIndex(m.index) } @@ -333,7 +352,12 @@ func (m *Model) SetIndex(index int) { } } -func (m Model) renderNetworkName() string { +func (m Model) renderHeader() string { + focusColor := colors.White + if m.focus { + focusColor = colors.Focus + } + bg := lipgloss.Color(m.Network().BgHexColor) fg := lipgloss.Color(m.Network().FgHexColor) @@ -344,22 +368,16 @@ func (m Model) renderNetworkName() string { nameStyle := lipgloss.NewStyle().Width(m.width). Padding(1).Align(lipgloss.Center). - Border(lipgloss.ThickBorder(), false, false, true). - BorderForeground(colors.White). + Border(lipgloss.ThickBorder(), config.ReadConfig().ScreenBorders, false, true). + BorderForeground(focusColor). Background(bg).Foreground(fg) - if m.focus { - nameStyle = nameStyle.BorderForeground(colors.Focus) - } networkName := nameStyle.Render(m.Network().Name) networkIdStyle := lipgloss.NewStyle().Width(m.width). MarginBottom(1).Padding(1, 2).Align(lipgloss.Center). Border(lipgloss.ThickBorder(), false, false, true). Background(colors.BackgroundDim).Foreground(colors.White). - BorderForeground(colors.White) - if m.focus { - networkIdStyle = networkIdStyle.BorderForeground(colors.Focus) - } + BorderForeground(focusColor) id := "Invite Code\n" + strconv.FormatInt(int64(m.Network().ID), 10) networkId := networkIdStyle.Render(id) diff --git a/internal/client/ui/core/memberlist/memberlist.go b/internal/client/ui/core/memberlist/memberlist.go index 14ff342..35e6804 100644 --- a/internal/client/ui/core/memberlist/memberlist.go +++ b/internal/client/ui/core/memberlist/memberlist.go @@ -7,6 +7,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -24,7 +25,9 @@ var ( symbolWidth = 2 widthWithoutMember = ((margin + padding) * 2) + symbolWidth - ellipsis = "…" + ellipsis = "…" + HorizontalSep = "━" + VerticalSep = "┃" ) type Model struct { @@ -135,16 +138,28 @@ func (m Model) View() string { builder.WriteString("\n") } + focusStyle := lipgloss.NewStyle().Background(colors.BackgroundDim).Foreground(colors.White) + if m.focus { + focusStyle = focusStyle.Foreground(colors.Focus) + } + + if config.ReadConfig().ScreenBorders { + builder.WriteString(strings.Repeat("\n", m.height-len(members)+1)) + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, m.width))) + } + sidebar := backgroundStyle.Height(ui.Height).Render(builder.String()) - sep := lipgloss.NewStyle().Width(0).Height(ui.Height). - BorderBackground(colors.BackgroundDim).BorderForeground(colors.White). - Border(lipgloss.ThickBorder(), false, true, false, false) - if m.focus { - sep = sep.BorderForeground(colors.Focus) + sep := "" + if config.ReadConfig().ScreenBorders { + sep = HorizontalSep + strings.Repeat("\n"+VerticalSep, ui.Height-2) + "\n" + HorizontalSep + } else { + sep = strings.Repeat(VerticalSep+"\n", ui.Height) + sep = sep[:len(sep)-1] } + sep = focusStyle.Render(sep) - result := lipgloss.JoinHorizontal(lipgloss.Top, sep.String(), sidebar) + result := lipgloss.JoinHorizontal(lipgloss.Top, sep, sidebar) return result } @@ -176,7 +191,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { // Calculate height for members m.height = ui.Height m.height -= lipgloss.Height(m.renderHeader()) - m.height -= 1 + m.height -= 1 // For bottom margin + if config.ReadConfig().ScreenBorders { + m.height -= 1 // Only bottom, top is calculated in renderHeader + } switch msg := msg.(type) { case tea.KeyMsg: @@ -535,7 +553,7 @@ func (m Model) renderHeader() string { headerStyle := lipgloss.NewStyle().Width(m.width). Background(colors.BackgroundDim). Margin(0, 0, 1).Padding(1).Align(lipgloss.Center). - Border(lipgloss.ThickBorder(), false, false, true). + Border(lipgloss.ThickBorder(), config.ReadConfig().ScreenBorders, false, true). BorderForeground(colors.White).Foreground(colors.White) if m.focus { headerStyle = headerStyle.BorderForeground(colors.Focus) diff --git a/internal/client/ui/core/networklist/networklist.go b/internal/client/ui/core/networklist/networklist.go index 7b7b6fe..382428e 100644 --- a/internal/client/ui/core/networklist/networklist.go +++ b/internal/client/ui/core/networklist/networklist.go @@ -5,6 +5,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -12,7 +13,11 @@ import ( "github.com/kyren223/eko/internal/packet" ) -const SignalsIndex = -1 +const ( + SignalsIndex = -1 + HorizontalSep = "━" + VerticalSep = "┃" +) type Model struct { base int @@ -41,6 +46,12 @@ func (m Model) View() string { notification := lipgloss.NewStyle(). Foreground(colors.White).Render(" \n◗\n ") + focusColor := colors.White + if m.focus { + focusColor = colors.Focus + } + focusStyle := lipgloss.NewStyle().Background(colors.BackgroundDimmer).Foreground(focusColor) + var builder strings.Builder pings := 0 @@ -55,7 +66,12 @@ func (m Model) View() string { signalsIcon = ui.IconStyleNotif(" ", colors.Turquoise, colors.DarkerCyan, colors.BackgroundDimmer, pings) } - builder.WriteString("\n") + if config.ReadConfig().ScreenBorders { + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, 8))) + builder.WriteByte('\n') + } + + builder.WriteByte('\n') if m.index == SignalsIndex { signalsButtonSelected := lipgloss.JoinHorizontal( ui.Center, @@ -69,6 +85,14 @@ func (m Model) View() string { Background(colors.BackgroundDimmer).Padding(0, 1, 1).String() builder.WriteString(signalsButtonStyle) } + + builder.WriteByte('\n') + builder.WriteString(focusStyle.Render(" ━━━━━━ ")) + builder.WriteByte('\n') + + if m.base != 0 { + builder.WriteString(lipgloss.NewStyle().Foreground(colors.Purple).Render(" 󰜷󰜷 ")) + } builder.WriteString("\n") networks := state.Data.Networks @@ -103,30 +127,45 @@ func (m Model) View() string { builder.WriteString(lipgloss.JoinHorizontal( ui.Center, selectedIndicator, - icon.Background(colors.BackgroundDimmer).Padding(0, 1, 1, 0).String(), + icon.Background(colors.BackgroundDimmer).Padding(0, 1, 0, 0).String(), )) } else if ok { builder.WriteString(lipgloss.JoinHorizontal( ui.Center, notification, - icon.Background(colors.BackgroundDimmer).Padding(0, 1, 1, 0).String(), + icon.Background(colors.BackgroundDimmer).Padding(0, 1, 0, 0).String(), )) } else { - builder.WriteString(icon.Background(colors.BackgroundDimmer).Padding(0, 1, 1).String()) + builder.WriteString(icon.Background(colors.BackgroundDimmer).Padding(0, 1, 0).String()) } builder.WriteString("\n") + + if upper != len(state.Data.Networks) && i == upper-1 { + builder.WriteString(lipgloss.NewStyle().Foreground(colors.Purple).Render(" 󰜮󰜮 ")) + } + + builder.WriteString("\n") + } + + if config.ReadConfig().ScreenBorders { + height := lipgloss.Height(builder.String()) + builder.WriteString(strings.Repeat("\n", ui.Height-height)) + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, 8))) } result := builder.String() + result = result[:len(result)-1] // Strip last \n - sep := lipgloss.NewStyle().Width(0).Height(ui.Height). - BorderBackground(colors.BackgroundDimmer).BorderForeground(colors.White). - Border(lipgloss.ThickBorder(), false, true, false, false) - if m.focus { - sep = sep.BorderForeground(colors.Focus) + sep := "" + if config.ReadConfig().ScreenBorders { + sep = HorizontalSep + strings.Repeat("\n"+VerticalSep, ui.Height-2) + "\n" + HorizontalSep + } else { + sep = strings.Repeat(VerticalSep+"\n", ui.Height) } + sep = focusStyle.Render(sep) + + result = lipgloss.JoinHorizontal(lipgloss.Top, result, sep) - result = lipgloss.JoinHorizontal(lipgloss.Top, result, sep.String()) return lipgloss.NewStyle().Background(colors.BackgroundDimmer).MaxHeight(ui.Height).Render(result) } @@ -136,8 +175,12 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { } m.height = ui.Height + if config.ReadConfig().ScreenBorders { + m.height -= 2 // Top/bottom Borders + } m.height -= 1 // Inital top margin - m.height /= 4 // 4 per icon + m.height -= 2 // Sep line + margin under it + m.height /= 4 // 4 per icon (3 icon + 1 margin) m.height -= 1 // For signals icon m.SetIndex(m.index) diff --git a/internal/client/ui/core/signallist/signallist.go b/internal/client/ui/core/signallist/signallist.go index c8c27a2..0724916 100644 --- a/internal/client/ui/core/signallist/signallist.go +++ b/internal/client/ui/core/signallist/signallist.go @@ -9,6 +9,7 @@ import ( "github.com/atotto/clipboard" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -29,6 +30,9 @@ var ( notifs = []string{ " 󰲠", " 󰲢", " 󰲤", " 󰲦", " 󰲨", " 󰲪", " 󰲬", " 󰲮", " 󰲰", " 󰲲", } + + HorizontalSep = "━" + VerticalSep = "┃" ) type Model struct { @@ -44,7 +48,7 @@ func New() Model { base: 0, index: -1, focus: false, - width: -1, + width: 1, height: 1, } } @@ -143,16 +147,28 @@ func (m Model) View() string { builder.WriteString("\n") } + focusStyle := lipgloss.NewStyle().Background(colors.BackgroundDim).Foreground(colors.White) + if m.focus { + focusStyle = focusStyle.Foreground(colors.Focus) + } + + if config.ReadConfig().ScreenBorders { + builder.WriteString(strings.Repeat("\n", m.height-len(signals)+1)) + builder.WriteString(focusStyle.Render(strings.Repeat(HorizontalSep, m.width))) + } + sidebar := builder.String() - sep := lipgloss.NewStyle().Width(0).Height(ui.Height). - BorderBackground(colors.BackgroundDim).BorderForeground(colors.White). - Border(lipgloss.ThickBorder(), false, true, false, false) - if m.focus { - sep = sep.BorderForeground(colors.Focus) + sep := "" + if config.ReadConfig().ScreenBorders { + sep = HorizontalSep + strings.Repeat("\n"+VerticalSep, ui.Height-2) + "\n" + HorizontalSep + } else { + sep = strings.Repeat(VerticalSep+"\n", ui.Height) + sep = sep[:len(sep)-1] // Strip last \n } + sep = focusStyle.Render(sep) - result := lipgloss.JoinHorizontal(lipgloss.Top, sidebar, sep.String()) + result := lipgloss.JoinHorizontal(lipgloss.Top, sidebar, sep) return backgroundStyle.Render(result) } @@ -160,7 +176,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { // Calculate height for frequencies m.height = ui.Height m.height -= lipgloss.Height(m.renderHeader()) - m.height -= 1 + m.height -= 1 // For bottom margin + if config.ReadConfig().ScreenBorders { + m.height -= 1 // Only bottom, top is calculated in renderHeader + } m.SetIndex(m.index) switch msg := msg.(type) { @@ -297,7 +316,7 @@ func (m *Model) SetIndex(index int) { func (m Model) renderHeader() string { nameStyle := lipgloss.NewStyle().Width(m.width). Padding(1).Align(lipgloss.Center). - Border(lipgloss.ThickBorder(), false, false, true). + Border(lipgloss.ThickBorder(), config.ReadConfig().ScreenBorders, false, true). Background(colors.DarkerCyan).Foreground(colors.Turquoise). BorderForeground(colors.White) if m.focus { diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go index ad31d9b..2729a4e 100644 --- a/internal/client/ui/ui.go +++ b/internal/client/ui/ui.go @@ -21,7 +21,7 @@ const ( DEBUG = true MinWidth = 85 - MinHeight = 10 + MinHeight = 25 Center lipgloss.Position = 0.499 ) -- cgit v1.3.1