// mouse release events
mouseReleased bool
+ // We need to keep track of insert key press toggle
+ isInsertMode bool
// This stores when the last click was
// This is useful for detecting double and triple clicks
lastClickTime time.Time
// Set mouseReleased to true because we assume the mouse is not being pressed when
// the editor is opened
v.mouseReleased = true
+ // Set isInsertMode to false, because we assume we are in the default mode when editor
+ // is opened
+ v.isInsertMode = false
v.lastClickTime = time.Time{}
}
}
}
}
+ if e.Key() == tcell.KeyInsert {
+ v.isInsertMode = !v.isInsertMode
+ }
if !isBinding && e.Key() == tcell.KeyRune {
// Check viewtype if readonly don't insert a rune (readonly help and log view etc.)
if v.Type.Readonly == false {
v.Cursor.DeleteSelection()
v.Cursor.ResetSelection()
}
- v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
+
+ if v.isInsertMode {
+ next := v.Cursor.Loc
+ next.X++
+ v.Buf.Replace(v.Cursor.Loc, next, string(e.Rune()))
+ } else {
+ v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
+ }
for pl := range loadedPlugins {
_, err := Call(pl+".onRune", string(e.Rune()), v)