mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 06:28:20 +00:00
Home/End
This commit is contained in:
9
main.go
9
main.go
@ -255,22 +255,31 @@ var sepLinePos = gglm.NewVec3(0, 0, 0)
|
||||
|
||||
func (p *program) MainUpdate() {
|
||||
|
||||
// Return
|
||||
if input.KeyClicked(sdl.K_RETURN) || input.KeyClicked(sdl.K_KP_ENTER) {
|
||||
p.WriteToCmdBuf([]rune{'\n'})
|
||||
p.HandleReturn()
|
||||
}
|
||||
|
||||
// Cursor movement and scroll
|
||||
if input.KeyClicked(sdl.K_LEFT) {
|
||||
p.cursorCharIndex = clamp(p.cursorCharIndex-1, 0, p.cmdBufLen)
|
||||
} else if input.KeyClicked(sdl.K_RIGHT) {
|
||||
p.cursorCharIndex = clamp(p.cursorCharIndex+1, 0, p.cmdBufLen)
|
||||
}
|
||||
|
||||
if input.KeyClicked(sdl.K_HOME) {
|
||||
p.cursorCharIndex = 0
|
||||
} else if input.KeyClicked(sdl.K_END) {
|
||||
p.cursorCharIndex = p.cmdBufLen
|
||||
}
|
||||
|
||||
mouseWheelYNorm := -int64(input.GetMouseWheelYNorm())
|
||||
if mouseWheelYNorm != 0 {
|
||||
p.scrollPos = clamp(p.scrollPos+p.scrollSpd*mouseWheelYNorm, 0, p.textBufLen)
|
||||
}
|
||||
|
||||
// Delete inputs
|
||||
// @TODO: Implement hold to delete
|
||||
if input.KeyClicked(sdl.K_BACKSPACE) {
|
||||
p.DeletePrevChar()
|
||||
|
||||
Reference in New Issue
Block a user