summaryrefslogtreecommitdiff
path: root/src/fltk_binding/fltk-text_buffers.ads
blob: a021dbf39ca58467a51ad52f5a00b6b744fcf2e8 (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
114
115
116
117
118
119
120


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 access procedure
           (Action       : in Modification;
            Place        : in Position;
            Length       : in Natural;
            Deleted_Text : in String);


    type Predelete_Callback is access procedure
           (Place  : in Position;
            Length : in Natural);


    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 : in     Modify_Callback);


    procedure Add_Predelete_Callback
           (This : in out Text_Buffer;
            Func : in     Predelete_Callback);


    procedure Call_Modify_Callbacks
           (This : in out Text_Buffer);


    procedure Call_Predelete_Callbacks
           (This : in out Text_Buffer);


    procedure Insert_Text
           (This : in out Text_Buffer;
            Pos  : in     Natural;
            Item : in     String);


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


    function Search_Forward
           (This       : in     Text_Buffer;
            Start_At   : in     Natural;
            Item       : in     String;
            Found_At   :    out Natural;
            Match_Case : in     Boolean)
        return Boolean;


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


private


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


    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;