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