src/Pure/PIDE/document.ML
changeset 44156 6aa25b80e1a5
parent 44113 0baa8bbd355a
child 44157 a21d3e1e64fd
equal deleted inserted replaced
44155:ae2906662eec 44156:6aa25b80e1a5
    13   type exec_id = id
    13   type exec_id = id
    14   val no_id: id
    14   val no_id: id
    15   val new_id: unit -> id
    15   val new_id: unit -> id
    16   val parse_id: string -> id
    16   val parse_id: string -> id
    17   val print_id: id -> string
    17   val print_id: id -> string
    18   type edit = string * ((command_id option * command_id option) list) option
    18   datatype node_edit = Remove | Edits of (command_id option * command_id option) list
       
    19   type edit = string * node_edit
    19   type header = string * (string * string list * string list)
    20   type header = string * (string * string list * string list)
    20   type state
    21   type state
    21   val init_state: state
    22   val init_state: state
    22   val get_theory: state -> version_id -> Position.T -> string -> theory
    23   val get_theory: state -> version_id -> Position.T -> string -> theory
    23   val cancel_execution: state -> unit -> unit
    24   val cancel_execution: state -> unit -> unit
    73 val empty_version = Version Graph.empty;
    74 val empty_version = Version Graph.empty;
    74 
    75 
    75 
    76 
    76 (* node edits and associated executions *)
    77 (* node edits and associated executions *)
    77 
    78 
    78 type edit =
    79 datatype node_edit = Remove | Edits of (command_id option * command_id option) list;
    79   string *
    80 type edit = string * node_edit;
    80   (*NONE: remove node, SOME: insert/remove commands*)
       
    81   ((command_id option * command_id option) list) option;
       
    82 
    81 
    83 type header = string * (string * string list * string list);
    82 type header = string * (string * string list * string list);
    84 
    83 
    85 fun the_entry (Node {entries, ...}) id =
    84 fun the_entry (Node {entries, ...}) id =
    86   (case Entries.lookup entries id of
    85   (case Entries.lookup entries id of
   106 val node_names_of = Graph.keys o nodes_of;
   105 val node_names_of = Graph.keys o nodes_of;
   107 
   106 
   108 fun get_node version name = Graph.get_node (nodes_of version) name
   107 fun get_node version name = Graph.get_node (nodes_of version) name
   109   handle Graph.UNDEF _ => empty_node;
   108   handle Graph.UNDEF _ => empty_node;
   110 
   109 
   111 fun edit_nodes (name, SOME edits) (Version nodes) =
   110 fun edit_nodes (name, Remove) (Version nodes) =
       
   111       Version (perhaps (try (Graph.del_node name)) nodes)
       
   112   | edit_nodes (name, Edits edits) (Version nodes) =
   112       Version (nodes
   113       Version (nodes
   113         |> Graph.default_node (name, empty_node)
   114         |> Graph.default_node (name, empty_node)
   114         |> Graph.map_node name (edit_node edits))
   115         |> Graph.map_node name (edit_node edits));
   115   | edit_nodes (name, NONE) (Version nodes) =
       
   116       Version (perhaps (try (Graph.del_node name)) nodes);
       
   117 
   116 
   118 fun put_node name node (Version nodes) =
   117 fun put_node name node (Version nodes) =
   119   Version (nodes
   118   Version (nodes
   120     |> Graph.default_node (name, empty_node)
   119     |> Graph.default_node (name, empty_node)
   121     |> Graph.map_node name (K node));
   120     |> Graph.map_node name (K node));