From 15a73fa1759733e5d518bec122ae6e8b3f454a50 Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Fri, 18 May 2018 23:53:27 +0100 Subject: [PATCH] clicking lines now selects the correct character --- gui/buffer.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gui/buffer.go b/gui/buffer.go index 34a0722..a37d418 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -1071,12 +1071,24 @@ var last = time.Now() func (b *Buffer) processLeftClick() { // here we set the cursor y position // based off the click location - yPos := strife.MouseCoords()[1] + coords := strife.MouseCoords() + xPos, yPos := coords[0], coords[1] - yPosToLine := ((yPos / (last_h + pad)) + 1) + b.cam.y + yPosToLine := (((yPos) / (last_h + pad)) + 1) + b.cam.y + xPosToLine := ((xPos - b.ex) / (last_w)) + b.cam.x + + fmt.Println(yPos, " line ", yPosToLine, " - ", xPos, " char ", xPosToLine) - fmt.Println(yPos, " line ", yPosToLine) b.gotoLine(int64(yPosToLine)) + + // we should be at the start of the line but lets + // move there anyways just to make sure + + b.moveToStartOfLine() + + for i := 0; i < xPosToLine; i++ { + b.moveRight() + } } func (b *Buffer) OnUpdate() bool {