summaryrefslogtreecommitdiffstats
path: root/otherlibs/labltk/builtin/selection_handle_set.ml
blob: 2dfc5763f7eca78e2d77c4f8194517578264612c (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
##ifdef CAMLTK

(* The function *must* use tkreturn *)
let handle_set opts w cmd =
  tkCommand [|
    TkToken"selection";
    TkToken"handle";
    TkTokenList
      (List.map
         (function x -> cCAMLtoTKicccm w icccm_selection_handle_table x)
         opts);
    cCAMLtoTKwidget widget_any_table w;
    let id = register_callback w (function args ->
      let (a1,args) = int_of_string (List.hd args), List.tl args in
      let (a2,args) = int_of_string (List.hd args), List.tl args in
      cmd a1 a2) in
    TkToken ("camlcb "^id)
  |]
;;

##else

(* The function *must* use tkreturn *)
let handle_set ~command =
selection_handle_icccm_optionals (fun opts w ->
  tkCommand [|
    TkToken"selection";
    TkToken"handle";
    TkTokenList opts;
    cCAMLtoTKwidget w;
    let id = register_callback w ~callback:
        begin fun args ->
          let pos = int_of_string (List.hd args) in
          let len = int_of_string (List.nth args 1) in
          tkreturn (command ~pos ~len)
        end
    in TkToken ("camlcb " ^ id)
  |])
;;

##endif