Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions internal/tui/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,35 @@ func TestScrollingAPaneStaysInsideIt(t *testing.T) {
}
}

func TestABareArrowScrollsTheDataPage(t *testing.T) {
m, set := fixtureTUIWith(t, haFixtureYAML)
m.phase = phasePicking
m.mode = modeData
m.rebuildRows()

el := set.Tenants[0].Elements[0]
next, cmd := m.openDataTabs([]sessionTarget{{eid: el.ID, name: el.Name, tsg: m.tenant.TSGID}})
m = runDataLoads(t, next.(tuiModel), cmd)
m.phase = phaseData
m.height = 12

next, _ = m.onDataKey("down")
down := next.(tuiModel)
at := down.data[0].scroll
if at == 0 {
t.Fatal("down did not scroll the page; the wheel has nothing else to arrive as")
}
next, _ = down.onDataKey("up")
if got := next.(tuiModel).data[0].scroll; got >= at {
t.Errorf("scroll = %d after up, want below %d", got, at)
}

if got := m.mouseMode(); got != tea.MouseModeNone {
t.Errorf("mouseMode() = %v; asking for the mouse here costs click-to-select and buys "+
"nothing, since a notch already arrives as the arrow key above", got)
}
}

func paneRows(m tuiModel) int {
_, rows := m.dataPaneSize()
return rows
Expand Down
13 changes: 1 addition & 12 deletions internal/tui/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

func (m tuiModel) mouseMode() tea.MouseMode {
switch m.phase {
case phaseSession, phaseData:
case phaseSession:
return tea.MouseModeCellMotion
}
return tea.MouseModeNone
Expand All @@ -30,17 +30,6 @@ func (m tuiModel) onWheel(up bool) (tea.Model, tea.Cmd) {
next, _ = next.onScrollKey(s, key)
}
return next, nil

case phaseData:
key := "down"
if up {
key = "up"
}
var model tea.Model = m
for range wheelStep {
model, _ = model.(tuiModel).onDataKey(key)
}
return model, nil
}
return m, nil
}
16 changes: 9 additions & 7 deletions internal/tui/scrollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,19 @@ func TestTypingReturnsThePaneToLive(t *testing.T) {

func TestOnlyTheScrollingPanesAskForTheMouse(t *testing.T) {
m, _ := scrolledPane(t)
for _, phase := range []tuiPhase{phasePicking, phaseResults, phaseMenu, phaseSettings, phaseMacros} {
for _, phase := range []tuiPhase{
phasePicking, phaseResults, phaseMenu, phaseSettings, phaseMacros, phaseData,
} {
m.phase = phase
if got := m.mouseMode(); got != tea.MouseModeNone {
t.Errorf("phase %d mouseMode() = %v, want the terminal to keep the mouse", phase, got)
t.Errorf("phase %d mouseMode() = %v, want the terminal to keep the mouse so text "+
"can be selected; a notch already arrives as an arrow key there", phase, got)
}
}
for _, phase := range []tuiPhase{phaseSession, phaseData} {
m.phase = phase
if got := m.mouseMode(); got == tea.MouseModeNone {
t.Errorf("phase %d asks for no mouse, so the wheel cannot reach it", phase)
}
m.phase = phaseSession
if got := m.mouseMode(); got == tea.MouseModeNone {
t.Error("the session pane asks for no mouse, so a notch recalls a command at the " +
"device prompt instead of scrolling")
}
}

Expand Down
Loading