tui: removed scrollbar

This commit is contained in:
Matt Low 2024-03-14 17:55:21 +00:00
parent f49b772960
commit 2ad93394b1
1 changed files with 2 additions and 26 deletions

View File

@ -249,23 +249,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
func (m model) View() string { func (m model) View() string {
if m.content.Width == 0 { if m.width == 0 {
// this is the case upon initial startup, but it's also a safe bet that // this is the case upon initial startup, but it's also a safe bet that
// we can just skip rendering if the terminal is really 0 width... // we can just skip rendering if the terminal is really 0 width...
// without this, the m.*View() functions may crash // without this, the m.*View() functions may crash
return "" return ""
} }
m.content.Height = m.height - m.getFixedComponentHeight()
sections := make([]string, 0, 6) sections := make([]string, 0, 6)
error := m.errorView()
scrollbar := m.scrollbarView()
sections = append(sections, m.headerView()) sections = append(sections, m.headerView())
if scrollbar != "" {
sections = append(sections, scrollbar)
}
sections = append(sections, m.contentView()) sections = append(sections, m.contentView())
error := m.errorView()
if error != "" { if error != "" {
sections = append(sections, error) sections = append(sections, error)
} }
@ -285,10 +279,6 @@ func (m *model) getFixedComponentHeight() int {
h += m.input.Height() h += m.input.Height()
h += lipgloss.Height(m.headerView()) h += lipgloss.Height(m.headerView())
h += lipgloss.Height(m.footerView()) h += lipgloss.Height(m.footerView())
scrollbar := m.scrollbarView()
if scrollbar != "" {
h += lipgloss.Height(scrollbar)
}
errorView := m.errorView() errorView := m.errorView()
if errorView != "" { if errorView != "" {
h += lipgloss.Height(errorView) h += lipgloss.Height(errorView)
@ -328,20 +318,6 @@ func (m *model) errorView() string {
Render(fmt.Sprintf("%s", m.err)) Render(fmt.Sprintf("%s", m.err))
} }
func (m *model) scrollbarView() string {
if m.content.AtTop() {
return ""
}
count := int(m.content.ScrollPercent() * float64(m.width-2))
fill := strings.Repeat("-", count)
return lipgloss.NewStyle().
Width(m.width).
PaddingLeft(1).
PaddingRight(1).
Render(fill)
}
func (m *model) inputView() string { func (m *model) inputView() string {
return m.input.View() return m.input.View()
} }