File: unicode_table.ml

package info (click to toggle)
lablgtk3 3.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,796 kB
  • sloc: ml: 40,890; ansic: 22,312; makefile: 133; sh: 17
file content (48 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download | duplicates (6)
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
(**************************************************************************)
(*    Lablgtk - Examples                                                  *)
(*                                                                        *)
(*    This code is in the public domain.                                  *)
(*    You may freely copy parts of it in your application.                *)
(*                                                                        *)
(**************************************************************************)

let start = try
    int_of_string Sys.argv.(1)
  with _ -> 
    prerr_endline "Usage : unicode_table <from> <to>"; 
    exit 1 
;;

let stop = try
   int_of_string Sys.argv.(2)
  with _ -> 
    prerr_endline "Usage : unicode_table <from> <to>"; 
    exit 1 
;;


GtkMain.Main.init ();;
     
let main () = 
  let w = GWindow.window 
	    ~width:640 ~height:480 ~title:"2)view_with_buffer" ()
  in
  let sw = GBin.scrolled_window ~packing:(w#add) () in
  let b = GText.buffer () in
  b#set_text (Printf.sprintf "Unicode characters from %d to %d Click to continue\n" start stop);
  let font = Pango.Font.from_string "Sans 15" in
  let tv = GText.view ~buffer:b ~packing:(sw#add) () in
  let _ = tv#misc#modify_font font in
  ignore (tv#event#connect#button_release 
	    ~callback:
	    (fun _ -> 
	       for i=start to stop do 
		 let c = Printf.sprintf "%d:%s:\n" i (Glib.Utf8.from_unichar i) in
		 b#insert c
	       done;false));
  w#show ();;


main () ;; 

GMain.Main.main ();;