1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2001-2007 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  This widget displays a view of a Gtk_Text_Buffer. Multiple views can be 
  26. --  set on a given buffer. 
  27. --  </description> 
  28. --  <c_version>2.8.17</c_version> 
  29. --  <screenshot>gtk-text_view.png</screenshot> 
  30. --  <see>Gtk.Text_Buffer</see> 
  31. --  <see>Gtk.Text_Tag</see> 
  32. --  <see>Gtk.Text_Attributes</see> 
  33. --  <testgtk>create_text_view.adb</testgtk> 
  34. --  <group>Multiline Text Editor</group> 
  35.  
  36. with Glib.Properties; 
  37. with Gdk.Rectangle; 
  38. with Gdk.Window; 
  39. with Gtk.Container; 
  40. with Gtk.Enums; 
  41. with Gtk.Text_Attributes; 
  42. with Gtk.Text_Buffer; 
  43. with Gtk.Text_Child; 
  44. with Gtk.Text_Iter; 
  45. with Gtk.Text_Mark; 
  46. with Gtk.Widget; 
  47. with Pango.Tabs; 
  48.  
  49. package Gtk.Text_View is 
  50.  
  51.    type Gtk_Text_View_Record is 
  52.      new Gtk.Container.Gtk_Container_Record with private; 
  53.    type Gtk_Text_View is access all Gtk_Text_View_Record'Class; 
  54.  
  55.    procedure Gtk_New 
  56.      (Widget : out Gtk_Text_View; 
  57.       Buffer : Gtk.Text_Buffer.Gtk_Text_Buffer := null); 
  58.    procedure Initialize 
  59.      (Widget : access Gtk_Text_View_Record'Class; 
  60.       Buffer : Gtk.Text_Buffer.Gtk_Text_Buffer); 
  61.    --  Creates or initializes a new Gtk_Text_View. 
  62.    --  If Buffer is null, an empty default buffer will be created for you. Get 
  63.    --  the buffer with Get_Buffer. 
  64.    --  Otherwise, create a new text view widget displaying Buffer. 
  65.    --  One buffer can be shared among many widgets. 
  66.    --  The text view adds its own reference count to the buffer; it does not 
  67.    --  take over an existing reference. 
  68.  
  69.    function Get_Type return Glib.GType; 
  70.    --  Return the internal value associated with this widget. 
  71.  
  72.    procedure Set_Buffer 
  73.      (Text_View : access Gtk_Text_View_Record; 
  74.       Buffer    : access Gtk.Text_Buffer.Gtk_Text_Buffer_Record'Class); 
  75.    --  Set Buffer as the buffer being displayed by Text_View. 
  76.    --  The previous buffer displayed by the text view is unreferenced, and a 
  77.    --  reference is added to Buffer. If you owned a reference to Buffer before 
  78.    --  passing it to this function, you must remove that reference yourself; 
  79.    --  Gtk_Text_View will not "adopt" it. 
  80.  
  81.    function Get_Buffer 
  82.      (Text_View : access Gtk_Text_View_Record) 
  83.       return Gtk.Text_Buffer.Gtk_Text_Buffer; 
  84.    --  Return the Gtk_Text_Buffer being displayed by this text view. 
  85.    --  The reference count on the buffer is not incremented; the caller of this 
  86.    --  function won't own a new reference. 
  87.  
  88.    function Scroll_To_Iter 
  89.      (Text_View     : access Gtk_Text_View_Record; 
  90.       Iter          : Gtk.Text_Iter.Gtk_Text_Iter; 
  91.       Within_Margin : Gdouble; 
  92.       Use_Align     : Boolean; 
  93.       Xalign        : Gdouble; 
  94.       Yalign        : Gdouble) return Boolean; 
  95.    --  Scroll Text_View so that Iter is on the screen in the position 
  96.    --  indicated by Xalign and Yalign. An alignment of 0.0 indicates left or 
  97.    --  top, 1.0 indicates right or bottom, 0.5 means center. If Use_Align is 
  98.    --  False, the text scrolls the minimal distance to get the mark onscreen, 
  99.    --  possibly not scrolling at all. The effective screen for purposes of this 
  100.    --  function is reduced by a margin of size Within_Margin. 
  101.    --  Note: This function uses the currently-computed height of the lines in 
  102.    --  the text buffer. Note that line heights are computed in an idle handler; 
  103.    --  so this function may not have the desired effect if it's called before 
  104.    --  the height computations. To avoid oddness, consider using 
  105.    --  Scroll_To_Mark which saves a point to be scrolled to after line 
  106.    --  validation. 
  107.  
  108.    procedure Scroll_To_Mark 
  109.      (Text_View     : access Gtk_Text_View_Record; 
  110.       Mark          : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class; 
  111.       Within_Margin : Gdouble := 0.0; 
  112.       Use_Align     : Boolean := False; 
  113.       Xalign        : Gdouble := 0.0; 
  114.       Yalign        : Gdouble := 0.0); 
  115.    --  Scroll Text_View so that Mark is on the screen in the position indicated 
  116.    --  by Xalign and Yalign. An alignment of 0.0 indicates left or top, 1.0 
  117.    --  indicates right or bottom, 0.5 means center. If Use_Align is False, the 
  118.    --  text scrolls the minimal distance to get the mark onscreen, possibly not 
  119.    --  scrolling at all. The effective screen for purposes of this function is 
  120.    --  reduced by a margin of size Within_Margin. 
  121.  
  122.    procedure Scroll_Mark_Onscreen 
  123.      (Text_View : access Gtk_Text_View_Record; 
  124.       Mark      : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class); 
  125.    --  Same as the above with the default values 
  126.  
  127.    function Move_Mark_Onscreen 
  128.      (Text_View : access Gtk_Text_View_Record; 
  129.       Mark      : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class) 
  130.       return Boolean; 
  131.    --  Move a mark within the buffer so that it's located within the 
  132.    --  currently-visible text area. 
  133.    --  Return value: True if the mark moved (wasn't already onscreen). 
  134.  
  135.    function Place_Cursor_Onscreen 
  136.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  137.    --  Move the cursor to the currently visible region of the buffer, if it 
  138.    --  isn't there already. 
  139.    --  Return value: True if the cursor had to be moved. 
  140.  
  141.    procedure Get_Visible_Rect 
  142.      (Text_View    : access Gtk_Text_View_Record; 
  143.       Visible_Rect : out Gdk.Rectangle.Gdk_Rectangle); 
  144.    --  Fill Visible_Rect with the currently-visible region of the buffer, in 
  145.    --  buffer coordinates. Convert to window coordinates with 
  146.    --  Buffer_To_Window_Coords. 
  147.  
  148.    procedure Get_Iter_Location 
  149.      (Text_View : access Gtk_Text_View_Record; 
  150.       Iter      : Gtk.Text_Iter.Gtk_Text_Iter; 
  151.       Location  : out Gdk.Rectangle.Gdk_Rectangle); 
  152.    --  Get a rectangle which roughly contains the character at iter. 
  153.    --  The rectangle position is in buffer coordinates; use 
  154.    --  Buffer_To_Window_Coords to convert these coordinates to coordinates for 
  155.    --  one of the windows in the text view. 
  156.  
  157.    procedure Get_Iter_At_Location 
  158.      (Text_View : access Gtk_Text_View_Record; 
  159.       Iter      : out Gtk.Text_Iter.Gtk_Text_Iter; 
  160.       X         : Gint; 
  161.       Y         : Gint); 
  162.    --  Retrieve the iterator at buffer coordinates X and Y. Buffer coordinates 
  163.    --  are coordinates for the entire buffer, not just the currently-displayed 
  164.    --  portion. If you have coordinates from an event, you have to convert 
  165.    --  those to buffer coordinates with Window_To_Buffer_Coords. 
  166.  
  167.    procedure Get_Iter_At_Position 
  168.      (Text_View : access Gtk_Text_View_Record; 
  169.       Iter      : out Gtk.Text_Iter.Gtk_Text_Iter; 
  170.       Trailing  : out Gint; 
  171.       X         : Gint; 
  172.       Y         : Gint); 
  173.    --  Retrieves the iterator pointing to the character at buffer coordinates X 
  174.    --  and Y. Buffer coordinates are coordinates for the entire buffer, not 
  175.    --  just the currently-displayed portion. If you have coordinates from an 
  176.    --  event, you have to convert those to buffer coordinates with 
  177.    --  Window_To_Buffer_Coords. 
  178.    --  Note that this is different from Get_Iter_At_Location(), 
  179.    --  which returns cursor locations, i.e. positions between characters) 
  180.    --  Trailing is set to indicate where in the grapheme the user clicked. It 
  181.    --  will be either 0, or the number of characters in the grapheme. 0 
  182.    --  represents the trailing edge of the grapheme. 
  183.  
  184.    procedure Get_Line_Yrange 
  185.      (Text_View : access Gtk_Text_View_Record; 
  186.       Iter      : Gtk.Text_Iter.Gtk_Text_Iter; 
  187.       Y         : out Gint; 
  188.       Height    : out Gint); 
  189.    --  Get the Y coordinate of the top of the line containing Iter, 
  190.    --  and the Height of the line. The coordinate is a buffer coordinate; 
  191.    --  convert to window coordinates with Buffer_To_Window_Coords. 
  192.  
  193.    procedure Get_Line_At_Y 
  194.      (Text_View   : access Gtk_Text_View_Record; 
  195.       Target_Iter : out Gtk.Text_Iter.Gtk_Text_Iter; 
  196.       Y           : Gint; 
  197.       Line_Top    : out Gint); 
  198.    --  Get the Gtk_Text_Iter at the start of the line containing the 
  199.    --  coordinate Y. Y is in buffer coordinates, convert from window 
  200.    --  coordinates with Window_To_Buffer_Coords. 
  201.    --  Line_Top will be filled with the coordinate of the top edge of the line. 
  202.  
  203.    procedure Buffer_To_Window_Coords 
  204.      (Text_View : access Gtk_Text_View_Record; 
  205.       Win       : Gtk.Enums.Gtk_Text_Window_Type; 
  206.       Buffer_X  : Gint; 
  207.       Buffer_Y  : Gint; 
  208.       Window_X  : out Gint; 
  209.       Window_Y  : out Gint); 
  210.    --  Convert coordinate (Buffer_X, Buffer_Y) to coordinates for the window 
  211.    --  Win, and store the result in (Window_X, Window_Y). 
  212.  
  213.    procedure Window_To_Buffer_Coords 
  214.      (Text_View : access Gtk_Text_View_Record; 
  215.       Win       : Gtk.Enums.Gtk_Text_Window_Type; 
  216.       Window_X  : Gint; 
  217.       Window_Y  : Gint; 
  218.       Buffer_X  : out Gint; 
  219.       Buffer_Y  : out Gint); 
  220.    --  Convert coordinates on the window identified by Win to buffer 
  221.    --  coordinates, storing the result in (Buffer_X, Buffer_Y). 
  222.  
  223.    function Get_Window 
  224.      (Text_View : access Gtk_Text_View_Record; 
  225.       Win       : Gtk.Enums.Gtk_Text_Window_Type) return Gdk.Window.Gdk_Window; 
  226.    --  Retrieve the Gdk_Window corresponding to an area of the text view; 
  227.    --  possible windows include the overall widget window, child windows on the 
  228.    --  left, right, top, bottom, and the window that displays the text buffer. 
  229.    --  Windows are null and nonexistent if their width or height is 0, and are 
  230.    --  nonexistent before the widget has been realized. 
  231.  
  232.    function Get_Window_Type 
  233.      (Text_View : access Gtk_Text_View_Record; 
  234.       Window    : Gdk.Window.Gdk_Window) return Gtk.Enums.Gtk_Text_Window_Type; 
  235.    --  Usually used to find out which window an event corresponds to. 
  236.    --  If you connect to an event signal on Text_View, this function should be 
  237.    --  called on Get_Window (Event) to see which window it was. 
  238.  
  239.    procedure Set_Border_Window_Size 
  240.      (Text_View : access Gtk_Text_View_Record; 
  241.       The_Type  : Gtk.Enums.Gtk_Text_Window_Type; 
  242.       Size      : Gint); 
  243.    function Get_Border_Window_Size 
  244.      (Text_View : access Gtk_Text_View_Record; 
  245.       The_Type  : Gtk.Enums.Gtk_Text_Window_Type) return Gint; 
  246.    --  Set the width of Text_Window_Left or Text_Window_Right, 
  247.    --  or the height of Text_Window_Top or Text_Window_Bottom. 
  248.    --  Automatically destroy the corresponding window if the size is set to 0, 
  249.    --  and create the window if the size is set to non-zero. 
  250.  
  251.    --  <doc_ignore> 
  252.    procedure Set_Disable_Scroll_On_Focus 
  253.      (Text_View : access Gtk_Text_View_Record; 
  254.       Set       : Boolean); 
  255.    function Get_Disable_Scroll_On_Focus 
  256.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  257.    --  Set whether the Text_View should scroll to the cursor when it gets the 
  258.    --  focus. (This is the default behaviour) 
  259.    --  This procedure has no effect for gtk+ 2.2.2 or later. 
  260.    --  </doc_ignore> 
  261.  
  262.    --------------- 
  263.    -- Iterators -- 
  264.    --------------- 
  265.    --  You can manipulate iterators either through the buffer directly (thus 
  266.    --  independently of any display properties), or through the property (if 
  267.    --  you need to reference to what the user is actually seeing on the screen) 
  268.  
  269.    procedure Forward_Display_Line 
  270.      (Text_View : access Gtk_Text_View_Record; 
  271.       Iter      : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  272.       Result    : out    Boolean); 
  273.    procedure Forward_Display_Line_End 
  274.      (Text_View : access Gtk_Text_View_Record; 
  275.       Iter      : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  276.       Result    : out    Boolean); 
  277.    --  Moves the given Iter forward by one display (wrapped) line.  A 
  278.    --  display line is different from a paragraph. Paragraphs are 
  279.    --  separated by newlines or other paragraph separator characters. 
  280.    --  Display lines are created by line-wrapping a paragraph.  If 
  281.    --  wrapping is turned off, display lines and paragraphs will be the 
  282.    --  same. Display lines are divided differently for each view, since 
  283.    --  they depend on the view's width; paragraphs are the same in all 
  284.    --  views, since they depend on the contents of the Gtk_Text_Buffer. 
  285.    --  Returns True if Iter was moved and is not on the end iterator. 
  286.  
  287.    procedure Backward_Display_Line 
  288.      (Text_View : access Gtk_Text_View_Record; 
  289.       Iter      : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  290.       Result    : out    Boolean); 
  291.    procedure Backward_Display_Line_Start 
  292.      (Text_View : access Gtk_Text_View_Record; 
  293.       Iter      : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  294.       Result    : out    Boolean); 
  295.    --  Moves the given Iter backward by one display (wrapped) line. A display 
  296.    --  line is different from a paragraph. Paragraphs are separated by newlines 
  297.    --  or other paragraph separator characters. Display lines are created by 
  298.    --  line-wrapping a paragraph. If wrapping is turned off, display lines and 
  299.    --  paragraphs will be the same. Display lines are divided differently for 
  300.    --  each view, since they depend on the view's width; paragraphs are the 
  301.    --  same in all views, since they depend on the contents of the 
  302.    --  Gtk_Text_Buffer. 
  303.    --  Returns True if Iter was moved and is not on the end iterator 
  304.  
  305.    function Starts_Display_Line 
  306.      (Text_View : access Gtk_Text_View_Record; 
  307.       Iter      : Gtk.Text_Iter.Gtk_Text_Iter) return Boolean; 
  308.    --  Determines whether Iter is at the start of a display line. See 
  309.    --  Forward_Display_Line for an explanation of display lines vs. paragraphs. 
  310.    --  Returns true if Iter begins a wrapped line. 
  311.  
  312.    procedure Move_Visually 
  313.      (Text_View : access Gtk_Text_View_Record; 
  314.       Iter      : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  315.       Count     : Gint; 
  316.       Result    : out Boolean); 
  317.    --  Move the iterator a given number of characters visually, treating it as 
  318.    --  the strong cursor position. If Count is positive, then the new strong 
  319.    --  cursor position will be Count positions to the right of the old cursor 
  320.    --  position. If Count is negative then the new strong cursor position will 
  321.    --  be Count positions to the left of the old cursor position. 
  322.    -- 
  323.    --  In the presence of bidirection text, the correspondence between logical 
  324.    --  and visual order will depend on the direction of the current run, and 
  325.    --  there may be jumps when the cursor is moved off of the end of a run. 
  326.    -- 
  327.    --  Returns True if Iter moved and is not on the end iterator 
  328.  
  329.    ---------------------- 
  330.    -- Children widgets -- 
  331.    ---------------------- 
  332.    --  Any widget can be put in a text_view, for instance to provide an 
  333.    --  interactive area. 
  334.  
  335.    procedure Add_Child_In_Window 
  336.      (Text_View    : access Gtk_Text_View_Record; 
  337.       Child        : access Gtk.Widget.Gtk_Widget_Record'Class; 
  338.       Which_Window : Gtk.Enums.Gtk_Text_Window_Type; 
  339.       Xpos         : Gint; 
  340.       Ypos         : Gint); 
  341.    --  Adds a child at fixed coordinates in one of the text widget's windows. 
  342.    --  The window must have nonzero size (see Set_Border_Window_Size). Note 
  343.    --  that the child coordinates are given relative to the Gdk_Window in 
  344.    --  question, and that these coordinates have no sane relationship to 
  345.    --  scrolling. When placing a child in GTK_TEXT_WINDOW_WIDGET, scrolling is 
  346.    --  irrelevant, the child floats above all scrollable areas. But when 
  347.    --  placing a child in one of the scrollable windows (border windows or text 
  348.    --  window), you'll need to compute the child's correct position in buffer 
  349.    --  coordinates any time scrolling occurs or buffer changes occur, and then 
  350.    --  call Move_Child() to update the child's position. Unfortunately there's 
  351.    --  no good way to detect that scrolling has occurred, using the current 
  352.    --  API; a possible hack would be to update all child positions when the 
  353.    --  scroll adjustments change or the text buffer changes. 
  354.  
  355.    procedure Add_Child_At_Anchor 
  356.      (Text_View : access Gtk_Text_View_Record; 
  357.       Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  358.       Anchor    : access Gtk.Text_Child.Gtk_Text_Child_Anchor_Record'Class); 
  359.    --  Adds a child widget in the text buffer, at the given Anchor. 
  360.  
  361.    procedure Move_Child 
  362.      (Text_View : access Gtk_Text_View_Record; 
  363.       Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  364.       Xpos      : Gint; 
  365.       Ypos      : Gint); 
  366.    --  Updates the position of a child, as for Add_Child_In_Window. 
  367.    --  Child must already have been added to the text_view. 
  368.  
  369.    ---------------- 
  370.    -- Attributes -- 
  371.    ---------------- 
  372.  
  373.    function Get_Default_Attributes 
  374.      (Text_View : access Gtk_Text_View_Record) 
  375.       return Gtk.Text_Attributes.Gtk_Text_Attributes; 
  376.    --  Obtains a copy of the default text attributes. These are the attributes 
  377.    --  used for text unless a tag overrides them. You'd typically pass the 
  378.    --  default attributes in to Gtk.Text_Iter.Get_Attributes in order to get 
  379.    --  the attributes in effect at a given text position. 
  380.    --  The returned value is a copy and should be freed by the caller. 
  381.  
  382.    procedure Set_Cursor_Visible 
  383.      (Text_View : access Gtk_Text_View_Record; 
  384.       Setting   : Boolean := True); 
  385.    function Get_Cursor_Visible 
  386.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  387.    --  Toggle whether the insertion point is displayed. 
  388.    --  A buffer with no editable text probably shouldn't have a visible cursor, 
  389.    --  so you may want to turn the cursor off. 
  390.  
  391.    procedure Set_Wrap_Mode 
  392.      (Text_View : access Gtk_Text_View_Record; 
  393.       Wrap_Mode : Gtk.Enums.Gtk_Wrap_Mode); 
  394.    function Get_Wrap_Mode 
  395.      (Text_View : access Gtk_Text_View_Record) return Gtk.Enums.Gtk_Wrap_Mode; 
  396.    --  Set the line wrapping for the view. 
  397.  
  398.    procedure Set_Editable 
  399.      (Text_View : access Gtk_Text_View_Record; 
  400.       Setting   : Boolean := True); 
  401.    function Get_Editable 
  402.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  403.    --  Set the default editability of the Gtk_Text_View. 
  404.    --  You can override this default setting with tags in the buffer, using the 
  405.    --  "editable" attribute of tags. 
  406.  
  407.    procedure Set_Pixels_Above_Lines 
  408.      (Text_View          : access Gtk_Text_View_Record; 
  409.       Pixels_Above_Lines : Gint); 
  410.    function Get_Pixels_Above_Lines 
  411.      (Text_View : access Gtk_Text_View_Record) return Gint; 
  412.    --  Sets the default number of blank pixels above paragraphs in Text_View. 
  413.    --  Tags in the buffer for Text_View may override the defaults. 
  414.  
  415.    procedure Set_Pixels_Below_Lines 
  416.      (Text_View          : access Gtk_Text_View_Record; 
  417.       Pixels_Below_Lines : Gint); 
  418.    function Get_Pixels_Below_Lines 
  419.      (Text_View : access Gtk_Text_View_Record) return Gint; 
  420.    --  Sets the default number of pixels of blank space 
  421.    --  to put below paragraphs in Text_View. May be overridden 
  422.    --  by tags applied to Text_View's buffer. 
  423.  
  424.    procedure Set_Pixels_Inside_Wrap 
  425.      (Text_View          : access Gtk_Text_View_Record; 
  426.       Pixels_Inside_Wrap : Gint); 
  427.    function Get_Pixels_Inside_Wrap 
  428.      (Text_View : access Gtk_Text_View_Record) return Gint; 
  429.    --  Sets the default number of pixels of blank space to leave between 
  430.    --  display/wrapped lines within a paragraph. May be overridden by 
  431.    --  tags in Text_View's buffer. 
  432.  
  433.    procedure Set_Justification 
  434.      (Text_View     : access Gtk_Text_View_Record; 
  435.       Justification : Gtk.Enums.Gtk_Justification); 
  436.    function Get_Justification 
  437.      (Text_View : access Gtk_Text_View_Record) 
  438.       return Gtk.Enums.Gtk_Justification; 
  439.    --  Sets the default justification of text in Text_View. 
  440.    --  Tags in the view's buffer may override the default. 
  441.  
  442.    procedure Set_Left_Margin 
  443.      (Text_View   : access Gtk_Text_View_Record; 
  444.       Left_Margin : Gint); 
  445.    function Get_Left_Margin 
  446.      (Text_View : access Gtk_Text_View_Record) return Gint; 
  447.    --  Sets the default left margin for text in Text_View. 
  448.    --  Tags in the buffer may override the default. 
  449.  
  450.    procedure Set_Right_Margin 
  451.      (Text_View    : access Gtk_Text_View_Record; 
  452.       Right_Margin : Gint); 
  453.    function Get_Right_Margin 
  454.      (Text_View : access Gtk_Text_View_Record) return Gint; 
  455.    --  Sets the default right margin for text in the text view. 
  456.    --  Tags in the buffer may override the default. 
  457.  
  458.    procedure Set_Indent 
  459.      (Text_View : access Gtk_Text_View_Record; Indent : Gint); 
  460.    function Get_Indent (Text_View : access Gtk_Text_View_Record) return Gint; 
  461.    --  Sets the default indentation for paragraphs in Text_View. 
  462.    --  Tags in the buffer may override the default. 
  463.  
  464.    procedure Set_Tabs 
  465.      (Text_View : access Gtk_Text_View_Record; 
  466.       Tabs      : Pango.Tabs.Pango_Tab_Array); 
  467.    function Get_Tabs 
  468.      (Text_View : access Gtk_Text_View_Record) 
  469.       return Pango.Tabs.Pango_Tab_Array; 
  470.    --  Sets the default tab stops for paragraphs in Text_View. Tags in the 
  471.    --  buffer may override the default 
  472.    --  The returned array will be Null_Tab_Array if "standard" (8-space) tabs 
  473.    --  are used. Free the return value Pango.Tabs.Free 
  474.  
  475.    procedure Set_Overwrite 
  476.      (Text_View : access Gtk_Text_View_Record; Overwrite : Boolean); 
  477.    function Get_Overwrite 
  478.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  479.    --  Changes the Text_View overwrite mode. 
  480.  
  481.    procedure Set_Accepts_Tab 
  482.      (Text_View   : access Gtk_Text_View_Record;  Accepts_Tab : Boolean); 
  483.    function Get_Accepts_Tab 
  484.      (Text_View : access Gtk_Text_View_Record) return Boolean; 
  485.    --  Sets the behavior of the text widget when the Tab key is pressed. If 
  486.    --  Accepts_Tab is True a tab character is inserted, otherwise the keyboard 
  487.    --  focus is moved to the next widget in the focus chain. 
  488.  
  489.    ---------------- 
  490.    -- Properties -- 
  491.    ---------------- 
  492.  
  493.    --  <properties> 
  494.    --  The following properties are defined for this widget. See 
  495.    --  Glib.Properties for more information on properties. 
  496.    -- 
  497.    --  Name:  Accepts_Tab_Property 
  498.    --  Type:  Boolean 
  499.    --  Descr: Whether Tab will result in a tab character being entered 
  500.    -- 
  501.    --  Name:  Buffer_Property 
  502.    --  Type:  Object 
  503.    --  Descr: The buffer which is displayed 
  504.    -- 
  505.    --  Name:  Cursor_Visible_Property 
  506.    --  Type:  Boolean 
  507.    --  Descr: If the insertion cursor is shown 
  508.    -- 
  509.    --  Name:  Editable_Property 
  510.    --  Type:  Boolean 
  511.    --  Descr: Whether the text can be modified by the user 
  512.    -- 
  513.    --  Name:  Indent_Property 
  514.    --  Type:  Int 
  515.    --  Descr: Amount to indent the paragraph, in pixels 
  516.    -- 
  517.    --  Name:  Justification_Property 
  518.    --  Type:  Enum 
  519.    --  Descr: Left, right, or center justification 
  520.    -- 
  521.    --  Name:  Left_Margin_Property 
  522.    --  Type:  Int 
  523.    --  Descr: Width of the left margin in pixels 
  524.    -- 
  525.    --  Name:  Overwrite_Property 
  526.    --  Type:  Boolean 
  527.    --  Descr: Whether entered text overwrites existing contents 
  528.    -- 
  529.    --  Name:  Pixels_Above_Lines_Property 
  530.    --  Type:  Int 
  531.    --  Descr: Pixels of blank space above paragraphs 
  532.    -- 
  533.    --  Name:  Pixels_Below_Lines_Property 
  534.    --  Type:  Int 
  535.    --  Descr: Pixels of blank space below paragraphs 
  536.    -- 
  537.    --  Name:  Pixels_Inside_Wrap_Property 
  538.    --  Type:  Int 
  539.    --  Descr: Pixels of blank space between wrapped lines in a paragraph 
  540.    -- 
  541.    --  Name:  Right_Margin_Property 
  542.    --  Type:  Int 
  543.    --  Descr: Width of the right margin in pixels 
  544.    -- 
  545.    --  Name:  Tabs_Property 
  546.    --  Type:  Boxed 
  547.    --  Descr: Custom tabs for this text 
  548.    -- 
  549.    --  Name:  Wrap_Mode_Property 
  550.    --  Type:  Enum 
  551.    --  Descr: Whether to wrap lines never, at word boundaries, or at character 
  552.    --         boundaries 
  553.    -- 
  554.    --  </properties> 
  555.  
  556.    Accepts_Tab_Property        : constant Glib.Properties.Property_Boolean; 
  557.    Buffer_Property             : constant Glib.Properties.Property_Object; 
  558.    Cursor_Visible_Property     : constant Glib.Properties.Property_Boolean; 
  559.    Editable_Property           : constant Glib.Properties.Property_Boolean; 
  560.    Indent_Property             : constant Glib.Properties.Property_Int; 
  561.    Justification_Property      : constant Gtk.Enums.Property_Gtk_Justification; 
  562.    Left_Margin_Property        : constant Glib.Properties.Property_Int; 
  563.    Overwrite_Property          : constant Glib.Properties.Property_Boolean; 
  564.    Pixels_Above_Lines_Property : constant Glib.Properties.Property_Int; 
  565.    Pixels_Below_Lines_Property : constant Glib.Properties.Property_Int; 
  566.    Pixels_Inside_Wrap_Property : constant Glib.Properties.Property_Int; 
  567.    Right_Margin_Property       : constant Glib.Properties.Property_Int; 
  568.    --  Tabs_Property           : constant Glib.Properties.Property_Boxed; 
  569.    Wrap_Mode_Property          : constant Gtk.Enums.Property_Gtk_Wrap_Mode; 
  570.  
  571.    ---------------------- 
  572.    -- Style Properties -- 
  573.    ---------------------- 
  574.    --  The following properties can be changed through the gtk theme and 
  575.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  576.  
  577.    --  <style_properties> 
  578.    --  Name:  Error_Underline_Color_Property 
  579.    --  Type:  Boxed 
  580.    --  Descr: Color with which to draw error-indication underlines 
  581.    --  </style_properties> 
  582.  
  583.    --  Error_Underline_Color_Property : constant 
  584.    --    Glib.Properties.Property_Boxed; 
  585.  
  586.    ------------- 
  587.    -- Signals -- 
  588.    ------------- 
  589.  
  590.    --  <signals> 
  591.    --  The following new signals are defined for this widget: 
  592.    -- 
  593.    --  - "set_scroll_adjustments" 
  594.    --    procedure Handler 
  595.    --      (Widget      : access Gtk_Text_View_Record'Class; 
  596.    --       Hadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class; 
  597.    --       Vadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  598.    -- 
  599.    --  - "populate_popup" 
  600.    --    procedure Handler 
  601.    --      (Widget : access Gtk_Text_View_Record'Class; 
  602.    --       Menu   : access Gtk.Menu.Gtk_Menu_Record'Class); 
  603.    -- 
  604.    --  - "move_cursor" 
  605.    --    procedure Handler 
  606.    --      (Widget           : access Gtk_Text_View_Record'Class; 
  607.    --       Step             : Gtk_Movement_Step; 
  608.    --       Count            : Gint; 
  609.    --       Extend_Selection : Boolean); 
  610.    -- 
  611.    --  - "set_anchor" 
  612.    --    procedure Handler (Widget : access Gtk_Text_View_Record'Class); 
  613.    -- 
  614.    --  - "insert_at_cursor" 
  615.    --    procedure Handler 
  616.    --      (Widget : access Gtk_Text_View_Record'Class; Str : UTF8_String); 
  617.    -- 
  618.    --  - "delete_from_cursor" 
  619.    --    procedure Handler 
  620.    --      (Widget   : access Gtk_Text_View_Record'Class; 
  621.    --       The_Type : Gtk_Delete_Type; 
  622.    --       Count    : Gint); 
  623.    -- 
  624.    --  - "cut_clipboard" 
  625.    --    procedure Handler (Widget : access Gtk_Text_View_Record'Class); 
  626.    -- 
  627.    --  - "copy_clipboard" 
  628.    --    procedure Handler (Widget : access Gtk_Text_View_Record'Class); 
  629.    -- 
  630.    --  - "paste_clipboard" 
  631.    --    procedure Handler (Widget : access Gtk_Text_View_Record'Class); 
  632.    -- 
  633.    --  - "toggle_overwrite" 
  634.    --    procedure Handler (Widget : access Gtk_Text_View_Record'Class); 
  635.    -- 
  636.    --  </signals> 
  637.  
  638.    Signal_Backspace              : constant Glib.Signal_Name := 
  639.                                      "backspace"; 
  640.    Signal_Copy_Clipboard         : constant Glib.Signal_Name := 
  641.                                      "copy_clipboard"; 
  642.    Signal_Cut_Clipboard          : constant Glib.Signal_Name := 
  643.                                      "cut_clipboard"; 
  644.    Signal_Delete_From_Cursor     : constant Glib.Signal_Name := 
  645.                                      "delete_from_cursor"; 
  646.    Signal_Insert_At_Cursor       : constant Glib.Signal_Name := 
  647.                                      "insert_at_cursor"; 
  648.    Signal_Move_Cursor            : constant Glib.Signal_Name := 
  649.                                      "move_cursor"; 
  650.    Signal_Move_Focus             : constant Glib.Signal_Name := 
  651.                                      "move_focus"; 
  652.    Signal_Move_Viewport          : constant Glib.Signal_Name := 
  653.                                      "move_viewport"; 
  654.    Signal_Page_Horizontally      : constant Glib.Signal_Name := 
  655.                                      "page_horizontally"; 
  656.    Signal_Paste_Clipboard        : constant Glib.Signal_Name := 
  657.                                      "paste_clipboard"; 
  658.    Signal_Populate_Popup         : constant Glib.Signal_Name := 
  659.                                      "populate_popup"; 
  660.    Signal_Select_All             : constant Glib.Signal_Name := 
  661.                                      "select_all"; 
  662.    Signal_Set_Anchor             : constant Glib.Signal_Name := 
  663.                                      "set_anchor"; 
  664.    Signal_Set_Scroll_Adjustments : constant Glib.Signal_Name := 
  665.                                      "set_scroll_adjustments"; 
  666.    Signal_Toggle_Overwrite       : constant Glib.Signal_Name := 
  667.                                      "toggle_overwrite"; 
  668.  
  669. private 
  670.    type Gtk_Text_View_Record is new Gtk.Container.Gtk_Container_Record with 
  671.      null record; 
  672.  
  673.    Accepts_Tab_Property : constant Glib.Properties.Property_Boolean := 
  674.      Glib.Properties.Build ("accepts-tab"); 
  675.    Buffer_Property : constant Glib.Properties.Property_Object := 
  676.      Glib.Properties.Build ("buffer"); 
  677.    Cursor_Visible_Property : constant Glib.Properties.Property_Boolean := 
  678.      Glib.Properties.Build ("cursor-visible"); 
  679.    Editable_Property : constant Glib.Properties.Property_Boolean := 
  680.      Glib.Properties.Build ("editable"); 
  681.    Indent_Property : constant Glib.Properties.Property_Int := 
  682.      Glib.Properties.Build ("indent"); 
  683.    Justification_Property : constant Gtk.Enums.Property_Gtk_Justification := 
  684.      Gtk.Enums.Build ("justification"); 
  685.    Left_Margin_Property : constant Glib.Properties.Property_Int := 
  686.      Glib.Properties.Build ("left-margin"); 
  687.    Overwrite_Property : constant Glib.Properties.Property_Boolean := 
  688.      Glib.Properties.Build ("overwrite"); 
  689.    Pixels_Above_Lines_Property : constant Glib.Properties.Property_Int := 
  690.      Glib.Properties.Build ("pixels-above-lines"); 
  691.    Pixels_Below_Lines_Property : constant Glib.Properties.Property_Int := 
  692.      Glib.Properties.Build ("pixels-below-lines"); 
  693.    Pixels_Inside_Wrap_Property : constant Glib.Properties.Property_Int := 
  694.      Glib.Properties.Build ("pixels-inside-wrap"); 
  695.    Right_Margin_Property : constant Glib.Properties.Property_Int := 
  696.      Glib.Properties.Build ("right-margin"); 
  697. --     Tabs_Property : constant Glib.Properties.Property_Boxed := 
  698. --       Glib.Properties.Build ("tabs"); 
  699.    Wrap_Mode_Property : constant Gtk.Enums.Property_Gtk_Wrap_Mode := 
  700.      Gtk.Enums.Build ("wrap-mode"); 
  701.  
  702. --     Error_Underline_Color_Property : constant Glib.Properties.Property_Boxed 
  703. --       := Glib.Properties.Build ("error-underline-color"); 
  704.  
  705.    pragma Import (C, Get_Type, "gtk_text_view_get_type"); 
  706. end Gtk.Text_View; 
  707.  
  708. --  No binding: gtk_text_view_new 
  709.  
  710. --  <example> 
  711. --  --  The following example creates an empty text view, and puts it in a 
  712. --  --  scrolling area so that if more text is added, scrollbars are created 
  713. --  --  automatically. 
  714. -- 
  715. --  declare 
  716. --     View     : Gtk_Text_View; 
  717. --     Buffer   : Gtk_Text_Buffer; 
  718. --     Scrolled : Gtk_Scrolled_Window; 
  719. --  begin 
  720. --     Gtk_New (Scrolled); 
  721. --     Set_Policy (Scrolled, Policy_Automatic, Policy_Automatic); 
  722. --     Gtk_New (Buffer); 
  723. --     Gtk_New (View, Buffer); 
  724. --     Add (Scrolled, View); 
  725. --  end; 
  726. --  </example>