mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-16 03:50:26 +09:00
@@ -47,6 +47,7 @@ func (v *View) deselect(index int) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[index]
|
||||
v.Cursor.ResetSelection()
|
||||
v.Cursor.StoreVisualX()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -215,6 +216,7 @@ func (v *View) CursorLeft(usePlugin bool) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[0]
|
||||
v.Cursor.ResetSelection()
|
||||
v.Cursor.StoreVisualX()
|
||||
} else {
|
||||
tabstospaces := v.Buf.Settings["tabstospaces"].(bool)
|
||||
tabmovement := v.Buf.Settings["tabmovement"].(bool)
|
||||
@@ -248,6 +250,7 @@ func (v *View) CursorRight(usePlugin bool) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[1].Move(-1, v.Buf)
|
||||
v.Cursor.ResetSelection()
|
||||
v.Cursor.StoreVisualX()
|
||||
} else {
|
||||
tabstospaces := v.Buf.Settings["tabstospaces"].(bool)
|
||||
tabmovement := v.Buf.Settings["tabmovement"].(bool)
|
||||
@@ -512,6 +515,7 @@ func (v *View) CursorEnd(usePlugin bool) bool {
|
||||
v.deselect(0)
|
||||
|
||||
v.Cursor.Loc = v.Buf.End()
|
||||
v.Cursor.StoreVisualX()
|
||||
|
||||
if usePlugin {
|
||||
return PostActionCall("CursorEnd", v)
|
||||
@@ -1373,6 +1377,7 @@ func (v *View) CursorPageUp(usePlugin bool) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[0]
|
||||
v.Cursor.ResetSelection()
|
||||
v.Cursor.StoreVisualX()
|
||||
}
|
||||
v.Cursor.UpN(v.Height)
|
||||
|
||||
@@ -1393,6 +1398,7 @@ func (v *View) CursorPageDown(usePlugin bool) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[1]
|
||||
v.Cursor.ResetSelection()
|
||||
v.Cursor.StoreVisualX()
|
||||
}
|
||||
v.Cursor.DownN(v.Height)
|
||||
|
||||
|
||||
@@ -350,6 +350,11 @@ func (c *Cursor) GetVisualX() int {
|
||||
return StringWidth(string(runes[:c.X]), tabSize)
|
||||
}
|
||||
|
||||
// StoreVisualX stores the current visual x value in the cursor
|
||||
func (c *Cursor) StoreVisualX() {
|
||||
c.LastVisualX = c.GetVisualX()
|
||||
}
|
||||
|
||||
// Relocate makes sure that the cursor is inside the bounds of the buffer
|
||||
// If it isn't, it moves it to be within the buffer's lines
|
||||
func (c *Cursor) Relocate() {
|
||||
|
||||
Reference in New Issue
Block a user