summaryrefslogtreecommitdiff
path: root/src/fltk_binding/fltk-text_buffers.ads
blob: aa6a49f9155a9ee9a86223a6147d2d576bb830f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81


private with Ada.Containers.Vectors;
private with System.Address_To_Access_Conversions;


package FLTK.Text_Buffers is


    type Text_Buffer is new Wrapper with private;
    type Text_Buffer_Cursor (Data : access Text_Buffer'Class) is limited null record
        with Implicit_Dereference => Data;


    type Position is new Natural;


    type Modification is (Insert, Restyle, Delete);
    type Modify_Callback is interface;
    procedure Call
           (This         : in Modify_Callback;
            Action       : in Modification;
            Place        : in Position;
            Length       : in Natural;
            Deleted_Text : in String) is abstract;


    type Predelete_Callback is interface;
    procedure Call
           (This   : in Predelete_Callback;
            Place  : in Position;
            Length : in Natural) is abstract;


    function Create
           (Requested_Size     : in Natural := 0;
            Preferred_Gap_Size : in Natural := 1024)
        return Text_Buffer;


    procedure Add_Modify_Callback
           (This : in out Text_Buffer;
            Func : not null access Modify_Callback'Class);


    procedure Add_Predelete_Callback
           (This : in out Text_Buffer;
            Func : not null access Predelete_Callback'Class);


private


    type Modify_Access is access all Modify_Callback'Class;
    type Predelete_Access is access all Predelete_Callback'Class;


    package Modify_Vectors is new Ada.Containers.Vectors
           (Index_Type => Positive,
            Element_Type => Modify_Access);
    package Predelete_Vectors is new Ada.Containers.Vectors
           (Index_Type => Positive,
            Element_Type => Predelete_Access);


    type Text_Buffer is new Wrapper with
        record
            Modify_CBs : Modify_Vectors.Vector;
            Predelete_CBs : Predelete_Vectors.Vector;
        end record;


    overriding procedure Finalize
           (This : in out Text_Buffer);


    package Text_Buffer_Convert is new System.Address_To_Access_Conversions (Text_Buffer);


end FLTK.Text_Buffers;