fix(tui): align action menu chrome
This commit is contained in:
parent
d383b64e56
commit
fd0fc10d35
24
tui/tui.go
24
tui/tui.go
@ -1641,7 +1641,7 @@ func (m model) renderContextPane(rect rect) string {
|
||||
|
||||
func (m model) renderDetailPane(rect rect) string {
|
||||
if m.menuOpen && !m.menuFloating {
|
||||
return pane(m.menuTitle, "enter/1-9 choose esc close", m.menuLines(paneContentWidth(rect.w)), rect, focusDetail, m.focus, detailPaneAccent)
|
||||
return m.renderDetailViewport(rect, m.menuLines(paneContentWidth(rect.w)))
|
||||
}
|
||||
item, ok := m.selectedItem()
|
||||
if !ok {
|
||||
@ -1702,7 +1702,7 @@ func (m model) menuLines(width int) []string {
|
||||
return []string{"No actions."}
|
||||
}
|
||||
palette := actionMenuColors(m.menuContext)
|
||||
title := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(palette.accent)).Render(firstNonEmpty(m.menuTitle, "Actions"))
|
||||
title := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(palette.accent)).Render(m.displayMenuTitle())
|
||||
lines := []string{title, dim(actionMenuSubtitle(m.menuContext)), ""}
|
||||
visible := m.menuVisibleCount()
|
||||
start := clampInt(m.menuOff, 0, maxInt(0, len(m.menuItems)-visible))
|
||||
@ -1737,6 +1737,15 @@ func (m model) menuLines(width int) []string {
|
||||
return lines
|
||||
}
|
||||
|
||||
func (m model) displayMenuTitle() string {
|
||||
switch m.menuTitle {
|
||||
case "Row Actions", "Context Actions", "Detail Actions":
|
||||
return "Actions"
|
||||
default:
|
||||
return firstNonEmpty(m.menuTitle, "Actions")
|
||||
}
|
||||
}
|
||||
|
||||
type actionMenuPalette struct {
|
||||
accent string
|
||||
background string
|
||||
@ -1775,16 +1784,7 @@ func actionMenuColors(context paneFocus) actionMenuPalette {
|
||||
}
|
||||
|
||||
func actionMenuSubtitle(context paneFocus) string {
|
||||
switch context {
|
||||
case focusRows:
|
||||
return "row scope"
|
||||
case focusContext:
|
||||
return "context scope"
|
||||
case focusDetail:
|
||||
return "detail scope"
|
||||
default:
|
||||
return "current selection"
|
||||
}
|
||||
return "current selection"
|
||||
}
|
||||
|
||||
func actionMenuTitle(context paneFocus) string {
|
||||
|
||||
@ -952,6 +952,28 @@ func TestKeyboardActionShortcutAliasOpensMenu(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionMenuUsesGitcrawlDetailChrome(t *testing.T) {
|
||||
m := newModel(Options{
|
||||
Title: "archive",
|
||||
Items: []Item{
|
||||
Row{Kind: "message", Title: "alpha", URL: "https://example.com/alpha"}.ItemForLayout(LayoutChat),
|
||||
},
|
||||
})
|
||||
m.width = 160
|
||||
m.height = 30
|
||||
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}})
|
||||
m = updated.(model)
|
||||
view := stripANSI(m.View())
|
||||
for _, want := range []string{"Detail compact", "Actions", "current selection", "Open selected URL"} {
|
||||
if !strings.Contains(view, want) {
|
||||
t.Fatalf("action menu chrome missing %q:\n%s", want, view)
|
||||
}
|
||||
}
|
||||
if strings.Contains(view, "Detail Row Actions") || strings.Contains(view, "row scope") {
|
||||
t.Fatalf("action menu should keep gitcrawl-style detail chrome:\n%s", view)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMouseDoubleClickOpensSelectedRowURL(t *testing.T) {
|
||||
previousOpen := openURL
|
||||
var opened []string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user