mirror of
https://github.com/Hopiu/micro.git
synced 2026-04-23 07:34:44 +00:00
parent
c661c65c8c
commit
59d2fa81dd
1 changed files with 21 additions and 8 deletions
|
|
@ -44,6 +44,15 @@ func PostActionCall(funcName string, view *View) bool {
|
|||
return relocate
|
||||
}
|
||||
|
||||
func (v *View) deselect(index int) bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[index]
|
||||
v.Cursor.ResetSelection()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Center centers the view on the cursor
|
||||
func (v *View) Center(usePlugin bool) bool {
|
||||
if usePlugin && !PreActionCall("Center", v) {
|
||||
|
|
@ -70,10 +79,7 @@ func (v *View) CursorUp(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[0]
|
||||
v.Cursor.ResetSelection()
|
||||
}
|
||||
v.deselect(0)
|
||||
v.Cursor.Up()
|
||||
|
||||
if usePlugin {
|
||||
|
|
@ -88,10 +94,7 @@ func (v *View) CursorDown(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[1]
|
||||
v.Cursor.ResetSelection()
|
||||
}
|
||||
v.deselect(1)
|
||||
v.Cursor.Down()
|
||||
|
||||
if usePlugin {
|
||||
|
|
@ -290,6 +293,8 @@ func (v *View) StartOfLine(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
v.deselect(0)
|
||||
|
||||
v.Cursor.Start()
|
||||
|
||||
if usePlugin {
|
||||
|
|
@ -304,6 +309,8 @@ func (v *View) EndOfLine(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
v.deselect(0)
|
||||
|
||||
v.Cursor.End()
|
||||
|
||||
if usePlugin {
|
||||
|
|
@ -369,6 +376,8 @@ func (v *View) CursorEnd(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
v.deselect(0)
|
||||
|
||||
v.Cursor.Loc = v.Buf.End()
|
||||
|
||||
if usePlugin {
|
||||
|
|
@ -1089,6 +1098,8 @@ func (v *View) CursorPageUp(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
v.deselect(0)
|
||||
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[0]
|
||||
v.Cursor.ResetSelection()
|
||||
|
|
@ -1107,6 +1118,8 @@ func (v *View) CursorPageDown(usePlugin bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
v.deselect(0)
|
||||
|
||||
if v.Cursor.HasSelection() {
|
||||
v.Cursor.Loc = v.Cursor.CurSelection[1]
|
||||
v.Cursor.ResetSelection()
|
||||
|
|
|
|||
Loading…
Reference in a new issue