fix mascot
This commit is contained in:
91
tui.go
91
tui.go
@@ -1874,7 +1874,7 @@ func (m App) dashboardViewportHeight() int {
|
||||
}
|
||||
|
||||
func (m App) dashboardMaxScroll() int {
|
||||
return max(0, len(m.dashboardLines())-m.dashboardViewportHeight())
|
||||
return max(0, len(m.dashboardDisplayLines())-m.dashboardViewportHeight())
|
||||
}
|
||||
|
||||
func (m App) detailPaneSize() (int, int) {
|
||||
@@ -1924,6 +1924,12 @@ func (m App) View() string {
|
||||
if len(mascot) != diffletHeight {
|
||||
return m.viewContent()
|
||||
}
|
||||
if m.diffletHiddenForCurrentView() {
|
||||
return m.viewContent()
|
||||
}
|
||||
if m.screen == dashboardScreen {
|
||||
return m.viewDashboardWithLines(m.dashboardLinesWithDifflet(mascot))
|
||||
}
|
||||
gap := diffletGap
|
||||
headerWidth := diffletHeaderWidth(m.width)
|
||||
if headerWidth < 1 {
|
||||
@@ -1959,11 +1965,15 @@ func (m App) View() string {
|
||||
)
|
||||
}
|
||||
|
||||
func (m App) diffletHeaderLineCount() (int, bool) {
|
||||
if m.helpVisible ||
|
||||
func (m App) diffletHiddenForCurrentView() bool {
|
||||
return m.helpVisible ||
|
||||
(m.aiMode != aiNone && m.aiMode != aiDiscussion) ||
|
||||
(m.writeMode != writeNone && m.writeMode != writeReply && m.writeMode != writePREdit) ||
|
||||
m.screen == healthScreen {
|
||||
(m.writeMode != writeNone && m.writeMode != writeReply) ||
|
||||
m.screen == healthScreen
|
||||
}
|
||||
|
||||
func (m App) diffletHeaderLineCount() (int, bool) {
|
||||
if m.diffletHiddenForCurrentView() {
|
||||
return 0, false
|
||||
}
|
||||
switch m.screen {
|
||||
@@ -1973,9 +1983,6 @@ func (m App) diffletHeaderLineCount() (int, bool) {
|
||||
if m.scroll > 0 {
|
||||
return 0, false
|
||||
}
|
||||
if m.writeMode == writePREdit {
|
||||
return 1, true
|
||||
}
|
||||
return len(m.dashboardHeaderLines()), true
|
||||
case threadScreen:
|
||||
return len(m.threadTopLines()), true
|
||||
@@ -2563,7 +2570,10 @@ func groupedPRRows(prs []PullRequest, selected int) ([]prListRow, int) {
|
||||
}
|
||||
|
||||
func (m App) viewDashboard() string {
|
||||
lines := m.dashboardLines()
|
||||
return m.viewDashboardWithLines(m.dashboardLines())
|
||||
}
|
||||
|
||||
func (m App) viewDashboardWithLines(lines []string) string {
|
||||
viewportHeight := m.dashboardViewportHeight()
|
||||
maxScroll := max(0, len(lines)-viewportHeight)
|
||||
scroll := min(m.scroll, maxScroll)
|
||||
@@ -2594,6 +2604,69 @@ func (m App) viewDashboard() string {
|
||||
return view
|
||||
}
|
||||
|
||||
func (m App) dashboardDisplayLines() []string {
|
||||
mascot := m.difflet.frameLines()
|
||||
if len(mascot) == diffletHeight && !m.diffletHiddenForCurrentView() {
|
||||
return m.dashboardLinesWithDifflet(mascot)
|
||||
}
|
||||
return m.dashboardLines()
|
||||
}
|
||||
|
||||
func (m App) dashboardLinesWithDifflet(mascot []string) []string {
|
||||
lines := m.dashboardLines()
|
||||
headerLines := len(m.dashboardHeaderLines())
|
||||
metadataStart := headerLines + 1
|
||||
if headerLines >= len(lines) ||
|
||||
strings.TrimSpace(ansi.Strip(lines[headerLines])) != "" {
|
||||
return lines
|
||||
}
|
||||
if len(lines) < metadataStart+diffletHeight {
|
||||
result := append([]string(nil), lines[:headerLines]...)
|
||||
result = append(result, centeredDiffletLines(mascot, m.width)...)
|
||||
return append(result, lines[metadataStart:]...)
|
||||
}
|
||||
band := renderDashboardMetadataWithDifflet(
|
||||
lines[metadataStart:metadataStart+diffletHeight],
|
||||
mascot,
|
||||
m.width,
|
||||
)
|
||||
result := append([]string(nil), lines[:headerLines]...)
|
||||
result = append(result, band...)
|
||||
return append(result, lines[metadataStart+diffletHeight:]...)
|
||||
}
|
||||
|
||||
func renderDashboardMetadataWithDifflet(metadata, mascot []string, width int) []string {
|
||||
mascotLeft := max(0, (width-diffletWidth)/2)
|
||||
if width <= diffletWidth || mascotLeft < diffletGap {
|
||||
centered := centeredDiffletLines(mascot, width)
|
||||
return append(centered, metadata...)
|
||||
}
|
||||
metadataWidth := max(1, mascotLeft-diffletGap)
|
||||
height := max(len(metadata), len(mascot))
|
||||
rendered := make([]string, 0, height)
|
||||
for row := range height {
|
||||
left, right := "", ""
|
||||
if row < len(metadata) {
|
||||
left = ansi.Truncate(metadata[row], metadataWidth, "…")
|
||||
}
|
||||
if row < len(mascot) {
|
||||
right = mascot[row]
|
||||
}
|
||||
rendered = append(rendered, pad(left, mascotLeft)+right)
|
||||
}
|
||||
return rendered
|
||||
}
|
||||
|
||||
func centeredDiffletLines(mascot []string, width int) []string {
|
||||
centered := make([]string, 0, len(mascot))
|
||||
for _, line := range mascot {
|
||||
centered = append(centered, lipgloss.PlaceHorizontal(
|
||||
width, lipgloss.Center, line,
|
||||
))
|
||||
}
|
||||
return centered
|
||||
}
|
||||
|
||||
func (m App) viewHealth() string {
|
||||
lines := m.healthLines()
|
||||
viewportHeight := m.healthViewportHeight()
|
||||
|
||||
Reference in New Issue
Block a user