1 (*************************************************************************)
3 (* Objective Caml LablTk library *)
5 (* Jacques Garrigue, Kyoto University RIMS *)
7 (* Copyright 1999 Institut National de Recherche en Informatique et *)
8 (* en Automatique and Kyoto University. All rights reserved. *)
9 (* This file is distributed under the terms of the GNU Library *)
10 (* General Public License, with the special exception on linking *)
11 (* described in file ../../../LICENSE. *)
13 (*************************************************************************)
15 (* $Id: jg_completion.ml 4144 2001-12-07 13:41:02Z xleroy $ *)
17 let lt_string ?(nocase=false) s1 s2 =
18 if nocase then String.lowercase s1 < String.lowercase s2 else s1 < s2
20 class completion ?nocase texts = object
21 val mutable texts = texts
23 val mutable prefix = ""
24 val mutable current = 0
27 while current < List.length texts - 1 &&
28 lt_string (List.nth texts current) prefix ?nocase
30 current <- current + 1
33 method current = current
34 method get_current = List.nth texts current
40 class timed ?nocase ?wait texts = object (self)
41 inherit completion texts ?nocase as super
42 val wait = match wait with None -> 500 | Some n -> n
43 val mutable timer = None
45 begin match timer with
47 | Some t -> Timer.remove t
49 timer <- Some (Timer.add ~ms:wait ~callback:(fun () -> self#reset));
52 timer <- None; super#reset