X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaScript.ml;h=7e4dcb9fc04e4200a8c00e15a77c02af7e617a37;hb=e5014674aed0dab6f3aa43773c8caeffcfe0ac32;hp=5fa044e5330779cd68f58ce1aa1aa27ccde2f67d;hpb=8df7fb956e77d5863338587ac3fdd5f46669d331;p=helm.git diff --git a/helm/matita/matitaScript.ml b/helm/matita/matitaScript.ml index 5fa044e53..7e4dcb9fc 100644 --- a/helm/matita/matitaScript.ml +++ b/helm/matita/matitaScript.ml @@ -57,7 +57,7 @@ let prepend_text header base = if Pcre.pmatch ~rex:heading_nl_RE base then sprintf "\n%s%s" header base else - sprintf "%s\n%s" header base + sprintf "\n%s\n%s" header base (** creates a statement AST for the Goal tactic, e.g. "goal 7" *) let goal_ast n = @@ -434,6 +434,8 @@ object (self) buffer#create_mark ~name:"locked" ~left_gravity:true buffer#start_iter val locked_tag = buffer#create_tag [`BACKGROUND "lightblue"; `EDITABLE false] + method locked_mark = locked_mark + (* history can't be empty, the invariant above grant that it contains at * least the init status *) method status = match history with hd :: _ -> hd | _ -> assert false @@ -592,34 +594,36 @@ List.iter (fun s -> prerr_endline ("'" ^ s ^ "'")) new_statements; set_star self#ppFilename false method goto (pos: [`Top | `Bottom | `Cursor]) () = - let getpos _ = buffer#get_iter_at_mark (`MARK locked_mark) in + let getoffset () = (buffer#get_iter_at_mark (`MARK locked_mark))#offset in match pos with | `Top -> self#goto_top; self#notify | `Bottom -> (try let rec dowhile pos = self#_advance (); - if pos#compare (getpos ()) < 0 then - dowhile (getpos ()) + let newpos = getoffset () in + if pos - newpos < 0 then + dowhile newpos in - dowhile (getpos ()); + dowhile (getoffset ()); self#notify with | Margin -> self#notify | exc -> self#notify; raise exc) | `Cursor -> - let locked_iter () = buffer#get_iter_at_mark (`NAME "locked") in - let cursor_iter = buffer#get_iter_at_mark `INSERT in - let cmp = (locked_iter ())#offset - cursor_iter#offset in + let locked_offset () = + (buffer#get_iter_at_mark (`NAME "locked"))#offset in + let cursor_offset () = (buffer#get_iter_at_mark `INSERT)#offset in + let cmp = (locked_offset ()) - cursor_offset () in let forward_until_cursor () = (* go forward until locked > cursor *) let rec aux oldpos = self#_advance (); - if (locked_iter ())#compare cursor_iter < 0 && - oldpos#compare (getpos ()) < 0 + if (locked_offset ()) - cursor_offset () < 0 && + oldpos - (getoffset ()) < 0 then - aux (getpos ()) + aux (getoffset ()) in - aux (getpos ()) + aux (getoffset ()) in let rec back_until_cursor len = (* go backward until locked < cursor *) function