+ method private nextLigature () =
+ let iter = source_buffer#get_iter_at_mark `INSERT in
+ let write_ligature len s =
+ source_buffer#delete ~start:iter ~stop:(iter#copy#backward_chars len);
+ source_buffer#insert ~iter:(source_buffer#get_iter_at_mark `INSERT) s
+ in
+ (match next_ligatures with
+ | [] -> (* find ligatures and fill next_ligatures, then try again *)
+ let last_word = iter#get_slice ~stop:iter#copy#backward_word_start in
+ let len = String.length last_word in
+ let i = ref (len - 1) in
+ while !i >= 0 && CicNotationLexer.is_ligature_char last_word.[!i] do
+ decr i
+ done;
+ let ligature = String.sub last_word (!i + 1) (len - (!i + 1)) in
+ (match CicNotationLexer.lookup_ligatures ligature with
+ | [] -> ()
+ | hd :: tl ->
+ write_ligature (String.length ligature) hd;
+ next_ligatures <- tl @ [ hd ])
+ | hd :: tl ->
+ write_ligature 1 hd;
+ next_ligatures <- tl @ [ hd ])
+