~ubuntu-branches/ubuntu/oneiric/codelite/oneiric

« back to all changes in this revision

Viewing changes to Interfaces/ieditor.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-04-09 02:03:19 UTC
  • mfrom: (0.1.3 sid) (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100409020319-302693n3vroavxwe
Tags: 2.5.2.4031~dfsg-1
* New upstream release.
* Refresh patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//////////////////////////////////////////////////////////////////////////////
2
 
//////////////////////////////////////////////////////////////////////////////
3
 
//
4
 
// copyright            : (C) 2008 by Eran Ifrah
5
 
// file name            : ieditor.h
6
 
//
7
 
// -------------------------------------------------------------------------
8
 
// A
9
 
//              _____           _      _     _ _
10
 
//             /  __ \         | |    | |   (_) |
11
 
//             | /  \/ ___   __| | ___| |    _| |_ ___
12
 
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
13
 
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
14
 
//              \____/\___/ \__,_|\___\_____/_|\__\___|
15
 
//
16
 
//                                                  F i l e
17
 
//
18
 
//    This program is free software; you can redistribute it and/or modify
19
 
//    it under the terms of the GNU General Public License as published by
20
 
//    the Free Software Foundation; either version 2 of the License, or
21
 
//    (at your option) any later version.
22
 
//
23
 
//////////////////////////////////////////////////////////////////////////////
24
 
//////////////////////////////////////////////////////////////////////////////
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
//////////////////////////////////////////////////////////////////////////////
 
3
//
 
4
// copyright            : (C) 2008 by Eran Ifrah
 
5
// file name            : ieditor.h
 
6
//
 
7
// -------------------------------------------------------------------------
 
8
// A
 
9
//              _____           _      _     _ _
 
10
//             /  __ \         | |    | |   (_) |
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
 
15
//
 
16
//                                                  F i l e
 
17
//
 
18
//    This program is free software; you can redistribute it and/or modify
 
19
//    it under the terms of the GNU General Public License as published by
 
20
//    the Free Software Foundation; either version 2 of the License, or
 
21
//    (at your option) any later version.
 
22
//
 
23
//////////////////////////////////////////////////////////////////////////////
 
24
//////////////////////////////////////////////////////////////////////////////
25
25
 #ifndef IEDITOR_H
26
26
#define IEDITOR_H
27
27
 
28
28
#include "wx/filename.h"
29
 
#include "browse_record.h"
 
29
#include "browse_record.h"
30
30
#include "wx/string.h"
31
 
#include <wx/colour.h>
32
 
#include "entry.h"
33
 
#include <vector>
34
 
 
35
 
class NavMgr;
 
31
#include <wx/colour.h>
 
32
#include "entry.h"
 
33
#include <vector>
 
34
 
 
35
class NavMgr;
36
36
 
37
37
//------------------------------------------------------------------
38
38
// Defines the interface to the editor control
39
39
//------------------------------------------------------------------
40
 
/**
41
 
 * @class IEditor
42
 
 * @author Eran
43
 
 * @date 05/07/08
44
 
 * @file ieditor.h
45
 
 * @brief an interface for the plugin to provide clean access to the editor class
46
 
 */
 
40
/**
 
41
 * @class IEditor
 
42
 * @author Eran
 
43
 * @date 05/07/08
 
44
 * @file ieditor.h
 
45
 * @brief an interface for the plugin to provide clean access to the editor class
 
46
 */
47
47
class IEditor {
48
48
public:
49
49
        IEditor(){}
50
50
        virtual ~IEditor(){}
51
 
 
52
 
        /**
53
 
         * @brief return true if the editor is modified
54
 
         */
55
 
        virtual bool IsModified() = 0;
56
 
 
57
 
        /**
58
 
         * \brief return the current editor content
59
 
         */
 
51
 
 
52
        /**
 
53
         * @brief return true if the editor is modified
 
54
         */
 
55
        virtual bool IsModified() = 0;
 
56
 
 
57
        /**
 
58
         * \brief return the current editor content
 
59
         */
60
60
        virtual wxString GetEditorText() = 0;
61
 
 
62
 
        /**
63
 
         * \brief sets the current editor's content with 'text'
64
 
         */
65
 
        virtual void SetEditorText(const wxString &text) = 0;
66
 
 
67
 
        /**
68
 
         * @brief append text to the editor
69
 
         * @param text text to append
70
 
         */
71
 
        virtual void AppendText(const wxString &text) = 0;
72
 
 
73
 
        /**
74
 
         * @brief insert text at a given position
75
 
         * @param text test to insert
76
 
         * @param pos position to insert it
77
 
         */
78
 
        virtual void InsertText(int pos, const wxString &text) = 0;
79
 
 
80
 
        /**
81
 
         * @brief return the document length
82
 
         * @return document length
83
 
         */
84
 
        virtual int GetLength() = 0;
85
 
 
86
 
        /**
87
 
         * \brief place the carte at a given position
88
 
         * \param pos position to place the caret
89
 
         */
 
61
 
 
62
        /**
 
63
         * \brief sets the current editor's content with 'text'
 
64
         */
 
65
        virtual void SetEditorText(const wxString &text) = 0;
 
66
 
 
67
        /**
 
68
         * @brief append text to the editor
 
69
         * @param text text to append
 
70
         */
 
71
        virtual void AppendText(const wxString &text) = 0;
 
72
 
 
73
        /**
 
74
         * @brief insert text at a given position
 
75
         * @param text test to insert
 
76
         * @param pos position to insert it
 
77
         */
 
78
        virtual void InsertText(int pos, const wxString &text) = 0;
 
79
 
 
80
        /**
 
81
         * @brief return the document length
 
82
         * @return document length
 
83
         */
 
84
        virtual int GetLength() = 0;
 
85
 
 
86
        /**
 
87
         * \brief place the carte at a given position
 
88
         * \param pos position to place the caret
 
89
         */
90
90
        virtual void SetCaretAt(long pos) = 0;
91
 
 
92
 
        /**
93
 
         * \brief reload the current file from disk - this function discards all changes made
94
 
         * to the  current file
95
 
         */
96
 
        virtual void ReloadFile() = 0;
97
 
 
98
 
        /**
99
 
         * \brief return the current position of the caret
100
 
         */
101
 
        virtual long GetCurrentPosition() = 0;
102
 
 
103
 
        /**
104
 
         * \brief return the current file name
105
 
         */
106
 
        virtual const wxFileName &GetFileName() const = 0;
107
 
 
108
 
        /**
109
 
         * \brief return the project which owns the current file name. return wxEmptyString
110
 
         * if this file has not project owner
111
 
         */
112
 
        virtual const wxString &GetProjectName() const = 0;
113
 
 
114
 
        /**
115
 
         * \brief return the current word under the caret. May return wxEmptyString
116
 
         */
117
 
        virtual wxString GetWordAtCaret() = 0;
118
 
 
119
 
        /**
120
 
         * @brief return the EOL mode of the editor.
121
 
         *      wxSCI_EOL_CRLF  0
122
 
         *      wxSCI_EOL_CR    1
123
 
         *      wxSCI_EOL_LF    2
124
 
         */
125
 
        virtual int GetEOL() = 0;
126
 
 
127
 
        /**
128
 
         * \brief return the current line number
129
 
         * \return the line number starting from 0
130
 
         */
131
 
        virtual int GetCurrentLine() = 0;
132
 
 
133
 
        /**
134
 
         * \brief replace the selection with 'text'. This function does nothing if there is no selected text
135
 
         * \param text text to replace the selection
136
 
         */
137
 
        virtual void ReplaceSelection (const wxString& text) = 0;
138
 
 
139
 
        /**
140
 
         * \brief return the selected text.
141
 
         * \return the selected text, or wxEmptyString if no selection exist in the document
142
 
         */
143
 
        virtual wxString GetSelection() = 0;
144
 
 
145
 
        /**
146
 
         * \brief select text at given position and length
147
 
         * \param startPos selection start position
148
 
         * \param len number of characters to select
149
 
         */
150
 
        virtual void SelectText(int startPos, int len) = 0;
151
 
 
152
 
        /**
153
 
         * \brief set user indicator style and colour
154
 
         * \param style can be any of
155
 
         *  #define wxSCI_INDIC_PLAIN 0
156
 
         *  #define wxSCI_INDIC_SQUIGGLE 1
157
 
         *  #define wxSCI_INDIC_TT 2
158
 
         *  #define wxSCI_INDIC_DIAGONAL 3
159
 
         *  #define wxSCI_INDIC_STRIKE 4
160
 
         *  #define wxSCI_INDIC_HIDDEN 5
161
 
         *  #define wxSCI_INDIC_BOX 6
162
 
         *  #define wxSCI_INDIC_ROUNDBOX 7
163
 
         * \param colour indicator colour
164
 
         */
165
 
        virtual void SetUserIndicatorStyleAndColour(int style, const wxColour &colour) = 0;
166
 
        /**
167
 
         * \brief set indicator at startPos with given length
168
 
         * \param startPos position to set the indicator
169
 
         * \param len indicator's length
170
 
         */
171
 
        virtual void SetUserIndicator(int startPos, int len) = 0;
172
 
 
173
 
        /**
174
 
         * \brief clear all user indicators from the document
175
 
         */
176
 
        virtual void ClearUserIndicators() = 0;
177
 
 
178
 
        /**
179
 
         * \brief return the first user indicator starting from 'pos'. along with 'GetUserIndicatorEnd' caller can
180
 
         * iterate through all user indicator in the document
181
 
         * \param pos position to search from
182
 
         * \return start position of the indicator
183
 
         */
184
 
        virtual int  GetUserIndicatorStart(int pos) = 0;
185
 
        /**
186
 
         * \brief return end of indicator range from pos
187
 
         * \param pos position to search from
188
 
         * \return end of indicator range
189
 
         */
190
 
        virtual int  GetUserIndicatorEnd(int pos) = 0;
191
 
 
192
 
        /**
193
 
         * \brief return the style at given position. Depends on the current lexer (Different lexers have different styles)
194
 
         * \param pos the position inside the editor styles.
195
 
         * \return style number.
196
 
         */
197
 
        virtual int GetStyleAtPos(int pos) = 0;
198
 
 
199
 
        /**
200
 
         * \brief return the editor's lexer ID as described in wxscintilla.h (wxSCI_LEX_*)
201
 
         */
202
 
        virtual int GetLexerId() = 0;
203
 
 
204
 
                /**
205
 
         * @brief displays teh code completion box. Unlike the previous metho, this method accepts owner and sends an event once selection is made
206
 
         * @param tags list if tags to display
207
 
         * @param word part of the word
208
 
         * @param owner event handler to be notified once a selection is made
209
 
         */
210
 
        virtual void ShowCompletionBox(const std::vector<TagEntryPtr> &tags, const wxString &word, wxEvtHandler *owner) = 0;
211
 
 
212
 
        /**
213
 
         * @brief register new user image fot TagEntry kind
214
 
         * @param kind the kind string that will be associated with the bitmap (TagEntry::GetKind())
215
 
         * @param bmp 16x16 bitmap
216
 
         */
217
 
        virtual void RegisterImageForKind(const wxString& kind, const wxBitmap& bmp) = 0;
218
 
 
219
 
        /**
220
 
         * @brief return true if the completion box is visible
221
 
         */
222
 
        virtual bool IsCompletionBoxShown() = 0;
223
 
 
224
 
        /**
225
 
         * @brief hide the completion box if it is active.
226
 
         */
227
 
        virtual void HideCompletionBox() = 0;
228
 
 
229
 
        /**
230
 
         * @brief Get position of start of word.
231
 
         * @param pos from position
232
 
         * @param onlyWordCharacters
233
 
         */
234
 
        virtual int WordStartPos (int pos, bool onlyWordCharacters) = 0;
235
 
 
236
 
        /**
237
 
         * @brief  Get position of end of word.
238
 
         * @param pos from position
239
 
         * @param onlyWordCharacters
240
 
         */
241
 
    virtual int WordEndPos (int pos, bool onlyWordCharacters) = 0;
242
 
 
243
 
        /**
244
 
         * Insert text to the editor and keeping the current position line indentation
245
 
         * \param text text to enter
246
 
         * \param pos position to insert the text
247
 
         */
248
 
        virtual wxString FormatTextKeepIndent(const wxString &text, int pos) = 0;
249
 
 
250
 
        /**
251
 
         * @brief creating a browsing record that can be stored in the navigation manager
252
 
         * @return browsing record
253
 
         */
254
 
        virtual BrowseRecord CreateBrowseRecord() = 0;
255
 
 
256
 
        /**
257
 
         * @brief search the editor for pattern. If pattern is found, the editor will then search for 'what'
258
 
         * inside the pattern and will select it
259
 
         * @param pattern pattern to search in the editor
260
 
         * @param what    sub string of pattern to select
261
 
         * @param navmgr  Navigation manager to place browsing recrods
262
 
         * @return return true if a match was found, false otherwise
263
 
         */
264
 
        virtual bool FindAndSelect(const wxString &pattern, const wxString &what, int from_pos, NavMgr *navmgr) = 0;
265
 
 
266
 
        /**
267
 
         * @brief set a lexer to the editor
268
 
         * @param lexerName
269
 
         */
270
 
        virtual void SetLexerName(const wxString &lexerName) = 0;
 
91
 
 
92
        /**
 
93
         * \brief reload the current file from disk - this function discards all changes made
 
94
         * to the  current file
 
95
         */
 
96
        virtual void ReloadFile() = 0;
 
97
 
 
98
        /**
 
99
         * \brief return the current position of the caret
 
100
         */
 
101
        virtual long GetCurrentPosition() = 0;
 
102
 
 
103
        /**
 
104
         * \brief return the current file name
 
105
         */
 
106
        virtual const wxFileName &GetFileName() const = 0;
 
107
 
 
108
        /**
 
109
         * \brief return the project which owns the current file name. return wxEmptyString
 
110
         * if this file has not project owner
 
111
         */
 
112
        virtual const wxString &GetProjectName() const = 0;
 
113
 
 
114
        /**
 
115
         * \brief return the current word under the caret. May return wxEmptyString
 
116
         */
 
117
        virtual wxString GetWordAtCaret() = 0;
 
118
 
 
119
        /**
 
120
         * @brief return the EOL mode of the editor.
 
121
         *      wxSCI_EOL_CRLF  0
 
122
         *      wxSCI_EOL_CR    1
 
123
         *      wxSCI_EOL_LF    2
 
124
         */
 
125
        virtual int GetEOL() = 0;
 
126
 
 
127
        /**
 
128
         * \brief return the current line number
 
129
         * \return the line number starting from 0
 
130
         */
 
131
        virtual int GetCurrentLine() = 0;
 
132
 
 
133
        /**
 
134
         * \brief replace the selection with 'text'. This function does nothing if there is no selected text
 
135
         * \param text text to replace the selection
 
136
         */
 
137
        virtual void ReplaceSelection (const wxString& text) = 0;
 
138
 
 
139
        /**
 
140
         * \brief return the selected text start position in bytes.
 
141
         */
 
142
        virtual int GetSelectionStart() = 0;
 
143
        
 
144
        /**
 
145
         * \brief return the selected text end position in bytes.
 
146
         */
 
147
        virtual int GetSelectionEnd() = 0;
 
148
        
 
149
        /**
 
150
         * \brief return the selected text.
 
151
         * \return the selected text, or wxEmptyString if no selection exist in the document
 
152
         */
 
153
        virtual wxString GetSelection() = 0;
 
154
 
 
155
        /**
 
156
         * \brief select text at given position and length
 
157
         * \param startPos selection start position
 
158
         * \param len number of characters to select
 
159
         */
 
160
        virtual void SelectText(int startPos, int len) = 0;
 
161
 
 
162
        /**
 
163
         * \brief set user indicator style and colour
 
164
         * \param style can be any of
 
165
         *  #define wxSCI_INDIC_PLAIN 0
 
166
         *  #define wxSCI_INDIC_SQUIGGLE 1
 
167
         *  #define wxSCI_INDIC_TT 2
 
168
         *  #define wxSCI_INDIC_DIAGONAL 3
 
169
         *  #define wxSCI_INDIC_STRIKE 4
 
170
         *  #define wxSCI_INDIC_HIDDEN 5
 
171
         *  #define wxSCI_INDIC_BOX 6
 
172
         *  #define wxSCI_INDIC_ROUNDBOX 7
 
173
         * \param colour indicator colour
 
174
         */
 
175
        virtual void SetUserIndicatorStyleAndColour(int style, const wxColour &colour) = 0;
 
176
        /**
 
177
         * \brief set indicator at startPos with given length
 
178
         * \param startPos position to set the indicator
 
179
         * \param len indicator's length
 
180
         */
 
181
        virtual void SetUserIndicator(int startPos, int len) = 0;
 
182
 
 
183
        /**
 
184
         * \brief clear all user indicators from the document
 
185
         */
 
186
        virtual void ClearUserIndicators() = 0;
 
187
 
 
188
        /**
 
189
         * \brief return the first user indicator starting from 'pos'. along with 'GetUserIndicatorEnd' caller can
 
190
         * iterate through all user indicator in the document
 
191
         * \param pos position to search from
 
192
         * \return start position of the indicator
 
193
         */
 
194
        virtual int  GetUserIndicatorStart(int pos) = 0;
 
195
        /**
 
196
         * \brief return end of indicator range from pos
 
197
         * \param pos position to search from
 
198
         * \return end of indicator range
 
199
         */
 
200
        virtual int  GetUserIndicatorEnd(int pos) = 0;
 
201
 
 
202
        /**
 
203
         * \brief return the style at given position. Depends on the current lexer (Different lexers have different styles)
 
204
         * \param pos the position inside the editor styles.
 
205
         * \return style number.
 
206
         */
 
207
        virtual int GetStyleAtPos(int pos) = 0;
 
208
 
 
209
        /**
 
210
         * \brief return the editor's lexer ID as described in wxscintilla.h (wxSCI_LEX_*)
 
211
         */
 
212
        virtual int GetLexerId() = 0;
 
213
 
 
214
                /**
 
215
         * @brief displays teh code completion box. Unlike the previous metho, this method accepts owner and sends an event once selection is made
 
216
         * @param tags list if tags to display
 
217
         * @param word part of the word
 
218
         * @param owner event handler to be notified once a selection is made
 
219
         */
 
220
        virtual void ShowCompletionBox(const std::vector<TagEntryPtr> &tags, const wxString &word, wxEvtHandler *owner) = 0;
 
221
 
 
222
        /**
 
223
         * @brief register new user image fot TagEntry kind
 
224
         * @param kind the kind string that will be associated with the bitmap (TagEntry::GetKind())
 
225
         * @param bmp 16x16 bitmap
 
226
         */
 
227
        virtual void RegisterImageForKind(const wxString& kind, const wxBitmap& bmp) = 0;
 
228
 
 
229
        /**
 
230
         * @brief return true if the completion box is visible
 
231
         */
 
232
        virtual bool IsCompletionBoxShown() = 0;
 
233
 
 
234
        /**
 
235
         * @brief hide the completion box if it is active.
 
236
         */
 
237
        virtual void HideCompletionBox() = 0;
 
238
 
 
239
        /**
 
240
         * @brief Get position of start of word.
 
241
         * @param pos from position
 
242
         * @param onlyWordCharacters
 
243
         */
 
244
        virtual int WordStartPos (int pos, bool onlyWordCharacters) = 0;
 
245
 
 
246
        /**
 
247
         * @brief  Get position of end of word.
 
248
         * @param pos from position
 
249
         * @param onlyWordCharacters
 
250
         */
 
251
    virtual int WordEndPos (int pos, bool onlyWordCharacters) = 0;
 
252
 
 
253
        /**
 
254
         * Insert text to the editor and keeping the current position line indentation
 
255
         * \param text text to enter
 
256
         * \param pos position to insert the text
 
257
         */
 
258
        virtual wxString FormatTextKeepIndent(const wxString &text, int pos) = 0;
 
259
 
 
260
        /**
 
261
         * @brief creating a browsing record that can be stored in the navigation manager
 
262
         * @return browsing record
 
263
         */
 
264
        virtual BrowseRecord CreateBrowseRecord() = 0;
 
265
 
 
266
        /**
 
267
         * @brief search the editor for pattern. If pattern is found, the editor will then search for 'what'
 
268
         * inside the pattern and will select it
 
269
         * @param pattern pattern to search in the editor
 
270
         * @param what    sub string of pattern to select
 
271
         * @param navmgr  Navigation manager to place browsing recrods
 
272
         * @return return true if a match was found, false otherwise
 
273
         */
 
274
        virtual bool FindAndSelect(const wxString &pattern, const wxString &what, int from_pos, NavMgr *navmgr) = 0;
 
275
 
 
276
        /**
 
277
         * @brief set a lexer to the editor
 
278
         * @param lexerName
 
279
         */
 
280
        virtual void SetLexerName(const wxString &lexerName) = 0;
271
281
};
272
282
 
273
283
#endif //IEDITOR_H