if c.y-c.v.topline < 0 || c.y-c.v.topline > c.v.height-1 {
c.v.s.HideCursor()
} else {
- voffset := NumOccurences(c.v.buf.lines[c.y][:c.x], '\t') * (tabSize - 1)
- c.v.s.ShowCursor(c.x+voffset+c.v.lineNumOffset, c.y-c.v.topline)
+ c.v.s.ShowCursor(c.GetVisualX()+c.v.lineNumOffset, c.y-c.v.topline)
// cursorStyle := tcell.StyleDefault.Reverse(true)
// c.v.s.SetContent(c.x+voffset, c.y-c.v.topline, c.runeUnder(), nil, cursorStyle)
}
eventType: TextEventInsert,
text: text,
start: start,
- end: start + len(text),
+ end: start + Count(text),
buf: eh.v.buf,
time: time.Now(),
}
// Execute a textevent and add it to the undo stack
func (eh *EventHandler) Execute(t *TextEvent) {
+ if eh.redo.Len() > 0 {
+ eh.redo = new(Stack)
+ }
eh.undo.Push(t)
ExecuteTextEvent(t)
}
te := t.(*TextEvent)
// Modifies the text event
UndoTextEvent(te)
- eh.redo.Push(t)
- eh.v.cursor = te.c
+ teCursor := te.c
+ te.c = eh.v.cursor
+ eh.v.cursor = teCursor
+
+ eh.redo.Push(te)
}
// Redo the first event in the redo stack
te := t.(*TextEvent)
// Modifies the text event
UndoTextEvent(te)
- eh.undo.Push(t)
- eh.v.cursor = te.c
+
+ teCursor := te.c
+ te.c = eh.v.cursor
+ eh.v.cursor = teCursor
+
+ eh.undo.Push(te)
}
- [ ] Help screen which lists keybindings and commands
- [ ] Opened with Ctrl-h
-- [ ] Undo/redo
+- [x] Undo/redo
- [x] Undo/redo stack
- - [ ] Functionality similar to nano
- [x] Clipboard support
- [x] Ctrl-v, Ctrl-c, and Ctrl-x