summaryrefslogtreecommitdiff
path: root/src/fltk_binding/fltk-text_buffers.ads
blob: eea9b733af452d8091e0498d9ff9e7fd1de3e22c (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113


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, None);
    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);


    procedure Call_Modify_Callbacks
           (This : in out Text_Buffer);


    procedure Call_Predelete_Callbacks
           (This : in out Text_Buffer);


    function Length
           (This : in Text_Buffer)
        return Natural;


    procedure Load_File
           (This : in Text_Buffer;
            Name : in String);


    procedure Remove_Selected_Text
           (This : in out Text_Buffer);


    procedure Save_File
           (This : in Text_Buffer;
            Name : in String);


    procedure Set_Selection
           (This          : in out Text_Buffer;
            Start, Finish : in     Natural);


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;