1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2001-2013, 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. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  This is the public representation of a text buffer to be used in 
  31. --  coordination with Gtk.Text_View. 
  32. --  </description> 
  33. --  <c_version>2.8.17</c_version> 
  34. --  <group>Multiline Text Editor</group> 
  35.  
  36. with Glib.Properties; 
  37. with Gdk.Pixbuf; 
  38. with Gtk.Clipboard; 
  39. with Gtk.Text_Child; 
  40. with Gtk.Text_Iter; 
  41. with Gtk.Text_Mark; 
  42. with Gtk.Text_Tag; 
  43. with Gtk.Text_Tag_Table; 
  44. with Gtkada.Types; 
  45.  
  46. package Gtk.Text_Buffer is 
  47.  
  48.    type Gtk_Text_Buffer_Record is new GObject_Record with private; 
  49.    type Gtk_Text_Buffer is access all Gtk_Text_Buffer_Record'Class; 
  50.  
  51.    procedure Gtk_New 
  52.      (Buffer : out Gtk_Text_Buffer; 
  53.       Table  : Gtk.Text_Tag_Table.Gtk_Text_Tag_Table := null); 
  54.    procedure Initialize 
  55.      (Buffer : access Gtk_Text_Buffer_Record'Class; 
  56.       Table  : Gtk.Text_Tag_Table.Gtk_Text_Tag_Table := null); 
  57.    --  Creates or initializes a new text buffer. 
  58.    --  Create a new table if Table is null. 
  59.    --  The buffer is created with a reference count of 1, and therefore should 
  60.    --  be manually unreferenced (Glib.Object.Unref). It is recommended to do 
  61.    --  that as soon as the buffer has been used to create a 
  62.    --  Gtk.Text_View.Gtk_Text_View widget. 
  63.  
  64.    function Get_Type return Glib.GType; 
  65.    --  Return the internal value associated with a Gtk_Text_Buffer. 
  66.  
  67.    function Get_Line_Count 
  68.      (Buffer : access Gtk_Text_Buffer_Record) return Gint; 
  69.    --  Return the number of lines in the buffer. 
  70.    --  This value is cached, so the function is very fast. 
  71.  
  72.    function Get_Char_Count 
  73.      (Buffer : access Gtk_Text_Buffer_Record) return Gint; 
  74.    --  Return the number of characters in the buffer. 
  75.    --  Note that characters and bytes are not the same, you can't e.g. expect 
  76.    --  the contents of the buffer in string form to be this many bytes long. 
  77.    --  The character count is cached, so this function is very fast. 
  78.  
  79.    --------------------------- 
  80.    -- Modifiying the buffer -- 
  81.    --------------------------- 
  82.  
  83.    procedure Set_Modified 
  84.      (Buffer  : access Gtk_Text_Buffer_Record; 
  85.       Setting : Boolean := True); 
  86.    function Get_Modified 
  87.      (Buffer : access Gtk_Text_Buffer_Record) return Boolean; 
  88.    --  Used to keep track of whether the buffer has been modified since the 
  89.    --  last time it was saved. Whenever the buffer is saved to disk, call 
  90.    --  Set_Modified (Buffer, False). When the buffer is modified, 
  91.    --  it will automatically toggled on the modified bit again. When the 
  92.    --  modified bit flips, the buffer emits a "modified_changed" signal. 
  93.  
  94.    procedure Set_Text 
  95.      (Buffer : access Gtk_Text_Buffer_Record; 
  96.       Text   : UTF8_String); 
  97.    --  Delete current contents of Buffer, and insert Text instead. 
  98.    --  If Text doesn't end with a newline, a newline is added; 
  99.    --  Gtk_Text_Buffer contents must always end with a newline. If Text 
  100.    --  ends with a newline, the new buffer contents will be exactly Text. 
  101.    --  Text: UTF-8 format text to insert. 
  102.  
  103.    procedure Insert 
  104.      (Buffer : access Gtk_Text_Buffer_Record; 
  105.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  106.       Text   : UTF8_String); 
  107.    procedure Insert 
  108.      (Buffer : access Gtk_Text_Buffer_Record; 
  109.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  110.       Text   : Gtkada.Types.Chars_Ptr); 
  111.    --  Insert Text at position Iter. 
  112.    --  Emit the "insert_text" signal; insertion actually occurs 
  113.    --  in the default handler for the signal. Iter is invalidated when 
  114.    --  insertion occurs (because the buffer contents change), but the 
  115.    --  default signal handler revalidates it to point to the end of the 
  116.    --  inserted text. 
  117.    --  Text: UTF-8 format text to insert. 
  118.  
  119.    procedure Insert_With_Tags 
  120.      (Buffer : access Gtk_Text_Buffer_Record; 
  121.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  122.       Text   : UTF8_String; 
  123.       Tag    : Gtk.Text_Tag.Gtk_Text_Tag); 
  124.    procedure Insert_With_Tags 
  125.      (Buffer : access Gtk_Text_Buffer_Record; 
  126.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  127.       Text   : Gtkada.Types.Chars_Ptr; 
  128.       Tag    : Gtk.Text_Tag.Gtk_Text_Tag); 
  129.    --  Same as Insert, but specifies the tag to apply to the range. 
  130.  
  131.    procedure Insert_With_Tags_By_Name 
  132.      (Buffer   : access Gtk_Text_Buffer_Record; 
  133.       Iter     : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  134.       Text     : UTF8_String; 
  135.       Tag_Name : String); 
  136.    --  Same as Insert_With_Tags, but the tag is specified by its name 
  137.  
  138.    procedure Insert_At_Cursor 
  139.      (Buffer : access Gtk_Text_Buffer_Record; 
  140.       Text   : UTF8_String); 
  141.    --  Call Buffer_Insert, using the current cursor position 
  142.    --  as the insertion point. 
  143.    --  Text: UTF-8 format text to insert. 
  144.  
  145.    procedure Insert_At_Cursor 
  146.      (Buffer : access Gtk_Text_Buffer_Record; 
  147.       Text   : Gtkada.Types.Chars_Ptr; 
  148.       Len    : Gint := -1); 
  149.    --  Call Buffer_Insert, using the current cursor position 
  150.    --  as the insertion point. 
  151.    --  Text: UTF-8 format C string to insert. 
  152.  
  153.    procedure Insert_Interactive 
  154.      (Buffer           : access Gtk_Text_Buffer_Record; 
  155.       Iter             : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  156.       Text             : UTF8_String; 
  157.       Default_Editable : Boolean; 
  158.       Result           : out Boolean); 
  159.    --  Like Insert, but the insertion will not occur if Iter is at a 
  160.    --  non-editable location in the buffer. Usually you 
  161.    --  want to prevent insertions at ineditable locations if the insertion 
  162.    --  results from a user action (is interactive). 
  163.    -- 
  164.    --  Default_Editable indicates the editability of text that doesn't 
  165.    --  have a tag affecting editability applied to it. Typically the 
  166.    --  result of Gtk.Text_View.Get_Editable is appropriate here. 
  167.    --  Text: UTF-8 format text to insert. 
  168.    --  Result: whether text was actually inserted. 
  169.  
  170.    function Insert_Interactive_At_Cursor 
  171.      (Buffer           : access Gtk_Text_Buffer_Record; 
  172.       Text             : UTF8_String; 
  173.       Default_Editable : Boolean) return Boolean; 
  174.    --  Call Insert_Interactive at the cursor position. 
  175.    --  Text: UTF-8 format text to insert. 
  176.    --  Return value: whether text was actually inserted. 
  177.  
  178.    procedure Insert_Range 
  179.      (Buffer  : access Gtk_Text_Buffer_Record; 
  180.       Iter    : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  181.       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  182.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  183.    --  Copy text, tags, and pixbufs between Start and End. 
  184.    --  The order of Start and End doesn't matter. 
  185.    --  Also insert the copy at Iter. 
  186.    --  Used instead of simply getting/inserting text because it preserves 
  187.    --  images and tags. If Start and End are in a different buffer from 
  188.    --  Buffer, the two buffers must share the same tag table. 
  189.    --  Implemented via emissions of the insert_text and apply_tag signals, 
  190.    --  so expect those. 
  191.  
  192.    procedure Insert_Range_Interactive 
  193.      (Buffer           : access Gtk_Text_Buffer_Record; 
  194.       Iter             : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  195.       Start            : Gtk.Text_Iter.Gtk_Text_Iter; 
  196.       The_End          : Gtk.Text_Iter.Gtk_Text_Iter; 
  197.       Default_Editable : Boolean; 
  198.       Result           : out Boolean); 
  199.    --  Like Insert_Range, does nothing if the insertion point isn't editable. 
  200.    --  The Default_Editable parameter indicates whether the text is editable at 
  201.    --  Iter if no tags enclosing Iter affect editability. Typically the result 
  202.    --  of Gtk.Text_View.Get_Editable is appropriate here. 
  203.    --  Result: whether an insertion was possible at Iter 
  204.  
  205.    procedure Insert_Pixbuf 
  206.      (Buffer : access Gtk_Text_Buffer_Record; 
  207.       Iter   : Gtk.Text_Iter.Gtk_Text_Iter; 
  208.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  209.    --  Insert an image into the text buffer at Iter. 
  210.    --  The image will be counted as one character in character counts, and when 
  211.    --  obtaining the buffer contents as a string, will be represented by the 
  212.    --  Unicode "object replacement character" 16#FFFC#. Note that the "slice" 
  213.    --  variants for obtaining portions of the buffer as a string include 
  214.    --  this character for pixbufs, but the "text" variants do not. e.g. see 
  215.    --  Get_Slice and Get_Text. 
  216.  
  217.    procedure Delete 
  218.      (Buffer  : access Gtk_Text_Buffer_Record; 
  219.       Start   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  220.       The_End : in out Gtk.Text_Iter.Gtk_Text_Iter); 
  221.    --  Delete text between Start and End. 
  222.    --  The order of Start and End is not actually relevant; 
  223.    --  Delete will reorder them. This function actually emits the 
  224.    --  "delete_range" signal, and the default handler of that signal deletes 
  225.    --  the text. Because the buffer is modified, all outstanding iterators 
  226.    --  become invalid after calling this function; however, the Start and End 
  227.    --  will be re-initialized to point to the location where text was deleted. 
  228.    -- 
  229.    --  Note that the final newline in the buffer may not be deleted; a 
  230.    --  Gtk_Text_Buffer always contains at least one newline. You can 
  231.    --  safely include the final newline in the range [Start,End) but it 
  232.    --  won't be affected by the deletion. 
  233.  
  234.    procedure Delete_Interactive 
  235.      (Buffer           : access Gtk_Text_Buffer_Record; 
  236.       Start_Iter       : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  237.       End_Iter         : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  238.       Default_Editable : Boolean; 
  239.       Result           : out Boolean); 
  240.    --  Delete all editable text in the given range. 
  241.    --  Call Delete for each editable sub-range of [Start,End). Start and End 
  242.    --  are revalidated to point to the location of the last deleted range, or 
  243.    --  left untouched if no text was deleted. 
  244.    --  Result: whether some text was actually deleted 
  245.  
  246.    function Backspace 
  247.      (Buffer           : access Gtk_Text_Buffer_Record; 
  248.       Iter             : Gtk.Text_Iter.Gtk_Text_Iter; 
  249.       Interactive      : Boolean; 
  250.       Default_Editable : Boolean) 
  251.       return Boolean; 
  252.    --  Performs the appropriate action as if the user hit the delete key with 
  253.    --  the cursor at the position specified by Iter. In the normal case a 
  254.    --  single character will be deleted, but when combining accents are 
  255.    --  involved, more than one character can be deleted, and when precomposed 
  256.    --  character and accent combinations are involved, less than one character 
  257.    --  will be deleted. 
  258.    --  Because the buffer is modified, all outstanding iterators become invalid 
  259.    --  after calling this function; however, Iter will be re-initialized to 
  260.    --  point to the location where text was deleted. 
  261.    --  Interactive should be true if the deletion is caused by user 
  262.    --  interaction. 
  263.    --  Default_Editable: Whether the buffer is editable by default. 
  264.    --  Returns True if the buffer was modified. 
  265.  
  266.    --------------------------------- 
  267.    -- Reading the buffer contents -- 
  268.    --------------------------------- 
  269.  
  270.    function Get_Text 
  271.      (Buffer               : access Gtk_Text_Buffer_Record; 
  272.       Start                : Gtk.Text_Iter.Gtk_Text_Iter; 
  273.       The_End              : Gtk.Text_Iter.Gtk_Text_Iter; 
  274.       Include_Hidden_Chars : Boolean := False) return UTF8_String; 
  275.    --  Return the text in the range [Start,End). 
  276.    --  Exclude undisplayed text (text marked with tags that set the 
  277.    --  invisibility attribute) if Include_Hidden_Chars is False. Does not 
  278.    --  include characters representing embedded images, so byte and character 
  279.    --  indexes into the returned string do not correspond to byte and character 
  280.    --  indexes into the buffer. Contrast with Get_Slice. 
  281.    --  Return value: an allocated UTF-8 string 
  282.  
  283.    function Get_Text 
  284.      (Buffer               : access Gtk_Text_Buffer_Record; 
  285.       Start                : Gtk.Text_Iter.Gtk_Text_Iter; 
  286.       The_End              : Gtk.Text_Iter.Gtk_Text_Iter; 
  287.       Include_Hidden_Chars : Boolean := False) return Gtkada.Types.Chars_Ptr; 
  288.    --  Same as Get_Text above, but return a pointer to a C string, for 
  289.    --  efficiency. 
  290.    --  The caller is responsible for freeing (using Gtkada.Types.g_free) the 
  291.    --  returned pointer. 
  292.  
  293.    function Get_Slice 
  294.      (Buffer               : access Gtk_Text_Buffer_Record; 
  295.       Start                : Gtk.Text_Iter.Gtk_Text_Iter; 
  296.       The_End              : Gtk.Text_Iter.Gtk_Text_Iter; 
  297.       Include_Hidden_Chars : Boolean := False) return UTF8_String; 
  298.    --  Return the text in the range [Start,End). 
  299.    --  Exclude undisplayed text (text marked with tags that set the 
  300.    --  invisibility attribute) if Include_Hidden_Chars is False. The returned 
  301.    --  string includes a 16#FFFC# character whenever the buffer contains 
  302.    --  embedded images, so byte and character indexes into 
  303.    --  the returned string do correspond to byte and character indexes into 
  304.    --  the buffer. Contrast with Get_Text. Note that 16#FFFC# can occur in 
  305.    --  normal text as well, so it is not a reliable indicator that a pixbuf or 
  306.    --  widget is in the buffer. 
  307.    --  Return value: an allocated UTF-8 string 
  308.  
  309.    function Get_Slice 
  310.      (Buffer               : access Gtk_Text_Buffer_Record; 
  311.       Start                : Gtk.Text_Iter.Gtk_Text_Iter; 
  312.       The_End              : Gtk.Text_Iter.Gtk_Text_Iter; 
  313.       Include_Hidden_Chars : Boolean := False) return Gtkada.Types.Chars_Ptr; 
  314.    --  Same as Get_Slice above, but return a pointer to a C string, for 
  315.    --  efficiency. 
  316.    --  The caller is responsible for freeing (using Gtkada.Types.g_free) the 
  317.    --  returned pointer. 
  318.  
  319.    ----------- 
  320.    -- Marks -- 
  321.    ----------- 
  322.    --  See Gtk.Text_Mark 
  323.  
  324.    function Create_Mark 
  325.      (Buffer       : access Gtk_Text_Buffer_Record; 
  326.       Mark_Name    : String := ""; 
  327.       Where        : Gtk.Text_Iter.Gtk_Text_Iter; 
  328.       Left_Gravity : Boolean := True) return Gtk.Text_Mark.Gtk_Text_Mark; 
  329.    --  Create a mark at position Where. 
  330.    --  If Mark_Name is null, the mark is anonymous; otherwise, the mark can be 
  331.    --  retrieved by name using Get_Mark. If a mark has left gravity, and text 
  332.    --  is inserted at the mark's current location, the mark will be moved to 
  333.    --  the left of the newly-inserted text. If the mark has right gravity 
  334.    --  (Left_Gravity = False), the mark will end up on the right of 
  335.    --  newly-inserted text. The standard left-to-right cursor is a mark 
  336.    --  with right gravity (when you type, the cursor stays on the right 
  337.    --  side of the text you're typing). 
  338.    -- 
  339.    --  The caller of this function does not own a reference to the returned 
  340.    --  Gtk_Text_Mark, so you can ignore the return value if you like. Marks are 
  341.    --  owned by the buffer and go away when the buffer does. 
  342.    --  Emit the "mark_set" signal as notification of the mark's initial 
  343.    --  placement. 
  344.    -- 
  345.    --  Return value: the new Gtk_Text_Mark object. 
  346.  
  347.    procedure Move_Mark 
  348.      (Buffer : access Gtk_Text_Buffer_Record; 
  349.       Mark   : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class; 
  350.       Where  : Gtk.Text_Iter.Gtk_Text_Iter); 
  351.    --  Move Mark to the new location Where. 
  352.    --  Emit the "mark_set" signal as notification of the move. 
  353.  
  354.    procedure Delete_Mark 
  355.      (Buffer : access Gtk_Text_Buffer_Record; 
  356.       Mark   : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class); 
  357.    --  Delete Mark, so that it's no longer located anywhere in the 
  358.    --  buffer. Remove the reference the buffer holds to the mark, so if 
  359.    --  you haven't called Ref on the mark, it will be freed. Even 
  360.    --  if the mark isn't freed, most operations on Mark become 
  361.    --  invalid. There is no way to undelete a mark. 
  362.    --  Gtk.Text_Mark.Get_Deleted will return True after this 
  363.    --  function has been called on a mark; Gtk.Text_Mark.Get_Deleted 
  364.    --  indicates that a mark no longer belongs to a buffer. The "mark_deleted" 
  365.    --  signal will be emitted as notification after the mark is deleted. 
  366.  
  367.    function Get_Mark 
  368.      (Buffer : access Gtk_Text_Buffer_Record; 
  369.       Name   : String) return Gtk.Text_Mark.Gtk_Text_Mark; 
  370.    --  Return the mark named Name in Buffer 
  371.    --  or null if no such mark exists in the buffer. 
  372.  
  373.    procedure Move_Mark_By_Name 
  374.      (Buffer : access Gtk_Text_Buffer_Record; 
  375.       Name   : String; 
  376.       Where  : Gtk.Text_Iter.Gtk_Text_Iter); 
  377.    --  Move the mark named Name (which must exist) to location Where. 
  378.    --  See Move_Mark for details. 
  379.  
  380.    procedure Delete_Mark_By_Name 
  381.      (Buffer : access Gtk_Text_Buffer_Record; 
  382.       Name   : String); 
  383.    --  Delete the mark named Name 
  384.    --  The mark must exist. See Delete_Mark for details. 
  385.  
  386.    function Get_Insert 
  387.      (Buffer : access Gtk_Text_Buffer_Record) 
  388.       return Gtk.Text_Mark.Gtk_Text_Mark; 
  389.    --  Return the mark that represents the cursor (insertion point). 
  390.    --  Equivalent to calling Get_Mark to get the mark name "insert", but 
  391.    --  slightly more efficient, and involves less typing. 
  392.  
  393.    function Get_Selection_Bound 
  394.      (Buffer : access Gtk_Text_Buffer_Record) 
  395.       return Gtk.Text_Mark.Gtk_Text_Mark; 
  396.    --  Return the mark that represents the selection bound. 
  397.    --  Equivalent to calling Get_Mark to get the mark name "selection_bound", 
  398.    --  but very slightly more efficient, and involves less typing. 
  399.    -- 
  400.    --  The currently-selected text in Buffer is the region between the 
  401.    --  "selection_bound" and "insert" marks. If "selection_bound" and 
  402.    --  "insert" are in the same place, then there is no current selection. 
  403.    --  Get_Selection_Bounds is another convenient function for handling the 
  404.    --  selection, if you just want to know whether there's a selection and what 
  405.    --  its bounds are. 
  406.  
  407.    function Get_Buffer 
  408.      (Mark : Gtk.Text_Mark.Gtk_Text_Mark) return Gtk_Text_Buffer; 
  409.    --  Return the buffer associated to the given mark 
  410.  
  411.    ------------ 
  412.    -- Cursor -- 
  413.    ------------ 
  414.    --  The cursor is a special mark in the buffer 
  415.  
  416.    procedure Place_Cursor 
  417.      (Buffer : access Gtk_Text_Buffer_Record; 
  418.       Where  : Gtk.Text_Iter.Gtk_Text_Iter); 
  419.    --  Move the "insert" and "selection_bound" marks simultaneously. 
  420.    --  If you move them to the same place in two steps with Move_Mark, you will 
  421.    --  temporarily select a region in between their old and new locations, 
  422.    --  which can be pretty inefficient since the temporarily-selected region 
  423.    --  will force stuff to be recomputed. This function moves them as a unit, 
  424.    --  which can be optimized. 
  425.    -- 
  426.    --  If you want to get the position of the cursor, the simplest way is 
  427.    --      Get_Iter_At_Mark (Buffer, Iter, Get_Insert (Buffer)); 
  428.  
  429.    --  gtk_text_buffer_create_tag not bound: variable number of arguments 
  430.    --  ??? Discuss this with the Gtk+ team. 
  431.    --  equivalent to Gtk_New + Gtk.Text_Tag_Table.Add 
  432.  
  433.    ---------- 
  434.    -- Tags -- 
  435.    ---------- 
  436.    --  Tags can be applied to change the properties of a range of text 
  437.  
  438.    function Create_Tag 
  439.      (Buffer              : access Gtk_Text_Buffer_Record; 
  440.       Tag_Name            : String := "") 
  441.       return Gtk.Text_Tag.Gtk_Text_Tag; 
  442.    --  Creates a tag and adds it to the tag table for Buffer. Equivalent to 
  443.    --  calling gtk.text_tag.gtk_new and then adding the tag to the buffer's tag 
  444.    --  table. The returned tag is owned by the buffer's tag table, so the ref 
  445.    --  count will be equal to one. 
  446.    -- 
  447.    --  If Tag_Name is NULL, the tag is anonymous, otherwise a tag called 
  448.    --  Tag_Name must not already exist in the tag table for this buffer. 
  449.  
  450.    function Get_Tag_Table 
  451.      (Buffer : access Gtk_Text_Buffer_Record) 
  452.       return Gtk.Text_Tag_Table.Gtk_Text_Tag_Table; 
  453.    --  Get the Gtk_Text_Tag_Table associated with this buffer. 
  454.  
  455.    procedure Apply_Tag 
  456.      (Buffer  : access Gtk_Text_Buffer_Record; 
  457.       Tag     : access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  458.       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  459.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  460.    --  Emit the "apply_tag" signal on Buffer. 
  461.    --  The default handler for the signal applies Tag to the given range. 
  462.    --  Start and End do not have to be in order. 
  463.  
  464.    procedure Remove_Tag 
  465.      (Buffer  : access Gtk_Text_Buffer_Record; 
  466.       Tag     : access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  467.       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  468.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  469.    --  Emit the "remove_tag" signal. 
  470.    --  The default handler for the signal removes all occurrences of Tag from 
  471.    --  the given range. Start and End don't have to be in order. 
  472.  
  473.    procedure Remove_All_Tags 
  474.      (Buffer  : access Gtk_Text_Buffer_Record; 
  475.       Start    : Gtk.Text_Iter.Gtk_Text_Iter; 
  476.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  477.    --  Remove all tags in the range between Start and End. 
  478.    --  Note that this procedure should be used carefully, as it might be 
  479.    --  removing tags that were added from another section of the code. 
  480.  
  481.    procedure Apply_Tag_By_Name 
  482.      (Buffer  : access Gtk_Text_Buffer_Record; 
  483.       Name    : String; 
  484.       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  485.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  486.    --  Call Gtk.Text_Tag_Table.Lookup on the buffer's tag table to 
  487.    --  get a Gtk_Text_Tag, then call Apply_Tag. 
  488.  
  489.    procedure Remove_Tag_By_Name 
  490.      (Buffer  : access Gtk_Text_Buffer_Record; 
  491.       Name    : String; 
  492.       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  493.       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  494.    --  Call Gtk.Text_Tag_Table.Lookup on the buffer's tag table to 
  495.    --  get a Gtk_Text_Tag, then call Remove_Tag. 
  496.  
  497.    --------------- 
  498.    -- Iterators -- 
  499.    --------------- 
  500.  
  501.    procedure Get_Iter_At_Line_Offset 
  502.      (Buffer      : access Gtk_Text_Buffer_Record; 
  503.       Iter        : out Gtk.Text_Iter.Gtk_Text_Iter; 
  504.       Line_Number : Gint; 
  505.       Char_Offset : Gint := 0); 
  506.    --  Obtain an iterator pointing to Char_Offset within the given line. The 
  507.    --  Char_Offset must exist, offsets off the end of the line are not allowed. 
  508.    --  Note characters, not bytes; UTF-8 may encode one character as multiple 
  509.    --  bytes. 
  510.    --  If the Line_Number is an existing line but the Char_Offset is past the 
  511.    --  last offset, the iter pointing at the beginning of the line is returned. 
  512.    --  If the Line_Number is not valid, the behavior is undetermined. 
  513.  
  514.    procedure Get_Iter_At_Line_Index 
  515.      (Buffer      : access Gtk_Text_Buffer_Record; 
  516.       Iter        : out Gtk.Text_Iter.Gtk_Text_Iter; 
  517.       Line_Number : Gint; 
  518.       Byte_Index  : Gint := 0); 
  519.    --  Obtain an iterator pointing to Byte_Index within the given line. 
  520.    --  Byte_Index must be the start of a UTF-8 character, and must not be 
  521.    --  beyond the end of the line. Note bytes, not characters; UTF-8 may encode 
  522.    --  one character as multiple bytes. 
  523.  
  524.    procedure Get_Iter_At_Offset 
  525.      (Buffer      : access Gtk_Text_Buffer_Record; 
  526.       Iter        : out Gtk.Text_Iter.Gtk_Text_Iter; 
  527.       Char_Offset : Gint); 
  528.    --  Initialize Iter to a position Char_Offset chars from the start of the 
  529.    --  entire buffer. 
  530.    --  Char_Offset: char offset from start of buffer, counting from 0. 
  531.  
  532.    procedure Get_Iter_At_Line 
  533.      (Buffer      : access Gtk_Text_Buffer_Record; 
  534.       Iter        : out Gtk.Text_Iter.Gtk_Text_Iter; 
  535.       Line_Number : Gint); 
  536.    --  Initialize Iter to the start of the given line. 
  537.    --  Line_Number: line number counting from 0. 
  538.  
  539.    procedure Get_Start_Iter 
  540.      (Buffer : access Gtk_Text_Buffer_Record; 
  541.       Iter   : out Gtk.Text_Iter.Gtk_Text_Iter); 
  542.    --  Initialize Iter with the first position in the text buffer. This is the 
  543.    --  same as using Get_Iter_At_Offset with Offset set to 0. 
  544.  
  545.    procedure Get_End_Iter 
  546.      (Buffer : access Gtk_Text_Buffer_Record; 
  547.       Iter   : out Gtk.Text_Iter.Gtk_Text_Iter); 
  548.    --  Initialize Iter with the "end iterator", one past the last valid 
  549.    --  character in the text buffer. If dereferenced with 
  550.    --  Gtk.Text_Iter.Get_Char, the end iterator has a character value of 0. 
  551.    --  The entire buffer lies in the range from the first position in the 
  552.    --  buffer (call Get_Iter_At_Offset to get character position 0) to the end 
  553.    --  iterator. 
  554.  
  555.    procedure Get_Bounds 
  556.      (Buffer  : access Gtk_Text_Buffer_Record; 
  557.       Start   : out Gtk.Text_Iter.Gtk_Text_Iter; 
  558.       The_End : out Gtk.Text_Iter.Gtk_Text_Iter); 
  559.    --  Retrieve the first and last iterators in the buffer. 
  560.    --  The entire buffer lies within the range [Start,End). 
  561.  
  562.    procedure Get_Iter_At_Mark 
  563.      (Buffer : access Gtk_Text_Buffer_Record; 
  564.       Iter   : out Gtk.Text_Iter.Gtk_Text_Iter; 
  565.       Mark   : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class); 
  566.    --  Initialize Iter with the current position of Mark. 
  567.  
  568.    function Get_Buffer 
  569.      (Iter : Gtk.Text_Iter.Gtk_Text_Iter) return Gtk_Text_Buffer; 
  570.    --  Return the buffer associated to the given Gtk_Text_Iterator. 
  571.  
  572.    ------------- 
  573.    -- Widgets -- 
  574.    ------------- 
  575.    --  Widgets can be put in the buffer at specific places. See 
  576.    --  Gtk.Text_Child 
  577.  
  578.    procedure Get_Iter_At_Child_Anchor 
  579.      (Buffer : access Gtk_Text_Buffer_Record; 
  580.       Iter   : out Gtk.Text_Iter.Gtk_Text_Iter; 
  581.       Anchor : access Gtk.Text_Child.Gtk_Text_Child_Anchor_Record'Class); 
  582.    --  Obtains the location of Anchor within Buffer. 
  583.  
  584.    procedure Insert_Child_Anchor 
  585.      (Buffer : access Gtk_Text_Buffer_Record; 
  586.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  587.       Anchor : access Gtk.Text_Child.Gtk_Text_Child_Anchor_Record'Class); 
  588.    --  Insert a child widget anchor into the text buffer at Iter. 
  589.    --  The anchor will be counted as one character in character counts, and 
  590.    --  when obtaining the buffer contents as a string, will be represented 
  591.    --  by the Unicode "object replacement character" 16#FFFC#. Note that the 
  592.    --  "slice" variants for obtaining portions of the buffer as a string 
  593.    --  include this character for pixbufs, but the "text" variants do 
  594.    --  not. e.g. see Get_Slice and Get_Text. Consider Create_Child_Anchor as a 
  595.    --  more convenient alternative to this function. The buffer will add a 
  596.    --  reference to the anchor, so you can unref it after insertion. 
  597.  
  598.    procedure Create_Child_Anchor 
  599.      (Buffer : access Gtk_Text_Buffer_Record; 
  600.       Iter   : in out Gtk.Text_Iter.Gtk_Text_Iter; 
  601.       Result : out Gtk.Text_Child.Gtk_Text_Child_Anchor); 
  602.    --  Convenience function which simply creates a child anchor with 
  603.    --  Gtk.Text_Child.Gtk_New and inserts it into the buffer with 
  604.    --  Insert_Child_Anchor. 
  605.    --  Result: the created child anchor. 
  606.  
  607.    ----------------------------- 
  608.    -- Clipboard and selection -- 
  609.    ----------------------------- 
  610.  
  611.    procedure Add_Selection_Clipboard 
  612.      (Buffer    : access Gtk_Text_Buffer_Record; 
  613.       Clipboard : Gtk.Clipboard.Gtk_Clipboard); 
  614.    --  Adds Clipboard to the list of clipboards in which the selection contents 
  615.    --  of Buffer are available. In most cases, Clipboard will be the clipboard 
  616.    --  corresponding to SELECTION_PRIMARY. 
  617.    --  You generally do not have to call this procedure yourself unless you are 
  618.    --  creating your own clipboards. 
  619.  
  620.    procedure Remove_Selection_Clipboard 
  621.      (Buffer    : access Gtk_Text_Buffer_Record; 
  622.       Clipboard : Gtk.Clipboard.Gtk_Clipboard); 
  623.    --  Removes a Clipboard added with Add_Selection_Clipboard 
  624.  
  625.    procedure Cut_Clipboard 
  626.      (Buffer           : access Gtk_Text_Buffer_Record; 
  627.       Clipboard        : Gtk.Clipboard.Gtk_Clipboard; 
  628.       Default_Editable : Boolean := True); 
  629.    --  Copy the currently-selected text to the clipboard, then delete 
  630.    --  it if editable. 
  631.    --  Default_Editable: default editability of the buffer. 
  632.  
  633.    procedure Copy_Clipboard 
  634.      (Buffer     : access Gtk_Text_Buffer_Record; 
  635.       Clipboard  : Gtk.Clipboard.Gtk_Clipboard); 
  636.    --  Copy the currently-selected text to the clipboard. 
  637.  
  638.    procedure Paste_Clipboard 
  639.      (Buffer            : access Gtk_Text_Buffer_Record; 
  640.       Clipboard         : Gtk.Clipboard.Gtk_Clipboard; 
  641.       Override_Location : Gtk.Text_Iter.Gtk_Text_Iter_Access := null; 
  642.       Default_Editable  : Boolean := True); 
  643.    --  Paste the clipboard contents at the insertion point, 
  644.    --  or at Override_Location if this parameter is not null. 
  645.    --  (Note: pasting is asynchronous, that is, we'll ask for the paste data 
  646.    --  and return, and at some point later after the main loop runs, the paste 
  647.    --  data will be inserted.) 
  648.  
  649.    function Selection_Exists 
  650.      (Buffer : access Gtk_Text_Buffer_Record) return Boolean; 
  651.    --  Return True if some text in the buffer is currently selected. 
  652.  
  653.    procedure Select_Range 
  654.      (Buffer : access Gtk_Text_Buffer_Record; 
  655.       Ins    : Gtk.Text_Iter.Gtk_Text_Iter; 
  656.       Bound  : Gtk.Text_Iter.Gtk_Text_Iter); 
  657.    --  This function moves the "insert" and "selection_bound" marks 
  658.    --  simultaneously. If you move them in two steps with Move_Mark, you will 
  659.    --  temporarily select region in between their old and new locations, which 
  660.    --  can be pretty inefficient since the temporarily-selected region will 
  661.    --  force stuff to be recalculated. This function moves them as a unit, 
  662.    --  which can be optimized. 
  663.  
  664.    procedure Get_Selection_Bounds 
  665.      (Buffer  : access Gtk_Text_Buffer_Record; 
  666.       Start   : out Gtk.Text_Iter.Gtk_Text_Iter; 
  667.       The_End : out Gtk.Text_Iter.Gtk_Text_Iter; 
  668.       Result  : out Boolean); 
  669.    --  Place the bounds of the selection in Start and End. If the selection 
  670.    --  has length 0, then Start and End are filled in with the same value. 
  671.    --  Start and End will be in ascending order. Result: whether the selection 
  672.    --  has nonzero length. 
  673.  
  674.    function Delete_Selection 
  675.      (Buffer           : access Gtk_Text_Buffer_Record; 
  676.       Interactive      : Boolean; 
  677.       Default_Editable : Boolean) return Boolean; 
  678.    --  Delete the range between the "insert" and "selection_bound" marks, 
  679.    --  that is, the currently-selected text. If Interactive is True, 
  680.    --  the editability of the selection will be considered (users can't delete 
  681.    --  uneditable text). 
  682.    --  Return value: whether there was a non-empty selection to delete. 
  683.  
  684.    ------------------ 
  685.    -- User actions -- 
  686.    ------------------ 
  687.  
  688.    procedure Begin_User_Action (Buffer : access Gtk_Text_Buffer_Record); 
  689.    --  Called to indicate that the buffer operations between here and a 
  690.    --  call to End_User_Action are part of a single user-visible operation. 
  691.    --  The operations between Begin_User_Action and End_User_Action can then be 
  692.    --  grouped when creating an undo stack. Gtk_Text_Buffer maintains a count 
  693.    --  of calls to Begin_User_Action that have not been closed with a call to 
  694.    --  End_User_Action, and emits the "begin_user_action" and "end_user_action" 
  695.    --  signals only for the outermost pair of calls. 
  696.    --  This allows you to build user actions from other user actions. 
  697.    -- 
  698.    --  The "interactive" buffer mutation functions, such as Insert_Interactive, 
  699.    --  automatically call begin/end user action around the buffer operations 
  700.    --  they perform, so there's no need to add extra calls if your user action 
  701.    --  consists solely of a single call to one of those functions. 
  702.  
  703.    procedure End_User_Action (Buffer : access Gtk_Text_Buffer_Record); 
  704.    --  Should be paired with a call to Begin_User_Action. 
  705.    --  See that function for a full explanation. 
  706.  
  707.    ---------------- 
  708.    -- Properties -- 
  709.    ---------------- 
  710.    --  <properties> 
  711.    --  The following properties are defined for this widget. See 
  712.    --  Glib.Properties for more information on properties. 
  713.    -- 
  714.    --  Name:  Tag_Table_Property 
  715.    --  Type:  Object 
  716.    --  Descr: Text Tag Table 
  717.    -- 
  718.    --  Name:  Text_Property 
  719.    --  Type:  String 
  720.    --  Descr: Current text of the buffer 
  721.    -- 
  722.    --  </properties> 
  723.  
  724.    Tag_Table_Property : constant Glib.Properties.Property_Object; 
  725.    Text_Property      : constant Glib.Properties.Property_String; 
  726.  
  727.    ------------- 
  728.    -- Signals -- 
  729.    ------------- 
  730.    --  <signals> 
  731.    --  The following new signals are defined for this widget: 
  732.    -- 
  733.    --  - "insert_text" 
  734.    --    procedure Handler 
  735.    --      (Widget : access Gtk_Text_Buffer_Record'Class; 
  736.    --       Pos    : Gtk.Text_Iter.Gtk_Text_Iter; 
  737.    --       Text   : UTF8_String; 
  738.    --       Length : Gint); 
  739.    -- 
  740.    --  - "insert_pixbuf" 
  741.    --    procedure Handler 
  742.    --      (Widget : access Gtk_Text_Buffer_Record'Class; 
  743.    --       Pos    : Gtk.Text_Iter.Gtk_Text_Iter; 
  744.    --       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  745.    -- 
  746.    --  - "insert_child_anchor" 
  747.    --    procedure Handler 
  748.    --      (Widget : access Gtk_Text_Buffer_Record'Class; 
  749.    --       Pos    : Gtk.Text_Iter.Gtk_Text_Iter; 
  750.    --       Anchor : access Gtk.Text_Child.Gtk_Text_Child_Anchor_Record'Class); 
  751.    -- 
  752.    --  - "delete_range" 
  753.    --    procedure Handler 
  754.    --      (Widget  : access Gtk_Text_Buffer_Record'Class; 
  755.    --       Start   : Gtk.Text_Iter.Gtk_Text_Iter; 
  756.    --       The_End : Gtk.Text_Iter.Gtk_Text_Iter); 
  757.    -- 
  758.    --  - "changed" 
  759.    --    procedure Handler (Widget : access Gtk_Text_Buffer_Record'Class); 
  760.    -- 
  761.    --  - "modified_changed" 
  762.    --    procedure Handler (Widget : access Gtk_Text_Buffer_Record'Class); 
  763.    -- 
  764.    --  - "mark_set" 
  765.    --    procedure Handler 
  766.    --      (Widget   : access Gtk_Text_Buffer_Record'Class; 
  767.    --       Location : Gtk.Text_Iter.Gtk_Text_Iter; 
  768.    --       Mark     : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class); 
  769.    -- 
  770.    --  - "mark_deleted" 
  771.    --    procedure Handler 
  772.    --      (Widget : access Gtk_Text_Buffer_Record'Class; 
  773.    --       Mark   : access Gtk.Text_Mark.Gtk_Text_Mark_Record'Class); 
  774.    -- 
  775.    --  - "apply_tag" 
  776.    --    procedure Handler 
  777.    --      (Widget     : access Gtk_Text_Buffer_Record'Class; 
  778.    --       Tag        : access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  779.    --       Start_Char : Gtk.Text_Iter.Gtk_Text_Iter; 
  780.    --       End_Char   : Gtk.Text_Iter.Gtk_Text_Iter); 
  781.    -- 
  782.    --  - "remove_tag" 
  783.    --    procedure Handler 
  784.    --      (Widget     : access Gtk_Text_Buffer_Record'Class; 
  785.    --       Tag        : access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  786.    --       Start_Char : Gtk.Text_Iter.Gtk_Text_Iter; 
  787.    --       End_Char   : Gtk.Text_Iter.Gtk_Text_Iter); 
  788.    -- 
  789.    --  - "begin_user_action" 
  790.    --    procedure Handler (Widget : access Gtk_Text_Buffer_Record'Class); 
  791.    -- 
  792.    --  - "end_user_action" 
  793.    --    procedure Handler (Widget : access Gtk_Text_Buffer_Record'Class); 
  794.    -- 
  795.    --  </signals> 
  796.  
  797.    Signal_Apply_Tag           : constant Glib.Signal_Name := 
  798.                                   "apply_tag"; 
  799.    Signal_Begin_User_Action   : constant Glib.Signal_Name := 
  800.                                   "begin_user_action"; 
  801.    Signal_Changed             : constant Glib.Signal_Name := 
  802.                                   "changed"; 
  803.    Signal_Delete_Range        : constant Glib.Signal_Name := 
  804.                                   "delete_range"; 
  805.    Signal_End_User_Action     : constant Glib.Signal_Name := 
  806.                                   "end_user_action"; 
  807.    Signal_Insert_Child_Anchor : constant Glib.Signal_Name := 
  808.                                   "insert_child_anchor"; 
  809.    Signal_Insert_Pixbuf       : constant Glib.Signal_Name := 
  810.                                   "insert_pixbuf"; 
  811.    Signal_Insert_Text         : constant Glib.Signal_Name := 
  812.                                   "insert_text"; 
  813.    Signal_Mark_Deleted        : constant Glib.Signal_Name := 
  814.                                   "mark_deleted"; 
  815.    Signal_Mark_Set            : constant Glib.Signal_Name := 
  816.                                   "mark_set"; 
  817.    Signal_Modified_Changed    : constant Glib.Signal_Name := 
  818.                                   "modified_changed"; 
  819.    Signal_Remove_Tag          : constant Glib.Signal_Name := 
  820.                                   "remove_tag"; 
  821.  
  822. private 
  823.    type Gtk_Text_Buffer_Record is new GObject_Record with null record; 
  824.  
  825.    Tag_Table_Property : constant Glib.Properties.Property_Object := 
  826.      Glib.Properties.Build ("tag-table"); 
  827.    Text_Property : constant Glib.Properties.Property_String := 
  828.      Glib.Properties.Build ("text"); 
  829.  
  830.    pragma Import (C, Get_Type, "gtk_text_buffer_get_type"); 
  831. end Gtk.Text_Buffer; 
  832.  
  833. --  No binding: gtk_text_buffer_create_tag 
  834. --  No binding: gtk_text_buffer_insert_with_tags 
  835. --  No binding: gtk_text_buffer_insert_with_tags_by_name