mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-10 22:52:51 +09:00
Add more option support
This commit is contained in:
@@ -471,7 +471,7 @@ func (h *BufPane) IndentSelection() bool {
|
||||
h.Cursor.SetSelectionEnd(buffer.Loc{X: endX + indentsize + 1, Y: endY})
|
||||
}
|
||||
}
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -490,7 +490,7 @@ func (h *BufPane) OutdentLine() bool {
|
||||
}
|
||||
h.Buf.Remove(buffer.Loc{X: 0, Y: h.Cursor.Y}, buffer.Loc{X: 1, Y: h.Cursor.Y})
|
||||
}
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ func (h *BufPane) OutdentSelection() bool {
|
||||
h.Buf.Remove(buffer.Loc{X: 0, Y: y}, buffer.Loc{X: 1, Y: y})
|
||||
}
|
||||
}
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
|
||||
}
|
||||
if !found || !inRange(locs[0]) || !inRange(locs[1]) {
|
||||
h.Cursor.ResetSelection()
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
|
||||
searchLoc.X += utf8.RuneCount(replace)
|
||||
} else if canceled {
|
||||
h.Cursor.ResetSelection()
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
return
|
||||
}
|
||||
if searching {
|
||||
@@ -617,8 +617,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
|
||||
doReplacement()
|
||||
}
|
||||
|
||||
// TODO: relocate all cursors?
|
||||
h.Cursor.Relocate()
|
||||
h.Buf.RelocateCursors()
|
||||
|
||||
if nreplaced > 1 {
|
||||
InfoBar.Message("Replaced ", nreplaced, " occurrences of ", search)
|
||||
|
||||
@@ -306,10 +306,14 @@ func (b *Buffer) ReOpen() error {
|
||||
|
||||
b.ModTime, err = GetModTime(b.Path)
|
||||
b.isModified = false
|
||||
b.RelocateCursors()
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *Buffer) RelocateCursors() {
|
||||
for _, c := range b.cursors {
|
||||
c.Relocate()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// RuneAt returns the rune at a given location in the buffer
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/zyedidia/micro/cmd/micro/config"
|
||||
. "github.com/zyedidia/micro/cmd/micro/util"
|
||||
@@ -58,19 +60,17 @@ func (b *Buffer) SaveAs(filename string) error {
|
||||
return errors.New("Cannot save scratch buffer")
|
||||
}
|
||||
|
||||
// TODO: rmtrailingws and updaterules
|
||||
b.UpdateRules()
|
||||
// if b.Settings["rmtrailingws"].(bool) {
|
||||
// for i, l := range b.lines {
|
||||
// pos := len(bytes.TrimRightFunc(l.data, unicode.IsSpace))
|
||||
//
|
||||
// if pos < len(l.data) {
|
||||
// b.deleteToEnd(Loc{pos, i})
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// b.Cursor.Relocate()
|
||||
// }
|
||||
if b.Settings["rmtrailingws"].(bool) {
|
||||
for i, l := range b.lines {
|
||||
leftover := utf8.RuneCount(bytes.TrimRightFunc(l.data, unicode.IsSpace))
|
||||
|
||||
linelen := utf8.RuneCount(l.data)
|
||||
b.Remove(Loc{leftover, i}, Loc{linelen, i})
|
||||
}
|
||||
|
||||
b.RelocateCursors()
|
||||
}
|
||||
|
||||
if b.Settings["eofnewline"].(bool) {
|
||||
end := b.End()
|
||||
|
||||
Reference in New Issue
Block a user