mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 14:38:19 +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() {
|
func (p *program) MainUpdate() {
|
||||||
|
|
||||||
|
// Return
|
||||||
if input.KeyClicked(sdl.K_RETURN) || input.KeyClicked(sdl.K_KP_ENTER) {
|
if input.KeyClicked(sdl.K_RETURN) || input.KeyClicked(sdl.K_KP_ENTER) {
|
||||||
p.WriteToCmdBuf([]rune{'\n'})
|
p.WriteToCmdBuf([]rune{'\n'})
|
||||||
p.HandleReturn()
|
p.HandleReturn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cursor movement and scroll
|
||||||
if input.KeyClicked(sdl.K_LEFT) {
|
if input.KeyClicked(sdl.K_LEFT) {
|
||||||
p.cursorCharIndex = clamp(p.cursorCharIndex-1, 0, p.cmdBufLen)
|
p.cursorCharIndex = clamp(p.cursorCharIndex-1, 0, p.cmdBufLen)
|
||||||
} else if input.KeyClicked(sdl.K_RIGHT) {
|
} else if input.KeyClicked(sdl.K_RIGHT) {
|
||||||
p.cursorCharIndex = clamp(p.cursorCharIndex+1, 0, p.cmdBufLen)
|
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())
|
mouseWheelYNorm := -int64(input.GetMouseWheelYNorm())
|
||||||
if mouseWheelYNorm != 0 {
|
if mouseWheelYNorm != 0 {
|
||||||
p.scrollPos = clamp(p.scrollPos+p.scrollSpd*mouseWheelYNorm, 0, p.textBufLen)
|
p.scrollPos = clamp(p.scrollPos+p.scrollSpd*mouseWheelYNorm, 0, p.textBufLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete inputs
|
||||||
// @TODO: Implement hold to delete
|
// @TODO: Implement hold to delete
|
||||||
if input.KeyClicked(sdl.K_BACKSPACE) {
|
if input.KeyClicked(sdl.K_BACKSPACE) {
|
||||||
p.DeletePrevChar()
|
p.DeletePrevChar()
|
||||||
|
|||||||
Reference in New Issue
Block a user