1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  You may wish to begin by reading the <link linkend="TextWidget">text 
  26. --  widget conceptual overview</link> which gives an overview of all the 
  27. --  objects and data types related to the text widget and how they work 
  28. --  together. 
  29. -- 
  30. --  A Gtk.Text_Mark.Gtk_Text_Mark is like a bookmark in a text buffer; it 
  31. --  preserves a position in the text. You can convert the mark to an iterator 
  32. --  using Gtk.Text_Buffer.Get_Iter_At_Mark. Unlike iterators, marks remain 
  33. --  valid across buffer mutations, because their behavior is defined when text 
  34. --  is inserted or deleted. When text containing a mark is deleted, the mark 
  35. --  remains in the position originally occupied by the deleted text. When text 
  36. --  is inserted at a mark, a mark with 'left gravity' will be moved to the 
  37. --  beginning of the newly-inserted text, and a mark with 'right gravity' will 
  38. --  be moved to the end. 
  39. -- 
  40. --  [ "left" and "right" here refer to logical direction (left is the toward 
  41. --  the start of the buffer); in some languages such as Hebrew the 
  42. --  logically-leftmost text is not actually on the left when displayed. ] 
  43. -- 
  44. --  Marks are reference counted, but the reference count only controls the 
  45. --  validity of the memory; marks can be deleted from the buffer at any time 
  46. --  with Gtk.Text_Buffer.Delete_Mark. Once deleted from the buffer, a mark is 
  47. --  essentially useless. 
  48. -- 
  49. --  Marks optionally have names; these can be convenient to avoid passing the 
  50. --  Gtk.Text_Mark.Gtk_Text_Mark object around. 
  51. -- 
  52. --  Marks are typically created using the Gtk.Text_Buffer.Create_Mark 
  53. --  function. 
  54. -- 
  55. --  </description> 
  56. pragma Ada_2005; 
  57.  
  58. pragma Warnings (Off, "*is already use-visible*"); 
  59. with Glib;            use Glib; 
  60. with Glib.Object;     use Glib.Object; 
  61. with Glib.Properties; use Glib.Properties; 
  62. with Glib.Values;     use Glib.Values; 
  63.  
  64. package Gtk.Text_Mark is 
  65.  
  66.    type Gtk_Text_Mark_Record is new GObject_Record with null record; 
  67.    type Gtk_Text_Mark is access all Gtk_Text_Mark_Record'Class; 
  68.  
  69.    ------------------ 
  70.    -- Constructors -- 
  71.    ------------------ 
  72.  
  73.    procedure Gtk_New 
  74.       (Mark         : out Gtk_Text_Mark; 
  75.        Name         : UTF8_String := ""; 
  76.        Left_Gravity : Boolean); 
  77.    procedure Initialize 
  78.       (Mark         : not null access Gtk_Text_Mark_Record'Class; 
  79.        Name         : UTF8_String := ""; 
  80.        Left_Gravity : Boolean); 
  81.    --  Creates a text mark. Add it to a buffer using Gtk.Text_Buffer.Add_Mark. 
  82.    --  If Name is null, the mark is anonymous; otherwise, the mark can be 
  83.    --  retrieved by name using Gtk.Text_Buffer.Get_Mark. If a mark has left 
  84.    --  gravity, and text is inserted at the mark's current location, the mark 
  85.    --  will be moved to the left of the newly-inserted text. If the mark has 
  86.    --  right gravity (Left_Gravity = False), the mark will end up on the right 
  87.    --  of newly-inserted text. The standard left-to-right cursor is a mark with 
  88.    --  right gravity (when you type, the cursor stays on the right side of the 
  89.    --  text you're typing). 
  90.    --  Since: gtk+ 2.12 
  91.    --  "name": mark name or null 
  92.    --  "left_gravity": whether the mark should have left gravity 
  93.  
  94.    function Gtk_Text_Mark_New 
  95.       (Name         : UTF8_String := ""; 
  96.        Left_Gravity : Boolean) return Gtk_Text_Mark; 
  97.    --  Creates a text mark. Add it to a buffer using Gtk.Text_Buffer.Add_Mark. 
  98.    --  If Name is null, the mark is anonymous; otherwise, the mark can be 
  99.    --  retrieved by name using Gtk.Text_Buffer.Get_Mark. If a mark has left 
  100.    --  gravity, and text is inserted at the mark's current location, the mark 
  101.    --  will be moved to the left of the newly-inserted text. If the mark has 
  102.    --  right gravity (Left_Gravity = False), the mark will end up on the right 
  103.    --  of newly-inserted text. The standard left-to-right cursor is a mark with 
  104.    --  right gravity (when you type, the cursor stays on the right side of the 
  105.    --  text you're typing). 
  106.    --  Since: gtk+ 2.12 
  107.    --  "name": mark name or null 
  108.    --  "left_gravity": whether the mark should have left gravity 
  109.  
  110.    function Get_Type return Glib.GType; 
  111.    pragma Import (C, Get_Type, "gtk_text_mark_get_type"); 
  112.  
  113.    ------------- 
  114.    -- Methods -- 
  115.    ------------- 
  116.  
  117.    function Get_Deleted 
  118.       (Mark : not null access Gtk_Text_Mark_Record) return Boolean; 
  119.    --  Returns True if the mark has been removed from its buffer with 
  120.    --  Gtk.Text_Buffer.Delete_Mark. See Gtk.Text_Buffer.Add_Mark for a way to 
  121.    --  add it to a buffer again. 
  122.  
  123.    function Get_Left_Gravity 
  124.       (Mark : not null access Gtk_Text_Mark_Record) return Boolean; 
  125.    --  Determines whether the mark has left gravity. 
  126.  
  127.    function Get_Name 
  128.       (Mark : not null access Gtk_Text_Mark_Record) return UTF8_String; 
  129.    --  Returns the mark name; returns NULL for anonymous marks. 
  130.  
  131.    function Get_Visible 
  132.       (Mark : not null access Gtk_Text_Mark_Record) return Boolean; 
  133.    --  Returns True if the mark is visible (i.e. a cursor is displayed for 
  134.    --  it). 
  135.  
  136.    procedure Set_Visible 
  137.       (Mark    : not null access Gtk_Text_Mark_Record; 
  138.        Setting : Boolean); 
  139.    --  Sets the visibility of Mark; the insertion point is normally visible, 
  140.    --  i.e. you can see it as a vertical bar. Also, the text widget uses a 
  141.    --  visible mark to indicate where a drop will occur when 
  142.    --  dragging-and-dropping text. Most other marks are not visible. Marks are 
  143.    --  not visible by default. 
  144.    --  "setting": visibility of mark 
  145.  
  146.    ---------------------- 
  147.    -- GtkAda additions -- 
  148.    ---------------------- 
  149.  
  150.    ------------------------------- 
  151.    -- Converting to/from GValue -- 
  152.    ------------------------------- 
  153.  
  154.    procedure Set_Text_Mark 
  155.      (Val  : in out Glib.Values.GValue; 
  156.       Mark : access Gtk_Text_Mark_Record); 
  157.    function Get_Text_Mark (Val : Glib.Values.GValue) return Gtk_Text_Mark; 
  158.    --  Set the value of the given GValue to Mark. 
  159.  
  160.    ---------------- 
  161.    -- Properties -- 
  162.    ---------------- 
  163.    --  The following properties are defined for this widget. See 
  164.    --  Glib.Properties for more information on properties) 
  165.  
  166.    Left_Gravity_Property : constant Glib.Properties.Property_Boolean; 
  167.  
  168.    Name_Property : constant Glib.Properties.Property_String; 
  169.  
  170. private 
  171.    Name_Property : constant Glib.Properties.Property_String := 
  172.      Glib.Properties.Build ("name"); 
  173.    Left_Gravity_Property : constant Glib.Properties.Property_Boolean := 
  174.      Glib.Properties.Build ("left-gravity"); 
  175. end Gtk.Text_Mark;