MCPcopy Index your code
hub / github.com/codehamr/codehamr / handlePageKey

Method handlePageKey

internal/tui/prompt.go:127–143  ·  view source on GitHub ↗

handlePageKey implements PgUp/PgDn. textarea disables its viewport keymap, so page keys aren't wired, so we translate them to N×CursorUp/CursorDown (one visible page, letting the viewport scroll to match), then snap out of any chip the move landed inside so the cursor never renders mid-label.

(msg tea.KeyMsg)

Source from the content-addressed store, hash-verified

125// visible page, letting the viewport scroll to match), then snap out of any
126// chip the move landed inside so the cursor never renders mid-label.
127func (p promptInput) handlePageKey(msg tea.KeyMsg) (bool, promptInput) {
128 var step func()
129 switch msg.Type {
130 case tea.KeyPgUp:
131 step = func() { p.ta.CursorUp() }
132 case tea.KeyPgDown:
133 step = func() { p.ta.CursorDown() }
134 default:
135 return false, p
136 }
137 n := max(p.ta.Height(), 1)
138 for range n {
139 step()
140 }
141 p.snapCursorOutOfChip()
142 return true, p
143}
144
145// snapCursorOutOfChip snaps a cursor sitting strictly inside a chip to the
146// nearer boundary. Returns the (possibly adjusted) offset so callers skip a

Callers 1

UpdateMethod · 0.95

Calls 2

snapCursorOutOfChipMethod · 0.95
HeightMethod · 0.80

Tested by

no test coverage detected