+// Execute actions executes the supplied actions
+func (v *View) ExecuteActions(actions []func(*View, bool) bool) bool {
+ relocate := false
+ readonlyBindingsList := []string{"Delete", "Insert", "Backspace", "Cut", "Play", "Paste", "Move", "Add", "DuplicateLine", "Macro"}
+ for _, action := range actions {
+ readonlyBindingsResult := false
+ funcName := ShortFuncName(action)
+ curv := CurView()
+ if curv.Type.Readonly == true {
+ // check for readonly and if true only let key bindings get called if they do not change the contents.
+ for _, readonlyBindings := range readonlyBindingsList {
+ if strings.Contains(funcName, readonlyBindings) {
+ readonlyBindingsResult = true
+ }
+ }
+ }
+ if !readonlyBindingsResult {
+ // call the key binding
+ relocate = action(curv, true) || relocate
+ // Macro
+ if funcName != "ToggleMacro" && funcName != "PlayMacro" {
+ if recordingMacro {
+ curMacro = append(curMacro, action)
+ }
+ }
+ }
+ }
+
+ return relocate
+}
+
+// SetCursor sets the view's and buffer's cursor
+func (v *View) SetCursor(c *Cursor) bool {
+ if c == nil {
+ return false
+ }
+ v.Cursor = c
+ v.Buf.curCursor = c.Num
+
+ return true
+}
+