tui: removed scrollbar
This commit is contained in:
parent
fdf8033aff
commit
2b0d474660
@ -249,23 +249,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
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
|
||||
// we can just skip rendering if the terminal is really 0 width...
|
||||
// without this, the m.*View() functions may crash
|
||||
return ""
|
||||
}
|
||||
|
||||
m.content.Height = m.height - m.getFixedComponentHeight()
|
||||
|
||||
sections := make([]string, 0, 6)
|
||||
error := m.errorView()
|
||||
scrollbar := m.scrollbarView()
|
||||
sections = append(sections, m.headerView())
|
||||
if scrollbar != "" {
|
||||
sections = append(sections, scrollbar)
|
||||
}
|
||||
sections = append(sections, m.contentView())
|
||||
error := m.errorView()
|
||||
if error != "" {
|
||||
sections = append(sections, error)
|
||||
}
|
||||
@ -285,10 +279,6 @@ func (m *model) getFixedComponentHeight() int {
|
||||
h += m.input.Height()
|
||||
h += lipgloss.Height(m.headerView())
|
||||
h += lipgloss.Height(m.footerView())
|
||||
scrollbar := m.scrollbarView()
|
||||
if scrollbar != "" {
|
||||
h += lipgloss.Height(scrollbar)
|
||||
}
|
||||
errorView := m.errorView()
|
||||
if errorView != "" {
|
||||
h += lipgloss.Height(errorView)
|
||||
@ -328,20 +318,6 @@ func (m *model) errorView() string {
|
||||
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 {
|
||||
return m.input.View()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user