2005-11-22 12:26:26 +00:00
|
|
|
/*
|
2007-05-28 16:07:30 +00:00
|
|
|
* editor.h - this file is part of Geany, a fast and lightweight IDE
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
2008-01-06 18:11:57 +00:00
|
|
|
* Copyright 2005-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
2007-06-17 17:56:48 +00:00
|
|
|
* $Id$
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2008-05-14 17:58:56 +00:00
|
|
|
|
2008-09-26 14:16:44 +00:00
|
|
|
#ifndef GEANY_EDITOR_H
|
|
|
|
#define GEANY_EDITOR_H 1
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-08-20 20:39:59 +00:00
|
|
|
#include "Scintilla.h"
|
|
|
|
#include "ScintillaWidget.h"
|
|
|
|
|
2008-04-23 16:47:42 +00:00
|
|
|
#define GEANY_WORDCHARS "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
|
|
#define GEANY_MAX_WORD_LENGTH 192
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-07-28 11:52:19 +00:00
|
|
|
/** Whether to use tabs, spaces or both to indent. */
|
2007-06-12 15:16:17 +00:00
|
|
|
typedef enum
|
2007-05-29 16:30:54 +00:00
|
|
|
{
|
2008-07-28 13:38:12 +00:00
|
|
|
GEANY_INDENT_TYPE_SPACES, /**< Spaces. */
|
2008-08-04 14:07:49 +00:00
|
|
|
GEANY_INDENT_TYPE_TABS, /**< Tabs. */
|
2008-07-28 11:52:19 +00:00
|
|
|
GEANY_INDENT_TYPE_BOTH /**< Both. */
|
|
|
|
}
|
|
|
|
GeanyIndentType;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GEANY_AUTOINDENT_NONE = 0,
|
|
|
|
GEANY_AUTOINDENT_BASIC,
|
|
|
|
GEANY_AUTOINDENT_CURRENTCHARS,
|
|
|
|
GEANY_AUTOINDENT_MATCHBRACES
|
|
|
|
}
|
|
|
|
GeanyAutoIndent;
|
|
|
|
|
2008-10-25 18:57:00 +00:00
|
|
|
/** Geany indicator types, can be used with Editor indicator functions to highlight
|
|
|
|
* text in the document. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/** Indicator to highlight errors in the document text. This is a red squiggly underline. */
|
|
|
|
GEANY_INDICATOR_ERROR = 0,
|
|
|
|
/** Indicator used to highlight search results in the document. This is a
|
|
|
|
* rounded box around the text. */
|
|
|
|
/* start container indicator outside of lexer indicators (0..7), see Scintilla docs */
|
|
|
|
GEANY_INDICATOR_SEARCH = 8
|
|
|
|
}
|
|
|
|
GeanyIndicator;
|
2007-05-29 16:30:54 +00:00
|
|
|
|
2008-07-30 15:26:49 +00:00
|
|
|
/** Indentation prefs that might be different according to project or filetype.
|
|
|
|
* Use @c editor_get_indent_prefs() to lookup the prefs for a particular document. */
|
2008-07-25 15:05:27 +00:00
|
|
|
typedef struct GeanyIndentPrefs
|
|
|
|
{
|
2008-07-28 11:52:19 +00:00
|
|
|
gint width; /**< Indent width. */
|
|
|
|
GeanyIndentType type; /**< Whether to use tabs, spaces or both to indent. */
|
2008-08-08 14:46:31 +00:00
|
|
|
/** Width of a tab, but only when using GEANY_INDENT_TYPE_BOTH.
|
|
|
|
* To get the display tab width, use sci_get_tab_width(). */
|
2008-08-11 16:53:03 +00:00
|
|
|
gint hard_tab_width;
|
2008-07-28 11:52:19 +00:00
|
|
|
GeanyAutoIndent auto_indent_mode;
|
2008-07-29 14:43:34 +00:00
|
|
|
gboolean detect_type;
|
2008-07-25 15:05:27 +00:00
|
|
|
}
|
|
|
|
GeanyIndentPrefs;
|
|
|
|
|
|
|
|
|
2008-07-30 15:26:49 +00:00
|
|
|
/* Default prefs when creating a new editor window.
|
2008-07-25 15:05:27 +00:00
|
|
|
* Some of these can be overridden per document. */
|
2008-05-16 12:08:39 +00:00
|
|
|
typedef struct GeanyEditorPrefs
|
2007-05-29 16:30:54 +00:00
|
|
|
{
|
2008-07-30 15:26:49 +00:00
|
|
|
GeanyIndentPrefs *indentation; /*< Default indentation prefs. @see editor_get_indent_prefs(). */
|
2007-05-29 16:30:54 +00:00
|
|
|
gboolean show_white_space;
|
|
|
|
gboolean show_indent_guide;
|
|
|
|
gboolean show_line_endings;
|
2007-08-24 16:20:33 +00:00
|
|
|
gint long_line_type;
|
|
|
|
gint long_line_column;
|
|
|
|
gchar *long_line_color;
|
2008-02-27 13:17:29 +00:00
|
|
|
gboolean show_markers_margin; /* view menu */
|
|
|
|
gboolean show_linenumber_margin; /* view menu */
|
|
|
|
gboolean show_scrollbars; /* hidden pref */
|
|
|
|
gboolean scroll_stop_at_last_line; /* hidden pref */
|
2007-08-24 16:20:33 +00:00
|
|
|
gboolean line_wrapping;
|
|
|
|
gboolean use_indicators;
|
2007-05-29 16:30:54 +00:00
|
|
|
gboolean folding;
|
|
|
|
gboolean unfold_all_children;
|
|
|
|
gboolean disable_dnd;
|
2008-09-18 12:43:41 +00:00
|
|
|
gboolean use_tab_to_indent; /* makes tab key indent instead of insert a tab char */
|
2007-07-12 15:44:13 +00:00
|
|
|
gboolean smart_home_key;
|
2007-10-18 11:52:47 +00:00
|
|
|
gboolean newline_strip;
|
2007-08-24 16:20:33 +00:00
|
|
|
gboolean auto_complete_symbols;
|
|
|
|
gboolean auto_close_xml_tags;
|
2007-11-12 09:36:25 +00:00
|
|
|
gboolean complete_snippets;
|
2007-12-01 17:53:36 +00:00
|
|
|
gint symbolcompletion_min_chars;
|
2007-11-12 09:36:25 +00:00
|
|
|
gint symbolcompletion_max_height;
|
|
|
|
GHashTable *snippets;
|
2008-02-27 13:17:29 +00:00
|
|
|
gboolean brace_match_ltgt; /* whether to highlight < and > chars (hidden pref) */
|
|
|
|
gboolean use_gtk_word_boundaries; /* hidden pref */
|
|
|
|
gboolean complete_snippets_whilst_editing; /* hidden pref */
|
2008-05-09 12:13:29 +00:00
|
|
|
gint line_break_column;
|
2008-05-14 15:36:27 +00:00
|
|
|
gboolean auto_continue_multiline;
|
2008-07-27 18:41:07 +00:00
|
|
|
gchar *comment_toggle_mark;
|
2008-08-29 17:00:02 +00:00
|
|
|
guint autocompletion_max_entries;
|
2008-05-16 12:08:39 +00:00
|
|
|
} GeanyEditorPrefs;
|
2007-05-29 16:30:54 +00:00
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
extern GeanyEditorPrefs editor_prefs;
|
2007-05-29 16:30:54 +00:00
|
|
|
|
|
|
|
|
2008-07-08 10:50:13 +00:00
|
|
|
/** Editor-owned fields for each document. */
|
|
|
|
typedef struct GeanyEditor
|
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
GeanyDocument *document; /**< The document associated with the editor. */
|
|
|
|
ScintillaObject *sci; /**< The Scintilla editor @c GtkWidget. */
|
2008-07-08 10:50:13 +00:00
|
|
|
gboolean line_wrapping; /**< @c TRUE if line wrapping is enabled. */
|
|
|
|
gboolean auto_indent; /**< @c TRUE if auto-indentation is enabled. */
|
|
|
|
/** Percentage to scroll view by on paint, if positive. */
|
|
|
|
gfloat scroll_percent;
|
2008-07-31 14:47:03 +00:00
|
|
|
GeanyIndentType indent_type; /* Use editor_get_indent_prefs() instead. */
|
2008-07-08 10:50:13 +00:00
|
|
|
gboolean line_breaking; /**< Whether to split long lines as you type. */
|
|
|
|
}
|
|
|
|
GeanyEditor;
|
|
|
|
|
|
|
|
|
2006-09-04 15:57:46 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
gchar *current_word; /* holds word under the mouse or keyboard cursor */
|
|
|
|
gint click_pos; /* text position where the mouse was clicked */
|
2006-09-04 15:57:46 +00:00
|
|
|
} EditorInfo;
|
|
|
|
|
|
|
|
extern EditorInfo editor_info;
|
|
|
|
|
2006-07-16 22:02:31 +00:00
|
|
|
|
2007-06-17 17:56:48 +00:00
|
|
|
|
|
|
|
|
2008-07-25 15:05:27 +00:00
|
|
|
void editor_init(void);
|
|
|
|
|
2008-07-11 14:11:53 +00:00
|
|
|
GeanyEditor *editor_create(GeanyDocument *doc);
|
2006-09-04 15:57:46 +00:00
|
|
|
|
2008-08-25 15:44:51 +00:00
|
|
|
void editor_destroy(GeanyEditor *editor);
|
|
|
|
|
2008-09-16 15:21:46 +00:00
|
|
|
ScintillaObject *editor_create_widget(GeanyEditor *editor);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean force);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gboolean editor_complete_snippet(GeanyEditor *editor, gint pos);
|
2006-03-10 00:49:19 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_auto_latex(GeanyEditor *editor, gint pos);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_show_macro_list(GeanyEditor *editor);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gboolean editor_show_calltip(GeanyEditor *editor, gint pos);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_do_comment_toggle(GeanyEditor *editor);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_lines, gboolean toggle);
|
2006-09-10 11:47:26 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle);
|
2006-07-31 09:39:33 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_highlight_braces(GeanyEditor *editor, gint cur_pos);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-05-28 16:07:30 +00:00
|
|
|
gboolean editor_lexer_is_c_like(gint lexer);
|
2006-12-15 12:52:52 +00:00
|
|
|
|
2007-05-28 16:07:30 +00:00
|
|
|
gint editor_lexer_get_type_keyword_idx(gint lexer);
|
2006-12-16 17:18:53 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_insert_multiline_comment(GeanyEditor *editor);
|
2007-01-06 15:03:53 +00:00
|
|
|
|
2008-07-08 13:53:08 +00:00
|
|
|
void editor_insert_alternative_whitespace(GeanyEditor *editor);
|
2007-03-25 20:51:45 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_smart_line_indentation(GeanyEditor *editor, gint pos);
|
2007-07-16 15:42:12 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_indentation_by_one_space(GeanyEditor *editor, gint pos, gboolean decrease);
|
2007-07-16 15:42:12 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gboolean editor_line_in_view(GeanyEditor *editor, gint line);
|
2008-02-22 13:30:16 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_scroll_to_line(GeanyEditor *editor, gint line, gfloat percent_of_view);
|
2007-07-17 16:27:49 +00:00
|
|
|
|
2008-07-08 13:53:08 +00:00
|
|
|
void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view);
|
2008-02-22 13:30:16 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void editor_finalize(void);
|
2007-06-17 17:56:48 +00:00
|
|
|
|
2008-06-30 16:14:55 +00:00
|
|
|
void editor_snippets_init(void);
|
|
|
|
|
|
|
|
void editor_snippets_free(void);
|
2008-01-14 17:30:59 +00:00
|
|
|
|
|
|
|
/* General editing functions */
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_find_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t wordlen,
|
2008-01-14 17:30:59 +00:00
|
|
|
const gchar *wc);
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gchar *editor_get_default_selection(GeanyEditor *editor, gboolean use_current_word, const gchar *wordchars);
|
2008-01-14 17:30:59 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_select_word(GeanyEditor *editor);
|
2008-01-14 17:30:59 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_select_lines(GeanyEditor *editor, gboolean extra_line);
|
2008-01-14 17:30:59 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_select_paragraph(GeanyEditor *editor);
|
2008-01-14 17:30:59 +00:00
|
|
|
|
2008-07-11 14:49:09 +00:00
|
|
|
void editor_set_indicator_on_line(GeanyEditor *editor, gint line);
|
2008-05-14 17:58:56 +00:00
|
|
|
|
2008-07-11 14:49:09 +00:00
|
|
|
void editor_set_indicator(GeanyEditor *editor, gint start, gint end);
|
2008-05-14 17:58:56 +00:00
|
|
|
|
2008-07-11 14:49:09 +00:00
|
|
|
void editor_clear_indicators(GeanyEditor *editor);
|
2008-05-14 17:58:56 +00:00
|
|
|
|
2008-07-11 17:09:01 +00:00
|
|
|
void editor_set_font(GeanyEditor *editor, const gchar *font);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-10-25 18:57:00 +00:00
|
|
|
void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint line);
|
|
|
|
|
|
|
|
void editor_set_indicator_full(GeanyEditor *editor, gint indic, gint start, gint end);
|
|
|
|
|
|
|
|
void editor_clear_indicators_full(GeanyEditor *editor, gint indic);
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
const gchar *editor_get_eol_char_name(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
gint editor_get_eol_char_len(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
const gchar *editor_get_eol_char(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_fold_all(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_unfold_all(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_replace_tabs(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_replace_spaces(GeanyEditor *editor);
|
2008-06-19 14:34:53 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_strip_line_trailing_spaces(GeanyEditor *editor, gint line);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_strip_trailing_spaces(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_ensure_final_newline(GeanyEditor *editor);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
void editor_insert_color(GeanyEditor *editor, const gchar *colour);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-07-31 14:47:03 +00:00
|
|
|
const GeanyIndentPrefs *editor_get_indent_prefs(GeanyEditor *editor);
|
|
|
|
|
|
|
|
void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-07-08 13:53:08 +00:00
|
|
|
void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap);
|
2008-05-15 13:43:29 +00:00
|
|
|
|
2008-07-08 13:53:08 +00:00
|
|
|
gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark);
|
2008-05-22 14:41:28 +00:00
|
|
|
|
2008-10-23 20:55:06 +00:00
|
|
|
gboolean editor_goto_line(GeanyEditor *editor, gint line_no);
|
|
|
|
|
2008-09-21 16:43:45 +00:00
|
|
|
void editor_set_indentation_guides(GeanyEditor *editor);
|
|
|
|
|
|
|
|
void editor_apply_update_prefs(GeanyEditor *editor);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#endif
|