- let s = match statement with Some s -> s | None -> self#getFuture in
- MatitaLog.debug ("evaluating: " ^ first_line s ^ " ...");
- let (entries, parsed_len) =
- eval_statement self#status mathviewer urichooser userGoal self s in
- let (new_statuses, new_statements) = List.split entries in
-(*
-prerr_endline "evalStatement returned";
-List.iter (fun s -> prerr_endline ("'" ^ s ^ "'")) new_statements;
-*)
- history <- List.rev new_statuses @ history;
- statements <- List.rev new_statements @ statements;
- let start = buffer#get_iter_at_mark (`MARK locked_mark) in
- let new_text = String.concat "" new_statements in
- if new_text <> String.sub s 0 parsed_len then
- begin
-(* prerr_endline ("new:" ^ new_text); *)
-(* prerr_endline ("s:" ^ String.sub s 0 parsed_len); *)
- let stop = start#copy#forward_chars parsed_len in
- buffer#delete ~start ~stop;
- buffer#insert ~iter:start new_text;
-(* prerr_endline "AUTOMATICALLY MODIFIED!!!!!" *)
- end;
- self#moveMark (String.length new_text)
-
- method private _retract () =
- match statements, history with
- | last_statement :: _, cur_status :: prev_status :: _ ->
- MatitaSync.time_travel ~present:cur_status ~past:prev_status;
- statements <- List.tl statements;
- history <- List.tl history;
- self#moveMark (- (String.length last_statement));
- | _ -> raise Margin
+ let s = match statement with Some s -> s | None -> self#getFuture in
+ HLog.debug ("evaluating: " ^ first_line s ^ " ...");
+ let (entries, parsed_len) =
+ try
+ eval_statement include_paths buffer guistuff self#lexicon_status
+ self#grafite_status userGoal self (`Raw s)
+ with End_of_file -> raise Margin
+ in
+ let new_statuses, new_statements =
+ let statuses, texts = List.split entries in
+ statuses, texts
+ in
+ history <- new_statuses @ history;
+ statements <- new_statements @ statements;
+ let start = buffer#get_iter_at_mark (`MARK locked_mark) in
+ let new_text = String.concat "" (List.rev new_statements) in
+ if statement <> None then
+ buffer#insert ~iter:start new_text
+ else begin
+ if new_text <> String.sub s 0 parsed_len then begin
+ buffer#delete ~start ~stop:(start#copy#forward_chars parsed_len);
+ buffer#insert ~iter:start new_text;
+ end;
+ end;
+ self#moveMark (String.length new_text);
+ (* here we need to set the Goal in case we are going to cursor (or to
+ bottom) and we will face a macro *)
+ match self#grafite_status.proof_status with
+ Incomplete_proof p ->
+ userGoal <-
+ (try Some (Continuationals.Stack.find_goal p.stack)
+ with Failure _ -> None)
+ | _ -> userGoal <- None
+
+ method private _retract offset lexicon_status grafite_status new_statements
+ new_history
+ =
+ let cur_grafite_status,cur_lexicon_status =
+ match history with s::_ -> s | [] -> assert false
+ in
+ LexiconSync.time_travel ~present:cur_lexicon_status ~past:lexicon_status;
+ GrafiteSync.time_travel ~present:cur_grafite_status ~past:grafite_status;
+ statements <- new_statements;
+ history <- new_history;
+ self#moveMark (- offset)