﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ooupLab3Zad2
{
  class CmdDelete: IEditAction
  {
    private TextEditorModel model;
    private string str;
    private Location start;

    public CmdDelete(TextEditorModel model, string str, Location start)
    {
      this.model = model;
      this.str = str;
      this.start = new Location(start);
    }

    public void execute_do()
    {
      model.cursorLocation = start;
      for (var i = 0; i < str.Length; ++i) model.deleteAfter();
    }

    public void execute_undo()
    {
      model.cursorLocation = start;
      model.insert(str);
    }
  }
}
