mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 07:45:30 +03:00
remove manual cursor move calls
This commit is contained in:
parent
fb6332f2d0
commit
02dc3753ac
@ -561,12 +561,7 @@ func (b *Buffer) deleteNext() {
|
||||
// FIXME clean this up!
|
||||
func (b *Buffer) deletePrev() {
|
||||
if b.curs.x > 0 {
|
||||
offs := -1
|
||||
if !b.cfg.Editor.Tabs_Are_Spaces {
|
||||
if b.table.Index(b.curs.y, b.curs.x) == '\t' {
|
||||
offs = int(-b.cfg.Editor.Tab_Size)
|
||||
}
|
||||
} else if b.cfg.Editor.Hungry_Backspace && b.curs.x >= int(b.cfg.Editor.Tab_Size) {
|
||||
if b.cfg.Editor.Hungry_Backspace && b.curs.x >= int(b.cfg.Editor.Tab_Size) {
|
||||
// cut out the last {TAB_SIZE} amount of characters
|
||||
// and check em
|
||||
tabSize := int(b.cfg.Editor.Tab_Size)
|
||||
@ -581,7 +576,10 @@ func (b *Buffer) deletePrev() {
|
||||
for i := 0; i < int(b.cfg.Editor.Tab_Size); i++ {
|
||||
|
||||
b.table.Delete(b.curs.y, b.curs.x)
|
||||
b.curs.move(-1, 0)
|
||||
|
||||
// FIXME this was -1, maybe we dont
|
||||
// want to handle tabs?
|
||||
b.moveLeft()
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -594,20 +592,22 @@ func (b *Buffer) deletePrev() {
|
||||
b.autoComplete.lastRunes = b.autoComplete.lastRunes[:len(b.autoComplete.lastRunes)-1]
|
||||
}
|
||||
|
||||
b.curs.moveRender(-1, 0, offs, 0)
|
||||
b.moveLeft()
|
||||
} else if b.curs.x == 0 && b.curs.y > 0 {
|
||||
// FIXME
|
||||
|
||||
// TODO this should set the previous word
|
||||
// in the auto complete to the word before the cursor after
|
||||
// wrapping back the line?
|
||||
|
||||
// start of line, wrap to previous
|
||||
prevLineLen := b.table.Lines[b.curs.y-1].Len()
|
||||
|
||||
val := b.table.Lines[b.curs.y].String()
|
||||
b.table.Insert(val, b.curs.y-1, b.table.Lines[b.curs.y-1].Len())
|
||||
|
||||
b.table.Lines = append(b.table.Lines[:b.curs.y], b.table.Lines[b.curs.y+1:]...)
|
||||
b.curs.move(prevLineLen, -1)
|
||||
|
||||
b.moveUp()
|
||||
b.moveToEndOfLine()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,25 +1015,28 @@ func (b *Buffer) processActionKey(key int) bool {
|
||||
if b.cfg.Editor.Tabs_Are_Spaces {
|
||||
// make an empty rune array of TAB_SIZE, cast to string
|
||||
// and insert it.
|
||||
b.table.Insert(b.makeTab(), b.curs.y, b.curs.x)
|
||||
b.curs.move(int(b.cfg.Editor.Tab_Size), 0)
|
||||
tab := b.makeTab()
|
||||
b.table.Insert(tab, b.curs.y, b.curs.x)
|
||||
for i := 0; i < len(tab); i++ {
|
||||
b.moveRight()
|
||||
}
|
||||
} else {
|
||||
b.table.Insert(string('\t'), b.curs.y, b.curs.x)
|
||||
// the actual position is + 1, but we make it
|
||||
// move by TAB_SIZE characters on the view.
|
||||
b.curs.moveRender(1, 0, int(b.cfg.Editor.Tab_Size), 0)
|
||||
b.moveRight()
|
||||
}
|
||||
|
||||
case sdl.K_END:
|
||||
currLine := b.table.Lines[b.curs.y]
|
||||
if b.curs.x < currLine.Len() {
|
||||
distToMove := currLine.Len() - b.curs.x
|
||||
b.curs.move(distToMove, 0)
|
||||
for i := 0; i < distToMove; i++ {
|
||||
b.moveRight()
|
||||
}
|
||||
}
|
||||
|
||||
case sdl.K_HOME:
|
||||
if b.curs.x > 0 {
|
||||
b.curs.move(-b.curs.x, 0)
|
||||
b.moveToStartOfLine()
|
||||
}
|
||||
|
||||
// TODO remove since this is handled in the keymap!
|
||||
|
Loading…
Reference in New Issue
Block a user