(****
 * Module Edit defines the objects and operations related to generic editing in
 * the EClass application.
 *)
 
module Edit;

from EClass import WorkSpace;
export Clipboard, Selection, SelectionContext;

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

object Selection is
  components: start_pos:integer and end_pos:integer and
      context:SelectionContext;
  description: (*
      A selection is defined as a start and end position within a
      SelectionContext.
  *);
end Selection;

object SelectionContext is
  components: string;
  description: (*
      The SelectContext is the context of the text that was cut or copied.
  *);
end SelectionContext;

operation EditUndo is
   inputs: ws:WorkSpace;
   outputs: ws':WorkSpace;
   description: (*
      The output WorkSpace is set to the input WorkSpace's previous state (a
      WorkSpace within itself. This means the entire state of the EClass
      application reverts back to how it was before the last action was
      preformed.
   *);
end EditUndo;

operation EditCut is
   inputs: ws:WorkSpace;
   outputs: ws':WorkSpace;
   description: (*
      The output WorkSpace's Clipboard text is set to the WorkSpace's current
      Selection. The Selection is removed from the SelectionContext.
   *);
end EditCut;

operation EditCopy is
   inputs: ws:WorkSpace;
   outputs: ws':WorkSpace;
   description: (*
      The output WorkSpace's Clipboard text is set to the WorkSpace's current
      Selection. The SelectionContext is not modified in any way.
   *);
end EditCopy;

operation EditPaste is
   inputs: ws:WorkSpace;
   outputs: ws':WorkSpace;
   description: (*
      The input WorkSpace's Clipboard text is inserted into the output
      WorkSpace's SelectionContext at the output WorkSpace's Selection.
      If any text is currently selected, it is replaced by the inserted
      text.
   *);
end EditPaste;

operation EditDelete is
   inputs: ws:WorkSpace;
   outputs: ws':WorkSpace;
   description: (*
      The currently selected text is deleted from the selected context. The
      output WorkSpace's selection is set to empty. The state of the Clipboard
      remains unchanged.
   *);
end EditDelete;

end Edit;