File: lambda_term_actions.ml

package info (click to toggle)
lambda-term 3.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,108 kB
  • sloc: ml: 14,981; ansic: 522; makefile: 32
file content (43 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(*
 * lambda_term_actions.ml
 * ----------------------
 * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of Lambda-Term.
 *)

(* List all available actions. *)

let print_action length (action, doc) =
  print_string action;
  for _ = String.length action to length do
    print_char ' '
  done;
  print_string ": ";
  print_string doc;
  print_char '\n'

let () =
  (* Collect actions. *)
  let edit_actions =
    ("insert(...)", "insert a character.")
    :: (List.map (fun (action, name) -> (name, Zed_edit.doc_of_action action)) Zed_edit.actions)
    @ (List.map (fun (action, name) -> (name, LTerm_edit.doc_of_action action)) LTerm_edit.actions)
  and read_line_actions =
    List.map (fun (action, name) -> (name, LTerm_read_line.doc_of_action action)) LTerm_read_line.actions
  in

  (* Search the longest line. *)
  let length = List.fold_left (fun acc (action, _doc) -> max (String.length action) acc) 0 edit_actions in
  let length = List.fold_left (fun acc (action, _doc) -> max (String.length action) acc) length read_line_actions in

  (* Print actions. *)
  print_string "General actions\n\
                ===============\n\n";
  List.iter (print_action length) edit_actions;
  print_string "\nRead-line actions\n\
                  =================\n\n";
  List.iter (print_action length) read_line_actions;

  flush stdout