1 let cols = int_of_string (Sys.getenv "COLUMNS")
10 if s = "" then false else
11 begin hl := s :: !hl; true end
14 if Scanf.fscanf ich "%s " add then read ich
16 let length l s = max l (String.length s)
20 let i = String.rindex s '.' in
21 if i = 0 then s, "" else
22 String.sub s 0 i, String.sub s i (String.length s - i)
23 with Not_found -> s, ""
26 let n1, e1 = split s1 in
27 let n2, e2 = split s2 in
28 let e = String.compare e1 e2 in
29 if e = 0 then String.compare n1 n2 else e
32 let pre, post = if List.mem s !hl then color, normal else "", "" in
33 let spc = String.make (l - String.length s) ' ' in
35 if c = 0 || c = cols then "", l else
36 if c + l < cols then " ", c + succ l else "\n", l
38 Printf.printf "%s%s%s%s%s" bol pre s post spc;
42 let ich = open_in fname in
43 read ich; close_in ich
48 Arg.parse [] process help;
49 let files = Sys.readdir "." in
50 let l = Array.fold_left length 0 files in
51 if cols < l then failwith "window too small";
52 Array.fast_sort compare files;
53 let c = Array.fold_left (write l) 0 files in
54 if 0 < c && c < cols then print_newline ();