aboutsummaryrefslogtreecommitdiff
path: root/ide/utils/configwin_html_config.ml
blob: 9a9c3f2d74b5f4f23c9e852cde2fe5a793b22298 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(***********************************************************************)
(*                               Configwin                             *)
(*                                                                     *)
(*            Maxence Guesdon, projet Cristal, INRIA Rocquencourt      *)
(*                                                                     *)
(*  Copyright 2002 Institut National de Recherche en Informatique et   *)
(*  en Automatique.  All rights reserved.  This file is distributed    *)
(*  under the terms of the Q Public License version 1.0.               *)
(*                                                                     *)
(***********************************************************************)

(** The HTML editor bindings configurator. *)

module C = Configwin_ihm
open Configwin_types
open Uoptions

let simple_get = C.simple_edit 
    ~with_apply: false ~apply: (fun () -> ())

let params_hb hb =
  let p_key = C.hotkey 
      ~f: (fun k -> hb.html_key <- k) Configwin_messages.mKey
      hb.html_key
  in
  let p_begin = C.string
      ~f: (fun s -> hb.html_begin <- s)
      Configwin_messages.html_begin
      hb.html_begin
  in
  let p_end = C.string
      ~f: (fun s -> hb.html_end <- s)
      Configwin_messages.html_end
      hb.html_end
  in
  [ p_key ; p_begin ; p_end ]

let edit_hb hb =
  ignore (simple_get Configwin_messages.mEdit (params_hb hb));
  hb

let add () =
  let hb = { html_key = KeyOption.string_to_key "C-a" ;
	     html_begin = "" ;
	     html_end = "" ;
	   } 
  in
  match simple_get Configwin_messages.mAdd (params_hb hb) with
    Return_ok -> [hb]
  | _ -> []

let main () =
  ignore (GMain.Main.init ());
  let (ini, bindings) = C.html_config_file_and_option () in
  let param = C.list
      ~f: (fun l -> bindings =:= l ; Uoptions.save_with_help ini)
      ~eq: (fun hb1 hb2 -> hb1.html_key = hb2.html_key)
      ~edit: edit_hb
      ~add: add
      ~titles: [ Configwin_messages.mKey ; Configwin_messages.html_begin ;
		 Configwin_messages.html_end ]
      Configwin_messages.shortcuts
      (fun hb -> [ KeyOption.key_to_string hb.html_key ;
		   hb.html_begin ; hb.html_end ])
      !!bindings
  in
  ignore (simple_get ~width: 300 ~height: 400 
	    Configwin_messages.html_config [param])

let _ = main ()