Geany dev
|
Editor-related functions for GeanyEditor. More...
Data Structures | |
struct | GeanyEditor |
Editor-owned fields for each document. More... | |
struct | GeanyEditorPrefs |
Default prefs when creating a new editor window. More... | |
struct | GeanyIndentPrefs |
Indentation prefs that might be different according to project or filetype. More... | |
Macros | |
#define | GEANY_WORDCHARS "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
Default character set to define which characters should be treated as part of a word. | |
Typedefs | |
typedef struct GeanyEditor | GeanyEditor |
Editor-owned fields for each document. | |
typedef struct GeanyEditorPrefs | GeanyEditorPrefs |
Default prefs when creating a new editor window. More... | |
typedef struct GeanyIndentPrefs | GeanyIndentPrefs |
Indentation prefs that might be different according to project or filetype. More... | |
Enumerations | |
enum | GeanyIndentType { GEANY_INDENT_TYPE_SPACES , GEANY_INDENT_TYPE_TABS , GEANY_INDENT_TYPE_BOTH } |
Whether to use tabs, spaces or both to indent. More... | |
enum | GeanyIndicator { GEANY_INDICATOR_ERROR = 0 , GEANY_INDICATOR_SEARCH = 8 , GEANY_INDICATOR_SNIPPET = 9 } |
Geany indicator types, can be used with Editor indicator functions to highlight text in the document. More... | |
Functions | |
ScintillaObject * | editor_create_widget (GeanyEditor *editor) |
Creates a new Scintilla GtkWidget based on the settings for editor. More... | |
const gchar * | editor_find_snippet (GeanyEditor *editor, const gchar *snippet_name) |
Gets snippet by name. More... | |
const gchar * | editor_get_eol_char (GeanyEditor *editor) |
Retrieves the used end of line characters (LF, CR/LF, CR) in the given editor. More... | |
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. More... | |
gint | editor_get_eol_char_mode (GeanyEditor *editor) |
Retrieves the end of line characters mode (LF, CR/LF, CR) in the given editor. More... | |
const gchar * | editor_get_eol_char_name (GeanyEditor *editor) |
Retrieves the localized name (for displaying) of the used end of line characters (LF, CR/LF, CR) in the given editor. More... | |
const GeanyIndentPrefs * | editor_get_indent_prefs (GeanyEditor *editor) |
Gets the indentation prefs for the editor. More... | |
gchar * | editor_get_word_at_pos (GeanyEditor *editor, gint pos, const gchar *wordchars) |
Finds the word at the position specified by pos. More... | |
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. More... | |
void | editor_indicator_clear (GeanyEditor *editor, gint indic) |
Deletes all currently set indicators matching indic in the editor window. More... | |
void | editor_indicator_set_on_line (GeanyEditor *editor, gint indic, gint line) |
Sets an indicator indic on line. More... | |
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. More... | |
void | editor_insert_snippet (GeanyEditor *editor, gint pos, const gchar *snippet) |
Replaces all special sequences in snippet and inserts it at pos. More... | |
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. More... | |
void | editor_set_indent_type (GeanyEditor *editor, GeanyIndentType type) |
Sets the indent type for editor. More... | |
void | editor_set_indent_width (GeanyEditor *editor, gint width) |
Sets the indent width for editor. More... | |
Editor-related functions for GeanyEditor.
Geany uses the Scintilla editing widget, and this file is mostly built around Scintilla's functionality.
typedef struct GeanyEditorPrefs GeanyEditorPrefs |
Default prefs when creating a new editor window.
Some of these can be overridden per document or per project.
typedef struct GeanyIndentPrefs GeanyIndentPrefs |
Indentation prefs that might be different according to project or filetype.
Use editor_get_indent_prefs()
to lookup the prefs for a particular document.
enum GeanyIndentType |
enum GeanyIndicator |
Geany indicator types, can be used with Editor indicator functions to highlight text in the document.
ScintillaObject * editor_create_widget | ( | GeanyEditor * | editor | ) |
Creates a new Scintilla GtkWidget
based on the settings for editor.
editor | Editor settings. |
const gchar * editor_find_snippet | ( | GeanyEditor * | editor, |
const gchar * | snippet_name | ||
) |
Gets snippet by name.
If editor is passed, returns a snippet specific to the document filetype. If editor is NULL
, returns a snippet from the default set.
editor | Editor or NULL . |
snippet_name | Snippet name. |
NULL
if it was not found. Must not be freed. const gchar * editor_get_eol_char | ( | GeanyEditor * | editor | ) |
Retrieves the used end of line characters (LF, CR/LF, CR) in the given editor.
If editor is NULL
, the default end of line characters are used. The returned value is either "\n", "\r\n" or "\r".
editor | The editor to operate on, or NULL to query the default value. |
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.
If editor is NULL
, the default end of line characters are used. The returned value is 1 for CR and LF and 2 for CR/LF.
editor | The editor to operate on, or NULL to query the default value. |
gint editor_get_eol_char_mode | ( | GeanyEditor * | editor | ) |
Retrieves the end of line characters mode (LF, CR/LF, CR) in the given editor.
If editor is NULL
, the default end of line characters are used.
editor | The editor to operate on, or NULL to query the default value. |
const gchar * editor_get_eol_char_name | ( | GeanyEditor * | editor | ) |
Retrieves the localized name (for displaying) of the used end of line characters (LF, CR/LF, CR) in the given editor.
If editor is NULL
, the default end of line characters are used.
editor | The editor to operate on, or NULL to query the default value. |
const GeanyIndentPrefs * editor_get_indent_prefs | ( | GeanyEditor * | editor | ) |
Gets the indentation prefs for the editor.
Prefs can be different according to project or document.
editor | The editor, or NULL to get the default indent prefs. |
gchar * editor_get_word_at_pos | ( | GeanyEditor * | editor, |
gint | pos, | ||
const gchar * | wordchars | ||
) |
Finds the word at the position specified by pos.
If any word is found, it is returned. Otherwise NULL is returned. Additional wordchars can be specified to define what to consider as a word.
editor | The editor to operate on. |
pos | The position where the word should be read from. May be -1 to use the current position. |
wordchars | The wordchars to separate words. wordchars mean all characters to count as part of a word. May be NULL to use the default wordchars, see GEANY_WORDCHARS. |
NULL
. Should be freed when no longer needed.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.
editor | Editor. |
pos | The position. |
mark | Whether to set a mark on the position. |
TRUE
if action has been performed, otherwise FALSE
.void editor_indicator_clear | ( | GeanyEditor * | editor, |
gint | indic | ||
) |
Deletes all currently set indicators matching indic in the editor window.
editor | The editor to operate on. |
indic | The indicator number to clear, this is a value of GeanyIndicator. |
void editor_indicator_set_on_line | ( | GeanyEditor * | editor, |
gint | indic, | ||
gint | line | ||
) |
Sets an indicator indic on line.
Whitespace at the start and the end of the line is not marked.
editor | The editor to operate on. |
indic | The indicator number to use, this is a value of GeanyIndicator. |
line | The line number which should be marked. |
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.
No error checking or whitespace removal is performed, this should be done by the calling function if necessary.
editor | The editor to operate on. |
indic | The indicator number to use, this is a value of GeanyIndicator. |
start | The starting position for the marker. |
end | The ending position for the marker. |
void editor_insert_snippet | ( | GeanyEditor * | editor, |
gint | pos, | ||
const gchar * | snippet | ||
) |
Replaces all special sequences in snippet and inserts it at pos.
If you insert at the current position, consider calling sci_scroll_caret()
after this function.
editor | . |
pos | . |
snippet | . |
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.
editor | Editor. |
text | Intended as e.g. "if (foo)\n\tbar();" . |
insert_pos | Document position to insert text at. |
cursor_index | If >= 0, the index into text to place the cursor. |
newline_indent_size | Indentation size (in spaces) to insert for each newline; use -1 to read the indent size from the line with insert_pos on it. |
replace_newlines | Whether to replace newlines. If newlines have been replaced already, this should be false, to avoid errors e.g. on Windows. |
void editor_set_indent_type | ( | GeanyEditor * | editor, |
GeanyIndentType | type | ||
) |
Sets the indent type for editor.
editor | Editor. |
type | Indent type. |
void editor_set_indent_width | ( | GeanyEditor * | editor, |
gint | width | ||
) |
Sets the indent width for editor.
editor | Editor. |
width | New indent width. |