/* * editor.h - this file is part of Geany, a fast and lightweight IDE * * Copyright 2005-2008 Enrico Tröger * Copyright 2006-2008 Nick Treleaven * * 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. * * $Id$ */ #ifndef GEANY_SCI_CB_H #define GEANY_SCI_CB_H 1 #include "Scintilla.h" #include "ScintillaWidget.h" #define GEANY_WORDCHARS "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" #define GEANY_MAX_WORD_LENGTH 192 /* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */ #define SSM(s, m, w, l) scintilla_send_message(s, m, w, l) /** Whether to use tabs, spaces or both to indent. */ typedef enum { GEANY_INDENT_TYPE_SPACES, /**< Spaces. */ GEANY_INDENT_TYPE_TABS, /**< Tabs. */ GEANY_INDENT_TYPE_BOTH /**< Both. */ } GeanyIndentType; typedef enum { GEANY_AUTOINDENT_NONE = 0, GEANY_AUTOINDENT_BASIC, GEANY_AUTOINDENT_CURRENTCHARS, GEANY_AUTOINDENT_MATCHBRACES } GeanyAutoIndent; /** 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. */ typedef struct GeanyIndentPrefs { gint width; /**< Indent width. */ GeanyIndentType type; /**< Whether to use tabs, spaces or both to indent. */ /** Width of a tab, but only when using GEANY_INDENT_TYPE_BOTH. * To get the display tab width, use sci_get_tab_width(). */ gint hard_tab_width; GeanyAutoIndent auto_indent_mode; gboolean detect_type; } GeanyIndentPrefs; /* Default prefs when creating a new editor window. * Some of these can be overridden per document. */ typedef struct GeanyEditorPrefs { GeanyIndentPrefs *indentation; /*< Default indentation prefs. @see editor_get_indent_prefs(). */ gboolean show_white_space; gboolean show_indent_guide; gboolean show_line_endings; gint long_line_type; gint long_line_column; gchar *long_line_color; 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 */ gboolean line_wrapping; gboolean use_indicators; gboolean folding; gboolean unfold_all_children; gboolean disable_dnd; gboolean use_tab_to_indent; /* makes tab key indent instead of insert a tab char */ gboolean smart_home_key; gboolean newline_strip; gboolean auto_complete_symbols; gboolean auto_close_xml_tags; gboolean complete_snippets; gint symbolcompletion_min_chars; gint symbolcompletion_max_height; GHashTable *snippets; 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 */ gint line_break_column; gboolean auto_continue_multiline; gchar *comment_toggle_mark; guint autocompletion_max_entries; } GeanyEditorPrefs; extern GeanyEditorPrefs editor_prefs; /** Editor-owned fields for each document. */ typedef struct GeanyEditor { GeanyDocument *document; /**< The document associated with the editor. */ ScintillaObject *sci; /**< The Scintilla editor @c GtkWidget. */ 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; GeanyIndentType indent_type; /* Use editor_get_indent_prefs() instead. */ gboolean line_breaking; /**< Whether to split long lines as you type. */ } GeanyEditor; typedef struct { gchar *current_word; /* holds word under the mouse or keyboard cursor */ gint click_pos; /* text position where the mouse was clicked */ } EditorInfo; extern EditorInfo editor_info; void editor_init(void); GeanyEditor *editor_create(GeanyDocument *doc); void editor_destroy(GeanyEditor *editor); ScintillaObject *editor_create_widget(GeanyEditor *editor); void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data); gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force); gboolean editor_complete_snippet(GeanyDocument *doc, gint pos); void editor_auto_latex(GeanyDocument *doc, gint pos); void editor_show_macro_list(ScintillaObject *sci); gboolean editor_show_calltip(GeanyDocument *doc, gint pos); void editor_do_comment_toggle(GeanyDocument *doc); void editor_do_comment(GeanyDocument *doc, gint line, gboolean allow_empty_lines, gboolean toggle); gint editor_do_uncomment(GeanyDocument *doc, gint line, gboolean toggle); void editor_highlight_braces(ScintillaObject *sci, gint cur_pos); gboolean editor_lexer_is_c_like(gint lexer); gint editor_lexer_get_type_keyword_idx(gint lexer); void editor_insert_multiline_comment(GeanyDocument *doc); void editor_insert_alternative_whitespace(GeanyEditor *editor); void editor_smart_line_indentation(GeanyDocument *doc, gint pos); void editor_indentation_by_one_space(GeanyDocument *doc, gint pos, gboolean decrease); gboolean editor_line_in_view(ScintillaObject *sci, gint line); void editor_scroll_to_line(ScintillaObject *sci, gint line, gfloat percent_of_view); void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view); void editor_finalize(void); void editor_snippets_init(void); void editor_snippets_free(void); /* General editing functions */ void editor_find_current_word(ScintillaObject *sci, gint pos, gchar *word, size_t wordlen, const gchar *wc); gchar *editor_get_default_selection(GeanyDocument *doc, gboolean use_current_word, const gchar *wordchars); void editor_select_word(ScintillaObject *sci); void editor_select_lines(ScintillaObject *sci, gboolean extra_line); void editor_select_paragraph(ScintillaObject *sci); void editor_set_indicator_on_line(GeanyEditor *editor, gint line); void editor_set_indicator(GeanyEditor *editor, gint start, gint end); void editor_clear_indicators(GeanyEditor *editor); void editor_set_font(GeanyEditor *editor, const gchar *font); const gchar *editor_get_eol_char_name(GeanyDocument *doc); gint editor_get_eol_char_len(GeanyDocument *doc); const gchar *editor_get_eol_char(GeanyDocument *doc); void editor_fold_all(GeanyDocument *doc); void editor_unfold_all(GeanyDocument *doc); void editor_replace_tabs(GeanyDocument *doc); void editor_replace_spaces(GeanyDocument *doc); void editor_strip_line_trailing_spaces(GeanyDocument *doc, gint line); void editor_strip_trailing_spaces(GeanyDocument *doc); void editor_ensure_final_newline(GeanyDocument *doc); void editor_insert_color(GeanyDocument *doc, const gchar *colour); const GeanyIndentPrefs *editor_get_indent_prefs(GeanyEditor *editor); void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type); void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap); gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark); void editor_set_indentation_guides(GeanyEditor *editor); void editor_apply_update_prefs(GeanyEditor *editor); #endif