geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

editor.h
Go to the documentation of this file.
1/*
2 * editor.h - this file is part of Geany, a fast and lightweight IDE
3 *
4 * Copyright 2005 The Geany contributors
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21
22#ifndef GEANY_EDITOR_H
23#define GEANY_EDITOR_H 1
24
25#include "tm_tag.h" /* for TMTag */
26
27#include "gtkcompat.h" /* Needed by ScintillaWidget.h */
28#include "Scintilla.h" /* Needed by ScintillaWidget.h */
29#include "ScintillaWidget.h" /* for ScintillaObject */
30
31#include <glib.h>
32
33
34G_BEGIN_DECLS
35
36/* Forward-declared to avoid including document.h since it includes this header */
37struct GeanyDocument;
38
39/** Default character set to define which characters should be treated as part of a word. */
40#define GEANY_WORDCHARS "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
41#define GEANY_MAX_WORD_LENGTH 192
42
43/** Whether to use tabs, spaces or both to indent. */
44typedef enum
45{
46 GEANY_INDENT_TYPE_SPACES, /**< Spaces. */
48 GEANY_INDENT_TYPE_BOTH /**< Both. */
51
52/** @gironly
53 * Auto indentation modes */
54typedef enum
55{
62
63/** Geany indicator types, can be used with Editor indicator functions to highlight
64 * text in the document. */
65typedef enum
66{
67 /** Indicator to highlight errors in the document text. This is a red squiggly underline. */
69 /** Indicator used to highlight search results in the document. This is a
70 * rounded box around the text. */
71 /* start container indicator outside of lexer indicators (0..7), see Scintilla docs */
76
77/** Indentation prefs that might be different according to project or filetype.
78 * Use @c editor_get_indent_prefs() to lookup the prefs for a particular document.
79 *
80 * @since 0.15
81 **/
82typedef struct GeanyIndentPrefs
83{
84 gint width; /**< Indent width. */
85 GeanyIndentType type; /**< Whether to use tabs, spaces or both to indent. */
86 /** Width of a tab, but only when using GEANY_INDENT_TYPE_BOTH.
87 * To get the display tab width, use sci_get_tab_width(). */
90 gboolean detect_type;
91 gboolean detect_width;
92}
94
95/** Default prefs when creating a new editor window.
96 * Some of these can be overridden per document or per project. */
97/* @warning Use @c editor_get_prefs() instead to include project overrides. */
98typedef struct GeanyEditorPrefs
99{
100 GeanyIndentPrefs *indentation; /* Default indentation prefs. Use editor_get_indent_prefs(). */
104 /* 0 - line, 1 - background, 2 - disabled. */
108 gboolean show_markers_margin; /* view menu */
109 gboolean show_linenumber_margin; /* view menu */
110 gboolean show_scrollbars; /* hidden pref */
114 gboolean folding;
116 gboolean disable_dnd;
117 gboolean use_tab_to_indent; /* makes tab key indent instead of insert a tab char */
125 gboolean brace_match_ltgt; /* whether to highlight < and > chars (hidden pref) */
126 gboolean use_gtk_word_boundaries; /* hidden pref */
127 gboolean complete_snippets_whilst_editing; /* hidden pref */
140 gint ime_interaction; /* input method editor's candidate window behaviour */
141}
143
144
145#define GEANY_TYPE_EDITOR (editor_get_type())
146GType editor_get_type (void);
147
148/** Editor-owned fields for each document. */
149typedef struct GeanyEditor
150{
151 struct GeanyDocument *document; /**< The document associated with the editor. */
152 ScintillaObject *sci; /**< The Scintilla editor @c GtkWidget. */
153 gboolean line_wrapping; /**< @c TRUE if line wrapping is enabled. */
154 gboolean auto_indent; /**< @c TRUE if auto-indentation is enabled. */
155 /** Percentage to scroll view by on paint, if positive. */
157 GeanyIndentType indent_type; /* Use editor_get_indent_prefs() instead. */
158 gboolean line_breaking; /**< Whether to split long lines as you type. */
160}
162
163
165
166ScintillaObject *editor_create_widget(GeanyEditor *editor);
167
168void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start, gint end);
169
170void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line);
171
172void editor_indicator_clear(GeanyEditor *editor, gint indic);
173
175
177
178gchar *editor_get_word_at_pos(GeanyEditor *editor, gint pos, const gchar *wordchars);
179
181
183
185
187 gint insert_pos, gint cursor_index,
188 gint newline_indent_size, gboolean replace_newlines);
189
191
192gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark);
193
194const gchar *editor_find_snippet(GeanyEditor *editor, const gchar *snippet_name);
195
196void editor_insert_snippet(GeanyEditor *editor, gint pos, const gchar *snippet);
197
198
199#ifdef GEANY_PRIVATE
200
202
203typedef enum
204{
205 GEANY_VIRTUAL_SPACE_DISABLED = 0,
206 GEANY_VIRTUAL_SPACE_SELECTION = 1,
207 GEANY_VIRTUAL_SPACE_ALWAYS = 3
208}
209GeanyVirtualSpace;
210
211/* Auto-close brackets/quotes */
212enum {
213 GEANY_AC_PARENTHESIS = 1,
214 GEANY_AC_CBRACKET = 2,
215 GEANY_AC_SBRACKET = 4,
216 GEANY_AC_SQUOTE = 8,
217 GEANY_AC_DQUOTE = 16
218};
219
220typedef struct
221{
222 gchar *current_word; /* holds word under the mouse or keyboard cursor */
223 gint click_pos; /* text position where the mouse was clicked */
224} EditorInfo;
225
226extern EditorInfo editor_info;
227
228
229void editor_init(void);
230
232
234
235void editor_sci_notify_cb(GtkWidget *widget, gint scn, gpointer scnt, gpointer data);
236
237gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean force);
238
240
242
244
246
248
249gint editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_lines, gboolean toggle,
250 gboolean single_comment);
251
252gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle);
253
255
257
258void editor_indent(GeanyEditor *editor, gboolean increase);
259
261
262void editor_indentation_by_one_space(GeanyEditor *editor, gint pos, gboolean decrease);
263
265
266void editor_scroll_to_line(GeanyEditor *editor, gint line, gfloat percent_of_view);
267
268void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view);
269
270void editor_finalize(void);
271
272void editor_snippets_init(void);
273
274void editor_snippets_free(void);
275
277
278
279/* General editing functions */
280
281void editor_find_current_word(GeanyEditor *editor, gint pos, gchar *word, gsize wordlen,
282 const gchar *wc);
283
284void editor_find_current_word_sciwc(GeanyEditor *editor, gint pos, gchar *word, gsize wordlen);
285
286gchar *editor_get_default_selection(GeanyEditor *editor, gboolean use_current_word, const gchar *wordchars);
287
288
290
291void editor_select_lines(GeanyEditor *editor, gboolean extra_line);
292
294
296
297
298void editor_set_font(GeanyEditor *editor, const gchar *font);
299
301
303
305
306void editor_replace_tabs(GeanyEditor *editor, gboolean ignore_selection);
307
308void editor_replace_spaces(GeanyEditor *editor, gboolean ignore_selection);
309
311
312void editor_strip_trailing_spaces(GeanyEditor *editor, gboolean ignore_selection);
313
315
316void editor_insert_color(GeanyEditor *editor, const gchar *colour);
317
318void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width);
319
320void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap);
321
322gboolean editor_goto_line(GeanyEditor *editor, gint line_no, gint offset);
323
325
327
329
330void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers);
331
332#endif /* GEANY_PRIVATE */
333
334G_END_DECLS
335
336#endif /* GEANY_EDITOR_H */
Interface to the edit control.
void editor_replace_spaces(GeanyEditor *editor, gboolean ignore_selection)
Definition: editor.c:4453
gchar * editor_get_default_selection(GeanyEditor *editor, gboolean use_current_word, const gchar *wordchars)
Definition: editor.c:4057
gboolean editor_complete_word_part(GeanyEditor *editor)
Definition: editor.c:5050
gboolean editor_line_in_view(GeanyEditor *editor, gint line)
Definition: editor.c:4087
gchar * editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag)
Definition: editor.c:2062
gboolean editor_show_calltip(GeanyEditor *editor, gint pos)
Definition: editor.c:1994
void editor_snippets_init(void)
Definition: editor.c:258
void editor_select_indent_block(GeanyEditor *editor)
Definition: editor.c:3887
GeanyEditor * editor_create(GeanyDocument *doc)
Definition: editor.c:5011
void editor_set_font(GeanyEditor *editor, const gchar *font)
Definition: editor.c:4622
void editor_init(void)
Definition: editor.c:5070
void editor_indent(GeanyEditor *editor, gboolean increase)
Definition: editor.c:5258
void editor_unfold_all(GeanyEditor *editor)
Definition: editor.c:4384
EditorInfo editor_info
Definition: editor.c:79
gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean force)
Definition: editor.c:2221
void editor_select_word(GeanyEditor *editor)
Definition: editor.c:3724
void editor_find_current_word_sciwc(GeanyEditor *editor, gint pos, gchar *word, gsize wordlen)
Definition: editor.c:1749
void editor_insert_color(GeanyEditor *editor, const gchar *colour)
Definition: editor.c:4238
const GeanyEditorPrefs * editor_get_prefs(GeanyEditor *editor)
Definition: editor.c:424
void editor_replace_tabs(GeanyEditor *editor, gboolean ignore_selection)
Definition: editor.c:4396
void editor_scroll_to_line(GeanyEditor *editor, gint line, gfloat percent_of_view)
Definition: editor.c:3674
gboolean editor_goto_line(GeanyEditor *editor, gint line_no, gint offset)
Definition: editor.c:4701
void editor_insert_multiline_comment(GeanyEditor *editor)
Definition: editor.c:3606
void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width)
Definition: editor.c:4668
void editor_select_paragraph(GeanyEditor *editor)
Definition: editor.c:3824
void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap)
Definition: editor.c:4633
void editor_sci_notify_cb(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gint scn, gpointer scnt, gpointer data)
Definition: editor.c:1055
gint editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_lines, gboolean toggle, gboolean single_comment)
Definition: editor.c:3284
void editor_finalize(void)
Definition: editor.c:4046
void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
Definition: editor.c:441
void editor_select_lines(GeanyEditor *editor, gboolean extra_line)
Definition: editor.c:3752
void editor_indicator_clear_errors(GeanyEditor *editor)
Definition: editor.c:4133
void editor_strip_line_trailing_spaces(GeanyEditor *editor, gint line)
Definition: editor.c:4522
void editor_ensure_final_newline(GeanyEditor *editor)
Definition: editor.c:4580
gchar * text
Definition: editor.c:83
gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle)
Definition: editor.c:2989
void editor_snippets_free(void)
Definition: editor.c:110
void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view)
Definition: editor.c:4108
void editor_strip_trailing_spaces(GeanyEditor *editor, gboolean ignore_selection)
Definition: editor.c:4547
gboolean editor_goto_next_snippet_cursor(GeanyEditor *editor)
Definition: editor.c:2557
void editor_find_current_word(GeanyEditor *editor, gint pos, gchar *word, gsize wordlen, const gchar *wc)
Definition: editor.c:1740
void editor_set_indentation_guides(GeanyEditor *editor)
Definition: editor.c:5091
void editor_do_comment_toggle(GeanyEditor *editor)
Definition: editor.c:3115
void editor_apply_update_prefs(GeanyEditor *editor)
Definition: editor.c:5161
void editor_indentation_by_one_space(GeanyEditor *editor, gint pos, gboolean decrease)
Definition: editor.c:3980
void editor_destroy(GeanyEditor *editor)
Definition: editor.c:5030
void editor_smart_line_indentation(GeanyEditor *editor)
Definition: editor.c:3938
gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
Definition: editor.c:2655
gint pos
Definition: editor.c:87
static gchar current_word[192]
Definition: editor.c:74
GeanyEditorPrefs editor_prefs
Definition: editor.c:77
void editor_fold_all(GeanyEditor *editor)
Definition: editor.c:4390
void editor_insert_alternative_whitespace(GeanyEditor *editor)
Definition: editor.c:3701
gint editor_get_eol_char_mode(GeanyEditor *editor)
Retrieves the end of line characters mode (LF, CR/LF, CR) in the given editor.
Definition: editor.c:4279
struct GeanyEditorPrefs GeanyEditorPrefs
Default prefs when creating a new editor window.
GeanyAutoIndent
Definition: editor.h:55
@ GEANY_AUTOINDENT_MATCHBRACES
Definition: editor.h:59
@ GEANY_AUTOINDENT_BASIC
Definition: editor.h:57
@ GEANY_AUTOINDENT_NONE
Definition: editor.h:56
@ GEANY_AUTOINDENT_CURRENTCHARS
Definition: editor.h:58
void editor_indicator_clear(GeanyEditor *editor, gint indic)
Deletes all currently set indicators matching indic in the editor window.
Definition: editor.c:4149
void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint insert_pos, gint cursor_index, gint newline_indent_size, gboolean replace_newlines)
Inserts text, replacing \t tab chars (0x9) and \n newline chars (0xA) accordingly for the document.
Definition: editor.c:2456
const GeanyIndentPrefs * editor_get_indent_prefs(GeanyEditor *editor)
Gets the indentation prefs for the editor.
Definition: editor.c:1267
const gchar * editor_find_snippet(GeanyEditor *editor, const gchar *snippet_name)
Gets snippet by name.
Definition: editor.c:5322
ScintillaObject * editor_create_widget(GeanyEditor *editor)
Creates a new Scintilla GtkWidget based on the settings for editor.
Definition: editor.c:4984
struct GeanyIndentPrefs GeanyIndentPrefs
Indentation prefs that might be different according to project or filetype.
GeanyIndentType
Whether to use tabs, spaces or both to indent.
Definition: editor.h:45
@ GEANY_INDENT_TYPE_BOTH
Both.
Definition: editor.h:48
@ GEANY_INDENT_TYPE_TABS
Tabs.
Definition: editor.h:47
@ GEANY_INDENT_TYPE_SPACES
Spaces.
Definition: editor.h:46
gint editor_get_eol_char_len(GeanyEditor *editor)
Retrieves the length of the used end of line characters (LF, CR/LF, CR) in the given editor.
Definition: editor.c:4323
void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line)
Sets an indicator indic on line.
Definition: editor.c:4175
struct GeanyEditor GeanyEditor
Editor-owned fields for each document.
void editor_insert_snippet(GeanyEditor *editor, gint pos, const gchar *snippet)
Replaces all special sequences in snippet and inserts it at pos.
Definition: editor.c:5339
void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start, gint end)
Sets an indicator on the range specified by start and end.
Definition: editor.c:4225
GType editor_get_type(void)
GeanyIndicator
Geany indicator types, can be used with Editor indicator functions to highlight text in the document.
Definition: editor.h:66
@ GEANY_INDICATOR_SEARCH
Indicator used to highlight search results in the document.
Definition: editor.h:72
@ GEANY_INDICATOR_SNIPPET
Definition: editor.h:73
@ GEANY_INDICATOR_ERROR
Indicator to highlight errors in the document text.
Definition: editor.h:68
void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type)
Sets the indent type for editor.
Definition: editor.c:4649
void editor_set_indent_width(GeanyEditor *editor, gint width)
Sets the indent width for editor.
Definition: editor.c:4662
const gchar * editor_get_eol_char(GeanyEditor *editor)
Retrieves the used end of line characters (LF, CR/LF, CR) in the given editor.
Definition: editor.c:4349
const gchar * editor_get_eol_char_name(GeanyEditor *editor)
Retrieves the localized name (for displaying) of the used end of line characters (LF,...
Definition: editor.c:4301
gchar * editor_get_word_at_pos(GeanyEditor *editor, gint pos, const gchar *wordchars)
Finds the word at the position specified by pos.
Definition: editor.c:1791
gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark)
Moves to position pos, switching to the document if necessary, setting a marker if mark is set.
Definition: editor.c:4732
vString * line
Definition: geany_cobol.c:133
gchar * wordchars
Definition: highlighting.c:113
Structure for representing an open tab with all its properties.
Definition: document.h:81
GeanyEditor * editor
The editor associated with the document.
Definition: document.h:98
Default prefs when creating a new editor window.
Definition: editor.h:99
gboolean unfold_all_children
Definition: editor.h:115
gint symbolcompletion_min_chars
Definition: editor.h:123
gboolean line_wrapping
Definition: editor.h:112
gboolean show_scrollbars
Definition: editor.h:110
gboolean scroll_stop_at_last_line
Definition: editor.h:111
gboolean newline_strip
Definition: editor.h:119
gboolean disable_dnd
Definition: editor.h:116
gboolean brace_match_ltgt
Definition: editor.h:125
gint autocompletion_update_freq
Definition: editor.h:138
GeanyIndentPrefs * indentation
Definition: editor.h:100
gboolean show_markers_margin
Definition: editor.h:108
gboolean auto_continue_multiline
Definition: editor.h:129
gboolean complete_snippets_whilst_editing
Definition: editor.h:127
gint line_break_column
Definition: editor.h:128
gint ime_interaction
Definition: editor.h:140
gboolean long_line_enabled
Definition: editor.h:137
gboolean use_tab_to_indent
Definition: editor.h:117
gboolean show_indent_guide
Definition: editor.h:102
gboolean show_linenumber_margin
Definition: editor.h:109
gint long_line_column
Definition: editor.h:106
guint autocompletion_max_entries
Definition: editor.h:131
gchar * color_scheme
Definition: editor.h:135
gint show_virtual_space
Definition: editor.h:136
guint autoclose_chars
Definition: editor.h:132
gchar * comment_toggle_mark
Definition: editor.h:130
gboolean autocomplete_doc_words
Definition: editor.h:133
gboolean auto_close_xml_tags
Definition: editor.h:121
gboolean auto_complete_symbols
Definition: editor.h:120
gboolean use_indicators
Definition: editor.h:113
gboolean complete_snippets
Definition: editor.h:122
gint symbolcompletion_max_height
Definition: editor.h:124
gint long_line_type
Definition: editor.h:105
gboolean use_gtk_word_boundaries
Definition: editor.h:126
gint scroll_lines_around_cursor
Definition: editor.h:139
gboolean smart_home_key
Definition: editor.h:118
gboolean show_line_endings
Definition: editor.h:103
gboolean folding
Definition: editor.h:114
gchar * long_line_color
Definition: editor.h:107
gboolean completion_drops_rest_of_word
Definition: editor.h:134
gboolean show_white_space
Definition: editor.h:101
Editor-owned fields for each document.
Definition: editor.h:150
GeanyIndentType indent_type
Definition: editor.h:157
gboolean line_breaking
Whether to split long lines as you type.
Definition: editor.h:158
gboolean auto_indent
TRUE if auto-indentation is enabled.
Definition: editor.h:154
ScintillaObject * sci
The Scintilla editor GtkWidget.
Definition: editor.h:152
struct GeanyDocument * document
The document associated with the editor.
Definition: editor.h:151
gboolean line_wrapping
TRUE if line wrapping is enabled.
Definition: editor.h:153
gint indent_width
Definition: editor.h:159
gfloat scroll_percent
Percentage to scroll view by on paint, if positive.
Definition: editor.h:156
Indentation prefs that might be different according to project or filetype.
Definition: editor.h:83
gboolean detect_type
Definition: editor.h:90
GeanyIndentType type
Whether to use tabs, spaces or both to indent.
Definition: editor.h:85
gboolean detect_width
Definition: editor.h:91
gint hard_tab_width
Width of a tab, but only when using GEANY_INDENT_TYPE_BOTH.
Definition: editor.h:88
GeanyAutoIndent auto_indent_mode
Definition: editor.h:89
gint width
Indent width.
Definition: editor.h:84
The TMTag structure represents a single tag in the tag manager.
Definition: tm_tag.h:88