mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
home toggles between start of line and start of text
by default home sends the cursor to the beginning of the line. if the cursor is at the beginning of the line already though, home will send the cursor to the first non-whitespace rune. tapping home will toggle between these two line starts.
This commit is contained in:
@@ -435,7 +435,11 @@ func (v *View) StartOfLine(usePlugin bool) bool {
|
|||||||
|
|
||||||
v.deselect(0)
|
v.deselect(0)
|
||||||
|
|
||||||
v.Cursor.Start()
|
if v.Cursor.X != 0 {
|
||||||
|
v.Cursor.Start()
|
||||||
|
} else {
|
||||||
|
v.Cursor.StartOfText()
|
||||||
|
}
|
||||||
|
|
||||||
if usePlugin {
|
if usePlugin {
|
||||||
return PostActionCall("StartOfLine", v)
|
return PostActionCall("StartOfLine", v)
|
||||||
|
|||||||
@@ -333,6 +333,18 @@ func (c *Cursor) Start() {
|
|||||||
c.LastVisualX = c.GetVisualX()
|
c.LastVisualX = c.GetVisualX()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StartOfText moves the cursor to the first non-whitespace rune of
|
||||||
|
// the line it is on
|
||||||
|
func (c *Cursor) StartOfText() {
|
||||||
|
c.Start()
|
||||||
|
for IsWhitespace(c.RuneUnder(c.X)) {
|
||||||
|
if c.X == Count(c.buf.Line(c.Y)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
c.Right()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetCharPosInLine gets the char position of a visual x y
|
// GetCharPosInLine gets the char position of a visual x y
|
||||||
// coordinate (this is necessary because tabs are 1 char but
|
// coordinate (this is necessary because tabs are 1 char but
|
||||||
// 4 visual spaces)
|
// 4 visual spaces)
|
||||||
|
|||||||
Reference in New Issue
Block a user