1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
4
// copyright : (C) 2008 by Eran Ifrah
5
// file name : ieditor.h
7
// -------------------------------------------------------------------------
10
// / __ \ | | | | (_) |
11
// | / \/ ___ __| | ___| | _| |_ ___
12
// | | / _ \ / _ |/ _ \ | | | __/ _ )
13
// | \__/\ (_) | (_| | __/ |___| | || __/
14
// \____/\___/ \__,_|\___\_____/_|\__\___|
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.
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
4
// copyright : (C) 2008 by Eran Ifrah
5
// file name : ieditor.h
7
// -------------------------------------------------------------------------
10
// / __ \ | | | | (_) |
11
// | / \/ ___ __| | ___| | _| |_ ___
12
// | | / _ \ / _ |/ _ \ | | | __/ _ )
13
// | \__/\ (_) | (_| | __/ |___| | || __/
14
// \____/\___/ \__,_|\___\_____/_|\__\___|
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.
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
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>
31
#include <wx/colour.h>
37
37
//------------------------------------------------------------------
38
38
// Defines the interface to the editor control
39
39
//------------------------------------------------------------------
45
* @brief an interface for the plugin to provide clean access to the editor class
45
* @brief an interface for the plugin to provide clean access to the editor class
50
50
virtual ~IEditor(){}
53
* @brief return true if the editor is modified
55
virtual bool IsModified() = 0;
58
* \brief return the current editor content
53
* @brief return true if the editor is modified
55
virtual bool IsModified() = 0;
58
* \brief return the current editor content
60
60
virtual wxString GetEditorText() = 0;
63
* \brief sets the current editor's content with 'text'
65
virtual void SetEditorText(const wxString &text) = 0;
68
* @brief append text to the editor
69
* @param text text to append
71
virtual void AppendText(const wxString &text) = 0;
74
* @brief insert text at a given position
75
* @param text test to insert
76
* @param pos position to insert it
78
virtual void InsertText(int pos, const wxString &text) = 0;
81
* @brief return the document length
82
* @return document length
84
virtual int GetLength() = 0;
87
* \brief place the carte at a given position
88
* \param pos position to place the caret
63
* \brief sets the current editor's content with 'text'
65
virtual void SetEditorText(const wxString &text) = 0;
68
* @brief append text to the editor
69
* @param text text to append
71
virtual void AppendText(const wxString &text) = 0;
74
* @brief insert text at a given position
75
* @param text test to insert
76
* @param pos position to insert it
78
virtual void InsertText(int pos, const wxString &text) = 0;
81
* @brief return the document length
82
* @return document length
84
virtual int GetLength() = 0;
87
* \brief place the carte at a given position
88
* \param pos position to place the caret
90
90
virtual void SetCaretAt(long pos) = 0;
93
* \brief reload the current file from disk - this function discards all changes made
96
virtual void ReloadFile() = 0;
99
* \brief return the current position of the caret
101
virtual long GetCurrentPosition() = 0;
104
* \brief return the current file name
106
virtual const wxFileName &GetFileName() const = 0;
109
* \brief return the project which owns the current file name. return wxEmptyString
110
* if this file has not project owner
112
virtual const wxString &GetProjectName() const = 0;
115
* \brief return the current word under the caret. May return wxEmptyString
117
virtual wxString GetWordAtCaret() = 0;
120
* @brief return the EOL mode of the editor.
125
virtual int GetEOL() = 0;
128
* \brief return the current line number
129
* \return the line number starting from 0
131
virtual int GetCurrentLine() = 0;
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
137
virtual void ReplaceSelection (const wxString& text) = 0;
140
* \brief return the selected text.
141
* \return the selected text, or wxEmptyString if no selection exist in the document
143
virtual wxString GetSelection() = 0;
146
* \brief select text at given position and length
147
* \param startPos selection start position
148
* \param len number of characters to select
150
virtual void SelectText(int startPos, int len) = 0;
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
165
virtual void SetUserIndicatorStyleAndColour(int style, const wxColour &colour) = 0;
167
* \brief set indicator at startPos with given length
168
* \param startPos position to set the indicator
169
* \param len indicator's length
171
virtual void SetUserIndicator(int startPos, int len) = 0;
174
* \brief clear all user indicators from the document
176
virtual void ClearUserIndicators() = 0;
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
184
virtual int GetUserIndicatorStart(int pos) = 0;
186
* \brief return end of indicator range from pos
187
* \param pos position to search from
188
* \return end of indicator range
190
virtual int GetUserIndicatorEnd(int pos) = 0;
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.
197
virtual int GetStyleAtPos(int pos) = 0;
200
* \brief return the editor's lexer ID as described in wxscintilla.h (wxSCI_LEX_*)
202
virtual int GetLexerId() = 0;
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
210
virtual void ShowCompletionBox(const std::vector<TagEntryPtr> &tags, const wxString &word, wxEvtHandler *owner) = 0;
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
217
virtual void RegisterImageForKind(const wxString& kind, const wxBitmap& bmp) = 0;
220
* @brief return true if the completion box is visible
222
virtual bool IsCompletionBoxShown() = 0;
225
* @brief hide the completion box if it is active.
227
virtual void HideCompletionBox() = 0;
230
* @brief Get position of start of word.
231
* @param pos from position
232
* @param onlyWordCharacters
234
virtual int WordStartPos (int pos, bool onlyWordCharacters) = 0;
237
* @brief Get position of end of word.
238
* @param pos from position
239
* @param onlyWordCharacters
241
virtual int WordEndPos (int pos, bool onlyWordCharacters) = 0;
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
248
virtual wxString FormatTextKeepIndent(const wxString &text, int pos) = 0;
251
* @brief creating a browsing record that can be stored in the navigation manager
252
* @return browsing record
254
virtual BrowseRecord CreateBrowseRecord() = 0;
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
264
virtual bool FindAndSelect(const wxString &pattern, const wxString &what, int from_pos, NavMgr *navmgr) = 0;
267
* @brief set a lexer to the editor
270
virtual void SetLexerName(const wxString &lexerName) = 0;
93
* \brief reload the current file from disk - this function discards all changes made
96
virtual void ReloadFile() = 0;
99
* \brief return the current position of the caret
101
virtual long GetCurrentPosition() = 0;
104
* \brief return the current file name
106
virtual const wxFileName &GetFileName() const = 0;
109
* \brief return the project which owns the current file name. return wxEmptyString
110
* if this file has not project owner
112
virtual const wxString &GetProjectName() const = 0;
115
* \brief return the current word under the caret. May return wxEmptyString
117
virtual wxString GetWordAtCaret() = 0;
120
* @brief return the EOL mode of the editor.
125
virtual int GetEOL() = 0;
128
* \brief return the current line number
129
* \return the line number starting from 0
131
virtual int GetCurrentLine() = 0;
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
137
virtual void ReplaceSelection (const wxString& text) = 0;
140
* \brief return the selected text start position in bytes.
142
virtual int GetSelectionStart() = 0;
145
* \brief return the selected text end position in bytes.
147
virtual int GetSelectionEnd() = 0;
150
* \brief return the selected text.
151
* \return the selected text, or wxEmptyString if no selection exist in the document
153
virtual wxString GetSelection() = 0;
156
* \brief select text at given position and length
157
* \param startPos selection start position
158
* \param len number of characters to select
160
virtual void SelectText(int startPos, int len) = 0;
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
175
virtual void SetUserIndicatorStyleAndColour(int style, const wxColour &colour) = 0;
177
* \brief set indicator at startPos with given length
178
* \param startPos position to set the indicator
179
* \param len indicator's length
181
virtual void SetUserIndicator(int startPos, int len) = 0;
184
* \brief clear all user indicators from the document
186
virtual void ClearUserIndicators() = 0;
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
194
virtual int GetUserIndicatorStart(int pos) = 0;
196
* \brief return end of indicator range from pos
197
* \param pos position to search from
198
* \return end of indicator range
200
virtual int GetUserIndicatorEnd(int pos) = 0;
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.
207
virtual int GetStyleAtPos(int pos) = 0;
210
* \brief return the editor's lexer ID as described in wxscintilla.h (wxSCI_LEX_*)
212
virtual int GetLexerId() = 0;
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
220
virtual void ShowCompletionBox(const std::vector<TagEntryPtr> &tags, const wxString &word, wxEvtHandler *owner) = 0;
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
227
virtual void RegisterImageForKind(const wxString& kind, const wxBitmap& bmp) = 0;
230
* @brief return true if the completion box is visible
232
virtual bool IsCompletionBoxShown() = 0;
235
* @brief hide the completion box if it is active.
237
virtual void HideCompletionBox() = 0;
240
* @brief Get position of start of word.
241
* @param pos from position
242
* @param onlyWordCharacters
244
virtual int WordStartPos (int pos, bool onlyWordCharacters) = 0;
247
* @brief Get position of end of word.
248
* @param pos from position
249
* @param onlyWordCharacters
251
virtual int WordEndPos (int pos, bool onlyWordCharacters) = 0;
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
258
virtual wxString FormatTextKeepIndent(const wxString &text, int pos) = 0;
261
* @brief creating a browsing record that can be stored in the navigation manager
262
* @return browsing record
264
virtual BrowseRecord CreateBrowseRecord() = 0;
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
274
virtual bool FindAndSelect(const wxString &pattern, const wxString &what, int from_pos, NavMgr *navmgr) = 0;
277
* @brief set a lexer to the editor
280
virtual void SetLexerName(const wxString &lexerName) = 0;
273
283
#endif //IEDITOR_H