+ end));
+ (match evbox with (* history key bindings *)
+ | None -> ()
+ | Some evbox ->
+ List.iter (fun (key, f) -> MatitaGtkMisc.add_key_binding key f evbox)
+ [ GdkKeysyms._p, (fun () -> self#previous_phrase);
+ GdkKeysyms._n, (fun () -> self#next_phrase);
+ ]);
+ ignore (self#connect#after#move_cursor
+ (* avoid cursor being placed at prompt's left *)
+ ~callback:(fun step count ~extend ->
+ let buf = self#buffer in
+ let cursor_iter = buf#get_iter_at_mark `INSERT in
+ let prompt_iter = buf#get_iter_at_mark (`NAME "USER_INPUT_START") in
+ if prompt_iter#compare cursor_iter = 1 then (* prompt > cursor *)
+ buf#place_cursor ~where:prompt_iter))
+
+ method private set_phrase phrase =
+ let buf = self#buffer in
+ buf#delete
+ ~start:(buf#get_iter_at_mark (`NAME "USER_INPUT_START"))
+ ~stop:buf#end_iter;
+ buf#insert ~iter:buf#end_iter phrase
+
+ method private invoke_callback phrase =
+ history#add (* do not push trailing phrase separator *)
+ (String.sub phrase 0
+ (String.length phrase - String.length _phrase_sep));
+ if _callback phrase then begin
+ self#hide ();
+ self#clear ()
+ (* else callback encountered troubles, don't hide console which
+ probably contains error message *)
+ end
+
+ method clear () =
+ let buf = self#buffer in
+ buf#delete ~start:buf#start_iter ~stop:buf#end_iter