mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Better fix for mouse clicking
This commit is contained in:
@@ -304,6 +304,9 @@ func (v *View) VSplitIndex(buf *Buffer, splitIndex int) {
|
|||||||
// GetSoftWrapLocation gets the location of a visual click on the screen and converts it to col,line
|
// GetSoftWrapLocation gets the location of a visual click on the screen and converts it to col,line
|
||||||
func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
|
func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
|
||||||
if !v.Buf.Settings["softwrap"].(bool) {
|
if !v.Buf.Settings["softwrap"].(bool) {
|
||||||
|
if vy >= v.Buf.NumLines {
|
||||||
|
vy = v.Buf.NumLines - 1
|
||||||
|
}
|
||||||
vx = v.Cursor.GetCharPosInLine(vy, vx)
|
vx = v.Cursor.GetCharPosInLine(vy, vx)
|
||||||
return vx, vy
|
return vx, vy
|
||||||
}
|
}
|
||||||
@@ -311,6 +314,9 @@ func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
|
|||||||
screenX, screenY := 0, v.Topline
|
screenX, screenY := 0, v.Topline
|
||||||
for lineN := v.Topline; lineN < v.Bottomline(); lineN++ {
|
for lineN := v.Topline; lineN < v.Bottomline(); lineN++ {
|
||||||
line := v.Buf.Line(lineN)
|
line := v.Buf.Line(lineN)
|
||||||
|
if lineN >= v.Buf.NumLines {
|
||||||
|
return 0, v.Buf.NumLines - 1
|
||||||
|
}
|
||||||
|
|
||||||
colN := 0
|
colN := 0
|
||||||
for _, ch := range line {
|
for _, ch := range line {
|
||||||
@@ -427,9 +433,6 @@ func (v *View) MoveToMouseClick(x, y int) {
|
|||||||
|
|
||||||
x, y = v.GetSoftWrapLocation(x, y)
|
x, y = v.GetSoftWrapLocation(x, y)
|
||||||
// x = v.Cursor.GetCharPosInLine(y, x)
|
// x = v.Cursor.GetCharPosInLine(y, x)
|
||||||
if y > v.Buf.NumLines {
|
|
||||||
y = v.Buf.NumLines - 1
|
|
||||||
}
|
|
||||||
if x > Count(v.Buf.Line(y)) {
|
if x > Count(v.Buf.Line(y)) {
|
||||||
x = Count(v.Buf.Line(y))
|
x = Count(v.Buf.Line(y))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user