~haaaad/geany/master

« back to all changes in this revision

Viewing changes to scintilla/gtk/ScintillaGTKAccessible.h

  • Committer: elextr
  • Author(s): Colomban Wendling
  • Date: 2017-07-24 23:24:05 UTC
  • Revision ID: git-v1:18360460abb4f4bec23dff127031ecf4e9120f7f
Update Scintilla to version 3.7.5 (#1503)

* Update Scintilla to version 3.7.5

This now requires a C++11-capable compiler.

Closes #1308.

* Test using newer dist on Travis

Since Scintilla needs C++11

* Add debugging code for when configure fails

* Workaround a pkg-config-corsswrapper bug on Ubuntu 14.04

See https://bugs.launchpad.net/ubuntu/+source/mingw-w64/+bug/1327242

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
        ScintillaGTK *sci;
22
22
 
23
23
        // cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
24
 
        std::vector<Position> character_offsets;
 
24
        std::vector<Sci::Position> character_offsets;
25
25
 
26
26
        // cached length of the deletion, in characters (see Notify())
27
27
        int deletionLengthChar;
28
28
        // local state for comparing
29
 
        Position old_pos;
 
29
        Sci::Position old_pos;
30
30
        std::vector<SelectionRange> old_sels;
31
31
 
 
32
        bool Enabled() const;
32
33
        void UpdateCursor();
33
34
        void Notify(GtkWidget *widget, gint code, SCNotification *nt);
34
35
        static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
37
38
                } catch (...) {}
38
39
        }
39
40
 
40
 
        Position ByteOffsetFromCharacterOffset(Position startByte, int characterOffset) {
41
 
                Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
 
41
        Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) {
 
42
                Sci::Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
42
43
                if (pos == INVALID_POSITION) {
43
44
                        // clamp invalid positions inside the document
44
45
                        if (characterOffset > 0) {
50
51
                return pos;
51
52
        }
52
53
 
53
 
        Position ByteOffsetFromCharacterOffset(int characterOffset) {
 
54
        Sci::Position ByteOffsetFromCharacterOffset(Sci::Position characterOffset) {
54
55
                return ByteOffsetFromCharacterOffset(0, characterOffset);
55
56
        }
56
57
 
57
 
        int CharacterOffsetFromByteOffset(Position byteOffset) {
58
 
                const Position line = sci->pdoc->LineFromPosition(byteOffset);
 
58
        Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) {
 
59
                const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset);
59
60
                if (character_offsets.size() <= static_cast<size_t>(line)) {
60
61
                        if (character_offsets.empty())
61
62
                                character_offsets.push_back(0);
62
 
                        for (Position i = character_offsets.size(); i <= line; i++) {
63
 
                                const Position start = sci->pdoc->LineStart(i - 1);
64
 
                                const Position end = sci->pdoc->LineStart(i);
 
63
                        for (Sci::Position i = character_offsets.size(); i <= line; i++) {
 
64
                                const Sci::Position start = sci->pdoc->LineStart(i - 1);
 
65
                                const Sci::Position end = sci->pdoc->LineStart(i);
65
66
                                character_offsets.push_back(character_offsets[i - 1] + sci->pdoc->CountCharacters(start, end));
66
67
                        }
67
68
                }
68
 
                const Position lineStart = sci->pdoc->LineStart(line);
 
69
                const Sci::Position lineStart = sci->pdoc->LineStart(line);
69
70
                return character_offsets[line] + sci->pdoc->CountCharacters(lineStart, byteOffset);
70
71
        }
71
72
 
72
 
        void CharacterRangeFromByteRange(Position startByte, Position endByte, int *startChar, int *endChar) {
 
73
        void CharacterRangeFromByteRange(Sci::Position startByte, Sci::Position endByte, int *startChar, int *endChar) {
73
74
                *startChar = CharacterOffsetFromByteOffset(startByte);
74
75
                *endChar = *startChar + sci->pdoc->CountCharacters(startByte, endByte);
75
76
        }
76
77
 
77
 
        void ByteRangeFromCharacterRange(int startChar, int endChar, Position& startByte, Position& endByte) {
 
78
        void ByteRangeFromCharacterRange(int startChar, int endChar, Sci::Position& startByte, Sci::Position& endByte) {
78
79
                startByte = ByteOffsetFromCharacterOffset(startChar);
79
80
                endByte = ByteOffsetFromCharacterOffset(startByte, endChar - startChar);
80
81
        }
81
82
 
82
 
        Position PositionBefore(Position pos) {
 
83
        Sci::Position PositionBefore(Sci::Position pos) {
83
84
                return sci->pdoc->MovePositionOutsideChar(pos - 1, -1, true);
84
85
        }
85
86
 
86
 
        Position PositionAfter(Position pos) {
 
87
        Sci::Position PositionAfter(Sci::Position pos) {
87
88
                return sci->pdoc->MovePositionOutsideChar(pos + 1, 1, true);
88
89
        }
89
90
 
90
 
        int StyleAt(Position position, bool ensureStyle = false) {
 
91
        int StyleAt(Sci::Position position, bool ensureStyle = false) {
91
92
                if (ensureStyle)
92
93
                        sci->pdoc->EnsureStyledTo(position);
93
94
                return sci->pdoc->StyleAt(position);
94
95
        }
95
96
 
96
97
        // For AtkText
97
 
        gchar *GetTextRangeUTF8(Position startByte, Position endByte);
 
98
        gchar *GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte);
98
99
        gchar *GetText(int startChar, int endChar);
99
100
        gchar *GetTextAfterOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
100
101
        gchar *GetTextBeforeOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
108
109
        gboolean SetCaretOffset(int charOffset);
109
110
        gint GetOffsetAtPoint(gint x, gint y, AtkCoordType coords);
110
111
        void GetCharacterExtents(int charOffset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords);
111
 
        AtkAttributeSet *GetAttributesForStyle(unsigned int style);
 
112
        AtkAttributeSet *GetAttributesForStyle(unsigned int styleNum);
112
113
        AtkAttributeSet *GetRunAttributes(int charOffset, int *startChar, int *endChar);
113
114
        AtkAttributeSet *GetDefaultAttributes();
114
115
        gint GetNSelections();
117
118
        gboolean RemoveSelection(int selection_num);
118
119
        gboolean SetSelection(gint selection_num, int startChar, int endChar);
119
120
        // for AtkEditableText
120
 
        bool InsertStringUTF8(Position bytePos, const gchar *utf8, int lengthBytes);
 
121
        bool InsertStringUTF8(Sci::Position bytePos, const gchar *utf8, Sci::Position lengthBytes);
121
122
        void SetTextContents(const gchar *contents);
122
 
        void InsertText(const gchar *contents, int lengthBytes, int *charPosition);
 
123
        void InsertText(const gchar *text, int lengthBytes, int *charPosition);
123
124
        void CopyText(int startChar, int endChar);
124
125
        void CutText(int startChar, int endChar);
125
126
        void DeleteText(int startChar, int endChar);
126
127
        void PasteText(int charPosition);
127
128
 
128
129
public:
129
 
        ScintillaGTKAccessible(GtkAccessible *accessible, GtkWidget *widget);
 
130
        ScintillaGTKAccessible(GtkAccessible *accessible_, GtkWidget *widget_);
130
131
        ~ScintillaGTKAccessible();
131
132
 
132
133
        static ScintillaGTKAccessible *FromAccessible(GtkAccessible *accessible);
136
137
        // So ScintillaGTK can notify us
137
138
        void ChangeDocument(Document *oldDoc, Document *newDoc);
138
139
        void NotifyReadOnly();
 
140
        void SetAccessibility();
139
141
 
140
142
        // Helper GtkWidget methods
141
143
        static AtkObject *WidgetGetAccessibleImpl(GtkWidget *widget, AtkObject **cache, gpointer widget_parent_class);