Skip to content
Merged
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
41 changes: 21 additions & 20 deletions cmd/lk/simulate_tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import (

func runSimulateTUI(config *simulateConfig) error {
m := newSimulateModel(config)
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithMouseCellMotion())
// No mouse capture, so the terminal keeps native drag-to-select. Arrow keys
// scroll (the wheel maps to them in alt-screen); i/j/k/l navigate the list.
p := tea.NewProgram(m, tea.WithAltScreen())
_, runErr := p.Run()

if m.launcher != nil {
Expand Down Expand Up @@ -631,15 +633,6 @@ func (m *simulateModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case tea.KeyMsg:
return m.handleKey(msg)

case tea.MouseMsg:
switch msg.Button {
case tea.MouseButtonWheelUp:
m.scrollBy(-1)
case tea.MouseButtonWheelDown:
m.scrollBy(1)
}
return m, nil
}
return m, nil
}
Expand Down Expand Up @@ -675,8 +668,8 @@ func (m *simulateModel) scrollActive(delta int, includeLogs bool) bool {
return true
}

// scrollBy routes a mouse-wheel step to the focused pane, falling back to
// scrolling the whole page.
// scrollBy scrolls the focused pane by delta lines (one arrow/wheel step),
// falling back to scrolling the whole page.
func (m *simulateModel) scrollBy(delta int) {
if m.scrollActive(delta, true) {
return
Expand Down Expand Up @@ -799,12 +792,20 @@ func (m *simulateModel) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
text, ok := m.copyScenario(m.detailJobID)
return m, m.showToast(text, ok)
}
case "up", "shift+tab":
// arrows never scroll logs (PgUp/PgDn do); in the list they move the cursor
case "up", "down":
// arrows scroll (the mouse wheel maps here in alt-screen): the focused
// pane if any, otherwise the whole page. i/k navigate the list.
delta := -1
if key == "down" {
delta = 1
}
m.scrollBy(delta)
case "i", "shift+tab":
// in a detail/description pane there is no cursor, so fall back to scroll
if !m.scrollActive(-1, false) {
m.moveCursor(-1)
}
case "down", "tab":
case "k", "tab":
if !m.scrollActive(1, false) {
m.moveCursor(1)
}
Expand All @@ -819,15 +820,15 @@ func (m *simulateModel) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
if !m.scrollActive(pageScroll, true) {
m.viewScrollOff += pageScroll // clamped on render
}
case "enter", "right":
case "enter", "l":
if m.detailJobID == "" {
jobs := m.filteredJobs()
if m.cursor >= 0 && m.cursor < len(jobs) {
m.detailJobID = jobs[m.cursor].job.Id
m.detailScrollOff = 0
}
}
case "esc", "left", "backspace":
case "esc", "j", "backspace":
if m.detailJobID != "" {
m.detailJobID = ""
m.detailScrollOff = 0
Expand Down Expand Up @@ -1813,7 +1814,7 @@ func (m *simulateModel) renderHint() string {
var parts []string
switch {
case m.detailJobID != "":
parts = append(parts, "↑↓ scroll · c copy scenario · ESC/ back")
parts = append(parts, "↑↓ scroll · c copy scenario · ESC/j back")
if m.hasLogs() {
if m.showLogs {
parts = append(parts, "Ctrl+L hide logs")
Expand All @@ -1825,9 +1826,9 @@ func (m *simulateModel) renderHint() string {
parts = append(parts, "↑↓ scroll · d collapse description")
default:
// the collapsed description block already carries "(press d to expand)"
nav := "↑↓ navigate · ENTER/ detail"
nav := "i/k navigate · ENTER/l detail · ↑↓ scroll"
if m.pageOverflow || m.viewScrollOff > 0 {
nav += " · PgUp/PgDn scroll"
nav += " · PgUp/PgDn page"
}
if m.canExportScenarios() {
nav += " · s save scenarios"
Expand Down
Loading