mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Implement moving cursor up/down within a wrapped line
Modified behavior of CursorUp, CursorDown, CursorPageUp etc: if softwrap is enabled, cursor moves by visual lines, not logical lines. TODO: implement it also for Home and End keys: move cursor to the visual start or end of a line. I haven't implemented it for now, because I'm not sure what should be the behavior of StartOfTextToggle then (considering that Home key is bound to StartOfTextToggle by default). Fixes #1598
This commit is contained in:
@@ -54,8 +54,15 @@ func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
|
||||
w.StartLine.Row = 0
|
||||
}
|
||||
w.Relocate()
|
||||
|
||||
for _, c := range w.Buf.GetCursors() {
|
||||
c.LastVisualX = c.GetVisualX()
|
||||
}
|
||||
}
|
||||
}
|
||||
b.GetVisualX = func(loc buffer.Loc) int {
|
||||
return w.VLocFromLoc(loc).VisualX
|
||||
}
|
||||
}
|
||||
|
||||
func (w *BufWindow) GetView() *View {
|
||||
@@ -68,7 +75,15 @@ func (w *BufWindow) SetView(view *View) {
|
||||
|
||||
func (w *BufWindow) Resize(width, height int) {
|
||||
w.Width, w.Height = width, height
|
||||
w.updateDisplayInfo()
|
||||
|
||||
w.Relocate()
|
||||
|
||||
if w.Buf.Settings["softwrap"].(bool) {
|
||||
for _, c := range w.Buf.GetCursors() {
|
||||
c.LastVisualX = c.GetVisualX()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *BufWindow) SetActive(b bool) {
|
||||
|
||||
Reference in New Issue
Block a user