From 744e9abfb38ae37e949bb94a456eafe60b3f134b Mon Sep 17 00:00:00 2001 From: bloeys Date: Fri, 15 Jul 2022 13:41:19 +0400 Subject: [PATCH] Home/End --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 66bc98f..b04e233 100755 --- a/main.go +++ b/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()