From 20ca9fb046fef01b1813d385b0c1bbd5f1dfb46a Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 9 Jun 2005 21:11:52 +0000 Subject: [PATCH] load "test.txt" and show it in a scrolled win --- helm/DEVEL/lablgtksourceview/test/test.ml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/helm/DEVEL/lablgtksourceview/test/test.ml b/helm/DEVEL/lablgtksourceview/test/test.ml index 08c942bc5..6eb369dfb 100644 --- a/helm/DEVEL/lablgtksourceview/test/test.ml +++ b/helm/DEVEL/lablgtksourceview/test/test.ml @@ -26,22 +26,30 @@ open Printf let win = GWindow.window ~title:"LablGtkSourceView test" () -let vbox = GPack.vbox ~packing:win#add () -let source_buffer = GSourceView.source_buffer ~check_brackets:true () +let scrolled_win = GBin.scrolled_window ~packing:win#add () +let text = + let ic = open_in "test.txt" in + let size = in_channel_length ic in + let buf = String.create size in + really_input ic buf 0 size; + close_in ic; + buf +let source_buffer = GSourceView.source_buffer ~text ~check_brackets:true () let source_view = GSourceView.source_view ~source_buffer ~auto_indent:true ~insert_spaces_instead_of_tabs:true ~tabs_width:2 ~show_line_numbers:true - ~margin:30 ~show_margin:true + ~margin:80 ~show_margin:true ~smart_home_end:true - ~packing:vbox#add ~height:400 ~width:300 + ~packing:scrolled_win#add ~height:500 ~width:650 () let _ = + win#set_allow_shrink true; ignore (win#connect#destroy (fun _ -> GMain.quit ())); - ignore (source_view#connect#move_cursor (fun _ _ ~extend -> +(* ignore (source_view#connect#move_cursor (fun _ _ ~extend -> prerr_endline "move_cursor")); - ignore (source_view#connect#undo (fun _ -> prerr_endline "undo")); + ignore (source_view#connect#undo (fun _ -> prerr_endline "undo")); *) win#show (); GMain.Main.main () -- 2.39.2