mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-19 07:15:34 -04:00
Use StoreVisualX() all over the code
Since we already have the StoreVisualX() helper, use it all over the place instead of setting LastVisualX directly. This will allow us to add more logic to StoreVisualX() add let this extra logic apply everywhere automatically.
This commit is contained in:
parent
d60413f03c
commit
85afb6eb87
@ -657,7 +657,7 @@ func (h *BufPane) InsertNewline() bool {
|
|||||||
h.Buf.Remove(buffer.Loc{X: 0, Y: h.Cursor.Y - 1}, buffer.Loc{X: util.CharacterCount(line), Y: h.Cursor.Y - 1})
|
h.Buf.Remove(buffer.Loc{X: 0, Y: h.Cursor.Y - 1}, buffer.Loc{X: util.CharacterCount(line), Y: h.Cursor.Y - 1})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.Cursor.LastVisualX = h.Cursor.GetVisualX()
|
h.Cursor.StoreVisualX()
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ func (h *BufPane) Backspace() bool {
|
|||||||
h.Buf.Remove(loc.Move(-1, h.Buf), loc)
|
h.Buf.Remove(loc.Move(-1, h.Buf), loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.Cursor.LastVisualX = h.Cursor.GetVisualX()
|
h.Cursor.StoreVisualX()
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (c *Cursor) GetCharPosInLine(b []byte, visualPos int) int {
|
|||||||
// Start moves the cursor to the start of the line it is on
|
// Start moves the cursor to the start of the line it is on
|
||||||
func (c *Cursor) Start() {
|
func (c *Cursor) Start() {
|
||||||
c.X = 0
|
c.X = 0
|
||||||
c.LastVisualX = c.GetVisualX()
|
c.StoreVisualX()
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartOfText moves the cursor to the first non-whitespace rune of
|
// StartOfText moves the cursor to the first non-whitespace rune of
|
||||||
@ -131,7 +131,7 @@ func (c *Cursor) IsStartOfText() bool {
|
|||||||
// End moves the cursor to the end of the line it is on
|
// End moves the cursor to the end of the line it is on
|
||||||
func (c *Cursor) End() {
|
func (c *Cursor) End() {
|
||||||
c.X = util.CharacterCount(c.buf.LineBytes(c.Y))
|
c.X = util.CharacterCount(c.buf.LineBytes(c.Y))
|
||||||
c.LastVisualX = c.GetVisualX()
|
c.StoreVisualX()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopySelection copies the user's selection to either "primary"
|
// CopySelection copies the user's selection to either "primary"
|
||||||
|
@ -104,7 +104,7 @@ func (eh *EventHandler) DoTextEvent(t *TextEvent, useUndo bool) {
|
|||||||
c.OrigSelection[0] = move(c.OrigSelection[0])
|
c.OrigSelection[0] = move(c.OrigSelection[0])
|
||||||
c.OrigSelection[1] = move(c.OrigSelection[1])
|
c.OrigSelection[1] = move(c.OrigSelection[1])
|
||||||
c.Relocate()
|
c.Relocate()
|
||||||
c.LastVisualX = c.GetVisualX()
|
c.StoreVisualX()
|
||||||
}
|
}
|
||||||
|
|
||||||
if useUndo {
|
if useUndo {
|
||||||
|
@ -107,7 +107,7 @@ function commentLine(bp, lineN, indentLen)
|
|||||||
bp.Cursor.Y = curpos.Y
|
bp.Cursor.Y = curpos.Y
|
||||||
end
|
end
|
||||||
bp.Cursor:Relocate()
|
bp.Cursor:Relocate()
|
||||||
bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
|
bp.Cursor:StoreVisualX()
|
||||||
end
|
end
|
||||||
|
|
||||||
function uncommentLine(bp, lineN, commentRegex)
|
function uncommentLine(bp, lineN, commentRegex)
|
||||||
@ -135,7 +135,7 @@ function uncommentLine(bp, lineN, commentRegex)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
bp.Cursor:Relocate()
|
bp.Cursor:Relocate()
|
||||||
bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
|
bp.Cursor:StoreVisualX()
|
||||||
end
|
end
|
||||||
|
|
||||||
function toggleCommentLine(bp, lineN, commentRegex)
|
function toggleCommentLine(bp, lineN, commentRegex)
|
||||||
|
Loading…
Reference in New Issue
Block a user