mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
Improve WordRight and WordLeft bindings
This commit is contained in:
@@ -289,8 +289,12 @@ func (v *View) CursorDown() bool {
|
|||||||
|
|
||||||
// CursorLeft moves the cursor left
|
// CursorLeft moves the cursor left
|
||||||
func (v *View) CursorLeft() bool {
|
func (v *View) CursorLeft() bool {
|
||||||
v.cursor.ResetSelection()
|
if v.cursor.HasSelection() {
|
||||||
v.cursor.Left()
|
v.cursor.SetLoc(v.cursor.curSelection[0])
|
||||||
|
v.cursor.ResetSelection()
|
||||||
|
} else {
|
||||||
|
v.cursor.Left()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +334,7 @@ func (v *View) SelectWordRight() bool {
|
|||||||
v.cursor.origSelection[0] = loc
|
v.cursor.origSelection[0] = loc
|
||||||
}
|
}
|
||||||
v.cursor.WordRight()
|
v.cursor.WordRight()
|
||||||
v.cursor.SelectTo(v.cursor.Loc())
|
v.cursor.SelectTo(v.cursor.Loc() - 1)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,8 +350,12 @@ func (v *View) SelectWordLeft() bool {
|
|||||||
|
|
||||||
// CursorRight moves the cursor right
|
// CursorRight moves the cursor right
|
||||||
func (v *View) CursorRight() bool {
|
func (v *View) CursorRight() bool {
|
||||||
v.cursor.ResetSelection()
|
if v.cursor.HasSelection() {
|
||||||
v.cursor.Right()
|
v.cursor.SetLoc(v.cursor.curSelection[1] - 1)
|
||||||
|
v.cursor.ResetSelection()
|
||||||
|
} else {
|
||||||
|
v.cursor.Right()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,17 +215,24 @@ func (c *Cursor) SelectTo(loc int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cursor) WordRight() {
|
func (c *Cursor) WordRight() {
|
||||||
|
c.Right()
|
||||||
|
for !IsWordChar(string(c.RuneUnder(c.x))) {
|
||||||
|
c.Right()
|
||||||
|
}
|
||||||
for IsWordChar(string(c.RuneUnder(c.x))) {
|
for IsWordChar(string(c.RuneUnder(c.x))) {
|
||||||
c.Right()
|
c.Right()
|
||||||
}
|
}
|
||||||
c.Right()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cursor) WordLeft() {
|
func (c *Cursor) WordLeft() {
|
||||||
|
c.Left()
|
||||||
|
for !IsWordChar(string(c.RuneUnder(c.x))) {
|
||||||
|
c.Left()
|
||||||
|
}
|
||||||
for IsWordChar(string(c.RuneUnder(c.x))) {
|
for IsWordChar(string(c.RuneUnder(c.x))) {
|
||||||
c.Left()
|
c.Left()
|
||||||
}
|
}
|
||||||
c.Left()
|
c.Right()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RuneUnder returns the rune under the given x position
|
// RuneUnder returns the rune under the given x position
|
||||||
|
|||||||
Reference in New Issue
Block a user