2 * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>,
3 * Stefano Zacchiroli <zack@cs.unibo.it>
5 * This file is part of lablgtksourceview, the OCaml binding for the
6 * GtkSourceView widget.
8 * lablgtksourceview is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * lablgtksourceview is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with lablgtksourceview; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 * For details, send a mail to the authors.
28 let lang_mime_type = "text/x-c"
30 let print_lang lang = prerr_endline (sprintf "language: %s" lang#get_name)
32 let win = GWindow.window ~title:"LablGtkSourceView test" ()
33 let scrolled_win = GBin.scrolled_window ~packing:win#add ()
35 GSourceView.source_view
37 (* ~insert_spaces_instead_of_tabs:true ~tabs_width:2 *)
38 ~show_line_numbers:true
39 ~margin:80 ~show_margin:true
41 ~packing:scrolled_win#add ~height:500 ~width:650
43 let lang_manager = GSourceView.source_languages_manager ()
46 let ic = open_in "test.txt" in
47 let size = in_channel_length ic in
48 let buf = String.create size in
49 really_input ic buf 0 size;
53 win#set_allow_shrink true;
54 source_view#misc#modify_font_by_name "Monospace 10";
55 (match lang_manager#get_language_from_mime_type lang_mime_type with
57 prerr_endline (sprintf "no language for mime-type: %s" lang_mime_type)
60 source_view#source_buffer#set_language lang);
61 source_view#source_buffer#set_highlight true;
62 source_view#source_buffer#set_text text;
63 ignore (win#connect#destroy (fun _ -> GMain.quit ()));
64 (* ignore (source_view#connect#move_cursor (fun _ _ ~extend ->
65 prerr_endline "move_cursor"));
66 ignore (source_view#connect#undo (fun _ -> prerr_endline "undo")); *)