summaryrefslogtreecommitdiff
path: root/src/change_vectors.ads
blob: b2b74b7bed0d9169dd228505d020495d25f8d044 (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


with FLTK.Text_Buffers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
private with Ada.Containers.Vectors;


package Change_Vectors is


    type Change_Vector is tagged private;


    type Change is
        record
            Action : FLTK.Text_Buffers.Modification;
            Place  : FLTK.Text_Buffers.Position;
            Length : Natural;
            Text   : Unbounded_String;
        end record;


    Empty_Vector : constant Change_Vector;


    procedure Push
           (This : in out Change_Vector;
            Item : in     Change);


    function Pop
           (This : in out Change_Vector)
        return Boolean;


    procedure Pop
           (This : in out Change_Vector);


    function Peek
           (This : in     Change_Vector;
            Item :    out Change)
        return Boolean;


    procedure Peek
           (This : in     Change_Vector;
            Item :    out Change);


    function Re_Push
           (This : in out Change_Vector)
        return Boolean;


    procedure Re_Push
           (This : in out Change_Vector);


    function At_Start
           (This : in Change_Vector)
        return Boolean;


    function At_End
           (This : in Change_Vector)
        return Boolean;


private


    package Internal_Vectors is new Ada.Containers.Vectors
           (Index_Type => Positive, Element_Type => Change);


    type Change_Vector is tagged
        record
            Near, Far : Natural;
            List      : Internal_Vectors.Vector;
        end record;


    Empty_Vector : constant Change_Vector :=
           (Near => 0,
            Far => 0,
            List => Internal_Vectors.Empty_Vector);


end Change_Vectors;