(****
 *
 * Module Edit defines the objects and operations related to generic editing
 * in the calendar system.
 *
 * Based on model in lecture notes weeks 9 & 10.
 *
 *)
module Edit;

  from File import all;
  from Tests import all;
  from StudentFunctionality import UserID;
  export all;

  object Clipboard is
    components: string;
    description: (*
        The clipboard holds a selection of cut or copied text.
    *);
  end Clipboard;

  object Selection is
    components: start_position:integer and end_position:integer and
        context:string;
    description: (*
        The workspace text selection is defined as the starting and ending
        character positions in current workspace text context.
    *);
  end Selection;

  object SelectionContext is
    components: string;
    description: (*
        SelectionContext is the text context in which the user makes a
        selection.
    *);
  end SelectionContext;

  operation EditUndo is
    inputs: uws:UserWorkSpace;
    outputs: uws':UserWorkSpace;
    description: (*
        Undo the most recent operation.  Only one level of undo/redo
        is specified here.  Successive invocations of undo toggle between the
        current and previous states of the calendar.  
    *);
  end EditUndo;

  operation EditCut is
    inputs: uws:UserWorkSpace;
    outputs: uws':UserWorkSpace;
    description: (*
        The currently selected text segment is copied into the clipboard and
        removed from its context.  The workspace selection in set to empty.
    *);
  end EditCut;

  operation EditCopy is
    inputs: uws:UserWorkSpace;
    outputs: uws':UserWorkSpace;
    description: (*
        The currently selected text segment is copied into the clipboard;
    *);
  end EditCopy;

  operation EditPaste is
    inputs: uws:UserWorkSpace;
    outputs: uws':UserWorkSpace;
    description: (*
        Paste the contents of the clipboard into the currently selected
        start position, replacing any selected text from start to end position.
    *);
  end EditPast;

  operation EditDelete is
    inputs: uws:UserWorkSpace;
    outputs: uws':UserWorkSpace;
    description: (*
        The currently selected text is removed from the context.  The workspace
        selection in set to empty.
    *);
  end EditDelete;

  operation SelectAll is
    inputs: uws:UserWorkSpace, select:Selection;
    outputs: uws':UserWorkSpace, select':Selection;
    description: (*
        Changes the current Selection to encompass the entire document being
        worked on.
    *);
  end SelectAll;

end Edit;