anjuta-extras r14 - in trunk: . plugins/sample1 plugins/scintilla plugins/scintilla/scintilla plugins/valgrind
- From: mcora svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta-extras r14 - in trunk: . plugins/sample1 plugins/scintilla plugins/scintilla/scintilla plugins/valgrind
- Date: Wed, 8 Apr 2009 22:31:22 +0000 (UTC)
Author: mcora
Date: Wed Apr 8 22:31:22 2009
New Revision: 14
URL: http://svn.gnome.org/viewvc/anjuta-extras?rev=14&view=rev
Log:
* Makefile:
* configure.ac:
* plugins/sample1/Makefile.in:
* plugins/scintilla/Makefile.am:
* plugins/scintilla/aneditor-autocomplete.cxx:
* plugins/scintilla/aneditor-calltip.cxx:
* plugins/scintilla/aneditor-indent.cxx:
* plugins/scintilla/aneditor-priv.h:
* plugins/scintilla/aneditor.cxx:
* plugins/scintilla/aneditor.h:
* plugins/scintilla/anjuta-bookmark-16.xpm:
* plugins/scintilla/anjuta-pcmark-16.xpm:
* plugins/scintilla/plugin.c (on_style_button_clicked),
(activate_plugin), (deactivate_plugin), (dispose), (finalize),
(editor_plugin_instance_init), (editor_plugin_class_init),
(itext_editor_factory_new_editor),
(itext_editor_factory_iface_init), (ipreferences_merge),
(ipreferences_unmerge), (ipreferences_iface_init):
* plugins/scintilla/scintilla/Makefile.am:
* plugins/scintilla/style-editor.c (style_data_get_string),
(style_data_set_font), (style_data_set_font_size_from_pango),
(style_data_set_fore), (style_data_set_back),
(style_data_set_item), (style_data_new), (style_data_destroy),
(style_data_new_parse), (on_use_default_font_toggled),
(on_use_default_attrib_toggled), (on_use_default_fore_toggled),
(on_use_default_back_toggled), (on_hilite_style_entry_changed),
(sync_from_props), (set_one_color), (sync_to_props),
(apply_styles), (on_response), (on_delete_event),
(create_style_editor_gui), (style_editor_new),
(style_editor_destroy), (style_editor_show), (style_editor_hide),
(style_editor_save):
* plugins/scintilla/style-editor.h:
* plugins/scintilla/text-editor-iterable.c (cell_style_destroy),
(IntFromHexDigit), (string_to_color), (cell_style_load_font),
(cell_style_init), (cell_style_new), (text_editor_cell_get_style),
(text_editor_cell_class_init), (text_editor_cell_instance_init),
(text_editor_cell_finalize), (text_editor_cell_new),
(text_editor_cell_get_editor), (text_editor_cell_set_position),
(text_editor_cell_get_position), (icell_get_character),
(icell_get_length), (icell_get_char), (icell_get_attribute),
(icell_iface_init), (icell_style_get_font_description),
(icell_style_get_color), (icell_style_get_background_color),
(icell_style_iface_init), (iiter_first), (iiter_next),
(iiter_previous), (iiter_last), (iiter_foreach),
(iiter_set_position), (iiter_get_position), (iiter_get_length),
(iiter_clone), (iiter_assign), (iiter_compare), (iiter_diff),
(iiter_iface_init):
* plugins/scintilla/text_editor.c (text_editor_instance_init),
(text_editor_dispose), (text_editor_hilite_one), (load_from_file),
(save_to_file), (text_editor_load_file),
(text_editor_set_line_number_width):
* plugins/scintilla/text_editor.h:
* plugins/scintilla/text_editor_cbs.c
(on_text_editor_scintilla_focus_in),
(on_text_editor_text_buttonpress_event),
(on_text_editor_text_keyrelease_event),
(on_text_editor_text_event), (scintilla_uri_dropped),
(click_timeout), (on_text_editor_scintilla_notify),
(on_text_editor_scintilla_size_allocate):
* plugins/scintilla/text_editor_cbs.h:
* plugins/scintilla/text_editor_prefs.c (pref_gconf_notify),
(on_gconf_notify_disable_hilite), (on_gconf_notify_zoom_factor),
(on_gconf_notify_tab_size),
(on_gconf_notify_use_tab_for_indentation),
(on_gconf_notify_automatic_indentation),
(on_gconf_notify_indent_size), (on_gconf_notify_wrap_bookmarks),
(on_gconf_notify_braces_check), (on_gconf_notify_indent_opening),
(on_gconf_notify_indent_closing),
(on_gconf_notify_indent_maintain), (on_gconf_notify_tab_indents),
(on_gconf_notify_backspace_unindents), (on_gconf_notify_view_eols),
(on_gconf_notify_view_whitespaces),
(on_gconf_notify_view_linewrap),
(on_gconf_notify_view_indentation_guides),
(on_gconf_notify_view_folds), (on_gconf_notify_view_markers),
(on_gconf_notify_view_linenums), (on_gconf_notify_fold_symbols),
(on_gconf_notify_fold_underline), (on_gconf_notify_edge_column),
(text_editor_prefs_init), (text_editor_prefs_finalize):
* plugins/valgrind/Makefile.in:
scintilla was very broken.
Added:
trunk/plugins/scintilla/aneditor-autocomplete.cxx
trunk/plugins/scintilla/aneditor-calltip.cxx
trunk/plugins/scintilla/aneditor-indent.cxx
trunk/plugins/scintilla/aneditor-priv.h
trunk/plugins/scintilla/aneditor.cxx
trunk/plugins/scintilla/aneditor.h
trunk/plugins/scintilla/anjuta-bookmark-16.xpm
trunk/plugins/scintilla/anjuta-pcmark-16.xpm
trunk/plugins/scintilla/plugin.c
trunk/plugins/scintilla/style-editor.c
trunk/plugins/scintilla/style-editor.h
trunk/plugins/scintilla/text-editor-iterable.c
trunk/plugins/scintilla/text_editor.h
trunk/plugins/scintilla/text_editor_cbs.c
trunk/plugins/scintilla/text_editor_cbs.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/plugins/sample1/Makefile.in
trunk/plugins/scintilla/Makefile.am
trunk/plugins/scintilla/scintilla/Makefile.am
trunk/plugins/scintilla/text_editor.c
trunk/plugins/scintilla/text_editor_prefs.c
trunk/plugins/valgrind/Makefile.in
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Apr 8 22:31:22 2009
@@ -19,11 +19,25 @@
LIBGRAPHVIZ_REQUIRED=1.0
GTK_REQUIRED=2.14.0
GLIB_REQUIRED=2.16.0
+GCONF_REQUIRED=2.12.0
AC_SUBST(LIBGRAPHVIZ_REQUIRED)
AC_SUBST(BINUTILS_REQUIRED)
AC_SUBST(GTK_REQUIRED)
AC_SUBST(GLIB_REQUIRED)
+AC_SUBST(GCONF_REQUIRED)
+
+
+dnl ***************************************************************************
+dnl we need gconftool-2 in order to install the schema
+dnl ***************************************************************************
+AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
+
+if test "x$GCONFTOOL" = "xno"; then
+ AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
+fi
+AM_GCONF_SOURCE_2
+
dnl Compiler settings
dnl ---------------------------------------------------------------------------
@@ -57,6 +71,7 @@
dnl Check for libanjuta
PKG_CHECK_MODULES(LIBANJUTA, [libanjuta-1.0 >= 2.27.0])
+
dnl Valgrind plugin
dnl check for libbfd
dnl -------------------------------------------------------------
Modified: trunk/plugins/sample1/Makefile.in
==============================================================================
--- trunk/plugins/sample1/Makefile.in (original)
+++ trunk/plugins/sample1/Makefile.in Wed Apr 8 22:31:22 2009
@@ -121,6 +121,7 @@
EXTRA_CFLAGS = @EXTRA_CFLAGS@
FGREP = @FGREP@
GCONFTOOL = @GCONFTOOL@
+GCONF_REQUIRED = @GCONF_REQUIRED@
GCONF_SCHEMAS_INSTALL_FALSE = @GCONF_SCHEMAS_INSTALL_FALSE@
GCONF_SCHEMAS_INSTALL_TRUE = @GCONF_SCHEMAS_INSTALL_TRUE@
GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@
Modified: trunk/plugins/scintilla/Makefile.am
==============================================================================
--- trunk/plugins/scintilla/Makefile.am (original)
+++ trunk/plugins/scintilla/Makefile.am Wed Apr 8 22:31:22 2009
@@ -22,20 +22,20 @@
plugin_LTLIBRARIES = libanjuta-editor.la
AM_CPPFLAGS = \
- $(GIO_CFLAGS) \
$(LIBANJUTA_CFLAGS) \
$(GTK_CFLAGS) \
- $(GLIB_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GLADE_CFLAGS) \
+ $(EXTRA_CFLAGS) \
-I$(srcdir)/scintilla/include \
-DG_LOG_DOMAIN=\"libanjuta-scintilla\"
libanjuta_editor_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
libanjuta_editor_la_LIBADD = \
- $(GIO_LIBS) \
$(LIBANJUTA_LIBS) \
$(GTK_LIBS) \
- $(GLIB_LIBS) \
+ $(GLIB_LIBS) \
$(GLADE_LIBS)
libanjuta_editor_la_SOURCES= \
Added: trunk/plugins/scintilla/aneditor-autocomplete.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor-autocomplete.cxx Wed Apr 8 22:31:22 2009
@@ -0,0 +1,1036 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ aneditor-calltip.cxx
+ Copyright (C) 2004 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#include "aneditor-priv.h"
+#include <glib.h>
+
+#if 0
+#define TYPESEP '?'
+
+static void free_word(gpointer key, gpointer value, gpointer user_data)
+{
+ g_free(key);
+}
+#endif
+
+bool AnEditor::FindWordInRegion(char *word, int maxlength,
+ SString ®ion, int offset) {
+/*
+ Tries to find a word in the region designated by 'region'
+ around the position given by 'offset' in that region.
+ If a word is found, it is copied (with a terminating '\0'
+ character) into 'word', which must be a buffer of at least
+ 'maxlength' characters; the method then returns true.
+ If no word is found, the buffer designated by 'word'
+ remains unmodified and the method returns false.
+*/
+ int startword = offset;
+ while (startword> 0 && wordCharacters.contains(region[startword - 1]))
+ startword--;
+ int endword = offset;
+ while (region[endword] && wordCharacters.contains(region[endword]))
+ endword++;
+ if(startword == endword)
+ return false;
+
+ region.change(endword, '\0');
+ int cplen = (maxlength < (endword-startword+1))?maxlength:(endword-startword+1);
+ strncpy (word, region.c_str() + startword, cplen);
+ return true;
+}
+
+bool AnEditor::GetWordAtPosition(char* buffer, int maxlength, int pos) {
+/*
+ Tries to find a word around position 'pos' in the text
+ and writes this '\0'-terminated word to 'buffer',
+ which must be a buffer of at least 'maxlength' characters.
+ Returns true if a word is found, false otherwise.
+*/
+ const int radius = 500;
+ int start = (pos >= radius ? pos - radius : 0);
+ int doclen = LengthDocument();
+ int end = (doclen - pos >= radius ? pos + radius : doclen);
+ char *chunk = SString::StringAllocate(2 * radius);
+ GetRange(start, end, chunk, false);
+ chunk[2 * radius] = '\0';
+ SString region;
+ region.attach(chunk);
+ return FindWordInRegion(buffer, maxlength, region, pos - start);
+}
+
+bool AnEditor::GetWordBeforeCarat(char *buffer, int maxlength) {
+ SString linebuf;
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+
+ buffer[0] = '\0';
+ int startword = current;
+ while ((startword > 0) &&
+ (wordCharacters.contains(linebuf[startword - 1])))
+ startword--;
+
+ if (startword >= current)
+ return false;
+
+ linebuf.change(current, '\0');
+ const char *root = linebuf.c_str() + startword;
+ strncpy (buffer, root, maxlength);
+
+ return true;
+}
+#if 0
+
+bool AnEditor::StartAutoComplete() {
+ SString linebuf;
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+
+ int startword = current;
+ while ((startword > 0) &&
+ (wordCharacters.contains(linebuf[startword - 1]) ||
+ autoCompleteStartCharacters.contains(linebuf[startword - 1])))
+ startword--;
+ linebuf.change(current, '\0');
+ const char *root = linebuf.c_str() + startword;
+ int rootlen = current - startword;
+ const GPtrArray *tags = tm_workspace_find(root, tm_tag_max_t, NULL,
+ TRUE, TRUE);
+ if (NULL != tags)
+ {
+ GString *words = g_string_sized_new(100);
+ TMTag *tag;
+ for (guint i = 0; ((i < tags->len) &&
+ (i < MAX_AUTOCOMPLETE_WORDS)); ++i)
+ {
+ tag = (TMTag *) tags->pdata[i];
+ if (i > 0)
+ g_string_append_c(words, ' ');
+ g_string_append(words, tag->name);
+ }
+ SendEditor(SCI_AUTOCSETAUTOHIDE, 1);
+ SendEditor(SCI_AUTOCSETDROPRESTOFWORD, 1);
+ SendEditorString(SCI_AUTOCSHOW, rootlen, words->str);
+ g_string_free(words, TRUE);
+ }
+ return true;
+}
+
+bool AnEditor::SendAutoCompleteRecordsFields(const GPtrArray *CurrentFileTags,
+ const char *ScanType)
+{
+ if (autocompletion) {
+ g_completion_free (autocompletion);
+ autocompletion = NULL;
+ }
+
+ if( !(ScanType && ScanType[0] != '\0') ) return false;
+
+ const GPtrArray *tags = tm_workspace_find_scope_members(CurrentFileTags,
+ ScanType, TRUE,
+ TRUE);
+
+ if ((tags) && (tags->len > 0))
+ {
+ TMTag *tag;
+ GList *aclist = NULL;
+ GHashTable *wordhash = g_hash_table_new(g_str_hash, g_str_equal);
+ GString *words = g_string_sized_new(256);
+
+ for (guint i=0; ((i < tags->len)); ++i)
+ {
+ tag = TM_TAG(tags->pdata[i]);
+ if (NULL == g_hash_table_lookup(wordhash,
+ (gconstpointer) tag->name))
+ {
+ g_hash_table_insert(wordhash,
+ g_strdup(tag->name), GINT_TO_POINTER (1));
+ aclist = g_list_prepend (aclist, tag->name);
+
+ if (words->len > 0)
+ {
+ g_string_append_c(words, ' ');
+ }
+ g_string_append(words, tag->name);
+ g_string_append_c(words, TYPESEP);
+ g_string_append_printf(words, "%d", tag->type);
+ // g_string_append_printf(words, "%d", sv_get_node_type (tag));
+ }
+ }
+
+ aclist = g_list_reverse (aclist);
+ if (aclist)
+ {
+ autocompletion = g_completion_new (NULL);
+ g_completion_add_items (autocompletion, aclist);
+
+ SendEditor(SCI_AUTOCSETAUTOHIDE, 0);
+ SendEditor(SCI_AUTOCSETDROPRESTOFWORD, 1);
+ //SendEditorString(SCI_AUTOCSHOW, 0, words->str);
+ SendEditorString(SCI_USERLISTSHOW, 0, words->str);
+ }
+ g_string_free(words, TRUE);
+
+ g_hash_table_foreach(wordhash, free_word, NULL);
+ g_hash_table_destroy(wordhash);
+
+ return true;
+ }
+ return false;
+}
+
+static bool IsRecordOperatorForward(char *ch)
+{
+ return (((ch[0] == '-') && (ch[1] == '>')) ||
+ ((ch[0] == ':') && (ch[1] == ':')));
+}
+
+static bool IsRecordOperatorBackward(char *ch)
+{
+ return (((ch[0] == '>') && (ch[-1] == '-')) ||
+ ((ch[0] == ':') && (ch[-1] == ':')));
+}
+
+static bool IsAlnum(char ch)
+{
+ return (ch == '_' || isalnum(ch));
+}
+
+static bool IsAlpha(char ch)
+{
+ return (ch == '_' || isalpha(ch));
+}
+
+static bool IsRecordOperator(char *ch)
+{
+ return ((ch[0] == '.') ||
+ IsRecordOperatorForward(ch) ||
+ IsRecordOperatorBackward(ch) );
+}
+
+TMTag ** AnEditor::FindTypeInLocalWords(GPtrArray *CurrentFileTags,
+ const char *root, const bool type,
+ int *retptr, int *count)
+{
+ int posCurrentWord = SendEditor (SCI_GETCURRENTPOS);
+ int Line = SendEditor(SCI_LINEFROMPOSITION , posCurrentWord);
+
+ {
+ TMTag *tag;
+ if(NULL == (tag = TM_TAG(tm_get_current_function(CurrentFileTags,
+ Line))))
+ {
+ return NULL;
+ }
+ Line = tag->atts.entry.line - 2;
+ }
+
+ size_t rootlen = strlen(root);
+ posCurrentWord -= (rootlen + (type ? 1 : 2));
+ int EndBlokLine =
+ GetBlockEndLine(SendEditor(SCI_LINEFROMPOSITION , posCurrentWord));
+ if(EndBlokLine < 0) return NULL;
+
+ SString linebuf;
+ const char *name;
+
+ /* find open block '{' */
+ do {
+ Line++;
+ GetLine(linebuf, Line);
+ name = linebuf.c_str();
+ name = strchr(name, '{');
+ } while(!name);
+
+ int posFind = SendEditor(SCI_POSITIONFROMLINE , Line) + (name - linebuf.c_str());
+
+ int doclen = LengthDocument();
+ TextToFind ft = {{0, 0}, 0, {0, 0}};
+ ft.lpstrText = const_cast<char*>(root);
+ ft.chrg.cpMin = posFind;
+
+ /* find close block '}' */
+ ft.chrg.cpMax = SendEditor(SCI_BRACEMATCH , posFind, 0);
+ if (ft.chrg.cpMax < ft.chrg.cpMin)
+ ft.chrg.cpMax = posCurrentWord;
+
+ for (;;) { // search all function blocks
+ posFind = SendEditorString(SCI_FINDTEXT,
+ (SCFIND_WHOLEWORD | SCFIND_MATCHCASE),
+ reinterpret_cast<char *>(&ft));
+
+ if (posFind == -1 || posFind >= doclen || posFind >= posCurrentWord)
+ {
+ break;
+ }
+
+ Line = SendEditor(SCI_LINEFROMPOSITION , posFind);
+ int current = GetBlockEndLine(Line);
+ if (current < 0) break;
+ if ( EndBlokLine > current )
+ {
+ /* not in our block */
+ ft.chrg.cpMin = posFind + rootlen;
+ continue;
+ }
+
+ if(GetFullLine(linebuf, Line) < 0) break;
+
+ /* find word position */
+ current = 0;
+ while(1)
+ {
+ current = linebuf.search(root, current);
+ if(current < 0) break;
+ if(!current && !IsAlnum(linebuf[rootlen]))
+ {
+ break;
+ }
+ if(current > 0 && !IsAlpha(linebuf[current-1]) &&
+ !IsAlnum(linebuf[current + rootlen]))
+ {
+ break;
+ }
+ current += rootlen;
+ }
+ if(current < 1) break;
+
+ int pointerOrder = 0;
+ int startword = current - 1;
+
+ {
+ /* find 'pointer' capability and move to "true start of line" */
+ bool findPointer = true;
+ while (startword > 0)
+ {
+ if(linebuf[startword] == ';' || linebuf[startword] == '{' ||
+ linebuf[startword] == '}')
+ {
+ break;
+ }
+ if(findPointer && linebuf[startword] == ',')
+ {
+ findPointer = false;
+ }
+ if(findPointer && linebuf[startword] == '*')
+ {
+ pointerOrder++;
+ }
+ startword--;
+ }
+ }
+
+ name = NULL;
+ for (;;)
+ {
+ /* find begin of word */
+ while (startword < current && !IsAlpha(linebuf[startword]))
+ {
+ startword++;
+ }
+ if (startword == current) break;
+
+ name = (linebuf.c_str() + startword);
+
+ /* find end of word */
+ while (startword < current && IsAlnum(linebuf[startword]))
+ {
+ startword++;
+ }
+ if (startword == current) break;
+
+ char backup = linebuf[startword];
+ linebuf.change(startword, '\0');
+
+ if (strcmp(name, root) == 0)
+ {
+ break;
+ }
+
+ if (strcmp(name, "struct") == 0 ||
+ strcmp(name, "class" ) == 0 ||
+ strcmp(name, "union" ) == 0 ||
+ strcmp(name, "const" ) == 0 ||
+ strcmp(name, "static") == 0 ||
+ strcmp(name, "auto" ) == 0 ||
+ strcmp(name, "register") == 0 ||
+ strcmp(name, "extern") == 0 ||
+ strcmp(name, "restrict") == 0)
+ {
+ linebuf.change(startword, backup);
+ continue;
+ }
+
+ /* search in file type tag's entrys */
+ doclen = 0;
+ TMTag **match = tm_tags_find(CurrentFileTags, name, FALSE, ¤t);
+ for(startword = 0; match && startword < current; ++startword)
+ {
+ if ((tm_tag_class_t | tm_tag_struct_t |tm_tag_typedef_t |
+ tm_tag_union_t | tm_tag_namespace_t) &
+ match[startword]->type)
+ {
+ doclen++;
+ }
+ }
+ if (!doclen)
+ {
+ /* search in global type tag's entrys */
+ const GPtrArray *tags = tm_workspace_find(name,
+ (tm_tag_class_t |
+ tm_tag_struct_t |
+ tm_tag_typedef_t |
+ tm_tag_union_t |
+ tm_tag_namespace_t),
+ NULL, FALSE, TRUE);
+ doclen = tags->len;
+ match = (TMTag **)tags->pdata;
+ }
+
+ if(retptr) *retptr = pointerOrder;
+ if(count) *count = doclen;
+ return match;
+ }
+ break;
+ }
+ return NULL;
+}
+
+static TMWorkObject * get_current_tm_file (GtkWidget *scintilla)
+{
+ GtkWidget *container;
+ container = gtk_widget_get_parent (scintilla);
+
+ g_return_val_if_fail (GTK_IS_VBOX (container), NULL);
+
+ TMWorkObject * tm_file =
+ TM_WORK_OBJECT (g_object_get_data (G_OBJECT (container), "tm_file"));
+ return tm_file;
+}
+
+static char * get_current_function_scope (GtkWidget *scintilla, int line)
+{
+ TMWorkObject * tm_file = get_current_tm_file (scintilla);
+
+ if((tm_file) && (tm_file->tags_array))
+ {
+ TMTag *tag;
+ /* g_message ("TMFile for editor found"); */
+ if(NULL != (tag = TM_TAG(tm_get_current_function(tm_file->tags_array,
+ line))))
+ {
+ return tag->atts.entry.scope;
+ }
+ }
+ return NULL;
+}
+
+static char * FindTypeInFunctionArgs(GPtrArray *CurrentFileTags,
+ const char *root, int *retptr, const int line)
+{
+ /* find type in function arguments */
+ if(CurrentFileTags)
+ {
+ char *name;
+ size_t rootlen;
+ int end, start;
+ TMTag *tag;
+ int pointerOrder;
+ if(NULL == (tag = TM_TAG(tm_get_current_function(CurrentFileTags, line))))
+ {
+ return NULL;
+ }
+ if(NULL == (name = tag->atts.entry.arglist))
+ {
+ return NULL;
+ }
+
+ rootlen = strlen(root);
+ while(name)
+ {
+ if(NULL == (name = strstr(name, root)))
+ {
+ return NULL;
+ }
+ end = name - tag->atts.entry.arglist;
+ if (!end || IsAlpha(name[-1]) || IsAlnum(name[rootlen]))
+ {
+ name++;
+ continue;
+ }
+ name = tag->atts.entry.arglist;
+ break;
+ }
+ pointerOrder = 0;
+ while(end > 0)
+ {
+ while(end > 0 && !IsAlnum(name[end - 1]))
+ {
+ if (name[end - 1] == '*')
+ {
+ pointerOrder++;
+ }
+ end--;
+ }
+ start = end;
+
+ while(start > 0 && IsAlnum(name[start - 1]))
+ {
+ start--;
+ }
+
+ char backup = name[end];
+ name[end] = '\0';
+ name += start;
+ if( (0 == strcmp("const", name)) ||
+ (0 == strcmp("restrict", name)))
+ {
+ name = tag->atts.entry.arglist;
+ name[end] = backup;
+ end = start;
+ continue;
+ }
+ name = g_strdup(name);
+ tag->atts.entry.arglist[end] = backup;
+ break;
+ }
+ if(retptr) *retptr = pointerOrder;
+ return name;
+ }
+
+ return NULL;
+}
+
+bool AnEditor::StartAutoCompleteRecordsFields (char ch)
+{
+ if (autocompletion) {
+ g_completion_free (autocompletion);
+ autocompletion = NULL;
+ }
+ /* TagManager autocompletion - only for C/C++/Java */
+ if (SCLEX_CPP != lexLanguage ||
+ ((ch != '.') && (ch != '>') && (ch != ':')))
+ return false;
+
+ SString linebuf;
+ const char *root;
+
+ int current = GetFullLine(linebuf);
+
+ if (current < 0) return false;
+ if ((ch == '>') && linebuf[current - 2] != '-') return false;
+ if ((ch == ':') && linebuf[current - 2] != ':') return false;
+
+ char tmp_chr;
+ bool was_long_decl = false, long_declaration = true;
+ int endword, startword = current;
+ TMTag *ScanType = NULL;
+ GPtrArray *CurrentFileTags = NULL;
+ const GPtrArray *tags = NULL;
+
+ /* scan entire record's chain */
+ while(long_declaration)
+ {
+ endword = startword;
+
+ while (endword > 1 && IsRecordOperator((char *)(linebuf.c_str() +
+ (endword - 1))) )
+ {
+ endword--;
+ }
+ /* detect function parameter list or others () */
+ if(linebuf[endword - 1] == ')')
+ {
+ int count = 0;
+ do {
+ endword--;
+ if(linebuf[endword] == ')') count++;
+ if(linebuf[endword] == '(') count--;
+ } while (endword > 0 && count);
+ }
+ else if(linebuf[endword - 1] == '>')
+ {
+ int count = 0;
+ do {
+ endword--;
+ if(linebuf[endword] == '>') count++;
+ if(linebuf[endword] == '<') count--;
+ } while (endword > 0 && count);
+ }
+ else
+ {
+ while(linebuf[endword - 1] == ']')
+ {
+ int count = 0;
+ do {
+ endword--;
+ if(linebuf[endword] == ']') count++;
+ if(linebuf[endword] == '[') count--;
+ } while (endword > 0 && count);
+ }
+ }
+
+ while (endword > 1 && isspace(linebuf[endword - 1]))
+ {
+ endword--;
+ }
+
+ startword = endword;
+ while (startword > 1 && IsAlnum(linebuf[startword - 1]))
+ {
+ startword--;
+ }
+
+ long_declaration = startword > 1 &&
+ IsRecordOperator((char *)(linebuf.c_str() + (startword - 1)));
+ if(!was_long_decl && long_declaration) was_long_decl = true;
+ }
+
+ tmp_chr = linebuf[endword];
+ linebuf.change(endword, '\0');
+ root = linebuf.c_str() + startword;
+
+ int pointerOrder;
+ char *name;
+ char *new_name = NULL;
+ int types = (ch == ':' ? tm_tag_class_t : (tm_tag_max_t & ~tm_tag_class_t));
+ {
+ TMWorkObject *tm_file = get_current_tm_file (GTK_WIDGET (GetID()));
+ CurrentFileTags = tm_file ? tm_file->tags_array : NULL;
+ }
+ if(0 == strcmp(root, "this"))
+ {
+ name = get_current_function_scope(GTK_WIDGET (GetID()),
+ GetCurrentLineNumber());
+ if(!name || name[0] == '\0') return false;
+ pointerOrder = 1;
+ }
+ else
+ {
+ TMTagAttrType attrs[] = {
+ tm_tag_attr_name_t,
+ tm_tag_attr_type_t,
+ tm_tag_attr_none_t
+ };
+ TMTag **match = NULL;
+ int count = 0;
+
+ tm_tags_sort(CurrentFileTags, attrs, FALSE);
+ match = tm_tags_find(CurrentFileTags, root, FALSE, &count);
+ if(count && ch == ':')
+ {
+ int real_count = 0;
+ for(int i = 0; i < count; ++i)
+ {
+ if(types & match[i]->type)
+ {
+ real_count++;
+ }
+ }
+ count = real_count;
+ }
+ if (!count || !match || !(*match))
+ {
+ /* search in global variables and functions tag's entrys */
+ tags = tm_workspace_find(root, types, attrs, FALSE, TRUE);
+ count = (tags != NULL)? tags->len: 0;
+ match = NULL;
+ }
+ ScanType = NULL;
+ if (count == 1)
+ {
+ ScanType = (match ? match[0] : TM_TAG(tags->pdata[0]));
+ if(!(!ScanType->atts.entry.scope ||
+ ((name =
+ get_current_function_scope(GTK_WIDGET (GetID()),
+ GetCurrentLineNumber())) &&
+ 0 == strcmp(name, ScanType->atts.entry.scope))) )
+ {
+ ScanType = NULL;
+ }
+ }
+ else
+ {
+ if((count > 0) &&
+ (name =
+ get_current_function_scope(GTK_WIDGET (GetID()),
+ GetCurrentLineNumber())))
+ {
+ int iter;
+ for( iter =0; iter < count; ++iter)
+ {
+ ScanType =
+ (match ? match[iter] : TM_TAG(tags->pdata[iter]));
+ if(ch != ':' && ScanType->atts.entry.scope &&
+ 0 == strcmp(name, ScanType->atts.entry.scope))
+ {
+ break;
+ }
+ if(ch == ':' && ScanType->type == tm_tag_class_t)
+ {
+ break;
+ }
+ }
+ if(iter == count) ScanType = NULL;
+ }
+ }
+ if(ScanType)
+ {
+ if(ScanType->type == tm_tag_class_t)
+ {
+ /* show nothing when use normal acces operators (./->) */
+ name = ScanType->name;
+ pointerOrder = (ch == '.');
+ }
+ else
+ {
+ name = ScanType->atts.entry.type_ref[1];
+ pointerOrder = ScanType->atts.entry.pointerOrder;
+ }
+ }
+ else
+ {
+ new_name = FindTypeInFunctionArgs(CurrentFileTags, root,
+ &pointerOrder,
+ GetCurrentLineNumber());
+ if(new_name)
+ {
+ name = new_name;
+ }
+ else
+ {
+ count = 0;
+ TMTag **match = FindTypeInLocalWords(CurrentFileTags,
+ root, (tmp_chr == '.'),
+ &pointerOrder, &count);
+ if ((match) && (count == 1) && (ScanType = match[0]))
+ {
+ name = ScanType->name;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ linebuf.change(endword, tmp_chr);
+
+ while(was_long_decl)
+ {
+ tags = tm_workspace_find_scope_members(CurrentFileTags, name, TRUE,
+ TRUE);
+ if (!((tags) && (tags->len > 0)))
+ {
+ if(new_name) g_free(new_name);
+ return false;
+ }
+
+ while (endword < current && isspace(linebuf[endword]))
+ {
+ endword++;
+ }
+ if(linebuf[endword] == '(')
+ {
+ int count = 0;
+ do {
+ if(linebuf[endword] == ')') count--;
+ if(linebuf[endword] == '(') count++;
+ endword++;
+ }
+ while (count && endword < current);
+ }
+ else if(linebuf[endword] == '<')
+ {
+ int count = 0;
+ do {
+ if(linebuf[endword] == '>') count--;
+ if(linebuf[endword] == '<') count++;
+ endword++;
+ }
+ while (count && endword < current);
+ }
+ else
+ {
+ while(linebuf[endword] == '[')
+ {
+ int count = 0;
+ do {
+ if(linebuf[endword] == ']') count--;
+ if(linebuf[endword] == '[') count++;
+ endword++;
+ }
+ while (count && endword < current);
+ }
+ }
+ while (endword < current &&
+ IsRecordOperator((char *)(linebuf.c_str() + endword)))
+ {
+ endword++;
+ }
+ if(!IsAlnum(linebuf[endword]))
+ break;
+
+ startword = endword;
+ while (endword < current && IsAlnum(linebuf[endword]))
+ {
+ endword++;
+ }
+
+ tmp_chr = linebuf[endword];
+ linebuf.change(endword, '\0');
+ root = linebuf.c_str() + startword;
+
+ unsigned int i;
+ for (i=0; (i < tags->len); ++i)
+ {
+ ScanType = TM_TAG(tags->pdata[i]);
+ if(ScanType && 0 == strcmp(ScanType->name, root))
+ {
+ break;
+ }
+ }
+ if (i >= tags->len)
+ {
+ if(new_name) g_free(new_name);
+ return false;
+ }
+ linebuf.change(endword, tmp_chr);
+
+ if (ScanType->atts.entry.file == NULL)
+ {
+ if(new_name) g_free(new_name);
+ return false;
+ }
+ CurrentFileTags = ScanType->atts.entry.file->work_object.tags_array;
+ name = ScanType->atts.entry.type_ref[1];
+ pointerOrder = ScanType->atts.entry.pointerOrder;
+ }
+ if (ch == ':' && ScanType && ScanType->type != tm_tag_class_t)
+ {
+ if(new_name) g_free(new_name);
+ //anjuta_status (_("Wrong acces operator ... "));
+ return false;
+ }
+ if (ch == '>' && pointerOrder != 1)
+ {
+ if(new_name) g_free(new_name);
+ //anjuta_status (_("Wrong acces operator... Please use \"->\""));
+ return false;
+ }
+ if (ch == '.' && pointerOrder != 0)
+ {
+ if(new_name) g_free(new_name);
+ //anjuta_status (_("Wrong acces operator... Please use \".\""));
+ return false;
+ }
+ bool retval = SendAutoCompleteRecordsFields(CurrentFileTags, name);
+ if(new_name) g_free(new_name);
+ return retval;
+}
+
+bool AnEditor::StartAutoCompleteWord(int autoShowCount) {
+ SString linebuf;
+ int nwords = 0;
+ int minWordLength = 0;
+ int wordlen = 0;
+
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+
+ bool isNum = true;
+ int startword = current;
+ while (startword > 0 && wordCharacters.contains(linebuf[startword - 1])) {
+ if (isNum && !isdigit(linebuf[startword - 1]))
+ isNum = false;
+ startword--;
+ }
+
+ if (startword == current)
+ return true;
+
+ // Don't show autocomple for numbers (very annoying).
+ if (isNum)
+ return true;
+
+ linebuf.change(current, '\0');
+ const char *root = linebuf.c_str() + startword;
+ int rootlen = current - startword;
+
+ GHashTable *wordhash = g_hash_table_new(g_str_hash, g_str_equal);
+ GString *words = g_string_sized_new(256);
+
+ // If user autocompletion list is active, complete within it.
+ if (autocompletion) {
+ // gint count = 0;
+ gchar *prefix = NULL;
+ GList *completed_list = g_completion_complete_utf8 (autocompletion,
+ root, &prefix);
+ if (prefix)
+ {
+ /* FIXME: May be we should insert it and select the inserted part */
+ GList *node = completed_list;
+ while (node) {
+ gchar *item = (gchar *)node->data;
+ g_hash_table_insert(wordhash, g_strdup(item),
+ GINT_TO_POINTER (1));
+
+ wordlen = strlen(item);
+ if (minWordLength < wordlen)
+ minWordLength = wordlen;
+
+ if (words->len > 0)
+ g_string_append_c(words, ' ');
+ g_string_append(words, item);
+ // g_string_append_c(words, TYPESEP);
+ // g_string_append_printf(words, "%d", count);
+ node = g_list_next (node);
+ }
+ }
+ if (prefix && completed_list) {
+ SendEditor(SCI_AUTOCSETAUTOHIDE, 1);
+ SendEditor(SCI_AUTOCSETDROPRESTOFWORD, 1);
+ SendEditorString(SCI_AUTOCSHOW, rootlen, words->str);
+ // SendEditor(SCI_AUTOCSETAUTOHIDE, 1);
+ // SendEditorString(SCI_USERLISTSHOW, 0, words->str);
+ } else {
+ SendEditor(SCI_AUTOCCANCEL);
+ if (autocompletion) {
+ g_completion_free (autocompletion);
+ autocompletion = NULL;
+ }
+ }
+ g_free (prefix);
+ g_string_free(words, TRUE);
+ g_hash_table_foreach(wordhash, free_word, NULL);
+ g_hash_table_destroy(wordhash);
+ return true;
+ }
+
+ /* TagManager autocompletion - only for C/C++/Java */
+ if (SCLEX_CPP == lexLanguage)
+ {
+ const GPtrArray *tags = tm_workspace_find(root, tm_tag_max_t,
+ NULL, TRUE, TRUE);
+ if ((tags) && (tags->len > 0))
+ {
+ TMTag *tag;
+ for (guint i = 0; ((i < tags->len) &&
+ (i < MAX_AUTOCOMPLETE_WORDS)); ++i)
+ {
+ tag = (TMTag *) tags->pdata[i];
+ if (NULL == g_hash_table_lookup(wordhash
+ , (gconstpointer) tag->name))
+ {
+ g_hash_table_insert(wordhash, g_strdup(tag->name),
+ GINT_TO_POINTER (1));
+ if (words->len > 0)
+ g_string_append_c(words, ' ');
+ g_string_append(words, tag->name);
+ g_string_append_c(words, TYPESEP);
+ g_string_append_printf(words, "%d", tag->type);
+ // g_string_append_printf(words, "%d",
+ // sv_get_node_type (tag));
+
+ wordlen = strlen(tag->name);
+ if (minWordLength < wordlen)
+ minWordLength = wordlen;
+
+ nwords++;
+ if (autoShowCount > 0 && nwords > autoShowCount) {
+ g_string_free(words, TRUE);
+ g_hash_table_foreach(wordhash, free_word, NULL);
+ g_hash_table_destroy(wordhash);
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ /* Word completion based on words in current buffer */
+ int doclen = LengthDocument();
+ TextToFind ft = {{0, 0}, 0, {0, 0}};
+ ft.lpstrText = const_cast<char*>(root);
+ ft.chrg.cpMin = 0;
+ ft.chrgText.cpMin = 0;
+ ft.chrgText.cpMax = 0;
+ int flags = SCFIND_WORDSTART |
+ (autoCompleteIgnoreCase ? 0 : SCFIND_MATCHCASE);
+ int posCurrentWord = SendEditor (SCI_GETCURRENTPOS) - rootlen;
+
+ for (;;) { // search all the document
+ ft.chrg.cpMax = doclen;
+ int posFind = SendEditorString(SCI_FINDTEXT, flags,
+ reinterpret_cast<char *>(&ft));
+ if (posFind == -1 || posFind >= doclen)
+ break;
+ if (posFind == posCurrentWord) {
+ ft.chrg.cpMin = posFind + rootlen;
+ continue;
+ }
+ // Grab the word and put spaces around it
+ const int wordMaxSize = 80;
+ char wordstart[wordMaxSize];
+ GetRange(wEditor, posFind, Platform::Minimum(posFind + wordMaxSize - 3,
+ doclen), wordstart);
+ char *wordend = wordstart + rootlen;
+ while (iswordcharforsel(*wordend))
+ wordend++;
+ *wordend = '\0';
+ wordlen = wordend - wordstart;
+ if (wordlen > rootlen) {
+ /* Check if the word is already there - if not, insert it */
+ if (NULL == g_hash_table_lookup(wordhash, wordstart))
+ {
+ g_hash_table_insert(wordhash, g_strdup(wordstart),
+ GINT_TO_POINTER (1));
+ if (0 < words->len)
+ g_string_append_c(words, ' ');
+ g_string_append(words, wordstart);
+
+ if (minWordLength < wordlen)
+ minWordLength = wordlen;
+
+ nwords++;
+ if (autoShowCount > 0 && nwords > autoShowCount) {
+ g_string_free(words, TRUE);
+ g_hash_table_foreach(wordhash, free_word, NULL);
+ g_hash_table_destroy(wordhash);
+ return true;
+ }
+ }
+ }
+ ft.chrg.cpMin = posFind + wordlen;
+ }
+ size_t length = (words->str) ? strlen (words->str) : 0;
+ if ((length > 2) && (autoShowCount <= 0 || (minWordLength > rootlen))) {
+ SendEditor(SCI_AUTOCSETAUTOHIDE, 1);
+ SendEditor(SCI_AUTOCSETDROPRESTOFWORD, 1);
+ SendEditorString(SCI_AUTOCSHOW, rootlen, words->str);
+ } else {
+ SendEditor(SCI_AUTOCCANCEL);
+ }
+
+ g_string_free(words, TRUE);
+ g_hash_table_foreach(wordhash, free_word, NULL);
+ g_hash_table_destroy(wordhash);
+ return true;
+}
+#endif
Added: trunk/plugins/scintilla/aneditor-calltip.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor-calltip.cxx Wed Apr 8 22:31:22 2009
@@ -0,0 +1,349 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ aneditor-calltip.cxx
+ Copyright (C) 2004 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <libanjuta/anjuta-debug.h>
+#include "aneditor-priv.h"
+
+bool AnEditor::StartCallTip_new() {
+#if 0
+ TMTagAttrType attrs[] =
+ {
+ tm_tag_attr_name_t, tm_tag_attr_type_t, tm_tag_attr_none_t
+ };
+ SString linebuf;
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+ call_tip_node.start_pos = SendEditor(SCI_GETCURRENTPOS);
+ call_tip_node.call_tip_start_pos = current;
+
+ int braces;
+ do {
+ braces = 0;
+ while (current > 0 && (braces || linebuf[current - 1] != '(')) {
+ if (linebuf[current - 1] == '(')
+ braces--;
+ else if (linebuf[current - 1] == ')')
+ braces++;
+ current--;
+ call_tip_node.start_pos--;
+ }
+ if (current > 0) {
+ current--;
+ call_tip_node.start_pos--;
+ } else
+ break;
+ while (current > 0 && isspace(linebuf[current - 1])) {
+ current--;
+ call_tip_node.start_pos--;
+ }
+ } while (current > 0 &&
+ !calltipWordCharacters.contains(linebuf[current - 1]));
+
+ if (current <= 0)
+ return true;
+
+ call_tip_node.startCalltipWord = current -1;
+
+ while (call_tip_node.startCalltipWord > 0 &&
+ calltipWordCharacters.contains(linebuf[call_tip_node.startCalltipWord - 1]))
+ call_tip_node.startCalltipWord--;
+
+ linebuf.change(current, '\0');
+ call_tip_node.rootlen = current - call_tip_node.startCalltipWord;
+
+ call_tip_node.max_def = 0;
+ call_tip_node.def_index = 0;
+
+ const GPtrArray *tags = tm_workspace_find(linebuf.c_str() +
+ call_tip_node.startCalltipWord,
+ tm_tag_prototype_t |
+ tm_tag_function_t |
+ tm_tag_macro_with_arg_t,
+ attrs, FALSE, TRUE);
+ if (tags && (tags->len > 0))
+ {
+ call_tip_node.max_def = (tags->len < 20)? tags->len:20;
+ printf ("Number of calltips found %d\n", tags->len);
+ for (unsigned int i = 0; (i < tags->len) && (i < 20); i++) {
+ TMTag *tag = (TMTag *) tags->pdata[0];
+ GString* tmp = g_string_new(NVL(tag->atts.entry.type_ref[1], ""));
+ for (unsigned int j = 0; j < tag->atts.entry.pointerOrder; j++)
+ g_string_append(tmp, "*");
+ g_string_append_printf(tmp, " %s%s", tag->name,
+ NVL(tag->atts.entry.arglist, ""));
+ call_tip_node.functionDefinition[i] = tmp->str;
+ g_string_free(tmp, TRUE);
+ }
+ char *real_tip;
+ if (call_tip_node.max_def > 1)
+ real_tip = g_strconcat ("\002",
+ call_tip_node.functionDefinition[0].c_str(),
+ NULL);
+ else
+ real_tip = g_strdup (call_tip_node.functionDefinition[0].c_str());
+
+ SendEditorString(SCI_CALLTIPSHOW, call_tip_node.start_pos -
+ call_tip_node.rootlen + 1, real_tip);
+ g_free (real_tip);
+ ContinueCallTip_new();
+ }
+#endif
+ return true;
+}
+
+static bool IsCallTipSeparator(char ch) {
+ return (ch == ',') || (ch == ';');
+}
+
+void AnEditor::ContinueCallTip_new() {
+ SString linebuf;
+ GetLine(linebuf);
+ unsigned current = GetCaretInLine();
+ int commas = 0;
+
+ for (unsigned i = call_tip_node.call_tip_start_pos; i < current; i++) {
+
+ unsigned char ch = linebuf[i];
+
+ // check whether the are some other functions nested.
+ // if found we'll skip them to evitate commas problems
+ if ( ch == '(' ) {
+ int braces = 1;
+ for (unsigned k = i+1; k < linebuf.length(); k++ ) {
+ if ( linebuf[k] == '(' ) {
+ braces++;
+ }
+ else
+ if ( linebuf[k] == ')' ) {
+ braces--;
+ }
+ if ( braces == 0 ) {
+ i = k;
+ break;
+ }
+ }
+ }
+
+ if (IsCallTipSeparator(ch))
+ commas++;
+ }
+
+ // lets start from 0
+ int startHighlight = 0;
+
+ while (call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] &&
+ call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] != '(')
+ startHighlight++;
+
+ if (call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] == '(') {
+ startHighlight++;
+ }
+
+ // printf(const char*, ...
+ // -------^
+
+ while (call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] &&
+ commas > 0) {
+ if (IsCallTipSeparator(call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] ) ||
+ call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] == ')')
+ commas--;
+ startHighlight++;
+ }
+
+ if (IsCallTipSeparator(call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight]) ||
+ call_tip_node.functionDefinition[call_tip_node.def_index][startHighlight] == ')')
+ startHighlight++;
+
+ int endHighlight = startHighlight;
+
+ if (call_tip_node.functionDefinition[call_tip_node.def_index][endHighlight])
+ endHighlight++;
+
+ while (call_tip_node.functionDefinition[call_tip_node.def_index][endHighlight] &&
+ !IsCallTipSeparator(call_tip_node.functionDefinition[call_tip_node.def_index][endHighlight])
+ && call_tip_node.functionDefinition[call_tip_node.def_index][endHighlight] != ')')
+ endHighlight++;
+
+ SendEditor(SCI_CALLTIPSETHLT, startHighlight, endHighlight);
+}
+
+//------------------------------------------------------------------------------
+// we're going to save the current status of call_tip_node in call_tip_node_list
+// to let another *new* call_tip to show up
+//
+
+void AnEditor::SaveCallTip() {
+
+ CallTipNode *ctn = new CallTipNode;
+// g_message( "***saving calltip..." );
+
+ ctn->startCalltipWord = call_tip_node.startCalltipWord;
+ ctn->def_index = call_tip_node.def_index;
+ ctn->max_def = call_tip_node.max_def;
+ for (int i = 0; i < ctn->max_def; i++) {
+ ctn->functionDefinition[i] = call_tip_node.functionDefinition[i];
+ }
+ ctn->start_pos = call_tip_node.start_pos;
+ ctn->rootlen = call_tip_node.rootlen;
+ ctn->call_tip_start_pos = call_tip_node.call_tip_start_pos;
+
+ // push it
+ g_queue_push_tail( call_tip_node_queue, ctn );
+
+ SetCallTipDefaults();
+}
+
+void AnEditor::ResumeCallTip(bool pop_from_stack) {
+
+ if (pop_from_stack) {
+ if (g_queue_is_empty (call_tip_node_queue)) {
+ ShutDownCallTip();
+ return;
+ }
+
+ CallTipNode_ptr tmp_node;
+
+ // set up next CallTipNode parameters in AnEditor::call_tip_node
+ tmp_node = (CallTipNode_ptr)g_queue_pop_tail( call_tip_node_queue );
+
+ g_return_if_fail( tmp_node != NULL );
+
+ call_tip_node.startCalltipWord = tmp_node->startCalltipWord;
+ call_tip_node.def_index = tmp_node->def_index;
+ call_tip_node.max_def = tmp_node->max_def;
+ for (int i = 0; i < call_tip_node.max_def; i++)
+ call_tip_node.functionDefinition[i] =
+ tmp_node->functionDefinition[i];
+ call_tip_node.start_pos = tmp_node->start_pos;
+ call_tip_node.rootlen = tmp_node->rootlen;
+ call_tip_node.call_tip_start_pos = tmp_node->call_tip_start_pos;
+
+ // in response to g_malloc on SaveCallTip
+ delete tmp_node;
+ }
+ if (call_tip_node.max_def > 1 &&
+ call_tip_node.def_index == 0) {
+
+ char *real_tip;
+ real_tip = g_strconcat ("\002",
+ call_tip_node.functionDefinition[call_tip_node.def_index].c_str(),
+ NULL);
+ SendEditorString(SCI_CALLTIPSHOW, call_tip_node.start_pos -
+ call_tip_node.rootlen + 1, real_tip);
+ g_free (real_tip);
+ } else if (call_tip_node.max_def > 1 &&
+ call_tip_node.def_index == (call_tip_node.max_def - 1)) {
+ char *real_tip;
+ real_tip = g_strconcat ("\001",
+ call_tip_node.functionDefinition[call_tip_node.def_index].c_str(),
+ NULL);
+ SendEditorString(SCI_CALLTIPSHOW, call_tip_node.start_pos -
+ call_tip_node.rootlen + 1, real_tip);
+ g_free (real_tip);
+ } else if (call_tip_node.max_def > 1) {
+ char *real_tip;
+ real_tip = g_strconcat ("\001\002",
+ call_tip_node.functionDefinition[call_tip_node.def_index].c_str(),
+ NULL);
+ SendEditorString(SCI_CALLTIPSHOW, call_tip_node.start_pos -
+ call_tip_node.rootlen + 1, real_tip);
+ g_free (real_tip);
+ } else {
+ SendEditorString(SCI_CALLTIPSHOW, call_tip_node.start_pos -
+ call_tip_node.rootlen + 1,
+ call_tip_node.functionDefinition[call_tip_node.def_index].c_str());
+ }
+}
+
+//------------------------------------------------------------------------------
+//
+
+void AnEditor::ShutDownCallTip() {
+
+// g_message( "***shutdowncalltip: length %d", g_queue_get_length( call_tip_node_queue ));
+
+ while ( g_queue_is_empty( call_tip_node_queue ) != TRUE ) {
+ CallTipNode_ptr tmp_node;
+
+ tmp_node = (CallTipNode_ptr)g_queue_pop_tail( call_tip_node_queue );
+
+ // in response to g_malloc on SaveCallTip
+ delete tmp_node;
+ }
+ // reset
+ SetCallTipDefaults();
+}
+
+//------------------------------------------------------------------------------
+//
+void AnEditor::SetCallTipDefaults( ) {
+
+ // we're going to set the default values to this.call_tip_node struct
+ call_tip_node.def_index = 0;
+ call_tip_node.max_def = 0;
+ call_tip_node.start_pos = 0;
+ call_tip_node.rootlen = 0;
+ call_tip_node.startCalltipWord = 0;
+ call_tip_node.call_tip_start_pos = 0;
+}
+
+//------------------------------------------------------------------------------
+// gives a list of calltips which match the word on the current caret and display
+// them
+
+void AnEditor::CompleteCallTip() {
+#if 0
+ char expr[256];
+ TMTagAttrType attrs[] = {tm_tag_attr_name_t, tm_tag_attr_type_t, tm_tag_attr_none_t};
+ int caret_position = SendEditor(SCI_GETCURRENTPOS);
+
+ if (SendEditor(SCI_CALLTIPACTIVE))
+ return;
+
+ // get the current word
+ GetWordAtPosition(expr, sizeof(expr), caret_position);
+ DEBUG_PRINT("completecalltip: on word %s and caret_position %d", expr, caret_position);
+
+ const GPtrArray *tags = tm_workspace_find(expr,
+ tm_tag_prototype_t |
+ tm_tag_function_t |
+ tm_tag_macro_with_arg_t,
+ attrs, FALSE, TRUE);
+
+ // we'll provide a function calltip
+ if (tags && (tags->len > 0))
+ {
+ TMTag *tag = (TMTag *) tags->pdata[0];
+ SString definition;
+ char *tmp;
+
+ tmp = g_strdup_printf("%s %s%s", NVL(tag->atts.entry.type_ref[1], ""),
+ tag->name, NVL(tag->atts.entry.arglist, ""));
+ definition = tmp;
+ g_free(tmp);
+
+ char *real_tip;
+ real_tip = g_strdup (definition.c_str());
+
+ SendEditorString(SCI_CALLTIPSHOW, caret_position, real_tip);
+ g_free (real_tip);
+ }
+#endif
+}
Added: trunk/plugins/scintilla/aneditor-indent.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor-indent.cxx Wed Apr 8 22:31:22 2009
@@ -0,0 +1,424 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ aneditor-indent.cxx
+ Copyright (C) 2004 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "aneditor-priv.h"
+
+void AnEditor::IndentationIncrease(){
+ CharacterRange crange = GetSelection();
+ if (crange.cpMin != crange.cpMax)
+ {
+ SendEditor (SCI_TAB);
+ return;
+ }
+ int line =SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ int indent =GetLineIndentation(line);
+ indent +=SendEditor(SCI_GETINDENT);
+ SetLineIndentation(line, indent);
+}
+
+void AnEditor::IndentationDecrease(){
+ CharacterRange crange = GetSelection();
+ if (crange.cpMin != crange.cpMax)
+ {
+ SendEditor (SCI_BACKTAB);
+ return;
+ }
+ int line =SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ int indent = GetLineIndentation(line);
+ indent -=SendEditor(SCI_GETINDENT);
+ if (indent < 0) indent = 0;
+ SetLineIndentation(line, indent);
+}
+
+void AnEditor::SetLineIndentation(int line, int indent) {
+ if (indent < 0)
+ return;
+ CharacterRange crange = GetSelection();
+ int posBefore = GetLineIndentPosition(line);
+ SendEditor(SCI_SETLINEINDENTATION, line, indent);
+ int posAfter = GetLineIndentPosition(line);
+ int posDifference = posAfter - posBefore;
+ if (posAfter > posBefore) {
+ // Move selection on
+ if (crange.cpMin >= posBefore) {
+ crange.cpMin += posDifference;
+ }
+ if (crange.cpMax >= posBefore) {
+ crange.cpMax += posDifference;
+ }
+ } else if (posAfter < posBefore) {
+ // Move selection back
+ if (crange.cpMin >= posAfter) {
+ if (crange.cpMin >= posBefore)
+ crange.cpMin += posDifference;
+ else
+ crange.cpMin = posAfter;
+ }
+ if (crange.cpMax >= posAfter) {
+ if (crange.cpMax >= posBefore)
+ crange.cpMax += posDifference;
+ else
+ crange.cpMax = posAfter;
+ }
+ }
+ SetSelection(crange.cpMin, crange.cpMax);
+}
+
+int AnEditor::GetLineIndentation(int line) {
+ return SendEditor(SCI_GETLINEINDENTATION, line);
+}
+
+int AnEditor::GetLineIndentPosition(int line) {
+ return SendEditor(SCI_GETLINEINDENTPOSITION, line);
+}
+
+bool AnEditor::RangeIsAllWhitespace(int start, int end) {
+ WindowAccessor acc(wEditor.GetID(), *props);
+ for (int i = start;i < end;i++) {
+ if ((acc[i] != ' ') && (acc[i] != '\t'))
+ return false;
+ }
+ return true;
+}
+
+#if 0
+
+unsigned int AnEditor::GetLinePartsInStyle(int line, int style1, int style2,
+ SString sv[], int len) {
+ for (int i = 0; i < len; i++)
+ sv[i] = "";
+ WindowAccessor acc(wEditor.GetID(), *props);
+ SString s;
+ int part = 0;
+ int thisLineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ int nextLineStart = SendEditor(SCI_POSITIONFROMLINE, line + 1);
+ for (int pos = thisLineStart; pos < nextLineStart; pos++) {
+ if ((acc.StyleAt(pos) == style1) || (acc.StyleAt(pos) == style2)) {
+ char c[2];
+ c[0] = acc[pos];
+ c[1] = '\0';
+ s += c;
+ } else if (s.length() > 0) {
+ if (part < len) {
+ sv[part++] = s;
+ }
+ s = "";
+ }
+ }
+ if ((s.length() > 0) && (part < len)) {
+ sv[part++] = s;
+ }
+ return part;
+}
+
+static bool includes(const StyleAndWords &symbols, const SString value) {
+ if (symbols.words.length() == 0) {
+ return false;
+ } else if (IsAlphabetic(symbols.words[0])) {
+ // Set of symbols separated by spaces
+ size_t lenVal = value.length();
+ const char *symbol = symbols.words.c_str();
+ while (symbol) {
+ const char *symbolEnd = strchr(symbol, ' ');
+ size_t lenSymbol = strlen(symbol);
+ if (symbolEnd)
+ lenSymbol = symbolEnd - symbol;
+ if (lenSymbol == lenVal) {
+ if (strncmp(symbol, value.c_str(), lenSymbol) == 0) {
+ return true;
+ }
+ }
+ symbol = symbolEnd;
+ if (symbol)
+ symbol++;
+ }
+ } else {
+ // Set of individual characters. Only one character allowed for now
+ char ch = symbols.words[0];
+ return strchr(value.c_str(), ch) != 0;
+ }
+ return false;
+}
+
+#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
+
+IndentationStatus AnEditor::GetIndentState(int line) {
+ // C like language indentation defined by braces and keywords
+ IndentationStatus indentState = isNone;
+ SString controlWords[20];
+ unsigned int parts = GetLinePartsInStyle(line, statementIndent.styleNumber,
+ -1, controlWords, ELEMENTS(controlWords));
+ for (unsigned int i = 0; i < parts; i++) {
+ if (includes(statementIndent, controlWords[i]))
+ indentState = isKeyWordStart;
+ }
+ // Braces override keywords
+ SString controlStrings[20];
+ parts = GetLinePartsInStyle(line, blockEnd.styleNumber,
+ -1, controlStrings, ELEMENTS(controlStrings));
+ for (unsigned int j = 0; j < parts; j++) {
+ if (includes(blockEnd, controlStrings[j]))
+ indentState = isBlockEnd;
+ if (includes(blockStart, controlStrings[j]))
+ indentState = isBlockStart;
+ }
+ return indentState;
+}
+
+int AnEditor::IndentOfBlockProper(int line) {
+
+ if (line < 0)
+ return 0;
+
+ int indentSize = SendEditor(SCI_GETINDENT);
+ int indentBlock = GetLineIndentation(line);
+ int minIndent = indentBlock;
+ int backLine = line;
+
+ IndentationStatus indentState = isNone;
+ if (statementIndent.IsEmpty() && blockStart.IsEmpty() && blockEnd.IsEmpty())
+ indentState = isBlockStart; // Don't bother searching backwards
+
+ int lineLimit = line - statementLookback;
+ if (lineLimit < 0)
+ lineLimit = 0;
+ bool noIndentFound = true;
+ while ((backLine >= lineLimit) && (indentState == 0)) {
+ indentState = GetIndentState(backLine);
+ if (indentState != 0) {
+ noIndentFound = false;
+ indentBlock = GetLineIndentation(backLine);
+ if (indentState == isBlockStart) {
+ if (!indentOpening)
+ indentBlock += indentSize;
+ }
+ if (indentState == isBlockEnd) {
+ if (indentClosing)
+ indentBlock -= indentSize;
+ if (indentBlock < 0)
+ indentBlock = 0;
+ }
+ if ((indentState == isKeyWordStart) && (backLine == line))
+ indentBlock += indentSize;
+ } else if (noIndentFound) {
+ int currentIndent = GetLineIndentation(backLine);
+ minIndent = MIN(minIndent, currentIndent);
+ }
+ backLine--;
+ }
+ if (noIndentFound && minIndent > 0)
+ indentBlock = minIndent;
+ return indentBlock;
+}
+
+int AnEditor::IndentOfBlock(int line) {
+
+ int backLine = line;
+
+ /* Find mismatched parenthesis */
+ if (lexLanguage == SCLEX_CPP) {
+ WindowAccessor acc(wEditor.GetID(), *props);
+ int currentPos = SendEditor(SCI_POSITIONFROMLINE, backLine + 1);
+
+ while (backLine >= 0) {
+ int thisLineStart = SendEditor(SCI_POSITIONFROMLINE, backLine);
+ int nextLineStart = currentPos;
+ // printf("Scanning at line: %d (%d)\n", backLine, currentPos);
+
+ int foundTerminator = false;
+ int pos;
+ for (pos = nextLineStart - 1; pos >= thisLineStart; pos--) {
+
+ // printf ("Style at %d = %d\n", pos, acc.StyleAt(pos));
+
+ if ((acc.StyleAt(pos) == 10)) {
+ char c[2];
+ c[0] = acc[pos];
+ c[1] = '\0';
+ // printf ("Looking at: \"%s\"\n", c);
+ if (includes(blockEnd, c) ||
+ includes(blockStart, c) ||
+ includes(statementEnd, c))
+ {
+ // printf ("Found block start/block end/statement end. Breaking\n");
+ foundTerminator = true;
+ break;
+ }
+ if (c[0] == '(' || c[0] == '[') {
+ int indentBlock = SendEditor(SCI_GETCOLUMN, pos) + 1;// - thisLineStart;
+ // printf ("Found Unmatched '(' at col: %d. Returning\n", indentBlock);
+ return indentBlock;
+ }
+ if (c[0] == ')' || c[0] == ']') {
+ int braceOpp;
+ int lineOpp;
+ braceOpp = SendEditor(SCI_BRACEMATCH, pos, 0);
+ // printf ("Brace opp. at %d\n", braceOpp);
+ if (braceOpp >= 0) {
+ currentPos = braceOpp - 1;
+ lineOpp = SendEditor (SCI_LINEFROMPOSITION,
+ braceOpp);
+ if (backLine != lineOpp) {
+ backLine = lineOpp;
+ // printf ("Jumping to line %d (%d)\n", backLine, currentPos);
+ break;
+ } else {
+ pos = currentPos;
+ }
+ } else {
+ foundTerminator = true;
+ break;
+ }
+ }
+ } else if ((acc.StyleAt(pos) == statementIndent.styleNumber) &&
+ (acc.StyleAt(pos+1) != statementIndent.styleNumber)) {
+ char buffer[128];
+ if (GetWordAtPosition (buffer, 128, pos)) {
+ if (includes (statementIndent, buffer)) {
+ printf ("Found keyword terminator before unmatched (\n");
+ foundTerminator = true;
+ break;
+ }
+ }
+ }
+ }
+ if (foundTerminator)
+ break;
+ if (pos < thisLineStart) {
+ backLine--;
+ currentPos = pos;
+ }
+ }
+ }
+ return IndentOfBlockProper(backLine);
+}
+#endif
+
+void AnEditor::MaintainIndentation(char ch) {
+ int eolMode = SendEditor(SCI_GETEOLMODE);
+ int curLine = GetCurrentLineNumber();
+ int lastLine = curLine - 1;
+ int indentAmount = 0;
+
+ if (((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
+ (eolMode == SC_EOL_CR && ch == '\r')) {
+ if (props->GetInt("indent.automatic")) {
+ while (lastLine >= 0 && GetLineLength(lastLine) == 0)
+ lastLine--;
+ }
+ if (lastLine >= 0) {
+ indentAmount = GetLineIndentation(lastLine);
+ }
+ if (indentAmount > 0) {
+ SetLineIndentation(curLine, indentAmount);
+ }
+ }
+}
+
+#if 0
+void AnEditor::AutomaticIndentation(char ch) {
+ CharacterRange crange = GetSelection();
+ int selStart = crange.cpMin;
+ int curLine = GetCurrentLineNumber();
+ int thisLineStart = SendEditor(SCI_POSITIONFROMLINE, curLine);
+ int indentSize = SendEditor(SCI_GETINDENT);
+
+ if (blockEnd.IsSingleChar() && ch == blockEnd.words[0]) {
+ // Dedent maybe
+ if (!indentClosing) {
+ if (RangeIsAllWhitespace(thisLineStart, selStart - 1)) {
+ int indentBlock = IndentOfBlockProper(curLine - 1);
+ SetLineIndentation(curLine, indentBlock - indentSize);
+ }
+ }
+ } else if (!blockEnd.IsSingleChar() && (ch == ' ')) {
+ // Dedent maybe
+ if (!indentClosing && (GetIndentState(curLine) == isBlockEnd)) {}
+ } else if (ch == blockStart.words[0]) {
+ // Dedent maybe if first on line and previous line was starting keyword
+ if (!indentOpening &&
+ (GetIndentState(curLine - 1) == isKeyWordStart)) {
+ if (RangeIsAllWhitespace(thisLineStart, selStart - 1)) {
+ int indentBlock = IndentOfBlockProper(curLine - 1);
+ SetLineIndentation(curLine, indentBlock - indentSize);
+ }
+ }
+ } else if ((ch == '\r' || ch == '\n') && (selStart == thisLineStart)) {
+ // printf("New line block\n");
+ int indentBlock = IndentOfBlock(curLine - 1);
+ if (!indentClosing && !blockEnd.IsSingleChar()) {
+ // Dedent previous line maybe
+
+ SString controlWords[1];
+ // printf ("First if\n");
+
+ if (GetLinePartsInStyle(curLine-1, blockEnd.styleNumber,
+ -1, controlWords, ELEMENTS(controlWords))) {
+ // printf ("Second if\n");
+ if (includes(blockEnd, controlWords[0])) {
+ // printf ("Third if\n");
+ // Check if first keyword on line is an ender
+ SetLineIndentation(curLine-1,
+ IndentOfBlockProper(curLine-2)
+ - indentSize);
+ // Recalculate as may have changed previous line
+ indentBlock = IndentOfBlock(curLine - 1);
+ }
+ }
+ }
+ SetLineIndentation(curLine, indentBlock);
+
+ // Home cursor.
+ if (SendEditor (SCI_GETCOLUMN,
+ SendEditor(SCI_GETCURRENTPOS)) < indentBlock)
+ SendEditor (SCI_VCHOME);
+
+ } else if (lexLanguage == SCLEX_CPP) {
+ if ((ch == '\t')) {
+
+ int indentBlock = IndentOfBlock(curLine - 1);
+ int indentState = GetIndentState (curLine);
+
+ if (blockStart.IsSingleChar() && indentState == isBlockStart) {
+ if (!indentOpening) {
+ if (RangeIsAllWhitespace(thisLineStart, selStart - 1)) {
+ // int indentBlock = IndentOfBlockProper(curLine - 1);
+ SetLineIndentation(curLine, indentBlock - indentSize);
+ }
+ }
+ } else if (blockEnd.IsSingleChar() && indentState == isBlockEnd) {
+ if (!indentClosing) {
+ if (RangeIsAllWhitespace(thisLineStart, selStart - 1)) {
+ // int indentBlock = IndentOfBlockProper(curLine - 1);
+ SetLineIndentation(curLine, indentBlock - indentSize);
+ }
+ }
+ } else {
+ SetLineIndentation(curLine, indentBlock);
+ }
+
+ // Home cursor.
+ if (SendEditor (SCI_GETCOLUMN,
+ SendEditor(SCI_GETCURRENTPOS)) < indentBlock)
+ SendEditor (SCI_VCHOME);
+ }
+ }
+}
+#endif
Added: trunk/plugins/scintilla/aneditor-priv.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor-priv.h Wed Apr 8 22:31:22 2009
@@ -0,0 +1,433 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ aneditor-priv.h
+ Copyright (C) 2004 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#ifndef __ANEDITOR_PRIV_H__
+#define __ANEDITOR_PRIV_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include <locale.h>
+
+#include <gnome.h>
+
+#define GTK
+#include "Platform.h"
+#include "PropSet.h"
+#include "Accessor.h"
+#include "WindowAccessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "ScintillaWidget.h"
+#include "SciLexer.h"
+#include "lexer.h"
+#include "properties_cxx.h"
+#include "properties.h"
+#include "aneditor.h"
+
+#include <libanjuta/resources.h>
+
+#include <string>
+#include <memory>
+
+using namespace std;
+
+// #include "debugger.h"
+
+#if 0
+
+#include "sv_unknown.xpm"
+#include "sv_class.xpm"
+#include "sv_function.xpm"
+#include "sv_macro.xpm"
+#include "sv_private_fun.xpm"
+#include "sv_private_var.xpm"
+#include "sv_protected_fun.xpm"
+#include "sv_protected_var.xpm"
+#include "sv_public_fun.xpm"
+#include "sv_public_var.xpm"
+#include "sv_struct.xpm"
+#include "sv_variable.xpm"
+
+#endif
+
+// #define DEBUG
+
+#define ANE_MARKER_BOOKMARK 0
+#define MAX_PATH 260
+#define MAXIMUM(x, y) ((x>y)?x:y)
+#define MINIMUM(x,y) ((x<y)?x:y)
+
+#define MAX_AUTOCOMPLETE_WORDS 50 /* Maximum number of autocomplete words to show */
+
+/* Colour has mysteriously vanished from scintilla */
+/* Using the substitute */
+typedef class ColourDesired Colour;
+
+template<int sz>
+class EntryMemory {
+ SString entries[sz];
+public:
+ void Insert(SString s) {
+ for (int i=0;i<sz;i++) {
+ if (entries[i] == s) {
+ for (int j=i;j>0;j--) {
+ entries[j] = entries[j-1];
+ }
+ entries[0] = s;
+ return;
+ }
+ }
+ for (int k=sz-1;k>0;k--) {
+ entries[k] = entries[k-1];
+ }
+ entries[0] = s;
+ }
+ int Length() const {
+ int len = 0;
+ for (int i=0;i<sz;i++)
+ if (entries[i].length())
+ len++;
+ return len;
+ }
+ SString At(int n)const {
+ return entries[n];
+ }
+};
+
+typedef EntryMemory<10> ComboMemory;
+
+struct StyleAndWords {
+ int styleNumber;
+ SString words;
+ bool IsEmpty() { return words.length() == 0; }
+ bool IsSingleChar() { return words.length() == 1; }
+};
+
+// will contain the parameters for the recursive function completion
+typedef struct _CallTipNode {
+ int startCalltipWord;
+ int def_index;
+ int max_def;
+ SString functionDefinition[20];
+ int rootlen;
+ int start_pos; // start position in editor
+ int call_tip_start_pos; // start position in calltip
+
+} CallTipNode, *CallTipNode_ptr;
+
+// Related to Utf8_16::encodingType but with additional values at end
+enum UniMode {
+ uni8Bit=0, uni16BE=1, uni16LE=2, uniUTF8=3,
+ uniCookie=4
+};
+
+// Codes representing the effect a line has on indentation.
+enum IndentationStatus {
+ isNone, // no effect on indentation
+ isBlockStart, // indentation block begin such as "{" or VB "function"
+ isBlockEnd, // indentation end indicator such as "}" or VB "end"
+ isKeyWordStart // Keywords that cause indentation
+};
+
+class AnEditor {
+
+protected:
+ char fileName[MAX_PATH+20]; // filename kept here temporarily
+
+ ComboMemory memFinds;
+ ComboMemory memReplaces;
+ ComboMemory memFiles;
+
+ int characterSet;
+ SString language;
+ int lexLanguage;
+ SString overrideExtension; // User has chosen to use a particular language
+ enum {numWordLists=5};
+ GtkAccelGroup* accelGroup;
+
+ int indentSize;
+ /*
+ bool indentOpening;
+ bool indentClosing;
+ */
+
+ bool indentMaintain;
+ /*
+ int statementLookback;
+ StyleAndWords statementIndent;
+ StyleAndWords statementEnd;
+ StyleAndWords blockStart;
+ StyleAndWords blockEnd;
+ enum { noPPC, ppcStart, ppcMiddle, ppcEnd, ppcDummy }; ///< Indicate the kind of preprocessor condition line
+ char preprocessorSymbol; ///< Preprocessor symbol (in C: #)
+ WordList preprocCondStart; ///< List of preprocessor conditional start keywords (in C: if ifdef ifndef)
+ WordList preprocCondMiddle; ///< List of preprocessor conditional middle keywords (in C: else elif)
+ WordList preprocCondEnd; ///< List of preprocessor conditional end keywords (in C: endif)
+ */
+
+ Window wEditor;
+
+ SciFnDirect fnEditor;
+ long ptrEditor;
+ SciFnDirect fnOutput;
+ long ptrOutput;
+ bool tbVisible;
+ bool tabVisible;
+ bool tabMultiLine;
+ bool sbVisible;
+ int visHeightTools;
+ int visHeightTab;
+ int visHeightStatus;
+ int visHeightEditor;
+ int heightBar;
+
+ int heightOutput;
+ int heightOutputStartDrag;
+ Point ptStartDrag;
+ bool capturedMouse;
+ bool firstPropertiesRead;
+ bool splitVertical;
+ bool bufferedDraw;
+ bool bracesCheck;
+ bool bracesSloppy;
+ int bracesStyle;
+ int braceCount;
+ SString sbValue;
+ bool wrapLine;
+ bool isReadOnly;
+
+ bool indentationWSVisible;
+
+ bool autoCompleteIgnoreCase;
+ bool callTipIgnoreCase;
+ bool autoCCausedByOnlyOne;
+ SString calltipWordCharacters;
+ SString calltipEndDefinition;
+ SString autoCompleteStartCharacters;
+ SString autoCompleteFillUpCharacters;
+ SString wordCharacters;
+ int startCalltipWord;
+
+ GQueue *call_tip_node_queue;
+ CallTipNode call_tip_node;
+
+ GCompletion *autocompletion;
+
+ // needed for calltips caret moving
+ int lastPos;
+
+ bool margin;
+ int marginWidth;
+ enum { marginWidthDefault = 20};
+
+ bool foldMargin;
+ int foldMarginWidth;
+ enum { foldMarginWidthDefault = 14};
+
+ bool lineNumbers;
+ int lineNumbersWidth;
+ enum { lineNumbersWidthDefault = 40};
+
+ bool usePalette;
+ bool clearBeforeExecute;
+ bool allowMenuActions;
+ bool isDirty;
+
+ bool calltipShown;
+ //bool debugTipOn;
+ static AnEditorID focusedID;
+ friend void aneditor_set_focused_ed_ID(AnEditorID id);
+ //friend void eval_output_arrived_for_aneditor(GList* lines, gpointer data);
+
+ PropSetFile *props;
+
+ int LengthDocument();
+ int GetCaretInLine();
+ void GetLine(SString & text, int line = -1);
+ int GetFullLine(SString & text, int line = -1);
+ void GetRange(Window &win, int start, int end, char *text);
+ /*
+ int IsLinePreprocessorCondition(const char *line);
+ bool FindMatchingPreprocessorCondition(int &curLine, int direction,
+ int condEnd1, int condEnd2);
+ bool FindMatchingPreprocCondPosition(bool isForward, int &mppcAtCaret,
+ int &mppcMatch);
+ */
+ bool FindMatchingBracePosition(bool editor, int &braceAtCaret,
+ int &braceOpposite, bool sloppy);
+ void BraceMatch(bool editor);
+
+ bool GetCurrentWord(char* buffer, int maxlength);
+ bool GetWordBeforeCarat(char* buffer, int maxlength);
+
+ bool FindWordInRegion(char *buffer, int maxlength, SString &linebuf,
+ int current);
+ bool GetWordAtPosition(char* buffer, int maxlength, int pos);
+
+ void IndentationIncrease();
+ void IndentationDecrease();
+
+ void ClearDocument();
+ void CountLineEnds(int &linesCR, int &linesLF, int &linesCRLF);
+ CharacterRange GetSelection();
+ void SelectionWord(char *word, int len);
+ void WordSelect();
+ void LineSelect();
+ void SelectionIntoProperties();
+ long Find (long flags, char* text);
+ bool HandleXml(char ch);
+ SString FindOpenXmlTag(const char sel[], int nSize);
+ void GoMatchingBrace(bool select);
+ void GetRange(guint start, guint end, gchar *text, gboolean styled);
+ bool StartCallTip_new();
+ void ContinueCallTip_new();
+ void SaveCallTip();
+ void ResumeCallTip(bool pop_from_stack = true);
+ void ShutDownCallTip();
+ void SetCallTipDefaults( );
+ void CompleteCallTip();
+
+ // TMTag ** FindTypeInLocalWords(GPtrArray *CurrentFileTags, const char *root,
+ // const bool type, int *retptr, int *count);
+ //bool SendAutoCompleteRecordsFields(const GPtrArray *CurrentFileTags,
+ // const char *ScanType);
+ // bool StartAutoCompleteRecordsFields(char ch);
+ // bool StartAutoComplete();
+ // bool StartAutoCompleteWord(int autoShowCount);
+ bool StartBlockComment();
+ bool CanBeCommented(bool box_stream);
+ bool StartBoxComment();
+ bool StartStreamComment();
+ // SString GetMode(SString language);
+ // bool InsertCustomIndent();
+
+ // unsigned int GetLinePartsInStyle(int line, int style1, int style2,
+ // SString sv[], int len);
+ void SetLineIndentation(int line, int indent);
+ int GetLineIndentation(int line);
+ int GetLineIndentPosition(int line);
+ // IndentationStatus GetIndentState(int line);
+ // int IndentOfBlockProper(int line);
+ // int IndentOfBlock(int line);
+ void MaintainIndentation(char ch);
+ // void AutomaticIndentation(char ch);
+ void CharAdded(char ch);
+ void FoldChanged(int line, int levelNow, int levelPrev);
+ void FoldChanged(int position);
+ void Expand(int &line, bool doExpand, bool force=false,
+ int visLevels=0, int level=-1);
+ bool MarginClick(int position,int modifiers);
+ //void HandleDwellStart(int mousePos);
+ void Notify(SCNotification *notification);
+ static void NotifySignal(GtkWidget *w, gint wParam, gpointer lParam,
+ AnEditor *scitew);
+ /*
+ int KeyPress (unsigned int state, unsigned int keyval);
+ static gint KeyPressEvent(GtkWidget *w, GdkEventKey *event,
+ AnEditor *editor);
+ */
+ void BookmarkToggle( int lineno = -1 );
+ void BookmarkFirst();
+ void BookmarkPrev();
+ void BookmarkNext();
+ void BookmarkLast();
+ void BookmarkClear();
+
+ void AssignKey(int key, int mods, int cmd);
+ StyleAndWords GetStyleAndWords(const char *base);
+ void SetOneStyle(Window &win, int style, const char *s);
+ void SetStyleFor(Window &win, const char *language);
+ SString ExtensionFileName();
+ void Command(int command, unsigned long wParam, long lparam);
+ void ForwardPropertyToEditor(const char *key);
+ SString FindLanguageProperty(const char *pattern,
+ const char *defaultValue="");
+ void ReadPropertiesInitial();
+ void ReadProperties(const char* fileForExt);
+ long SendEditor(unsigned int msg, unsigned long wParam=0, long lParam=0);
+ long SendEditorString(unsigned int msg, unsigned long wParam,
+ const char *s);
+ void SetOverrideLanguage(int ID);
+ void ViewWhitespace(bool view);
+ bool RangeIsAllWhitespace(int start, int end);
+ void SaveToHTML(const char *saveName);
+ void SaveToRTF(const char *saveName);
+ void SetSelection(int anchor, int currentPos);
+ int GetLineLength(int line);
+ int GetCurrentLineNumber();
+ int GetCurrentScrollPosition();
+ void FoldOpenAll();
+ void FoldCloseAll();
+ void FoldCode(bool expanding);
+ void FoldToggle();
+ void SelectBlock ();
+ int GetBlockStartLine(int lineno = -1);
+ int GetBlockEndLine(int lineno = -1);
+ void GotoBlockStart();
+ void GotoBlockEnd();
+ void EnsureRangeVisible(int posStart, int posEnd);
+ void SetAccelGroup(GtkAccelGroup* acl);
+ int GetBookmarkLine( const int nLineStart );
+ void DefineMarker(int marker, int makerType, Colour fore, Colour back);
+ void SetLineWrap(bool wrap);
+ void SetReadOnly(bool readonly);
+ void SetFoldSymbols(SString fold_symbols);
+ bool iswordcharforsel(char ch);
+
+public:
+
+ AnEditor(PropSetFile* p);
+ ~AnEditor();
+ WindowID GetID() { return wEditor.GetID(); }
+ long Command(int cmdID, long wParam, long lParam);
+
+ void FocusInEvent(GtkWidget* widget);
+ void FocusOutEvent(GtkWidget* widget);
+ /*
+ void EvalOutputArrived(GList* lines, int textPos,
+ const string &expression);
+ void EndDebugEval();
+ */
+ void SetParent(AnEditor *parent);
+};
+
+class ExpressionEvaluationTipInfo
+// Utility class to help displaying expression values in tips.
+{
+public:
+ AnEditor *editor;
+ int textPos;
+ string expression;
+
+ ExpressionEvaluationTipInfo(AnEditor *e, int pos, const string &expr)
+ : editor(e), textPos(pos), expression(expr) {}
+};
+
+#endif
Added: trunk/plugins/scintilla/aneditor.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor.cxx Wed Apr 8 22:31:22 2009
@@ -0,0 +1,3149 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ aneditor.cxx
+ Copyright (C) 2003 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+/*
+ * Most of the code stolen from SciTE and heavily modified.
+ * If code sections are later imported from SciTE, utmost care
+ * should be taken to ensure that it does not conflict with the present code.
+ */
+
+#include "aneditor-priv.h"
+
+#include <libanjuta/anjuta-debug.h>
+
+static void lowerCaseString(char *s);
+static AnEditor * aneditor_get(AnEditorID id);
+
+gint on_aneditor_focus_in(GtkWidget* widget, gpointer * unused, AnEditor* ed);
+gint on_aneditor_focus_out(GtkWidget* widget, gpointer * unused, AnEditor* ed);
+
+static const char *extList[] = {
+ "", "x", "x.cpp", "x.cpp", "x.html", "x.xml", "x.js", "x.vbs", "x.mak", "x.java",
+ "x.lua", "x.py", "x.pl", "x.sql", "x.spec", "x.php3", "x.tex", "x.diff", "x.pas",
+ "x.cs", "x.properties", "x.conf", "x.bc", "x.adb", "x.lisp", "x.rb", ".m"
+};
+
+const AnEditorID ANE_ID_INVALID = G_MAXUINT;
+AnEditorID AnEditor::focusedID = ANE_ID_INVALID;
+
+AnEditor::AnEditor(PropSetFile* p) {
+
+ characterSet = 0;
+ language = "java";
+ lexLanguage = SCLEX_CPP;
+ /*
+ indentSize = 8;
+ indentOpening = true;
+ indentClosing = true;
+ statementLookback = 10;
+ */
+ indentMaintain = true;
+
+ wrapLine = true;
+ isReadOnly = false;
+ fnEditor = 0;
+ ptrEditor = 0;
+ fnOutput = 0;
+ ptrOutput = 0;
+ tbVisible = false;
+ sbVisible = false;
+ tabVisible = false;
+ tabMultiLine = false;
+ visHeightTools = 0;
+ visHeightStatus = 0;
+ visHeightEditor = 1;
+ heightBar = 7;
+
+ heightOutput = 0;
+
+ allowMenuActions = true;
+ isDirty = false;
+
+ ptStartDrag.x = 0;
+ ptStartDrag.y = 0;
+ capturedMouse = false;
+ firstPropertiesRead = true;
+ splitVertical = false;
+ bufferedDraw = true;
+ bracesCheck = true;
+ bracesSloppy = false;
+ bracesStyle = 0;
+ braceCount = 0;
+
+ indentationWSVisible = true;
+
+ autoCompleteIgnoreCase = false;
+ callTipIgnoreCase = false;
+ autoCCausedByOnlyOne = false;
+// startCalltipWord = 0;
+
+ // init calltips
+ SetCallTipDefaults( );
+ call_tip_node_queue = g_queue_new();
+ lastPos = 0;
+
+ autocompletion = NULL;
+
+ margin = false;
+ marginWidth = marginWidthDefault;
+ foldMargin = true;
+ foldMarginWidth = foldMarginWidthDefault;
+ lineNumbers = false;
+ lineNumbersWidth = lineNumbersWidthDefault;
+ usePalette = false;
+
+ accelGroup = NULL;
+ calltipShown = false;
+ // debugTipOn = false;
+
+ fileName[0] = '\0';
+ props = p;
+
+ wEditor = scintilla_new();
+ g_object_ref (G_OBJECT (wEditor.GetID()));
+ gtk_object_sink (GTK_OBJECT (wEditor.GetID()));
+ scintilla_set_id(SCINTILLA(wEditor.GetID()), 0);
+
+ fnEditor = reinterpret_cast<SciFnDirect>(Platform::SendScintilla(
+ wEditor.GetID(), SCI_GETDIRECTFUNCTION, 0, 0));
+
+ ptrEditor = Platform::SendScintilla(wEditor.GetID(),
+ SCI_GETDIRECTPOINTER, 0, 0);
+
+ g_signal_connect(wEditor.GetID(), "sci-notify", G_CALLBACK(NotifySignal), this);
+
+ /* We will handle all accels ourself */
+ /* SendEditor(SCI_CLEARALLCMDKEYS); */
+
+ /*We have got our own popup menu */
+ SendEditor(SCI_USEPOPUP, false);
+ /* Set default editor mode */
+ SendEditor(SCI_SETEOLMODE, SC_EOL_LF);
+
+#if 0
+ // Trap 'TAB' key for automatic indentation.
+ // SendEditor (SCI_ASSIGNCMDKEY, SCK_TAB, SCI_NULL);
+ g_signal_connect (wEditor.GetID(), "key-press-event",
+ G_CALLBACK (KeyPressEvent), this);
+
+ /* Register images to be used for autocomplete */
+ typedef struct {
+ SVNodeType type;
+ char **xpm_data;
+ } PixAndType;
+ PixAndType pix_list[] = {
+ { sv_none_t , sv_unknown_xpm }
+ , { sv_class_t, sv_class_xpm }
+ , { sv_struct_t, sv_struct_xpm }
+ , { sv_union_t, sv_struct_xpm }
+ , { sv_function_t, sv_function_xpm }
+ , { sv_macro_t, sv_macro_xpm }
+ , { sv_variable_t, sv_variable_xpm }
+ , { sv_private_func_t, sv_private_fun_xpm }
+ , { sv_private_var_t, sv_private_var_xpm }
+ , { sv_protected_func_t, sv_protected_fun_xpm }
+ , { sv_protected_var_t, sv_protected_var_xpm }
+ , { sv_public_func_t, sv_public_fun_xpm }
+ , { sv_public_var_t, sv_public_var_xpm }
+ };
+ for (guint i = 0; i < (sizeof(pix_list)/sizeof(pix_list[0])); ++i)
+ {
+ SendEditor(SCI_REGISTERIMAGE, (long) pix_list[i].type
+ , reinterpret_cast<long>(pix_list[i].xpm_data));
+ }
+#endif
+}
+
+void AnEditor::SetParent(AnEditor *parent)
+{
+ long pdoc = parent->SendEditor(SCI_GETDOCPOINTER, 0, 0);
+ SendEditor(SCI_SETDOCPOINTER, 0, pdoc);
+}
+
+#if 0
+static SVNodeType
+sv_get_node_type (TMTag *tag)
+{
+ char access;
+
+ if (!tag || (tm_tag_file_t == tag->type))
+ return sv_none_t;
+
+ access = tag->atts.entry.access;
+ switch (tag->type)
+ {
+ case tm_tag_class_t:
+ return sv_class_t;
+ case tm_tag_struct_t:
+ return sv_struct_t;
+ case tm_tag_union_t:
+ return sv_union_t;
+ case tm_tag_function_t:
+ case tm_tag_prototype_t:
+ switch (access)
+ {
+ case TAG_ACCESS_PRIVATE:
+ return sv_private_func_t;
+
+ case TAG_ACCESS_PROTECTED:
+ return sv_protected_func_t;
+
+ case TAG_ACCESS_PUBLIC:
+ return sv_public_func_t;
+
+ default:
+ return sv_function_t;
+ }
+ case tm_tag_member_t:
+ switch (access)
+ {
+ case TAG_ACCESS_PRIVATE:
+ return sv_private_var_t;
+
+ case TAG_ACCESS_PROTECTED:
+ return sv_protected_var_t;
+
+ case TAG_ACCESS_PUBLIC:
+ return sv_public_var_t;
+
+ default:
+ return sv_variable_t;
+ }
+
+ case tm_tag_externvar_t:
+ case tm_tag_variable_t:
+ return sv_variable_t;
+
+ case tm_tag_macro_t:
+ case tm_tag_macro_with_arg_t:
+ return sv_macro_t;
+
+ default:
+ return sv_none_t;
+
+ }
+
+}
+#endif
+
+void
+AnEditor::SetAccelGroup(GtkAccelGroup* acl) {
+ accelGroup = acl;
+}
+
+AnEditor::~AnEditor() {
+ g_object_unref (G_OBJECT (wEditor.GetID()));
+}
+
+long AnEditor::SendEditor(unsigned int msg, unsigned long wParam, long lParam) {
+ return fnEditor(ptrEditor, msg, wParam, lParam);
+}
+
+long AnEditor::SendEditorString(unsigned int msg, unsigned long wParam, const char *s) {
+ return SendEditor(msg, wParam, reinterpret_cast<long>(s));
+}
+
+void AnEditor::ViewWhitespace(bool view) {
+ if (view && indentationWSVisible)
+ SendEditor(SCI_SETVIEWWS, SCWS_VISIBLEALWAYS);
+ else if (view)
+ SendEditor(SCI_SETVIEWWS, SCWS_VISIBLEAFTERINDENT);
+ else
+ SendEditor(SCI_SETVIEWWS, SCWS_INVISIBLE);
+}
+
+StyleAndWords AnEditor::GetStyleAndWords(const char *base) {
+ StyleAndWords sw;
+ SString fileNameForExtension = ExtensionFileName();
+ SString sAndW = props->GetNewExpand(base, fileNameForExtension.c_str());
+ sw.styleNumber = sAndW.value();
+ const char *space = strchr(sAndW.c_str(), ' ');
+ if (space)
+ sw.words = space + 1;
+ return sw;
+}
+
+void AnEditor::AssignKey(int key, int mods, int cmd) {
+ SendEditor(SCI_ASSIGNCMDKEY,
+ Platform::LongFromTwoShorts(static_cast<short>(key),
+ static_cast<short>(mods)), cmd);
+}
+
+void AnEditor::SetOverrideLanguage(int ID) {
+ overrideExtension = extList[ID - TE_LEXER_BASE];
+}
+
+int AnEditor::LengthDocument() {
+ return SendEditor(SCI_GETLENGTH);
+}
+
+int AnEditor::GetCaretInLine() {
+ int caret = SendEditor(SCI_GETCURRENTPOS);
+ int line = SendEditor(SCI_LINEFROMPOSITION, caret);
+ int lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ return caret - lineStart;
+}
+
+void AnEditor::GetLine(SString & text, int line) {
+ if (line < 0)
+ line = GetCurrentLineNumber();
+ int lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+ int len = lineEnd - lineStart + 1;
+ char *text_buffer = SString::StringAllocate (len);
+ GetRange(wEditor, lineStart, lineEnd, text_buffer);
+ text_buffer[len] = '\0';
+ text.attach(text_buffer, len);
+}
+
+int AnEditor::GetFullLine(SString & text, int line) {
+ int caret, lineStart, lineEnd;
+ if (line < 0)
+ {
+ line = GetCurrentLineNumber();
+ caret = GetCaretInLine();
+ lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+ }
+ else
+ {
+ lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+ caret = lineEnd - lineStart - 1;
+ }
+ int count = 25, current;
+ int len = lineEnd - lineStart + 1;
+ text.clear();
+ while(count)
+ {
+ {
+ char *text_buffer = SString::StringAllocate (len + text.length());
+ GetRange(wEditor, lineStart, lineEnd, text_buffer);
+ memcpy(text_buffer + len - 1, text.c_str(), text.length());
+ text_buffer[len + text.length()] = '\0';
+ text.attach(text_buffer, len + text.length());
+ }
+ current = caret;
+ while(current > 0)
+ {
+ if(text[current - 1] == ';' ||
+ text[current - 1] == '{' || text[current - 1] == '}')
+ {
+ return caret;
+ }
+ current--;
+ }
+ line--;
+ if(line < 0) break;
+ lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+ len = lineEnd - lineStart;
+ caret += len;
+ len++;
+ count--;
+ }
+ text.clear();
+ return -1;
+}
+
+
+void AnEditor::GetRange(Window &win, int start, int end, char *text) {
+ TextRange tr;
+ tr.chrg.cpMin = start;
+ tr.chrg.cpMax = end;
+ tr.lpstrText = text;
+ Platform::SendScintilla(win.GetID(), SCI_GETTEXTRANGE, 0, reinterpret_cast<long>(&tr));
+}
+
+void AnEditor::GetRange(guint start, guint end, gchar *text, gboolean styled) {
+ TextRange tr;
+ tr.chrg.cpMin = start;
+ tr.chrg.cpMax = end;
+ tr.lpstrText = text;
+ if (styled)
+ SendEditor (SCI_GETSTYLEDTEXT, 0, reinterpret_cast<long>(&tr));
+ else
+ SendEditor (SCI_GETTEXTRANGE, 0, reinterpret_cast<long>(&tr));
+}
+
+#if 0
+
+/**
+ * Check if the given line is a preprocessor condition line.
+ * @return The kind of preprocessor condition (enum values).
+ */
+int AnEditor::IsLinePreprocessorCondition(const char *line) {
+ const char *currChar = line;
+ char word[32];
+ int i = 0;
+
+ if (!currChar) {
+ return false;
+ }
+ while (isspacechar(*currChar) && *currChar) {
+ currChar++;
+ }
+ if (preprocessorSymbol && (*currChar == preprocessorSymbol)) {
+ currChar++;
+ while (isspacechar(*currChar) && *currChar) {
+ currChar++;
+ }
+ while (!isspacechar(*currChar) && *currChar) {
+ word[i++] = *currChar++;
+ }
+ word[i] = '\0';
+ if (preprocCondStart.InList(word)) {
+ return ppcStart;
+ }
+ if (preprocCondMiddle.InList(word)) {
+ return ppcMiddle;
+ }
+ if (preprocCondEnd.InList(word)) {
+ return ppcEnd;
+ }
+ }
+ return noPPC;
+}
+
+/**
+ * Search a matching preprocessor condition line.
+ * @return @c true if the end condition are meet.
+ * Also set curLine to the line where one of these conditions is mmet.
+ */
+bool AnEditor::FindMatchingPreprocessorCondition(
+ int &curLine, ///< Number of the line where to start the search
+ int direction, ///< Direction of search: 1 = forward, -1 = backward
+ int condEnd1, ///< First status of line for which the search is OK
+ int condEnd2) { ///< Second one
+
+ bool isInside = false;
+ SString line;
+ int status, level = 0;
+ int maxLines = SendEditor(SCI_GETLINECOUNT);
+
+ while (curLine < maxLines && curLine > 0 && !isInside) {
+ curLine += direction; // Increment or decrement
+ GetLine(line, curLine);
+ status = IsLinePreprocessorCondition(line.c_str());
+
+ if ((direction == 1 && status == ppcStart) || (direction == -1 && status == ppcEnd)) {
+ level++;
+ } else if (level > 0 && ((direction == 1 && status == ppcEnd) || (direction == -1 && status == ppcStart))) {
+ level--;
+ } else if (level == 0 && (status == condEnd1 || status == condEnd2)) {
+ isInside = true;
+ }
+ }
+
+ return isInside;
+}
+
+/**
+ * Find if there is a preprocessor condition after or before the caret position,
+ * @return @c true if inside a preprocessor condition.
+ */
+#ifdef __BORLANDC__
+// Borland warns that isInside is assigned a value that is never used in this method.
+// This is OK so turn off the warning just for this method.
+#pragma warn -aus
+#endif
+bool AnEditor::FindMatchingPreprocCondPosition(
+ bool isForward, ///< @c true if search forward
+ int &mppcAtCaret, ///< Matching preproc. cond.: current position of caret
+ int &mppcMatch) { ///< Matching preproc. cond.: matching position
+
+ bool isInside = false;
+ int curLine;
+ SString line;
+ int status;
+
+ // Get current line
+ curLine = SendEditor(SCI_LINEFROMPOSITION, mppcAtCaret);
+ GetLine(line, curLine);
+ status = IsLinePreprocessorCondition(line.c_str());
+
+ switch (status) {
+ case ppcStart:
+ if (isForward) {
+ isInside = FindMatchingPreprocessorCondition(curLine, 1, ppcMiddle, ppcEnd);
+ } else {
+ mppcMatch = mppcAtCaret;
+ return true;
+ }
+ break;
+ case ppcMiddle:
+ if (isForward) {
+ isInside = FindMatchingPreprocessorCondition(curLine, 1, ppcMiddle, ppcEnd);
+ } else {
+ isInside = FindMatchingPreprocessorCondition(curLine, -1, ppcStart, ppcMiddle);
+ }
+ break;
+ case ppcEnd:
+ if (isForward) {
+ mppcMatch = mppcAtCaret;
+ return true;
+ } else {
+ isInside = FindMatchingPreprocessorCondition(curLine, -1, ppcStart, ppcMiddle);
+ }
+ break;
+ default: // Should be noPPC
+
+ if (isForward) {
+ isInside = FindMatchingPreprocessorCondition(curLine, 1, ppcMiddle, ppcEnd);
+ } else {
+ isInside = FindMatchingPreprocessorCondition(curLine, -1, ppcStart, ppcMiddle);
+ }
+ break;
+ }
+
+ if (isInside) {
+ mppcMatch = SendEditor(SCI_POSITIONFROMLINE, curLine);
+ }
+ return isInside;
+}
+#endif
+
+#ifdef __BORLANDC__
+#pragma warn .aus
+#endif
+
+/**
+ * Find if there is a brace next to the caret, checking before caret first, then
+ * after caret. If brace found also find its matching brace.
+ * @return @c true if inside a bracket pair.
+ */
+bool AnEditor::FindMatchingBracePosition(bool editor, int &braceAtCaret, int &braceOpposite, bool sloppy) {
+ bool isInside = false;
+ // Window &win = editor ? wEditor : wOutput;
+ Window &win = wEditor;
+ int bracesStyleCheck = editor ? bracesStyle : 0;
+ int caretPos = Platform::SendScintilla(win.GetID(), SCI_GETCURRENTPOS, 0, 0);
+ braceAtCaret = -1;
+ braceOpposite = -1;
+ char charBefore = '\0';
+ char styleBefore = '\0';
+ WindowAccessor acc(win.GetID(), *props);
+ if (caretPos > 0) {
+ charBefore = acc[caretPos - 1];
+ styleBefore = static_cast<char>(acc.StyleAt(caretPos - 1) & 31);
+ }
+ // Priority goes to character before caret
+ if (charBefore && strchr("[](){}", charBefore) &&
+ ((styleBefore == bracesStyleCheck) || (!bracesStyle))) {
+ braceAtCaret = caretPos - 1;
+ }
+ bool colonMode = false;
+ if (lexLanguage == SCLEX_PYTHON && ':' == charBefore) {
+ braceAtCaret = caretPos - 1;
+ colonMode = true;
+ }
+ bool isAfter = true;
+ if (sloppy && (braceAtCaret < 0)) {
+ // No brace found so check other side
+ char charAfter = acc[caretPos];
+ char styleAfter = static_cast<char>(acc.StyleAt(caretPos) & 31);
+ if (charAfter && strchr("[](){}", charAfter) && (styleAfter == bracesStyleCheck)) {
+ braceAtCaret = caretPos;
+ isAfter = false;
+ }
+ if (lexLanguage == SCLEX_PYTHON && ':' == charAfter) {
+ braceAtCaret = caretPos;
+ colonMode = true;
+ }
+ }
+ if (braceAtCaret >= 0) {
+ if (colonMode) {
+ int lineStart = Platform::SendScintilla(win.GetID(), SCI_LINEFROMPOSITION, braceAtCaret);
+ int lineMaxSubord = Platform::SendScintilla(win.GetID(), SCI_GETLASTCHILD, lineStart, -1);
+ braceOpposite = Platform::SendScintilla(win.GetID(), SCI_GETLINEENDPOSITION, lineMaxSubord);
+ } else {
+ braceOpposite = Platform::SendScintilla(win.GetID(), SCI_BRACEMATCH, braceAtCaret, 0);
+ }
+ if (braceOpposite > braceAtCaret) {
+ isInside = isAfter;
+ } else {
+ isInside = !isAfter;
+ }
+ }
+ return isInside;
+}
+
+void AnEditor::BraceMatch(bool editor) {
+ if (!bracesCheck)
+ return;
+ int braceAtCaret = -1;
+ int braceOpposite = -1;
+ FindMatchingBracePosition(editor, braceAtCaret, braceOpposite, bracesSloppy);
+ // Window &win = editor ? wEditor : wOutput;
+ Window &win = wEditor;
+ if ((braceAtCaret != -1) && (braceOpposite == -1)) {
+ Platform::SendScintilla(win.GetID(), SCI_BRACEBADLIGHT, braceAtCaret, 0);
+ SendEditor(SCI_SETHIGHLIGHTGUIDE, 0);
+ } else {
+ char chBrace = static_cast<char>(Platform::SendScintilla(
+ win.GetID(), SCI_GETCHARAT, braceAtCaret, 0));
+ Platform::SendScintilla(win.GetID(), SCI_BRACEHIGHLIGHT, braceAtCaret, braceOpposite);
+ int columnAtCaret = Platform::SendScintilla(win.GetID(), SCI_GETCOLUMN, braceAtCaret, 0);
+ int columnOpposite = Platform::SendScintilla(win.GetID(), SCI_GETCOLUMN, braceOpposite, 0);
+ if (chBrace == ':') {
+ int lineStart = Platform::SendScintilla(win.GetID(), SCI_LINEFROMPOSITION, braceAtCaret);
+ int indentPos = Platform::SendScintilla(win.GetID(), SCI_GETLINEINDENTPOSITION, lineStart, 0);
+ int indentPosNext = Platform::SendScintilla(win.GetID(), SCI_GETLINEINDENTPOSITION, lineStart + 1, 0);
+ columnAtCaret = Platform::SendScintilla(win.GetID(), SCI_GETCOLUMN, indentPos, 0);
+ int columnAtCaretNext = Platform::SendScintilla(win.GetID(), SCI_GETCOLUMN, indentPosNext, 0);
+ int indentationSize = Platform::SendScintilla(win.GetID(), SCI_GETINDENT);
+ if (columnAtCaretNext - indentationSize > 1)
+ columnAtCaret = columnAtCaretNext - indentationSize;
+ //Platform::DebugPrintf(": %d %d %d\n", lineStart, indentPos, columnAtCaret);
+ if (columnOpposite == 0) // If the final line of the structure is empty
+ columnOpposite = columnAtCaret;
+ }
+
+ if (props->GetInt("highlight.indentation.guides"))
+ Platform::SendScintilla(win.GetID(), SCI_SETHIGHLIGHTGUIDE, Platform::Minimum(columnAtCaret, columnOpposite), 0);
+ }
+}
+
+CharacterRange AnEditor::GetSelection() {
+ CharacterRange crange;
+ crange.cpMin = SendEditor(SCI_GETSELECTIONSTART);
+ crange.cpMax = SendEditor(SCI_GETSELECTIONEND);
+ return crange;
+}
+
+void AnEditor::SetSelection(int anchor, int currentPos) {
+ SendEditor(SCI_SETSEL, anchor, currentPos);
+}
+
+bool AnEditor::iswordcharforsel(char ch) {
+ return !strchr("\t\n\r !\"#$%&'()*+,-./:;<=>? [\\]^`{|}~", ch);
+}
+
+void AnEditor::SelectionWord(char *word, int len) {
+ int lengthDoc = LengthDocument();
+ CharacterRange cr = GetSelection();
+ int selStart = cr.cpMin;
+ int selEnd = cr.cpMax;
+ if (selStart == selEnd) {
+ WindowAccessor acc(wEditor.GetID(), *props);
+ // Try and find a word at the caret
+ if (iswordcharforsel(acc[selStart])) {
+ while ((selStart > 0) && (iswordcharforsel(acc[selStart - 1])))
+ selStart--;
+ while ((selEnd < lengthDoc - 1) && (iswordcharforsel(acc[selEnd + 1])))
+ selEnd++;
+ if (selStart < selEnd)
+ selEnd++; // Because normal selections end one past
+ }
+ }
+ word[0] = '\0';
+ if ((selStart < selEnd) && ((selEnd - selStart + 1) < len)) {
+ GetRange(wEditor, selStart, selEnd, word);
+ }
+}
+
+void AnEditor::WordSelect() {
+ int lengthDoc = LengthDocument();
+ int selStart;
+ int selEnd;
+
+ selStart = selEnd = SendEditor(SCI_GETCURRENTPOS);
+ WindowAccessor acc(wEditor.GetID(), *props);
+ if (iswordcharforsel(acc[selStart])) {
+ while ((selStart > 0) && (iswordcharforsel(acc[selStart - 1])))
+ selStart--;
+ while ((selEnd < lengthDoc - 1) && (iswordcharforsel(acc[selEnd + 1])))
+ selEnd++;
+ if (selStart < selEnd)
+ selEnd++; // Because normal selections end one past
+ }
+ SetSelection(selStart, selEnd);
+}
+
+void AnEditor::LineSelect() {
+ int pos = SendEditor(SCI_GETCURRENTPOS);
+ int line = SendEditor(SCI_LINEFROMPOSITION, pos);
+ int lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+ int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+
+ SetSelection(lineStart, lineEnd);
+}
+
+void AnEditor::SelectionIntoProperties() {
+ CharacterRange cr = GetSelection();
+ char currentSelection[1000];
+ if ((cr.cpMin < cr.cpMax) && ((cr.cpMax - cr.cpMin + 1) < static_cast<int>(sizeof(currentSelection)))) {
+ GetRange(wEditor, cr.cpMin, cr.cpMax, currentSelection);
+ int len = strlen(currentSelection);
+ if (len > 2 && iscntrl(currentSelection[len - 1]))
+ currentSelection[len - 1] = '\0';
+ if (len > 2 && iscntrl(currentSelection[len - 2]))
+ currentSelection[len - 2] = '\0';
+ props->Set("CurrentSelection", currentSelection);
+ }
+ char word[200];
+ SelectionWord(word, sizeof(word));
+ props->Set("CurrentWord", word);
+}
+
+long AnEditor::Find (long flags, char* findWhat) {
+ if (!findWhat) return -1;
+ TextToFind ft = {{0, 0}, 0, {0, 0}};
+ CharacterRange crange = GetSelection();
+ if (flags & ANEFIND_REVERSE_FLAG) {
+ ft.chrg.cpMin = crange.cpMin - 1;
+ ft.chrg.cpMax = 1;
+ } else {
+ ft.chrg.cpMin = crange.cpMax;
+ ft.chrg.cpMax = LengthDocument();
+ }
+ ft.lpstrText = findWhat;
+ ft.chrgText.cpMin = 0;
+ ft.chrgText.cpMax = 0;
+ int posFind = SendEditor(SCI_FINDTEXT, flags, reinterpret_cast<long>(&ft));
+ if (posFind >= 0) {
+ EnsureRangeVisible(ft.chrgText.cpMin, ft.chrgText.cpMax);
+ SetSelection(ft.chrgText.cpMin, ft.chrgText.cpMax);
+ }
+ return posFind;
+}
+
+void AnEditor::BookmarkToggle( int lineno ) {
+ if (lineno == -1)
+
+
+
+
+
+ lineno = GetCurrentLineNumber();
+ int state = SendEditor(SCI_MARKERGET, lineno);
+ if ( state & (1 << ANE_MARKER_BOOKMARK))
+ SendEditor(SCI_MARKERDELETE, lineno, ANE_MARKER_BOOKMARK);
+ else {
+ SendEditor(SCI_MARKERADD, lineno, ANE_MARKER_BOOKMARK);
+ }
+}
+
+void AnEditor::BookmarkFirst() {
+ int lineno = GetCurrentLineNumber();
+ int nextLine = SendEditor(SCI_MARKERNEXT, 0, 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine < 0 || nextLine == lineno)
+ gdk_beep(); // how do I beep? -- like this ;-)
+ else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine);
+ SendEditor(SCI_GOTOLINE, nextLine);
+ }
+}
+
+void AnEditor::BookmarkPrev() {
+ int lineno = GetCurrentLineNumber();
+ int nextLine = SendEditor(SCI_MARKERPREVIOUS, lineno - 1, 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine < 0 || nextLine == lineno) {
+ if(props->GetInt("editor.wrapbookmarks")) {
+ int nrOfLines = SendEditor(SCI_GETLINECOUNT, 0, 1 << ANE_MARKER_BOOKMARK);
+ int nextLine1 = SendEditor(SCI_MARKERPREVIOUS, nrOfLines, 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine1 < 0 || nextLine1 == lineno) {
+ gdk_beep(); // how do I beep? -- like this ;-)
+ } else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine1);
+ SendEditor(SCI_GOTOLINE, nextLine1);
+ }
+ }
+ } else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine);
+ SendEditor(SCI_GOTOLINE, nextLine);
+ }
+}
+
+void AnEditor::BookmarkNext() {
+ int lineno = GetCurrentLineNumber();
+ int nextLine = SendEditor(SCI_MARKERNEXT, lineno + 1, 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine < 0 || nextLine == lineno) {
+ if(props->GetInt("editor.wrapbookmarks")) {
+ int nextLine1 = SendEditor(SCI_MARKERNEXT, 0, 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine1 < 0 || nextLine1 == lineno) {
+ gdk_beep(); // how do I beep? -- like this ;-)
+ } else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine1);
+ SendEditor(SCI_GOTOLINE, nextLine1);
+ }
+ }
+ } else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine);
+ SendEditor(SCI_GOTOLINE, nextLine);
+ }
+}
+
+void AnEditor::BookmarkLast() {
+ int lineno = GetCurrentLineNumber();
+ int nextLine = SendEditor(SCI_MARKERPREVIOUS,
+ SendEditor(SCI_GETLINECOUNT), 1 << ANE_MARKER_BOOKMARK);
+ if (nextLine < 0 || nextLine == lineno)
+ gdk_beep(); // how do I beep? -- like this ;-)
+ else {
+ SendEditor(SCI_ENSUREVISIBLE, nextLine);
+ SendEditor(SCI_GOTOLINE, nextLine);
+ }
+}
+
+void AnEditor::BookmarkClear() {
+ SendEditor(SCI_MARKERDELETEALL, ANE_MARKER_BOOKMARK);
+}
+
+bool AnEditor::GetCurrentWord(char* buffer, int length) {
+ SString linebuf;
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+ return FindWordInRegion(buffer, length, linebuf, current);
+}
+
+bool AnEditor::StartBlockComment() {
+ SString fileNameForExtension = ExtensionFileName();
+ SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SString base("comment.block.");
+ SString comment_at_line_start("comment.block.at.line.start.");
+ base += language;
+ comment_at_line_start += language;
+ SString comment = props->Get(base.c_str());
+ if (comment == "") { // user friendly error message box
+ //SString error("Block comment variable \"");
+ //error += base;
+ //error += "\" is not defined in SciTE *.properties!";
+ //WindowMessageBox(wEditor, error, MB_OK | MB_ICONWARNING);
+ return true;
+ }
+ comment += " ";
+ SString long_comment = comment;
+ char linebuf[1000];
+ size_t comment_length = comment.length();
+ size_t selectionStart = SendEditor(SCI_GETSELECTIONSTART);
+ size_t selectionEnd = SendEditor(SCI_GETSELECTIONEND);
+ size_t caretPosition = SendEditor(SCI_GETCURRENTPOS);
+ // checking if caret is located in _beginning_ of selected block
+ bool move_caret = caretPosition < selectionEnd;
+ int selStartLine = SendEditor(SCI_LINEFROMPOSITION, selectionStart);
+ int selEndLine = SendEditor(SCI_LINEFROMPOSITION, selectionEnd);
+ int lines = selEndLine - selStartLine;
+ size_t firstSelLineStart = SendEditor(SCI_POSITIONFROMLINE, selStartLine);
+ // "caret return" is part of the last selected line
+ if ((lines > 0) &&
+ (selectionEnd == static_cast<size_t>(SendEditor(SCI_POSITIONFROMLINE, selEndLine))))
+ selEndLine--;
+ SendEditor(SCI_BEGINUNDOACTION);
+ for (int i = selStartLine; i <= selEndLine; i++) {
+ int lineStart = SendEditor(SCI_POSITIONFROMLINE, i);
+ int lineIndent = lineStart;
+ int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, i);
+ if (props->GetInt(comment_at_line_start.c_str())) {
+ GetRange(wEditor, lineIndent, lineEnd, linebuf);
+ } else {
+ lineIndent = GetLineIndentPosition(i);
+ GetRange(wEditor, lineIndent, lineEnd, linebuf);
+ }
+ // empty lines are not commented
+ if (strlen(linebuf) < 1)
+ continue;
+ if (memcmp(linebuf, comment.c_str(), comment_length - 1) == 0) {
+ if (memcmp(linebuf, long_comment.c_str(), comment_length) == 0) {
+ // removing comment with space after it
+ SendEditor(SCI_SETSEL, lineIndent, lineIndent + comment_length);
+ SendEditorString(SCI_REPLACESEL, 0, "");
+ if (i == selStartLine) // is this the first selected line?
+ selectionStart -= comment_length;
+ selectionEnd -= comment_length; // every iteration
+ continue;
+ } else {
+ // removing comment _without_ space
+ SendEditor(SCI_SETSEL, lineIndent, lineIndent + comment_length - 1);
+ SendEditorString(SCI_REPLACESEL, 0, "");
+ if (i == selStartLine) // is this the first selected line?
+ selectionStart -= (comment_length - 1);
+ selectionEnd -= (comment_length - 1); // every iteration
+ continue;
+ }
+ }
+ if (i == selStartLine) // is this the first selected line?
+ selectionStart += comment_length;
+ selectionEnd += comment_length; // every iteration
+ SendEditorString(SCI_INSERTTEXT, lineIndent, long_comment.c_str());
+ }
+ // after uncommenting selection may promote itself to the lines
+ // before the first initially selected line;
+ // another problem - if only comment symbol was selected;
+ if (selectionStart < firstSelLineStart) {
+ if (selectionStart >= selectionEnd - (comment_length - 1))
+ selectionEnd = firstSelLineStart;
+ selectionStart = firstSelLineStart;
+ }
+ if (move_caret) {
+ // moving caret to the beginning of selected block
+ SendEditor(SCI_GOTOPOS, selectionEnd);
+ SendEditor(SCI_SETCURRENTPOS, selectionStart);
+ } else {
+ SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
+ }
+ SendEditor(SCI_ENDUNDOACTION);
+ return true;
+}
+
+// Return true if the selected zone can be commented
+// Return false if it cannot be commented or has been uncommented
+// BOX_COMMENT : box_stream = true STREAM_COMMENT : box_stream = false
+// Uncomment if the selected zone or the cursor is inside the comment
+//
+bool AnEditor::CanBeCommented(bool box_stream) {
+ SString fileNameForExtension = ExtensionFileName();
+ SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SString start_base("comment.box.start.");
+ SString middle_base("comment.box.middle.");
+ SString end_base("comment.box.end.");
+ SString white_space(" ");
+ start_base += language;
+ middle_base += language;
+ end_base += language;
+ SString start_comment = props->Get(start_base.c_str());
+ SString middle_cmt = props->Get(middle_base.c_str());
+ SString end_comment = props->Get(end_base.c_str());
+ start_comment += white_space;
+ middle_cmt += white_space;
+ white_space += end_comment;
+ end_comment = white_space;
+ size_t start_comment_length = start_comment.length();
+ size_t end_comment_length = end_comment.length();
+ size_t middle_cmt_length = middle_cmt.length();
+ SString start_base_stream ("comment.stream.start.");
+ start_base_stream += language;
+ SString end_base_stream ("comment.stream.end.");
+ end_base_stream += language;
+ SString end_comment_stream = props->Get(end_base_stream.c_str());
+ SString white_space_stream(" ");
+ //SString end_white_space_stream(" ");
+ SString start_comment_stream = props->Get(start_base_stream.c_str());
+ start_comment_stream += white_space_stream;
+ size_t start_comment_stream_length = start_comment_stream.length();
+ white_space_stream +=end_comment_stream;
+ end_comment_stream = white_space_stream ;
+ size_t end_comment_stream_length = end_comment_stream.length();
+
+ char linebuf[1000];
+ size_t selectionStart = SendEditor(SCI_GETSELECTIONSTART);
+ size_t selectionEnd = SendEditor(SCI_GETSELECTIONEND);
+ if (selectionStart == selectionEnd)
+ return FALSE;
+ int line = SendEditor(SCI_LINEFROMPOSITION, selectionStart);
+ if (line < 0)
+ return FALSE;
+ bool start1 = false, start2 = false;
+ bool end1 = false, end2 = false;
+ int lineEnd1;
+ if (box_stream)
+ lineEnd1 = selectionStart + start_comment_length;
+ else
+ lineEnd1 = selectionStart + start_comment_stream_length +1;
+ if (lineEnd1 > LengthDocument())
+ lineEnd1 = LengthDocument();
+
+ int lineStart1 = 0;
+ size_t start_cmt = 0, end_cmt = 0;
+ int index = 0;
+ // Find Backward StartComment
+ while (line >= 0 && start1 == false && end1 == false)
+ {
+ lineStart1 = SendEditor(SCI_POSITIONFROMLINE, line);
+ GetRange(wEditor, lineStart1, lineEnd1, linebuf);
+
+ for (index = lineEnd1-lineStart1; index >= 0; index--)
+ {
+ if (end1= ((end_comment_length > 1 && !memcmp(linebuf+index,
+ end_comment.c_str(), end_comment_length ))
+ || (end_comment_stream_length > 0 && !memcmp(linebuf+index,
+ end_comment_stream.c_str(), end_comment_stream_length))))
+ break;
+ if (start1=((start_comment_length > 1 && !memcmp(linebuf+index,
+ start_comment.c_str(), start_comment_length))
+ || (start_comment_stream_length > 0 && !memcmp(linebuf+index,
+ start_comment_stream.c_str(), start_comment_stream_length))))
+ break;
+ }
+ line --;
+ lineEnd1= SendEditor(SCI_GETLINEENDPOSITION, line);
+ }
+ start_cmt = index + lineStart1;
+ line = SendEditor(SCI_LINEFROMPOSITION, selectionEnd);
+ if (box_stream)
+ lineStart1 = selectionEnd - start_comment_length;
+ else
+ lineStart1 = selectionEnd - start_comment_stream_length;
+ int last_line = SendEditor(SCI_GETLINECOUNT);
+ // Find Forward EndComment
+ while (line <= last_line && start2 == false && end2 == false)
+ {
+ lineEnd1= SendEditor(SCI_GETLINEENDPOSITION, line);
+ GetRange(wEditor, lineStart1, lineEnd1, linebuf);
+ for (index = 0; index <= (lineEnd1-lineStart1); index++)
+ {
+ if (start2= ((start_comment_length > 1 && !memcmp(linebuf+index,
+ start_comment.c_str(), start_comment_length))
+ || (start_comment_stream_length > 0 && !memcmp(linebuf+index,
+ start_comment_stream.c_str(), start_comment_stream_length))))
+ break;
+ if (end2= ((end_comment_length > 1 && !memcmp(linebuf+index,
+ end_comment.c_str(), end_comment_length ))
+ || (end_comment_stream_length > 0 && !memcmp(linebuf+index,
+ end_comment_stream.c_str(), end_comment_stream_length))))
+ break;
+ }
+ line ++;
+ end_cmt = lineStart1 + index;
+ lineStart1 = SendEditor(SCI_POSITIONFROMLINE, line);
+ }
+ // Uncomment
+ if(start1 || end2)
+ {
+ if (start1 && end2)
+ {
+ SendEditor(SCI_BEGINUNDOACTION);
+ if (box_stream) // Box
+ {
+ SendEditor(SCI_SETSEL, start_cmt, start_cmt +
+ start_comment_length);
+ end_cmt -= start_comment_length;
+ }
+ else // Stream
+ {
+ SendEditor(SCI_SETSEL, start_cmt, start_cmt +
+ start_comment_stream_length);
+ end_cmt -= start_comment_stream_length;
+ }
+ SendEditorString(SCI_REPLACESEL, 0, "");
+ line = SendEditor(SCI_LINEFROMPOSITION, start_cmt) + 1;
+ last_line = SendEditor(SCI_LINEFROMPOSITION, end_cmt) ;
+ for (int i = line; i < last_line; i++)
+ {
+ int s = SendEditor(SCI_POSITIONFROMLINE, i);
+ int e = SendEditor(SCI_GETLINEENDPOSITION, i);
+ GetRange(wEditor, s, e, linebuf);
+ if (!memcmp(linebuf, middle_cmt.c_str(), middle_cmt_length))
+ {
+ SendEditor(SCI_SETSEL, s, s + middle_cmt_length);
+ SendEditorString(SCI_REPLACESEL, 0, "");
+ end_cmt -= middle_cmt_length;
+ }
+ }
+ if (box_stream) // Box
+ SendEditor(SCI_SETSEL, end_cmt, end_cmt + end_comment_length);
+ else // Stream
+ SendEditor(SCI_SETSEL, end_cmt, end_cmt + end_comment_stream_length);
+ SendEditorString(SCI_REPLACESEL, 0, "");
+ SendEditor(SCI_ENDUNDOACTION);
+ }
+ return false;
+ }
+ return true;
+}
+
+
+bool AnEditor::StartBoxComment() {
+ SString fileNameForExtension = ExtensionFileName();
+ SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SString start_base("comment.box.start.");
+ SString middle_base("comment.box.middle.");
+ SString end_base("comment.box.end.");
+ SString white_space(" ");
+ start_base += language;
+ middle_base += language;
+ end_base += language;
+ SString start_comment = props->Get(start_base.c_str());
+ SString middle_comment = props->Get(middle_base.c_str());
+ SString end_comment = props->Get(end_base.c_str());
+ if (start_comment == "" || middle_comment == "" || end_comment == "") {
+ //SString error("Box comment variables \"");
+ //error += start_base;
+ //error += "\", \"";
+ //error += middle_base;
+ //error += "\"\nand \"";
+ //error += end_base;
+ //error += "\" are not ";
+ //error += "defined in SciTE *.properties!";
+ //WindowMessageBox(wSciTE, error, MB_OK | MB_ICONWARNING);
+ return true;
+ }
+ start_comment += white_space;
+ middle_comment += white_space;
+ white_space += end_comment;
+ end_comment = white_space;
+ size_t start_comment_length = start_comment.length();
+ size_t middle_comment_length = middle_comment.length();
+ size_t selectionStart = SendEditor(SCI_GETSELECTIONSTART);
+ size_t selectionEnd = SendEditor(SCI_GETSELECTIONEND);
+ size_t caretPosition = SendEditor(SCI_GETCURRENTPOS);
+ // checking if caret is located in _beginning_ of selected block
+ bool move_caret = caretPosition < selectionEnd;
+ size_t selStartLine = SendEditor(SCI_LINEFROMPOSITION, selectionStart);
+ size_t selEndLine = SendEditor(SCI_LINEFROMPOSITION, selectionEnd);
+ size_t lines = selEndLine - selStartLine;
+ // "caret return" is part of the last selected line
+ if ((lines > 0) && (
+ selectionEnd == static_cast<size_t>(SendEditor(SCI_POSITIONFROMLINE, selEndLine)))) {
+ selEndLine--;
+ lines--;
+ // get rid of CRLF problems
+ selectionEnd = SendEditor(SCI_GETLINEENDPOSITION, selEndLine);
+ }
+ // Comment , Uncomment or Do Nothing
+ if (CanBeCommented(true))
+ {
+ SendEditor(SCI_BEGINUNDOACTION);
+ // first commented line (start_comment)
+ int lineStart = SendEditor(SCI_POSITIONFROMLINE, selStartLine);
+ SendEditorString(SCI_INSERTTEXT, lineStart, start_comment.c_str());
+ selectionStart += start_comment_length;
+ // lines between first and last commented lines (middle_comment)
+ for (size_t i = selStartLine + 1; i <= selEndLine; i++) {
+ lineStart = SendEditor(SCI_POSITIONFROMLINE, i);
+ SendEditorString(SCI_INSERTTEXT, lineStart, middle_comment.c_str());
+ selectionEnd += middle_comment_length;
+ }
+ // last commented line (end_comment)
+ int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, selEndLine);
+ if (lines > 0) {
+ SendEditorString(SCI_INSERTTEXT, lineEnd, "\n");
+ SendEditorString(SCI_INSERTTEXT, lineEnd + 1, (end_comment.c_str() + 1));
+ } else {
+ SendEditorString(SCI_INSERTTEXT, lineEnd, end_comment.c_str());
+ }
+ selectionEnd += (start_comment_length);
+ if (move_caret) {
+ // moving caret to the beginning of selected block
+ SendEditor(SCI_GOTOPOS, selectionEnd);
+ SendEditor(SCI_SETCURRENTPOS, selectionStart);
+ } else {
+ SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
+ }
+ SendEditor(SCI_ENDUNDOACTION);
+ }
+ return true;
+}
+
+bool AnEditor::StartStreamComment() {
+ SString fileNameForExtension = ExtensionFileName();
+ SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SString start_base("comment.stream.start.");
+ SString end_base("comment.stream.end.");
+ SString white_space(" ");
+ //SString end_white_space(" ");
+ start_base += language;
+ end_base += language;
+ SString start_comment = props->Get(start_base.c_str());
+ SString end_comment = props->Get(end_base.c_str());
+ if (start_comment == "" || end_comment == "") {
+ //SString error("Stream comment variables \"");
+ //error += start_base;
+ //error += "\" and \n\"";
+ //error += end_base;
+ //error += "\" are not ";
+ //error += "defined in SciTE *.properties!";
+ //WindowMessageBox(wSciTE, error, MB_OK | MB_ICONWARNING);
+ return true;
+ }
+ start_comment += white_space;
+ white_space += end_comment;
+ end_comment = white_space;
+ size_t start_comment_length = start_comment.length();
+ size_t selectionStart = SendEditor(SCI_GETSELECTIONSTART);
+ size_t selectionEnd = SendEditor(SCI_GETSELECTIONEND);
+ size_t caretPosition = SendEditor(SCI_GETCURRENTPOS);
+ // checking if caret is located in _beginning_ of selected block
+ bool move_caret = caretPosition < selectionEnd;
+ // if there is no selection?
+ if (selectionEnd - selectionStart <= 0) {
+ int selLine = SendEditor(SCI_LINEFROMPOSITION, selectionStart);
+ int lineIndent = GetLineIndentPosition(selLine);
+ int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, selLine);
+ if (RangeIsAllWhitespace(lineIndent, lineEnd))
+ return true; // we are not dealing with empty lines
+ SString linebuf;
+ GetLine(linebuf);
+ int current = GetCaretInLine();
+ // checking if we are not inside a word
+ if (!wordCharacters.contains(linebuf[current]))
+ return true; // caret is located _between_ words
+ int startword = current;
+ int endword = current;
+ int start_counter = 0;
+ int end_counter = 0;
+ while (startword > 0 && wordCharacters.contains(linebuf[startword - 1])) {
+ start_counter++;
+ startword--;
+ }
+ // checking _beginning_ of the word
+ if (startword == current)
+ return true; // caret is located _before_ a word
+ while (linebuf[endword + 1] != '\0' && wordCharacters.contains(linebuf[endword + 1])) {
+ end_counter++;
+ endword++;
+ }
+ selectionStart -= start_counter;
+ selectionEnd += (end_counter + 1);
+ }
+ // Comment , Uncomment or Do Nothing
+ if (CanBeCommented(false))
+ {
+ SendEditor(SCI_BEGINUNDOACTION);
+ SendEditorString(SCI_INSERTTEXT, selectionStart, start_comment.c_str());
+ selectionEnd += start_comment_length;
+ selectionStart += start_comment_length;
+ SendEditorString(SCI_INSERTTEXT, selectionEnd, end_comment.c_str());
+ if (move_caret) {
+ // moving caret to the beginning of selected block
+ SendEditor(SCI_GOTOPOS, selectionEnd);
+ SendEditor(SCI_SETCURRENTPOS, selectionStart);
+ } else {
+ SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
+ }
+ SendEditor(SCI_ENDUNDOACTION);
+ }
+ return true;
+}
+
+#if 0
+SString AnEditor::GetMode(SString language) {
+ SString mode;
+ if (strcmp(language.c_str(), "cpp") == 0)
+ {
+ mode += " Mode: C;";
+ if (props->GetInt("use.tabs"))
+ mode += " indent-tabs-mode: t;";
+ mode += " c-basic-offset: ";
+ mode += g_strdup_printf("%d", props->GetInt("indent.size"));
+ mode += "; tab-width: ";
+ mode += g_strdup_printf("%d ", props->GetInt("tabsize"));
+ }
+//~ Other languages
+//~ .....
+ return mode;
+}
+
+/* Insert or Modify a Comment line
+ giving File indent */
+bool AnEditor::InsertCustomIndent() {
+ #define MAXBUF 1000
+
+ SString fileNameForExtension = ExtensionFileName();
+ SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SString start_box_base("comment.box.start.");
+ start_box_base += language;
+ SString start_stream_base("comment.stream.start.");
+ start_stream_base += language;
+ SString end_box_base("comment.box.end.");
+ end_box_base += language;
+ SString end_stream_base("comment.stream.end.");
+ end_stream_base += language;
+ SString start_box = props->Get(start_box_base.c_str());
+ SString start_stream = props->Get(start_stream_base.c_str());
+ SString end_box = props->Get(end_box_base.c_str());
+ SString end_stream = props->Get(end_stream_base.c_str());
+ SString mark("-*-");
+ int text_length = SendEditor(SCI_GETTEXTLENGTH);
+ char buf[MAXBUF];
+ int bufmax = text_length < MAXBUF ? text_length : MAXBUF;
+
+ GetRange(wEditor, 0, bufmax - 1, buf);
+
+ bool start_comment = false;
+ bool indent_comment = false;
+ int end_indent_comment = 0;
+
+ for (int index = 0; index < bufmax; index++)
+ {
+ if (!start_comment)
+ {
+ if (memcmp(buf+index, start_box.c_str(), start_box.length()) == 0)
+ {
+ index += (start_box.length() - 1);
+ start_comment = true;
+ continue;
+ }
+ if (memcmp(buf+index, start_stream.c_str(), start_stream.length()) == 0)
+ {
+ index += (start_stream.length() - 1);
+ start_comment = true;
+ continue;
+ }
+ if (buf[index] != ' ' && buf[index] != '\t' && buf[index] != '\n')
+ break;
+ }
+ else
+ {
+ if (!indent_comment)
+ {
+ if (buf[index] == ' ' || buf[index] == '\t' || buf[index] == '\n')
+ continue;
+ if (memcmp(buf+index, mark.c_str(), 3) == 0)
+ {
+ index += 3;
+ indent_comment = true;
+ }
+ else
+ break;
+ }
+ else
+ {
+ if (memcmp(buf+index, end_box.c_str(), end_box.length()) == 0)
+ {
+ end_indent_comment = index + end_box.length() - 1;
+ break;
+ }
+ if (memcmp(buf+index, end_stream.c_str(), end_stream.length()) == 0)
+ {
+ end_indent_comment = index + end_stream.length() - 1;
+ break;
+ }
+ }
+ }
+ }
+ SString mode = GetMode(language);
+ if (mode.c_str() != "")
+ {
+ SString comment ;
+ comment += start_stream.c_str() ;
+ comment += " ";
+ comment += mark.c_str();
+ comment += mode.c_str();
+ comment += mark.c_str();
+ comment += " ";
+ comment += end_stream.c_str() ;
+
+ if (indent_comment)
+ {
+ SendEditor(SCI_SETSEL, 0, end_indent_comment + 1);
+ SendEditorString(SCI_REPLACESEL, 0, comment.c_str());
+ }
+ else
+ {
+ comment += "\n\n";
+ SendEditorString(SCI_INSERTTEXT, 0, comment.c_str());
+ }
+ }
+ return TRUE;
+}
+
+#endif
+
+/**
+ * Return the length of the given line, not counting the EOL.
+ */
+int AnEditor::GetLineLength(int line) {
+ return SendEditor(SCI_GETLINEENDPOSITION, line) - SendEditor(SCI_POSITIONFROMLINE, line);
+}
+
+int AnEditor::GetCurrentLineNumber() {
+ CharacterRange crange = GetSelection();
+ int selStart = crange.cpMin;
+ return SendEditor(SCI_LINEFROMPOSITION, selStart);
+}
+
+int AnEditor::GetCurrentScrollPosition() {
+ int lineDisplayTop = SendEditor(SCI_GETFIRSTVISIBLELINE);
+ return SendEditor(SCI_DOCLINEFROMVISIBLE, lineDisplayTop);
+}
+
+// Upon a character being added, AnEditor may decide to perform some action
+// such as displaying a completion list.
+void AnEditor::CharAdded(char ch) {
+ CharacterRange crange = GetSelection();
+ int selStart = crange.cpMin;
+ int selEnd = crange.cpMax;
+ if ((selEnd == selStart) && (selStart > 0)) {
+ int style = SendEditor(SCI_GETSTYLEAT, selStart - 1, 0);
+ if (style != 1) {
+ if (SendEditor(SCI_CALLTIPACTIVE)) { // calltip is active
+ } else if (SendEditor(SCI_AUTOCACTIVE)) { // word autocompletion
+ } else if (HandleXml(ch)) {
+ // Handled in the routine
+ } else { // we don't have autocompetion nor calltip active
+ if (indentMaintain)
+ MaintainIndentation(ch);
+ }
+ }
+ }
+}
+
+/**
+ * This routine will auto complete XML or HTML tags that are still open by closing them
+ * @parm ch The characer we are dealing with, currently only works with the '/' character
+ * @return True if handled, false otherwise
+ */
+bool AnEditor::HandleXml(char ch) {
+ // We're looking for this char
+ // Quit quickly if not found
+ if (ch != '>') {
+ return false;
+ }
+
+ // This may make sense only in certain languages
+ if (lexLanguage != SCLEX_HTML && lexLanguage != SCLEX_XML &&
+ lexLanguage != SCLEX_ASP && lexLanguage != SCLEX_PHP) {
+ return false;
+ }
+
+ // If the user has turned us off, quit now.
+ // Default is off
+ SString value = props->GetExpanded("xml.auto.close.tags");
+ if ((value.length() == 0) || (value == "0")) {
+ return false;
+ }
+
+ // Grab the last 512 characters or so
+ int nCaret = SendEditor(SCI_GETCURRENTPOS);
+ char sel[512];
+ int nMin = nCaret - (sizeof(sel) - 1);
+ if (nMin < 0) {
+ nMin = 0;
+ }
+
+ if (nCaret - nMin < 3) {
+ return false; // Smallest tag is 3 characters ex. <p>
+ }
+ GetRange(wEditor, nMin, nCaret, sel);
+ sel[sizeof(sel) - 1] = '\0';
+
+ if (sel[nCaret - nMin - 2] == '/') {
+ // User typed something like "<br/>"
+ return false;
+ }
+
+ SString strFound = FindOpenXmlTag(sel, nCaret - nMin);
+
+ if (strFound.length() > 0) {
+ SendEditor(SCI_BEGINUNDOACTION);
+ SString toInsert = "</";
+ toInsert += strFound;
+ toInsert += ">";
+ SendEditorString(SCI_REPLACESEL, 0, toInsert.c_str());
+ SetSelection(nCaret, nCaret);
+ SendEditor(SCI_ENDUNDOACTION);
+ return true;
+ }
+
+ return false;
+}
+
+/** Search backward through nSize bytes looking for a '<', then return the tag if any
+ * @return The tag name
+ */
+SString AnEditor::FindOpenXmlTag(const char sel[], int nSize) {
+ SString strRet = "";
+
+ if (nSize < 3) {
+ // Smallest tag is "<p>" which is 3 characters
+ return strRet;
+ }
+ const char* pBegin = &sel[0];
+ const char* pCur = &sel[nSize - 1];
+
+ pCur--; // Skip past the >
+ while (pCur > pBegin) {
+ if (*pCur == '<') {
+ break;
+ } else if (*pCur == '>') {
+ break;
+ }
+ --pCur;
+ }
+
+ if (*pCur == '<') {
+ pCur++;
+ while (strchr(":_-.", *pCur) || isalnum(*pCur)) {
+ strRet += *pCur;
+ pCur++;
+ }
+ }
+
+ // Return the tag name or ""
+ return strRet;
+}
+
+void AnEditor::GoMatchingBrace(bool select) {
+ int braceAtCaret = -1;
+ int braceOpposite = -1;
+ bool isInside = FindMatchingBracePosition(true, braceAtCaret, braceOpposite, true);
+ // Convert the character positions into caret positions based on whether
+ // the caret position was inside or outside the braces.
+ if (isInside) {
+ if (braceOpposite > braceAtCaret) {
+ braceAtCaret++;
+ } else {
+ braceOpposite++;
+ }
+ } else { // Outside
+ if (braceOpposite > braceAtCaret) {
+ braceOpposite++;
+ } else {
+ braceAtCaret++;
+ }
+ }
+ if (braceOpposite >= 0) {
+ EnsureRangeVisible(braceOpposite, braceOpposite);
+ if (select) {
+ SetSelection(braceAtCaret, braceOpposite);
+ } else {
+ SetSelection(braceOpposite, braceOpposite);
+ }
+ }
+}
+
+int ControlIDOfCommand(unsigned long wParam) {
+ return wParam & 0xffff;
+}
+
+long AnEditor::Command(int cmdID, long wParam, long lParam) {
+ switch (cmdID) {
+
+ case ANE_INSERTTEXT:
+ SendEditor(SCI_INSERTTEXT,wParam,lParam);
+ break;
+
+ case ANE_GETBOOKMARK_POS:
+ return GetBookmarkLine( wParam );
+ break; /* pleonastico */
+
+ case ANE_BOOKMARK_TOGGLE_LINE:
+ BookmarkToggle( wParam );
+ break;
+
+ case ANE_UNDO:
+ SendEditor(SCI_UNDO);
+ break;
+
+ case ANE_REDO:
+ SendEditor(SCI_REDO);
+ break;
+
+ case ANE_CUT:
+ SendEditor(SCI_CUT);
+ break;
+
+ case ANE_COPY:
+ SendEditor(SCI_COPY);
+ break;
+
+ case ANE_PASTE:
+ SendEditor(SCI_PASTE);
+ break;
+
+ case ANE_CLEAR:
+ SendEditor(SCI_CLEAR);
+ break;
+
+ case ANE_SELECTALL:
+ SendEditor(SCI_SELECTALL);
+ break;
+
+ case ANE_FIND:
+ return Find (wParam, (char*) lParam);
+
+ case ANE_GOTOLINE:
+ SendEditor(SCI_GOTOLINE, wParam);
+ break;
+
+ case ANE_SETZOOM:
+ SendEditor(SCI_SETZOOM, wParam);
+ break;
+
+ case ANE_MATCHBRACE:
+ GoMatchingBrace(false);
+ break;
+
+ case ANE_SELECTBLOCK:
+ SelectBlock();
+ break;
+
+ case ANE_SELECTTOBRACE:
+ GoMatchingBrace(true);
+ break;
+
+ case ANE_GETBLOCKSTARTLINE:
+ return GetBlockStartLine();
+
+ case ANE_GETBLOCKENDLINE:
+ return GetBlockEndLine();
+
+ case ANE_GETCURRENTWORD:
+ return GetCurrentWord((char*)wParam, (int)lParam);
+
+ case ANE_GETWORDBEFORECARAT:
+ return GetWordBeforeCarat((char*)wParam, (int)lParam);
+
+ case ANE_SHOWCALLTIP:
+ StartCallTip_new();
+ break;
+
+ case ANE_COMPLETECALLTIP:
+ CompleteCallTip();
+ break;
+ /*
+ case ANE_COMPLETE:
+ StartAutoComplete();
+ break;
+
+ case ANE_COMPLETEWORD:
+ StartAutoCompleteWord(false);
+ break;
+ */
+ case ANE_TOGGLE_FOLD:
+ FoldToggle();
+ break;
+
+ case ANE_OPEN_FOLDALL:
+ FoldOpenAll();
+ break;
+
+ case ANE_CLOSE_FOLDALL:
+ FoldCloseAll();
+ break;
+
+ case ANE_UPRCASE:
+ SendEditor(SCI_UPPERCASE);
+ break;
+
+ case ANE_LWRCASE:
+ SendEditor(SCI_LOWERCASE);
+ break;
+
+ case ANE_EXPAND:
+ SendEditor(SCI_TOGGLEFOLD, GetCurrentLineNumber());
+ break;
+
+ case ANE_LINENUMBERMARGIN:
+ lineNumbers = wParam;
+ SendEditor(SCI_SETMARGINWIDTHN, 0, lineNumbers ? lineNumbersWidth : 0);
+ break;
+
+ case ANE_SELMARGIN:
+ margin = wParam;
+ SendEditor(SCI_SETMARGINWIDTHN, 1, margin ? marginWidth : 0);
+ break;
+
+ case ANE_FOLDMARGIN:
+ foldMargin = wParam;
+ SendEditor(SCI_SETMARGINWIDTHN, 2, foldMargin ? foldMarginWidth : 0);
+ break;
+
+ case ANE_VIEWEOL:
+ SendEditor(SCI_SETVIEWEOL, wParam);
+ break;
+
+ case ANE_EOL_CRLF:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_CRLF);
+ break;
+
+ case ANE_EOL_CR:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_CR);
+ break;
+
+ case ANE_EOL_LF:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_LF);
+ break;
+
+ case ANE_EOL_CONVERT:
+ switch (wParam) {
+ case ANE_EOL_CRLF:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_CRLF);
+ SendEditor(SCI_CONVERTEOLS, SC_EOL_CRLF);
+ break;
+ case ANE_EOL_LF:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_LF);
+ SendEditor(SCI_CONVERTEOLS, SC_EOL_LF);
+ break;
+ case ANE_EOL_CR:
+ SendEditor(SCI_SETEOLMODE, SC_EOL_CR);
+ SendEditor(SCI_CONVERTEOLS, SC_EOL_CR);
+ break;
+ default:
+ SendEditor(SCI_CONVERTEOLS, SendEditor(SCI_GETEOLMODE));
+ break;
+ }
+ break;
+
+ case ANE_WORDPARTLEFT:
+ SendEditor(SCI_WORDPARTLEFT);
+ break;
+
+ case ANE_WORDPARTLEFTEXTEND:
+ SendEditor(SCI_WORDPARTLEFTEXTEND);
+ break;
+
+ case ANE_WORDPARTRIGHT:
+ SendEditor(SCI_WORDPARTRIGHT);
+ break;
+
+ case ANE_WORDPARTRIGHTEXTEND:
+ SendEditor(SCI_WORDPARTRIGHTEXTEND);
+ break;
+
+ case ANE_VIEWSPACE:
+ ViewWhitespace(wParam);
+ break;
+
+ case ANE_VIEWGUIDES:
+ SendEditor(SCI_SETINDENTATIONGUIDES, wParam);
+ break;
+
+ case ANE_BOOKMARK_TOGGLE:
+ BookmarkToggle();
+ break;
+ case ANE_BOOKMARK_FIRST:
+ BookmarkFirst();
+ break;
+ case ANE_BOOKMARK_PREV:
+ BookmarkPrev();
+ break;
+ case ANE_BOOKMARK_NEXT:
+ BookmarkNext();
+ break;
+ case ANE_BOOKMARK_LAST:
+ BookmarkLast();
+ break;
+ case ANE_BOOKMARK_CLEAR:
+ BookmarkClear();
+ break;
+
+ case ANE_SETTABSIZE:
+ SendEditor(SCI_SETTABWIDTH, wParam);
+ break;
+
+ case ANE_SETLANGUAGE:
+ SetOverrideLanguage(wParam);
+ break;
+
+ case ANE_SETHILITE:
+ ReadProperties((char*)wParam);
+ SendEditor(SCI_COLOURISE, 0, -1);
+ break;
+
+ case ANE_SETACCELGROUP:
+ SetAccelGroup((GtkAccelGroup*)wParam);
+ break;
+
+ case ANE_GETTEXTRANGE: {
+ guint start, end;
+ if(wParam == lParam) return 0;
+ start = (guint) MINIMUM(wParam, lParam);
+ end = (guint) MAXIMUM(wParam, lParam);
+ gchar *buff = (gchar*) g_malloc(end-start+10);
+ if(!buff) return 0;
+ GetRange(start, end, buff, false);
+ return (long) buff;
+ }
+ break;
+
+ case ANE_INDENT_INCREASE:
+ IndentationIncrease();
+ break;
+
+ case ANE_INDENT_DECREASE:
+ IndentationDecrease();
+ break;
+
+ case ANE_GETLENGTH:
+ return SendEditor(SCI_GETLENGTH);
+
+ case ANE_GET_LINENO:
+ return GetCurrentLineNumber();
+
+ case ANE_LINEWRAP:
+ SetLineWrap((bool)wParam);
+ break;
+
+ case ANE_READONLY:
+ SetReadOnly((bool)wParam);
+ break;
+
+ case ANE_GETSTYLEDTEXT: {
+ guint start, end;
+ if(wParam == lParam) return 0;
+ start = (guint) MINIMUM(wParam, lParam);
+ end = (guint) MAXIMUM(wParam, lParam);
+ /* Allocate a bit more space to allow reading multi
+ * byte characters more easily */
+ gchar *buff = (gchar*) g_malloc((end-start+10)*2);
+ if(!buff) return 0;
+ GetRange(start, end, buff, true);
+ memset (buff + (end-start) * 2, 0, 20);
+ return (long) buff;
+ }
+ break;
+ case ANE_TEXTWIDTH:
+ return SendEditor(SCI_TEXTWIDTH, wParam, lParam);
+ case ANE_GETLANGUAGE:
+ return (long) language.c_str();
+
+ case ANE_BLOCKCOMMENT:
+ return StartBlockComment();
+
+ case ANE_BOXCOMMENT:
+ return StartBoxComment();
+
+ case ANE_STREAMCOMMENT:
+ return StartStreamComment();
+ /*
+ case ANE_CUSTOMINDENT:
+ return InsertCustomIndent();
+ */
+ case ANE_WORDSELECT:
+ WordSelect();
+ break;
+
+ case ANE_LINESELECT:
+ LineSelect();
+ break;
+
+ case ANE_GETCURRENTPOS:
+ return SendEditor(SCI_GETCURRENTPOS);
+
+ case ANE_GOTOPOS:
+ return SendEditor(SCI_GOTOPOS, wParam);
+
+ case ANE_SETWRAPBOOKMARKS:
+ // Nothing to do.
+ break;
+ /*
+ case ANE_SETAUTOINDENTATION:
+ // Nothing to do.
+ break;
+ */
+ case ANE_SETUSETABFORINDENT:
+ SendEditor(SCI_SETUSETABS, wParam);
+ break;
+
+ case ANE_SETINDENTSIZE:
+ indentSize = wParam;
+ SendEditor(SCI_SETINDENT, wParam);
+ break;
+
+ case ANE_SETINDENTBRACESCHECK:
+ bracesCheck = wParam;
+ break;
+ /*
+ case ANE_SETINDENTOPENING:
+ indentOpening = wParam;
+ break;
+
+ case ANE_SETINDENTCLOSING:
+ indentClosing = wParam;
+ break;
+ */
+ case ANE_SETINDENTMAINTAIN:
+ if (wParam)
+ props->Set ("indent.maintain.*", "1");
+ else
+ props->Set ("indent.opening.*", "0");
+ indentMaintain = wParam;
+ break;
+
+ case ANE_SETTABINDENTS:
+ SendEditor(SCI_SETTABINDENTS, wParam);
+ break;
+
+ case ANE_SETBACKSPACEUNINDENTS:
+ SendEditor(SCI_SETBACKSPACEUNINDENTS, wParam);
+ break;
+
+ case ANE_SETFOLDSYMBOLS:
+ SetFoldSymbols(reinterpret_cast<char *> (wParam));
+ break;
+
+ case ANE_SETFOLDUNDERLINE:
+ if (wParam)
+ SendEditor(SCI_SETFOLDFLAGS, props->GetInt("fold.flags"));
+ else
+ SendEditor(SCI_SETFOLDFLAGS, 0);
+ break;
+ case ANE_SETLINENUMWIDTH:
+ lineNumbersWidth = wParam;
+ SendEditor(SCI_SETMARGINWIDTHN, 0, lineNumbers ? lineNumbersWidth : 0);
+ break;
+ case ANE_SETEDGECOLUMN:
+ SendEditor(SCI_SETEDGECOLUMN, wParam);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+void AnEditor::FoldChanged(int line, int levelNow, int levelPrev) {
+ if (levelNow & SC_FOLDLEVELHEADERFLAG) {
+ SendEditor(SCI_SETFOLDEXPANDED, line, 1);
+ } else if (levelPrev & SC_FOLDLEVELHEADERFLAG) {
+ if (!SendEditor(SCI_GETFOLDEXPANDED, line)) {
+ // Removing the fold from one that has been contracted so should expand
+ // otherwise lines are left invisible with no way to make them visible
+ Expand(line, true, false, 0, levelPrev);
+ }
+ }
+}
+
+void AnEditor::Expand(int &line, bool doExpand, bool force, int visLevels, int level) {
+ int lineMaxSubord = SendEditor(SCI_GETLASTCHILD, line, level);
+ line++;
+ while (line <= lineMaxSubord) {
+ if (force) {
+ if (visLevels > 0)
+ SendEditor(SCI_SHOWLINES, line, line);
+ else
+ SendEditor(SCI_HIDELINES, line, line);
+ } else {
+ if (doExpand)
+ SendEditor(SCI_SHOWLINES, line, line);
+ }
+ int levelLine = level;
+ if (levelLine ==-1)
+ levelLine = SendEditor(SCI_GETFOLDLEVEL, line);
+ if (levelLine & SC_FOLDLEVELHEADERFLAG) {
+ if (force) {
+ if (visLevels > 1)
+ SendEditor(SCI_SETFOLDEXPANDED, line, 1);
+ else
+ SendEditor(SCI_SETFOLDEXPANDED, line, 0);
+ Expand(line, doExpand, force, visLevels - 1);
+ } else {
+ if (doExpand && SendEditor(SCI_GETFOLDEXPANDED, line)) {
+ Expand(line, true, force, visLevels - 1);
+ } else {
+ Expand(line, false, force, visLevels - 1);
+ }
+ }
+ } else {
+ line++;
+ }
+ }
+}
+
+void AnEditor::FoldCode(bool expanding) {
+ int maxLine = SendEditor (SCI_GETTEXTLENGTH);
+ SendEditor(SCI_COLOURISE, 0, -1);
+ for (int line = 0; line < maxLine; line++) {
+ int level = SendEditor(SCI_GETFOLDLEVEL, line);
+ if ((level & SC_FOLDLEVELHEADERFLAG) &&
+ (SC_FOLDLEVELBASE == (level & SC_FOLDLEVELNUMBERMASK))) {
+ if (expanding) {
+ SendEditor(SCI_SETFOLDEXPANDED, line, 1);
+ Expand(line, true);
+ line--;
+ } else {
+ int lineMaxSubord = SendEditor(SCI_GETLASTCHILD, line, -1);
+ SendEditor(SCI_SETFOLDEXPANDED, line, 0);
+ if (lineMaxSubord > line)
+ SendEditor(SCI_HIDELINES, line + 1, lineMaxSubord);
+ }
+ }
+ }
+}
+
+void AnEditor::FoldOpenAll() {
+ FoldCode (true);
+}
+
+void AnEditor::FoldCloseAll() {
+ FoldCode (false);
+}
+
+void AnEditor::FoldToggle() {
+ int curLine = SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ int level = SendEditor(SCI_GETFOLDLEVEL, curLine);
+ if (level & SC_FOLDLEVELHEADERFLAG) {
+ SendEditor(SCI_TOGGLEFOLD, curLine);
+ return;
+ }
+ int parent = SendEditor (SCI_GETFOLDPARENT, curLine);
+ int lastChild = SendEditor (SCI_GETLASTCHILD, parent, -1);
+ if (curLine > parent && curLine <= lastChild)
+ {
+ SendEditor(SCI_TOGGLEFOLD, parent);
+ SendEditor(SCI_SETCURRENTPOS, SendEditor (SCI_POSITIONFROMLINE, parent));
+ SendEditor(SCI_GOTOLINE, parent);
+ }
+ else
+ gdk_beep ();
+}
+
+void AnEditor::SelectBlock () {
+ int curLine = SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ int parent = SendEditor (SCI_GETFOLDPARENT, curLine);
+ int lastChild = SendEditor (SCI_GETLASTCHILD, parent, -1);
+ if (curLine > parent && curLine <= lastChild)
+ {
+ gint start, end;
+ start = SendEditor(SCI_POSITIONFROMLINE, parent);
+ end = SendEditor(SCI_POSITIONFROMLINE, lastChild+1);
+ SetSelection(start, end);
+ }
+ else
+ gdk_beep ();
+}
+
+int AnEditor::GetBlockStartLine (int curLine) {
+ if(curLine < 0)
+ {
+ curLine = SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ }
+ int level = SendEditor(SCI_GETFOLDLEVEL, curLine);
+ if (level & SC_FOLDLEVELHEADERFLAG) {
+ return curLine;
+ }
+ int parent = -1;
+ int lastChild = curLine;
+ while(parent == -1)
+ {
+ parent = SendEditor (SCI_GETFOLDPARENT, lastChild);
+ if (parent == -1)
+ {
+ return -1;
+ }
+ lastChild = SendEditor (SCI_GETLASTCHILD, parent, -1);
+ if (curLine > parent && curLine <= lastChild)
+ {
+ return parent;
+ }
+ lastChild = parent - 1;
+ parent = -1;
+ }
+ return -1;
+}
+
+int AnEditor::GetBlockEndLine (int curLine) {
+ if(curLine < 0)
+ {
+ curLine = SendEditor(SCI_LINEFROMPOSITION, SendEditor (SCI_GETCURRENTPOS));
+ }
+ int level = SendEditor(SCI_GETFOLDLEVEL, curLine);
+ if (level & SC_FOLDLEVELHEADERFLAG) {
+ /* this may be a problem when we use this function on "start" block line */
+ return curLine;
+ }
+ int parent = -1;
+ int lastChild = curLine;
+ while(parent == -1)
+ {
+ parent = SendEditor (SCI_GETFOLDPARENT, lastChild);
+ if (parent == -1)
+ {
+ return -1;
+ }
+ lastChild = SendEditor (SCI_GETLASTCHILD, parent, -1);
+ if (curLine > parent && curLine <= lastChild)
+ {
+ return lastChild;
+ }
+ lastChild = parent - 1;
+ parent = -1;
+ }
+ return -1;
+}
+
+void AnEditor::EnsureRangeVisible(int posStart, int posEnd) {
+ int lineStart = SendEditor(SCI_LINEFROMPOSITION, Platform::Minimum(posStart, posEnd));
+ int lineEnd = SendEditor(SCI_LINEFROMPOSITION, Platform::Maximum(posStart, posEnd));
+ for (int line = lineStart; line <= lineEnd; line++) {
+ SendEditor(SCI_ENSUREVISIBLE, line);
+ }
+}
+
+void AnEditor::SetLineWrap(bool wrap) {
+ wrapLine = wrap;
+ SendEditor(SCI_SETWRAPMODE, wrapLine ? SC_WRAP_WORD : SC_WRAP_NONE);
+ SendEditor(SCI_SETHSCROLLBAR, !wrapLine);
+}
+
+void AnEditor::SetReadOnly(bool readonly) {
+ isReadOnly = readonly;
+ SendEditor(SCI_SETREADONLY, isReadOnly);
+}
+
+bool AnEditor::MarginClick(int position, int modifiers) {
+ int lineClick = SendEditor(SCI_LINEFROMPOSITION, position);
+ // SendEditor(SCI_GETFOLDLEVEL, lineClick) & SC_FOLDLEVELHEADERFLAG);
+ if (modifiers & SCMOD_SHIFT) {
+ FoldCloseAll();
+ } else if (modifiers & SCMOD_CTRL) {
+ FoldOpenAll();
+ } else if (SendEditor(SCI_GETFOLDLEVEL, lineClick) & SC_FOLDLEVELHEADERFLAG) {
+ if (modifiers & SCMOD_SHIFT) {
+ // Ensure all children visible
+ SendEditor(SCI_SETFOLDEXPANDED, lineClick, 1);
+ Expand(lineClick, true, true, 100);
+ } else if (modifiers & SCMOD_CTRL) {
+ if (SendEditor(SCI_GETFOLDEXPANDED, lineClick)) {
+ // Contract this line and all children
+ SendEditor(SCI_SETFOLDEXPANDED, lineClick, 0);
+ Expand(lineClick, false, true, 0);
+ } else {
+ // Expand this line and all children
+ SendEditor(SCI_SETFOLDEXPANDED, lineClick, 1);
+ Expand(lineClick, true, true, 100);
+ }
+ } else {
+ // Toggle this line
+ SendEditor(SCI_TOGGLEFOLD, lineClick);
+ }
+ }
+ return true;
+}
+
+#if 0
+gint AnEditor::KeyPressEvent(GtkWidget *, GdkEventKey *event, AnEditor *anedit) {
+ return anedit->KeyPress(event->state, event->keyval);
+}
+#endif
+
+void AnEditor::NotifySignal(GtkWidget *, gint /*wParam*/, gpointer lParam, AnEditor *anedit) {
+ anedit->Notify(reinterpret_cast<SCNotification *>(lParam));
+}
+
+// FIXME:
+#if 0
+void
+eval_output_arrived_for_aneditor(GList* lines, gpointer data)
+{
+ // We expect lines->data to be a string of the form VARIABLE = VALUE,
+ // and 'data' to be a pointer to an object of type
+ // 'ExpressionEvaluationTipInfo'.
+
+ if (data == NULL)
+ return;
+
+ auto_ptr<ExpressionEvaluationTipInfo> info(
+ (ExpressionEvaluationTipInfo *) data);
+
+ if (info->editor == NULL)
+ return;
+
+ if (info->editor != aneditor_get(AnEditor::focusedID))
+ return;
+
+ info->editor->EvalOutputArrived(lines, info->textPos, info->expression);
+}
+
+void AnEditor::EvalOutputArrived(GList* lines, int textPos,
+ const string &expression) {
+
+ if (textPos <= 0)
+ return;
+
+ // Return if debug Tip has been canceled
+ if (!debugTipOn)
+ return;
+
+ if (g_list_length(lines) == 0 || lines->data == NULL)
+ return;
+
+ string result = (char *) lines->data;
+ string::size_type posEquals = result.find(" = ");
+ if (posEquals != string::npos)
+ result.replace(0, posEquals, expression);
+
+ SendEditorString(SCI_CALLTIPSHOW, textPos, result.c_str());
+ SendEditor(SCI_CALLTIPSETHLT, 0, result.length());
+}
+
+void AnEditor::EndDebugEval() {
+ if (debugTipOn)
+ {
+ SendEditor(SCI_CALLTIPCANCEL);
+ debugTipOn = false;
+ }
+}
+
+void AnEditor::HandleDwellStart(int mousePos) {
+ if (mousePos == -1)
+ return;
+
+ char expr[256];
+ if (!debugger_is_active() || !debugger_is_ready())
+ {
+ // Do not show expression tip if it can't be shown.
+ // string s = string(expr) + ": " + _("debugger not active");
+ // SendEditorString(SCI_CALLTIPSHOW, mousePos, s.c_str());
+ return;
+ }
+ // If debug tip is already running, return.
+ if (debugTipOn)
+ return;
+
+ CharacterRange crange = GetSelection();
+ if (crange.cpMin == crange.cpMax
+ || mousePos < crange.cpMin
+ || mousePos >= crange.cpMax)
+ {
+ // There is no selection, or the mouse pointer is
+ // out of the selection, so we search for a word
+ // around the mouse pointer:
+ if (!GetWordAtPosition(expr, sizeof(expr), mousePos))
+ return;
+ }
+ else
+ {
+ long lensel = crange.cpMax - crange.cpMin;
+ long max = sizeof(expr) - 1;
+ guint end = (lensel < max ? crange.cpMax : crange.cpMin + max);
+ GetRange(crange.cpMin, end, expr, false);
+
+ // If there is any control character except TAB
+ // in the expression, disregard it.
+ size_t i;
+ for (i = 0; i < end - crange.cpMin; i++)
+ if ((unsigned char) expr[i] < ' ' && expr[i] != '\t')
+ return;
+ if (i < end - crange.cpMin)
+ return;
+ }
+
+ // Imitation of on_eval_ok_clicked():
+ // The function eval_output_arrived_for_aneditor() will
+ // be called eventually by the debugger with the result
+ // of the print command for 'expr', and with the 'info'
+ // pointer. That function must call delete on 'info'.
+ //
+ // We don't turn GDB "pretty printing" on because we want
+ // the entire value on a single line, in the case of a
+ // struct or class.
+ // We don't want static members of classes to clutter up
+ // the displayed tip, however.
+
+ ExpressionEvaluationTipInfo *info =
+ new ExpressionEvaluationTipInfo(this, mousePos, expr);
+ debugger_query_evaluate_expr_tip (expr, eval_output_arrived_for_aneditor, info);
+ debugger_query_execute ();
+ debugTipOn = true;
+}
+#endif
+
+#if 0
+int AnEditor::KeyPress(unsigned int state, unsigned int keyval){
+
+ unsigned int mask = GDK_SHIFT_MASK | GDK_LOCK_MASK |
+ GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD3_MASK |
+ GDK_MOD4_MASK | GDK_MOD5_MASK;
+ if (state & mask)
+ return false;
+
+ // Trap 'TAB' key for automatic indentation.
+ // printf ("Key is '%c'\n", notification->ch);
+ if ((keyval == GDK_Tab) &&
+ (lexLanguage == SCLEX_CPP) &&
+ (!indentMaintain) &&
+ (props->GetInt("indent.automatic")) &&
+ (!SendEditor(SCI_CALLTIPACTIVE)) &&
+ (!SendEditor(SCI_AUTOCACTIVE))) {
+
+ CharacterRange crange = GetSelection();
+ int selStart = crange.cpMin;
+ int selEnd = crange.cpMax;
+
+ if (selStart == selEnd) {
+ AutomaticIndentation('\t');
+ return true;
+ }
+ }
+ return false;
+}
+#endif
+
+void AnEditor::Notify(SCNotification *notification) {
+ switch (notification->nmhdr.code) {
+ case SCN_CALLTIPCLICK:
+ if (notification->position == 1) {
+ call_tip_node.def_index--;
+ if (call_tip_node.def_index < 0)
+ call_tip_node.def_index = 0;
+ }
+ if (notification->position == 2) {
+ call_tip_node.def_index++;
+ if (call_tip_node.def_index >= call_tip_node.max_def)
+ call_tip_node.def_index = call_tip_node.max_def - 1;
+ }
+ ResumeCallTip (false);
+ break;
+ case SCN_KEY: {
+ if(!accelGroup) break;
+ int mods = 0;
+ if (notification->modifiers & SCMOD_SHIFT)
+ mods |= GDK_SHIFT_MASK;
+ if (notification->modifiers & SCMOD_CTRL)
+ mods |= GDK_CONTROL_MASK;
+ if (notification->modifiers & SCMOD_ALT)
+ mods |= GDK_MOD1_MASK;
+ gtk_accel_groups_activate(G_OBJECT (accelGroup), notification->ch,
+ static_cast<GdkModifierType>(mods));
+ }
+
+ case SCN_CHARADDED:
+ CharAdded(static_cast<char>(notification->ch));
+ break;
+
+ case SCN_SAVEPOINTREACHED:
+ isDirty = false;
+ break;
+
+ case SCN_SAVEPOINTLEFT:
+ isDirty = true;
+ break;
+
+ case SCN_UPDATEUI:
+ {
+ int pos = SendEditor(SCI_GETCURRENTPOS);
+ BraceMatch(true);
+ if (SendEditor(SCI_CALLTIPACTIVE) ) {
+ // if we have a caret movement on left or right
+ if (abs(pos - lastPos) == 1 ) {
+ ContinueCallTip_new();
+ }
+ }
+ lastPos = pos;
+ }
+ break;
+
+ case SCN_MODIFIED:
+ if (notification->modificationType == SC_MOD_CHANGEFOLD) {
+ FoldChanged(notification->line,
+ notification->foldLevelNow, notification->foldLevelPrev);
+ }
+ break;
+
+ case SCN_MARGINCLICK:
+ if (notification->margin == 2)
+ MarginClick(notification->position, notification->modifiers);
+ break;
+
+ case SCN_NEEDSHOWN: {
+ EnsureRangeVisible(notification->position, notification->position + notification->length);
+ }
+ break;
+/*
+ case SCN_DWELLSTART:
+ HandleDwellStart(notification->position);
+ break;
+
+ case SCN_DWELLEND:
+ EndDebugEval();
+ // SendEditor(SCI_CALLTIPCANCEL);
+ break;
+*/
+ }
+}
+
+static int IntFromHexDigit(const char ch) {
+ if (isdigit(ch))
+ return ch - '0';
+ else if (ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 10;
+ else if (ch >= 'a' && ch <= 'f')
+ return ch - 'a' + 10;
+ else
+ return 0;
+}
+
+static Colour ColourFromString(const char *val) {
+ int r = IntFromHexDigit(val[1]) * 16 + IntFromHexDigit(val[2]);
+ int g = IntFromHexDigit(val[3]) * 16 + IntFromHexDigit(val[4]);
+ int b = IntFromHexDigit(val[5]) * 16 + IntFromHexDigit(val[6]);
+ return Colour(r, g, b);
+}
+
+static long ColourOfProperty(PropSet *props, const char *key, ColourDesired colourDefault) {
+ SString colour = props->Get(key);
+ if (colour.length()) {
+ return ColourFromString(colour.c_str()).AsLong();
+ }
+ return colourDefault.AsLong();
+}
+
+void AnEditor::SetOneStyle(Window &win, int style, const char *s) {
+ char *val = StringDup(s);
+ char *opt = val;
+ while (opt) {
+ char *cpComma = strchr(opt, ',');
+ if (cpComma)
+ *cpComma = '\0';
+ char *colon = strchr(opt, ':');
+ if (colon)
+ *colon++ = '\0';
+ if (0 == strcmp(opt, "italics"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETITALIC, style, 1);
+ if (0 == strcmp(opt, "notitalics"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETITALIC, style, 0);
+ if (0 == strcmp(opt, "bold"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETBOLD, style, 1);
+ if (0 == strcmp(opt, "notbold"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETBOLD, style, 0);
+ if (0 == strcmp(opt, "font"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETFONT, style, reinterpret_cast<long>(colon));
+ if (0 == strcmp(opt, "fore"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETFORE, style, ColourFromString(colon).AsLong());
+ if (0 == strcmp(opt, "back"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETBACK, style, ColourFromString(colon).AsLong());
+ if (0 == strcmp(opt, "size"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETSIZE, style, atoi(colon));
+ if (0 == strcmp(opt, "eolfilled"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETEOLFILLED, style, 1);
+ if (0 == strcmp(opt, "noteolfilled"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETEOLFILLED, style, 0);
+ if (0 == strcmp(opt, "underlined"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETUNDERLINE, style, 1);
+ if (0 == strcmp(opt, "notunderlined"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETUNDERLINE, style, 0);
+ if (0 == strcmp(opt, "case")) {
+ if (*colon == 'u') {
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCASE, style, SC_CASE_UPPER);
+ } else if (*colon == 'l') {
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCASE, style, SC_CASE_LOWER);
+ } else {
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCASE, style, SC_CASE_MIXED);
+ }
+ }
+ if (0 == strcmp(opt, "visible"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETVISIBLE, style, 1);
+ if (0 == strcmp(opt, "notvisible"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETVISIBLE, style, 0);
+ if (0 == strcmp(opt, "changeable"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCHANGEABLE, style, 1);
+ if (0 == strcmp(opt, "notchangeable"))
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCHANGEABLE, style, 0);
+ if (cpComma)
+ opt = cpComma + 1;
+ else
+ opt = 0;
+ }
+ if (val)
+ delete []val;
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETCHARACTERSET, style, characterSet);
+}
+
+void AnEditor::SetStyleFor(Window &win, const char *lang) {
+ for (int style = 0; style <= STYLE_MAX; style++) {
+ if (style != STYLE_DEFAULT) {
+ char key[200];
+ sprintf(key, "style.%s.%0d", lang, style);
+ SString sval = props->GetExpanded(key);
+ // g_print ("Style for %s:%0d == %s\n", lang, style, sval.c_str());
+ SetOneStyle(win, style, sval.c_str());
+ }
+ }
+}
+
+void lowerCaseString(char *s) {
+ while (*s) {
+ *s = static_cast<char>(tolower(*s));
+ s++;
+ }
+}
+
+SString AnEditor::ExtensionFileName() {
+ if (overrideExtension.length())
+ return overrideExtension;
+ else if (fileName[0]) {
+ // Force extension to lower case
+ char fileNameWithLowerCaseExtension[MAX_PATH];
+ strcpy(fileNameWithLowerCaseExtension, fileName);
+ char *extension = strrchr(fileNameWithLowerCaseExtension, '.');
+ if (extension) {
+ lowerCaseString(extension);
+ }
+ return SString(fileNameWithLowerCaseExtension);
+ } else
+ return props->Get("default.file.ext");
+}
+
+void AnEditor::ForwardPropertyToEditor(const char *key) {
+ SString value = props->Get(key);
+ SendEditorString(SCI_SETPROPERTY,
+ reinterpret_cast<uptr_t>(key), value.c_str());
+}
+
+SString AnEditor::FindLanguageProperty(const char *pattern, const char *defaultValue) {
+ SString key = pattern;
+ key.substitute("*", language.c_str());
+ SString ret = props->GetExpanded(key.c_str());
+ if (ret == "")
+ ret = props->GetExpanded(pattern);
+ if (ret == "")
+ ret = defaultValue;
+ return ret;
+}
+
+void AnEditor::ReadProperties(const char *fileForExt) {
+ //DWORD dwStart = timeGetTime();
+ if (fileForExt)
+ strcpy (fileName, fileForExt);
+ else
+ fileName[0] = '\0';
+
+ SString fileNameForExtension;
+ if(overrideExtension.length())
+ fileNameForExtension = overrideExtension;
+ else {
+ fileNameForExtension = fileForExt;
+ }
+
+ language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETLEXERLANGUAGE, 0, language.c_str());
+ lexLanguage = SendEditor(SCI_GETLEXER);
+
+ if ((lexLanguage == SCLEX_HTML) || (lexLanguage == SCLEX_XML))
+ SendEditor(SCI_SETSTYLEBITS, 7);
+ else
+ SendEditor(SCI_SETSTYLEBITS, 5);
+
+ SendEditor(SCI_SETLEXER, lexLanguage);
+
+ SString kw0 = props->GetNewExpand("keywords.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 0, kw0.c_str());
+ SString kw2 = props->GetNewExpand("keywords3.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 2, kw2.c_str());
+ /* For C/C++ projects, get list of typedefs for colorizing */
+ /* TODO: Either remove or port to IAnjutaSymbolManager */
+#if 0
+ if (SCLEX_CPP == lexLanguage)
+ {
+ const TMWorkspace *workspace = tm_get_workspace();
+
+ /* Assign global keywords */
+ if ((workspace) && (workspace->global_tags))
+ {
+ GPtrArray *g_typedefs = tm_tags_extract(workspace->global_tags
+ , tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
+ if ((g_typedefs) && (g_typedefs->len > 0))
+ {
+ GString *s = g_string_sized_new(g_typedefs->len * 10);
+ for (guint i = 0; i < g_typedefs->len; ++i)
+ {
+ if (!(TM_TAG(g_typedefs->pdata[i])->atts.entry.scope))
+ {
+ g_string_append(s, TM_TAG(g_typedefs->pdata[i])->name);
+ g_string_append_c(s, ' ');
+ }
+ }
+ SendEditorString(SCI_SETKEYWORDS, 3, s->str);
+ g_string_free(s, TRUE);
+ }
+ g_ptr_array_free(g_typedefs, TRUE);
+ }
+
+ /* Assign project keywords */
+ if ((workspace) && (workspace->work_object.tags_array))
+ {
+ GPtrArray *typedefs = tm_tags_extract(workspace->work_object.tags_array
+ , tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
+ if ((typedefs) && (typedefs->len > 0))
+ {
+ GString *s = g_string_sized_new(typedefs->len * 10);
+ for (guint i = 0; i < typedefs->len; ++i)
+ {
+ if (!(TM_TAG(typedefs->pdata[i])->atts.entry.scope))
+ {
+ if (TM_TAG(typedefs->pdata[i])->name)
+ {
+ g_string_append(s, TM_TAG(typedefs->pdata[i])->name);
+ g_string_append_c(s, ' ');
+ }
+ }
+ }
+ SendEditorString(SCI_SETKEYWORDS, 1, s->str);
+ g_string_free(s, TRUE);
+ }
+ g_ptr_array_free(typedefs, TRUE);
+ }
+ }
+ else
+#endif
+ {
+ SString kw1 = props->GetNewExpand("keywords2.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 1, kw1.c_str());
+ SString kw3 = props->GetNewExpand("keywords4.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 3, kw3.c_str());
+ SString kw4 = props->GetNewExpand("keywords5.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 4, kw4.c_str());
+ SString kw5 = props->GetNewExpand("keywords6.", fileNameForExtension.c_str());
+ SendEditorString(SCI_SETKEYWORDS, 5, kw5.c_str());
+ }
+
+ ForwardPropertyToEditor("fold");
+ ForwardPropertyToEditor("fold.use.plus");
+ ForwardPropertyToEditor("fold.comment");
+ ForwardPropertyToEditor("fold.comment.python");
+ ForwardPropertyToEditor("fold.compact");
+ ForwardPropertyToEditor("fold.html");
+ ForwardPropertyToEditor("fold.preprocessor");
+ ForwardPropertyToEditor("fold.quotes.python");
+ ForwardPropertyToEditor("styling.within.preprocessor");
+ ForwardPropertyToEditor("tab.timmy.whinge.level");
+ ForwardPropertyToEditor("asp.default.language");
+
+ // codePage = props->GetInt("code.page");
+ //if (unicodeMode != uni8Bit) {
+ // Override properties file to ensure Unicode displayed.
+ // codePage = SC_CP_UTF8;
+ // }
+ // SendEditor(SCI_SETCODEPAGE, codePage);
+
+ // Use unicode everytime.
+ SendEditor(SCI_SETCODEPAGE, SC_CP_UTF8);
+
+ characterSet = props->GetInt("character.set");
+ setlocale(LC_CTYPE, props->Get("LC_CTYPE").c_str());
+
+ SendEditor(SCI_SETCARETFORE,
+ ColourOfProperty(props, "caret.fore", ColourDesired(0, 0, 0)));
+ SendEditor(SCI_SETCARETWIDTH, props->GetInt("caret.width", 1));
+ SendEditor(SCI_SETMOUSEDWELLTIME, props->GetInt("dwell.period", 750), 0);
+
+ SString caretLineBack = props->Get("caret.line.back");
+ if (caretLineBack.length()) {
+ SendEditor(SCI_SETCARETLINEVISIBLE, 1);
+ SendEditor(SCI_SETCARETLINEBACK,
+ ColourFromString(caretLineBack.c_str()).AsLong());
+ } else {
+ SendEditor(SCI_SETCARETLINEVISIBLE, 0);
+ }
+
+ SString controlCharSymbol = props->Get("control.char.symbol");
+ if (controlCharSymbol.length()) {
+ SendEditor(SCI_SETCONTROLCHARSYMBOL, static_cast<unsigned char>(controlCharSymbol[0]));
+ } else {
+ SendEditor(SCI_SETCONTROLCHARSYMBOL, 0);
+ }
+
+ SendEditor(SCI_CALLTIPSETBACK,
+ ColourOfProperty(props, "calltip.back", ColourDesired(0xff, 0xff, 0xff)));
+
+ SString caretPeriod = props->Get("caret.period");
+ if (caretPeriod.length()) {
+ SendEditor(SCI_SETCARETPERIOD, caretPeriod.value());
+ }
+
+ int caretSlop = props->GetInt("caret.policy.xslop", 1) ? CARET_SLOP : 0;
+ int caretZone = props->GetInt("caret.policy.width", 50);
+ int caretStrict = props->GetInt("caret.policy.xstrict") ? CARET_STRICT : 0;
+ int caretEven = props->GetInt("caret.policy.xeven", 1) ? CARET_EVEN : 0;
+ int caretJumps = props->GetInt("caret.policy.xjumps") ? CARET_JUMPS : 0;
+ SendEditor(SCI_SETXCARETPOLICY, caretStrict | caretSlop | caretEven | caretJumps, caretZone);
+
+ caretSlop = props->GetInt("caret.policy.yslop", 1) ? CARET_SLOP : 0;
+ caretZone = props->GetInt("caret.policy.lines");
+ caretStrict = props->GetInt("caret.policy.ystrict") ? CARET_STRICT : 0;
+ caretEven = props->GetInt("caret.policy.yeven", 1) ? CARET_EVEN : 0;
+ caretJumps = props->GetInt("caret.policy.yjumps") ? CARET_JUMPS : 0;
+ SendEditor(SCI_SETYCARETPOLICY, caretStrict | caretSlop | caretEven | caretJumps, caretZone);
+
+ int visibleStrict = props->GetInt("visible.policy.strict") ? VISIBLE_STRICT : 0;
+ int visibleSlop = props->GetInt("visible.policy.slop", 1) ? VISIBLE_SLOP : 0;
+ int visibleLines = props->GetInt("visible.policy.lines");
+ SendEditor(SCI_SETVISIBLEPOLICY, visibleStrict | visibleSlop, visibleLines);
+
+ SendEditor(SCI_SETEDGECOLUMN, props->GetInt("edge.column", 0));
+ SendEditor(SCI_SETEDGEMODE, props->GetInt("edge.mode", EDGE_NONE));
+ SendEditor(SCI_SETEDGECOLOUR,
+ ColourOfProperty(props, "edge.colour", ColourDesired(0xff, 0xda, 0xda)));
+
+ SString selfore = props->Get("selection.fore");
+ if (selfore.length()) {
+ SendEditor(SCI_SETSELFORE, 1, ColourFromString(selfore.c_str()).AsLong());
+ } else {
+ SendEditor(SCI_SETSELFORE, 0, 0);
+ }
+ SString selBack = props->Get("selection.back");
+ if (selBack.length()) {
+ SendEditor(SCI_SETSELBACK, 1, ColourFromString(selBack.c_str()).AsLong());
+ } else {
+ if (selfore.length())
+ SendEditor(SCI_SETSELBACK, 0, 0);
+ else // Have to show selection somehow
+ SendEditor(SCI_SETSELBACK, 1, ColourDesired(0xC0, 0xC0, 0xC0).AsLong());
+ }
+
+ SString whitespaceFore = props->Get("whitespace.fore");
+ if (whitespaceFore.length()) {
+ SendEditor(SCI_SETWHITESPACEFORE, 1, ColourFromString(whitespaceFore.c_str()).AsLong());
+ } else {
+ SendEditor(SCI_SETWHITESPACEFORE, 0, 0);
+ }
+ SString whitespaceBack = props->Get("whitespace.back");
+ if (whitespaceBack.length()) {
+ SendEditor(SCI_SETWHITESPACEBACK, 1, ColourFromString(whitespaceBack.c_str()).AsLong());
+ } else {
+ SendEditor(SCI_SETWHITESPACEBACK, 0, 0);
+ }
+
+ for (int i = 0; i < 3; i++) {
+
+ SString value_str;
+ long default_indic_type[] = {INDIC_TT, INDIC_DIAGONAL, INDIC_SQUIGGLE};
+ const char *default_indic_color[] = {"0000FF", "#00FF00", "#FF0000"};
+ const char *style_name[] = {"normal", "warning", "error"};
+ char key[200];
+ sprintf(key, "indicators.style.%s", style_name[i]);
+
+ value_str = props->Get(key);
+ if (value_str.length() > 0) {
+ if (strcasecmp (value_str.c_str(), "underline-plain") == 0) {
+ SendEditor(SCI_INDICSETSTYLE, i, INDIC_PLAIN);
+ } else if (strcasecmp (value_str.c_str(), "underline-tt") == 0) {
+ SendEditor(SCI_INDICSETSTYLE, i, INDIC_TT);
+ } else if (strcasecmp (value_str.c_str(), "underline-squiggle") == 0) {
+ SendEditor(SCI_INDICSETSTYLE, i, INDIC_SQUIGGLE);
+ } else if (strcasecmp (value_str.c_str(), "strike-out") == 0) {
+ SendEditor(SCI_INDICSETSTYLE, i, INDIC_STRIKE);
+ } else if (strcasecmp (value_str.c_str(), "diagonal") == 0) {
+ SendEditor(SCI_INDICSETSTYLE, i, INDIC_DIAGONAL);
+ } else {
+ SendEditor(SCI_INDICSETSTYLE, i, default_indic_type[i]);
+ }
+ } else {
+ SendEditor(SCI_INDICSETSTYLE, i, default_indic_type[i]);
+ }
+ sprintf(key, "indicator.%d.color", i);
+ value_str = props->GetExpanded(key);
+ if (value_str.length()) {
+ SendEditor(SCI_INDICSETFORE, i, ColourFromString(value_str.c_str()).AsLong());
+ } else {
+ SendEditor(SCI_INDICSETFORE, i, ColourFromString(default_indic_color[i]).AsLong());
+ }
+ }
+
+ char bracesStyleKey[200];
+ sprintf(bracesStyleKey, "braces.%s.style", language.c_str());
+ bracesStyle = props->GetInt(bracesStyleKey, 0);
+
+ char key[200];
+ SString sval;
+
+ sval = FindLanguageProperty("calltip.*.ignorecase");
+ callTipIgnoreCase = sval == "1";
+
+ calltipWordCharacters = FindLanguageProperty("calltip.*.word.characters",
+ "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
+ calltipEndDefinition = FindLanguageProperty("calltip.*.end.definition");
+
+ sprintf(key, "autocomplete.%s.start.characters", language.c_str());
+ autoCompleteStartCharacters = props->GetExpanded(key);
+ if (autoCompleteStartCharacters == "")
+ autoCompleteStartCharacters = props->GetExpanded("autocomplete.*.start.characters");
+ // "" is a quite reasonable value for this setting
+
+ sprintf(key, "autocomplete.%s.fillups", language.c_str());
+ autoCompleteFillUpCharacters = props->GetExpanded(key);
+ if (autoCompleteFillUpCharacters == "")
+ autoCompleteFillUpCharacters =
+ props->GetExpanded("autocomplete.*.fillups");
+ SendEditorString(SCI_AUTOCSETFILLUPS, 0,
+ autoCompleteFillUpCharacters.c_str());
+
+ sprintf(key, "autocomplete.%s.ignorecase", "*");
+ sval = props->GetNewExpand(key, "");
+ autoCompleteIgnoreCase = sval == "1";
+ sprintf(key, "autocomplete.%s.ignorecase", language.c_str());
+ sval = props->GetNewExpand(key, "");
+ if (sval != "")
+ autoCompleteIgnoreCase = sval == "1";
+ SendEditor(SCI_AUTOCSETIGNORECASE, autoCompleteIgnoreCase ? 1 : 0);
+
+ int autoCChooseSingle = props->GetInt("autocomplete.choose.single");
+ SendEditor(SCI_AUTOCSETCHOOSESINGLE, autoCChooseSingle),
+
+ SendEditor(SCI_AUTOCSETCANCELATSTART, 0),
+ SendEditor(SCI_AUTOCSETDROPRESTOFWORD, 0),
+
+ // Set styles
+ // For each window set the global default style,
+ // then the language default style,
+ // then the other global styles,
+ // then the other language styles
+
+ SendEditor(SCI_STYLERESETDEFAULT, 0, 0);
+
+ sprintf(key, "style.%s.%0d", "*", STYLE_DEFAULT);
+ sval = props->GetNewExpand(key, "");
+ SetOneStyle(wEditor, STYLE_DEFAULT, sval.c_str());
+
+ sprintf(key, "style.%s.%0d", language.c_str(), STYLE_DEFAULT);
+ sval = props->GetNewExpand(key, "");
+ SetOneStyle(wEditor, STYLE_DEFAULT, sval.c_str());
+
+ SendEditor(SCI_STYLECLEARALL, 0, 0);
+
+ SetStyleFor(wEditor, "*");
+ SetStyleFor(wEditor, language.c_str());
+
+ if (firstPropertiesRead) {
+ ReadPropertiesInitial();
+ }
+
+ /* Gtk handles it correctly */
+ SendEditor(SCI_SETUSEPALETTE, 0);
+
+ SendEditor(SCI_SETPRINTMAGNIFICATION, props->GetInt("print.magnification"));
+ SendEditor(SCI_SETPRINTCOLOURMODE, props->GetInt("print.colour.mode"));
+
+ int blankMarginLeft = props->GetInt("blank.margin.left", 1);
+ int blankMarginRight = props->GetInt("blank.margin.right", 1);
+ SendEditor(SCI_SETMARGINLEFT, 0, blankMarginLeft);
+ SendEditor(SCI_SETMARGINRIGHT, 0, blankMarginRight);
+
+ SendEditor(SCI_SETMARGINWIDTHN, 1, margin ? marginWidth : 0);
+ SendEditor(SCI_SETMARGINWIDTHN, 0, lineNumbers ?lineNumbersWidth : 0);
+
+ bufferedDraw = props->GetInt("buffered.draw", 1);
+ SendEditor(SCI_SETBUFFEREDDRAW, bufferedDraw);
+
+ SendEditor(SCI_SETLAYOUTCACHE, props->GetInt("cache.layout"));
+
+ bracesCheck = props->GetInt("braces.check");
+ bracesSloppy = props->GetInt("braces.sloppy");
+
+ wordCharacters = props->GetNewExpand("word.characters.", fileNameForExtension.c_str());
+ if (wordCharacters.length()) {
+ SendEditorString(SCI_SETWORDCHARS, 0, wordCharacters.c_str());
+ } else {
+ SendEditor(SCI_SETWORDCHARS, 0, 0);
+ wordCharacters = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ }
+ // Why call this??
+ // SendEditor(SCI_MARKERDELETEALL, static_cast<unsigned long>( -1));
+
+ SendEditor(SCI_SETTABINDENTS, props->GetInt("tab.indents", 1));
+ SendEditor(SCI_SETBACKSPACEUNINDENTS, props->GetInt("backspace.unindents", 1));
+
+ SendEditor(SCI_SETUSETABS, props->GetInt("use.tabs", 1));
+ int tabSize = props->GetInt("tabsize");
+ if (tabSize) {
+ SendEditor(SCI_SETTABWIDTH, tabSize);
+ }
+ indentSize = props->GetInt("indent.size");
+ SendEditor(SCI_SETINDENT, indentSize);
+ /*
+ indentOpening = props->GetInt("indent.opening");
+ indentClosing = props->GetInt("indent.closing");
+ */
+ indentMaintain = props->GetNewExpand("indent.maintain.", fileNameForExtension.c_str()).value();
+ /*
+ SString lookback = props->GetNewExpand("statement.lookback.", fileNameForExtension.c_str());
+ statementLookback = lookback.value();
+ statementIndent = GetStyleAndWords("statement.indent.");
+ statementEnd =GetStyleAndWords("statement.end.");
+ blockStart = GetStyleAndWords("block.start.");
+ blockEnd = GetStyleAndWords("block.end.");
+ */
+
+ /*
+ SString list;
+ list = props->GetNewExpand("preprocessor.symbol.", fileNameForExtension.c_str());
+ preprocessorSymbol = list[0];
+ list = props->GetNewExpand("preprocessor.start.", fileNameForExtension.c_str());
+ preprocCondStart.Clear();
+ preprocCondStart.Set(list.c_str());
+ list = props->GetNewExpand("preprocessor.middle.", fileNameForExtension.c_str());
+ preprocCondMiddle.Clear();
+ preprocCondMiddle.Set(list.c_str());
+ list = props->GetNewExpand("preprocessor.end.", fileNameForExtension.c_str());
+ preprocCondEnd.Clear();
+ preprocCondEnd.Set(list.c_str());
+ */
+
+ if (props->GetInt("vc.home.key", 1)) {
+ AssignKey(SCK_HOME, 0, SCI_VCHOME);
+ AssignKey(SCK_HOME, SCMOD_SHIFT, SCI_VCHOMEEXTEND);
+ } else {
+ AssignKey(SCK_HOME, 0, SCI_HOME);
+ AssignKey(SCK_HOME, SCMOD_SHIFT, SCI_HOMEEXTEND);
+ }
+ if (props->GetInt("fold.underline"))
+ SendEditor(SCI_SETFOLDFLAGS, props->GetInt("fold.flags"));
+ else
+ SendEditor(SCI_SETFOLDFLAGS, 0);
+
+ // To put the folder markers in the line number region
+ //SendEditor(SCI_SETMARGINMASKN, 0, SC_MASK_FOLDERS);
+
+ SendEditor(SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD);
+
+ if (0==props->GetInt("undo.redo.lazy")) {
+ // Trap for insert/delete notifications (also fired by undo
+ // and redo) so that the buttons can be enabled if needed.
+ SendEditor(SCI_SETMODEVENTMASK, SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT
+ | SC_LASTSTEPINUNDOREDO | SendEditor(SCI_GETMODEVENTMASK, 0));
+
+ //SC_LASTSTEPINUNDOREDO is probably not needed in the mask; it
+ //doesn't seem to fire as an event of its own; just modifies the
+ //insert and delete events.
+ }
+
+ // Create a margin column for the folding symbols
+ SendEditor(SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
+
+ SendEditor(SCI_SETMARGINWIDTHN, 2, foldMargin ? foldMarginWidth : 0);
+
+ SendEditor(SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
+ SendEditor(SCI_SETMARGINSENSITIVEN, 1, 1); // Breakpoints-Bookmarks
+ SendEditor(SCI_SETMARGINSENSITIVEN, 2, 1);
+
+ SString fold_symbols = props->Get("fold.symbols");
+ SetFoldSymbols (fold_symbols);
+
+ // Well, unlike scite, we want it everytime.
+ firstPropertiesRead = true;
+}
+
+void AnEditor::SetFoldSymbols(SString fold_symbols)
+{
+ if (fold_symbols.length() <= 0)
+ fold_symbols = "plus/minus";
+ if (strcasecmp(fold_symbols.c_str(), "arrows") == 0)
+ {
+ // Arrow pointing right for contracted folders, arrow pointing down for expanded
+ DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_ARROWDOWN, Colour(0, 0, 0), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_ARROW, Colour(0, 0, 0), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, Colour(0, 0, 0), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, Colour(0, 0, 0), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ } else if (strcasecmp(fold_symbols.c_str(), "circular") == 0) {
+ // Like a flattened tree control using circular headers and curved joins
+ DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_CIRCLEMINUS, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_CIRCLEPLUS, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNERCURVE, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_CIRCLEPLUSCONNECTED, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_CIRCLEMINUSCONNECTED, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNERCURVE, Colour(0xff, 0xff, 0xff), Colour(0x40, 0x40, 0x40));
+ } else if (strcasecmp(fold_symbols.c_str(), "squares") == 0) {
+ // Like a flattened tree control using square headers
+ DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER, Colour(0xff, 0xff, 0xff), Colour(0x80, 0x80, 0x80));
+ } else { // Default
+ // Plus for contracted folders, minus for expanded
+ DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, Colour(0xff, 0xff, 0xff), Colour(0, 0, 0));
+ }
+}
+
+// Anjuta: In our case, we read it everytime
+void AnEditor::ReadPropertiesInitial() {
+ indentationWSVisible = props->GetInt("view.indentation.whitespace", 1);
+ ViewWhitespace(props->GetInt("view.whitespace"));
+ SendEditor(SCI_SETINDENTATIONGUIDES, props->GetInt("view.indentation.guides"));
+ SendEditor(SCI_SETVIEWEOL, props->GetInt("view.eol"));
+
+ SetReadOnly(props->GetInt("file.readonly", 0));
+ SetLineWrap(props->GetInt("view.line.wrap", 1));
+
+ //lineNumbersWidth = 0;
+ /* FIXME: This is nowhere configureable
+ SString linenums = props->Get("margin.linenumber.width");
+ if (linenums.length())
+ lineNumbersWidth = linenums.value(); */
+ //lineNumbers = lineNumbersWidth;
+ /* We do this dynamicly in text_editor_load_file now */
+ /* if (lineNumbersWidth == 0)
+ lineNumbersWidth = lineNumbersWidthDefault;*/
+
+ marginWidth = 0;
+ SString margwidth = props->Get("margin.marker.width");
+ if (margwidth.length())
+ marginWidth = margwidth.value();
+ margin = marginWidth;
+ if (marginWidth == 0)
+ marginWidth = marginWidthDefault;
+
+ foldMarginWidth = props->GetInt("margin.fold.width", foldMarginWidthDefault);
+ foldMargin = foldMarginWidth;
+ if (foldMarginWidth == 0)
+ foldMarginWidth = foldMarginWidthDefault;
+
+ lineNumbers = props->GetInt("margin.linenumber.visible", 0);
+ SendEditor(SCI_SETMARGINWIDTHN, 0, lineNumbers ? lineNumbersWidth : 0);
+ margin = props->GetInt("margin.marker.visible", 0);
+ SendEditor(SCI_SETMARGINWIDTHN, 1, margin ? marginWidth : 0);
+
+ foldMargin = props->GetInt("margin.fold.visible", 1);
+ SendEditor(SCI_SETMARGINWIDTHN, 2, foldMargin ? foldMarginWidth : 0);
+}
+
+void AnEditor::DefineMarker(int marker, int markerType, Colour fore, Colour back)
+{
+ SendEditor(SCI_MARKERDEFINE, marker, markerType);
+ SendEditor(SCI_MARKERSETFORE, marker, fore.AsLong());
+ SendEditor(SCI_MARKERSETBACK, marker, back.AsLong());
+}
+
+int AnEditor::GetBookmarkLine( const int nLineStart )
+{
+ int nNextLine = SendEditor(SCI_MARKERNEXT, nLineStart+1, 1 << ANE_MARKER_BOOKMARK);
+ //printf( "...look %d --> %d\n", nLineStart, nNextLine );
+ if ( (nNextLine < 0) || (nNextLine == nLineStart) )
+ return -1 ;
+ else
+ return nNextLine;
+}
+
+void AnEditor::FocusInEvent(GtkWidget* widget)
+{
+ if (calltipShown)
+ {
+ StartCallTip_new();
+ }
+}
+
+void AnEditor::FocusOutEvent(GtkWidget* widget)
+{
+ if (SendEditor(SCI_CALLTIPACTIVE))
+ {
+ SendEditor(SCI_CALLTIPCANCEL);
+ calltipShown = true;
+ }
+ else
+ {
+ calltipShown = false;
+ }
+}
+
+static GList* editors;
+
+static AnEditor*
+aneditor_get(AnEditorID id)
+{
+ AnEditor* ed;
+ if(id >= g_list_length(editors))
+ {
+ DEBUG_PRINT("%s", "Invalid AnEditorID supplied");
+ return NULL;
+ }
+ ed = (AnEditor*)g_list_nth_data(editors, (guint)id);
+ if(!ed)
+ {
+ DEBUG_PRINT("%s", "Trying to use already destroyed AnEditor Object");
+ return NULL;
+ }
+ return ed;
+}
+
+AnEditorID
+aneditor_new(gpointer propset)
+{
+ AnEditor* ed = new AnEditor((PropSetFile*)propset);
+ if (!ed)
+ {
+ DEBUG_PRINT("%s", "Memory allocation error.");
+ return ANE_ID_INVALID;
+ }
+ g_signal_connect(ed->GetID(), "focus_in_event",
+ G_CALLBACK(on_aneditor_focus_in), ed);
+ g_signal_connect(ed->GetID(), "focus_out_event",
+ G_CALLBACK(on_aneditor_focus_out), ed);
+ editors = g_list_append(editors, ed);
+ return (AnEditorID)(g_list_length(editors) - 1);
+}
+
+void
+aneditor_destroy(AnEditorID id)
+{
+ AnEditor* ed;
+
+ ed = aneditor_get(id);
+ if(!ed) return;
+
+ /* We will not remove the editor from the list */
+ /* so that already assigned handles work properly */
+ /* We'll simply make it NULL to indicate that the */
+ /* editor is destroyed */
+ g_list_nth(editors, id)->data = NULL;
+
+ /* Disconnect the focus in/out signals */
+ g_signal_handlers_disconnect_by_func (ed->GetID(),
+ (void*)G_CALLBACK(on_aneditor_focus_in), ed);
+ g_signal_handlers_disconnect_by_func (ed->GetID(),
+ (void*)G_CALLBACK(on_aneditor_focus_out), ed);
+
+ delete ed;
+}
+
+GtkWidget*
+aneditor_get_widget(AnEditorID handle)
+{
+ AnEditor *ed;
+ ed = aneditor_get(handle);
+ if(!ed) return NULL;
+
+ // Forced conversion is safe here, so do it.
+ return (GtkWidget*)ed->GetID();
+}
+
+glong
+aneditor_command(AnEditorID handle, gint command, glong wparam, glong lparam)
+{
+ AnEditor *ed;
+ ed = aneditor_get(handle);
+ if(!ed) return 0;
+ return ed->Command(command, wparam, lparam);
+}
+
+void
+aneditor_set_focused_ed_ID(AnEditorID id)
+{
+ AnEditor::focusedID = id;
+}
+
+void
+aneditor_set_parent(AnEditorID id, AnEditorID parent_id)
+{
+ AnEditor *editor;
+ AnEditor *parent;
+
+ editor = aneditor_get (id);
+ parent = aneditor_get (parent_id);
+ editor->SetParent(parent);
+}
+
+gint
+on_aneditor_focus_in (GtkWidget* widget, gpointer* unused, AnEditor* ed)
+{
+ ed->FocusInEvent(widget);
+ return FALSE;
+}
+
+gint
+on_aneditor_focus_out (GtkWidget* widget, gpointer * unused, AnEditor* ed)
+{
+ /* ed->EndDebugEval(); */
+ ed->FocusOutEvent(widget);
+ return FALSE;
+}
Added: trunk/plugins/scintilla/aneditor.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/aneditor.h Wed Apr 8 22:31:22 2009
@@ -0,0 +1,154 @@
+/*
+ aneditor.h
+ Copyright (C) 2000 Kh. Naba Kumar Singh
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#ifndef _ANEDITOR_H_
+#define _ANEDITOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <gtk/gtk.h>
+
+#define ANE_COMMAND_BASE 0
+#define ANE_UNDO (ANE_COMMAND_BASE+1)
+#define ANE_REDO (ANE_COMMAND_BASE+2)
+#define ANE_CUT (ANE_COMMAND_BASE+3)
+#define ANE_COPY (ANE_COMMAND_BASE+4)
+#define ANE_PASTE (ANE_COMMAND_BASE+5)
+#define ANE_CLEAR (ANE_COMMAND_BASE+6)
+#define ANE_SELECTALL (ANE_COMMAND_BASE+7)
+#define ANE_FIND (ANE_COMMAND_BASE+8)
+
+/*
+ * This is not an Aneditor command, so don't use it as command.
+ * Scintilla does not define it. So, I did here because I need it.
+ * For the time being, let's assume scintilla does not use this bit field.
+ */
+#define ANEFIND_REVERSE_FLAG 0x40000000
+
+#define ANE_GETBLOCKSTARTLINE (ANE_COMMAND_BASE+9)
+#define ANE_GETBLOCKENDLINE (ANE_COMMAND_BASE+10)
+#define ANE_GETCURRENTWORD (ANE_COMMAND_BASE+11)
+ /* 12 => Reserved */
+#define ANE_MATCHBRACE (ANE_COMMAND_BASE+13)
+#define ANE_SELECTTOBRACE (ANE_COMMAND_BASE+14)
+#define ANE_SHOWCALLTIP (ANE_COMMAND_BASE+15)
+/*
+#define ANE_COMPLETE (ANE_COMMAND_BASE+16)
+#define ANE_COMPLETEWORD (ANE_COMMAND_BASE+17)
+*/
+#define ANE_SELECTBLOCK (ANE_COMMAND_BASE+18)
+#define ANE_UPRCASE (ANE_COMMAND_BASE+19)
+#define ANE_LWRCASE (ANE_COMMAND_BASE+20)
+#define ANE_EXPAND (ANE_COMMAND_BASE+21)
+#define ANE_LINENUMBERMARGIN (ANE_COMMAND_BASE+22)
+#define ANE_SELMARGIN (ANE_COMMAND_BASE+23)
+#define ANE_FOLDMARGIN (ANE_COMMAND_BASE+24)
+#define ANE_VIEWEOL (ANE_COMMAND_BASE+25)
+#define ANE_EOL_CRLF (ANE_COMMAND_BASE+26)
+#define ANE_EOL_CR (ANE_COMMAND_BASE+27)
+#define ANE_EOL_LF (ANE_COMMAND_BASE+28)
+#define ANE_EOL_CONVERT (ANE_COMMAND_BASE+29)
+#define ANE_WORDPARTLEFT (ANE_COMMAND_BASE+30)
+#define ANE_WORDPARTLEFTEXTEND (ANE_COMMAND_BASE+31)
+#define ANE_WORDPARTRIGHT (ANE_COMMAND_BASE+32)
+#define ANE_WORDPARTRIGHTEXTEND (ANE_COMMAND_BASE+33)
+#define ANE_VIEWSPACE (ANE_COMMAND_BASE+34)
+#define ANE_VIEWGUIDES (ANE_COMMAND_BASE+35)
+#define ANE_BOOKMARK_TOGGLE (ANE_COMMAND_BASE+36)
+#define ANE_BOOKMARK_FIRST (ANE_COMMAND_BASE+37)
+#define ANE_BOOKMARK_PREV (ANE_COMMAND_BASE+38)
+#define ANE_BOOKMARK_NEXT (ANE_COMMAND_BASE+39)
+#define ANE_BOOKMARK_LAST (ANE_COMMAND_BASE+40)
+#define ANE_BOOKMARK_CLEAR (ANE_COMMAND_BASE+41)
+#define ANE_SETTABSIZE (ANE_COMMAND_BASE+42)
+#define ANE_SETLANGUAGE (ANE_COMMAND_BASE+43)
+#define ANE_SETHILITE (ANE_COMMAND_BASE+44)
+#define ANE_READPROPERTIES (ANE_COMMAND_BASE+45)
+#define ANE_GOTOLINE (ANE_COMMAND_BASE+46)
+#define ANE_GOTOPOINT (ANE_COMMAND_BASE+47)
+#define ANE_SETZOOM (ANE_COMMAND_BASE+48)
+#define ANE_SETACCELGROUP (ANE_COMMAND_BASE+49)
+#define ANE_GETTEXTRANGE (ANE_COMMAND_BASE+50)
+#define ANE_TOGGLE_FOLD (ANE_COMMAND_BASE+51)
+#define ANE_CLOSE_FOLDALL (ANE_COMMAND_BASE+52)
+#define ANE_OPEN_FOLDALL (ANE_COMMAND_BASE+53)
+#define ANE_INDENT_INCREASE (ANE_COMMAND_BASE+54)
+#define ANE_INDENT_DECREASE (ANE_COMMAND_BASE+55)
+#define ANE_INSERTTEXT (ANE_COMMAND_BASE+56)
+#define ANE_GETBOOKMARK_POS (ANE_COMMAND_BASE+57)
+#define ANE_BOOKMARK_TOGGLE_LINE (ANE_COMMAND_BASE+58)
+#define ANE_GETLENGTH (ANE_COMMAND_BASE+59)
+#define ANE_GET_LINENO (ANE_COMMAND_BASE+60)
+#define ANE_LINEWRAP (ANE_COMMAND_BASE+61)
+#define ANE_READONLY (ANE_COMMAND_BASE+62)
+#define ANE_GETSTYLEDTEXT (ANE_COMMAND_BASE+63)
+#define ANE_TEXTWIDTH (ANE_COMMAND_BASE+64)
+#define ANE_GETLANGUAGE (ANE_COMMAND_BASE+65)
+#define ANE_BLOCKCOMMENT (ANE_COMMAND_BASE+66)
+#define ANE_BOXCOMMENT (ANE_COMMAND_BASE+67)
+#define ANE_STREAMCOMMENT (ANE_COMMAND_BASE+68)
+#define ANE_WORDSELECT (ANE_COMMAND_BASE+69)
+#define ANE_LINESELECT (ANE_COMMAND_BASE+70)
+/*
+#define ANE_CUSTOMINDENT (ANE_COMMAND_BASE+71)
+*/
+#define ANE_GETCURRENTPOS (ANE_COMMAND_BASE+72)
+#define ANE_GOTOPOS (ANE_COMMAND_BASE+73)
+
+#define ANE_SETWRAPBOOKMARKS (ANE_COMMAND_BASE+74)
+/*
+#define ANE_SETAUTOINDENTATION (ANE_COMMAND_BASE+75)
+*/
+#define ANE_SETUSETABFORINDENT (ANE_COMMAND_BASE+76)
+#define ANE_SETINDENTSIZE (ANE_COMMAND_BASE+77)
+#define ANE_SETINDENTBRACESCHECK (ANE_COMMAND_BASE+78)
+/*
+#define ANE_SETINDENTOPENING (ANE_COMMAND_BASE+79)
+#define ANE_SETINDENTCLOSING (ANE_COMMAND_BASE+80)
+*/
+#define ANE_SETINDENTMAINTAIN (ANE_COMMAND_BASE+81)
+#define ANE_SETTABINDENTS (ANE_COMMAND_BASE+82)
+#define ANE_SETBACKSPACEUNINDENTS (ANE_COMMAND_BASE+83)
+#define ANE_SETFOLDSYMBOLS (ANE_COMMAND_BASE+84)
+#define ANE_SETFOLDUNDERLINE (ANE_COMMAND_BASE+85)
+#define ANE_SETLINENUMWIDTH (ANE_COMMAND_BASE+86)
+
+#define ANE_COMPLETECALLTIP (ANE_COMMAND_BASE+87)
+#define ANE_SETEDGECOLUMN (ANE_COMMAND_BASE+88)
+#define ANE_GETWORDBEFORECARAT (ANE_COMMAND_BASE+89)
+
+typedef guint AnEditorID;
+extern const AnEditorID ANE_ID_INVALID;
+
+typedef struct _FindParameters FindParameters;
+
+AnEditorID aneditor_new(gpointer p);
+void aneditor_destroy(AnEditorID id);
+GtkWidget* aneditor_get_widget(AnEditorID id);
+glong aneditor_command(AnEditorID id, gint command,
+ glong wparam, glong wlaram);
+void aneditor_set_focused_ed_ID(AnEditorID id);
+void aneditor_set_parent(AnEditorID id, AnEditorID parent_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ANEDITOR_H_ */
Added: trunk/plugins/scintilla/anjuta-bookmark-16.xpm
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/anjuta-bookmark-16.xpm Wed Apr 8 22:31:22 2009
@@ -0,0 +1,62 @@
+/* XPM */
+static char *anjuta_bookmark_16_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 40 1",
+" c #2D2E2F",
+". c #2E3436",
+"X c #33393B",
+"o c #A80404",
+"O c #8B0F10",
+"+ c #AF1717",
+"@ c #A50707",
+"# c #AA1918",
+"$ c #AF1616",
+"% c #AB211E",
+"& c #AE2D2C",
+"* c #B83B38",
+"= c #AD1010",
+"- c #C53C37",
+"; c #BB4139",
+": c #BB5A53",
+"> c #C2554E",
+", c #C75853",
+"< c #D75A59",
+"1 c #E85959",
+"2 c #C56767",
+"3 c #C17272",
+"4 c #EB6A6A",
+"5 c gray60",
+"6 c #A9A9A9",
+"7 c gray",
+"8 c #D08989",
+"9 c #EF8C8C",
+"0 c #D3A3A3",
+"q c #CEC9C9",
+"w c #D3CECE",
+"e c #DAD9D9",
+"r c #EADBDB",
+"t c #F2DDDD",
+"y c #E7E6E6",
+"u c #F1E7E7",
+"i c #F8F8F8",
+"p c #373B3D",
+"a c #A50101",
+"s c None",
+/* pixels */
+"sa=+$$$ossssssss",
+"s$29999%ssssssss",
+"pO&4114# ..X..Xp",
+" r#<--<@tiiiiiiX",
+".t#>**,@q55555i.",
+".t#,*-,@qyyyyyi.",
+".t#,--,@q55667i.",
+".t#,-*,@wyyeyui.",
+".t#:;;,@e6666yi.",
+".t#::::@eeeeyyi.",
+".t%:&&:@y66766i.",
+" r #*&# eeeeeei ",
+" t 3yy:@yiiiiii.",
+".t0yyii8uiiiiii.",
+"XiiiiiiiiiiiiiiX",
+"pX............Xp"
+};
Added: trunk/plugins/scintilla/anjuta-pcmark-16.xpm
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/anjuta-pcmark-16.xpm Wed Apr 8 22:31:22 2009
@@ -0,0 +1,90 @@
+/* XPM */
+static char *anjuta_pcmark_16_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 68 1",
+" c #8F5902",
+". c #905A02",
+"X c #905B02",
+"o c #915C02",
+"O c #915C03",
+"+ c #925D02",
+"@ c #945F02",
+"# c #946002",
+"$ c #956004",
+"% c #9F6E07",
+"& c #946008",
+"* c #97630A",
+"= c #966409",
+"- c #976409",
+"; c #94600D",
+": c #95610F",
+"> c #97650C",
+", c #98650D",
+"< c #9A680C",
+"1 c #976515",
+"2 c #EDD400",
+"3 c #EDD401",
+"4 c #EED60B",
+"5 c #EED60D",
+"6 c #EED710",
+"7 c #EED713",
+"8 c #EED815",
+"9 c #EFD816",
+"0 c #EFD817",
+"q c #EFD818",
+"w c #F3E359",
+"e c #D9C161",
+"r c #E9D770",
+"t c #EBDB7E",
+"y c #F4E668",
+"u c #F5E56A",
+"i c #F5E66B",
+"p c #F5E66C",
+"a c #F5E76E",
+"s c #F6E97F",
+"d c #E9D884",
+"f c #ECDF94",
+"g c #ECDF96",
+"h c #F6EA87",
+"j c #F7EB89",
+"k c #F7EB8C",
+"l c #EDE099",
+"z c #F7ED91",
+"x c #F7EC93",
+"c c #F7ED94",
+"v c #F8ED95",
+"b c #F8ED97",
+"n c #F8EE9B",
+"m c #F9EEA0",
+"M c #F9EFA6",
+"N c #F9F0A6",
+"B c #F9F0A9",
+"V c #F9F0AA",
+"C c #FAF2B9",
+"Z c #FBF6C9",
+"A c #FBF6CB",
+"S c #FCF6D0",
+"D c #FCF8D9",
+"F c #FDF9D9",
+"G c #FCFAE0",
+"H c #FDFAE1",
+"J c #FDFBE6",
+"K c None",
+/* pixels */
+"KKKKKKKKKKKKKKKK",
+"KKKKKKKK$KKKKKKK",
+"KKKKKKKK :KKKKKK",
+"KKKKKKKK d,KKKKK",
+"KKKKKKKK Cl,KKKK",
+"KK+ XX@@<Zzl,KKK",
+"KK1FHJJHFAykl=KK",
+"KK:Ahxbcjhiwjl,K",
+"KKOV055678qq0be@",
+"KK1n22222222it=K",
+"KK:VVVVVVn2at=KK",
+"KK+ X ++%Nat=KKK",
+"KKKKKKKKXNt=KKKK",
+"KKKKKKKK r=KKKKK",
+"KKKKKKKK @KKKKKK",
+"KKKKKKKK#KKKKKKK"
+};
Added: trunk/plugins/scintilla/plugin.c
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/plugin.c Wed Apr 8 22:31:22 2009
@@ -0,0 +1,157 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.c
+ Copyright (C) 2000 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <config.h>
+#include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-encodings.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
+#include <libanjuta/interfaces/ianjuta-file.h>
+#include <libanjuta/interfaces/ianjuta-file-savable.h>
+#include <libanjuta/interfaces/ianjuta-editor-factory.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+
+
+#include "aneditor.h"
+#include "lexer.h"
+#include "plugin.h"
+#include "style-editor.h"
+#include "text_editor.h"
+
+#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-editor-scintilla.glade"
+#define ICON_FILE "anjuta-editor-scintilla-plugin-48.png"
+
+gpointer parent_class;
+
+static void
+on_style_button_clicked(GtkWidget* button, AnjutaPreferences* prefs)
+{
+ StyleEditor* se = style_editor_new(prefs);
+ style_editor_show(se);
+}
+
+static gboolean
+activate_plugin (AnjutaPlugin *plugin)
+{
+ return TRUE;
+}
+
+static gboolean
+deactivate_plugin (AnjutaPlugin *plugin)
+{
+
+ return TRUE;
+}
+
+static void
+dispose (GObject *obj)
+{
+ /* EditorPlugin *eplugin = ANJUTA_PLUGIN_EDITOR (obj); */
+
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+finalize (GObject *obj)
+{
+ /* Finalization codes here */
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+editor_plugin_instance_init (GObject *obj)
+{
+ /* EditorPlugin *plugin = ANJUTA_PLUGIN_EDITOR (obj); */
+}
+
+static void
+editor_plugin_class_init (GObjectClass *klass)
+{
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ plugin_class->activate = activate_plugin;
+ plugin_class->deactivate = deactivate_plugin;
+ klass->dispose = dispose;
+ klass->finalize = finalize;
+}
+
+static IAnjutaEditor*
+itext_editor_factory_new_editor(IAnjutaEditorFactory* factory,
+ GFile* file,
+ const gchar* filename,
+ GError** error)
+{
+ AnjutaShell *shell = ANJUTA_PLUGIN (factory)->shell;
+ AnjutaPreferences *prefs = anjuta_shell_get_preferences (shell, NULL);
+ AnjutaStatus *status = anjuta_shell_get_status (shell, NULL);
+ /* file can be NULL, if we open a buffer, not a file */
+ gchar* uri = file ? g_file_get_uri (file) : NULL;
+ IAnjutaEditor* editor = IANJUTA_EDITOR(text_editor_new(status, prefs, shell,
+ uri, filename));
+ g_free(uri);
+ return editor;
+}
+
+static void
+itext_editor_factory_iface_init (IAnjutaEditorFactoryIface *iface)
+{
+ iface->new_editor = itext_editor_factory_new_editor;
+}
+
+static void
+ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
+{
+ GladeXML* gxml;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (ipref);
+ gxml = glade_xml_new (PREFS_GLADE, "preferences_dialog", NULL);
+ plugin->style_button = glade_xml_get_widget(gxml, "style_button");
+ g_signal_connect(G_OBJECT(plugin->style_button), "clicked",
+ G_CALLBACK(on_style_button_clicked), prefs);
+ anjuta_preferences_add_page (prefs,
+ gxml, "Editor", _("Scintilla Editor"), ICON_FILE);
+ g_object_unref(gxml);
+}
+
+static void
+ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
+{
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (ipref);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->style_button),
+ G_CALLBACK(on_style_button_clicked),
+ anjuta_shell_get_preferences(ANJUTA_PLUGIN(plugin)->shell, NULL));
+
+ anjuta_preferences_remove_page(prefs, _("Scintilla Editor"));
+}
+
+static void
+ipreferences_iface_init(IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+ANJUTA_PLUGIN_BEGIN (EditorPlugin, editor_plugin);
+ANJUTA_TYPE_ADD_INTERFACE(itext_editor_factory, IANJUTA_TYPE_EDITOR_FACTORY);
+ANJUTA_TYPE_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (EditorPlugin, editor_plugin);
Modified: trunk/plugins/scintilla/scintilla/Makefile.am
==============================================================================
--- trunk/plugins/scintilla/scintilla/Makefile.am (original)
+++ trunk/plugins/scintilla/scintilla/Makefile.am Wed Apr 8 22:31:22 2009
@@ -5,9 +5,12 @@
noinst_LTLIBRARIES = libanjuta-scintilla.la
AM_CPPFLAGS = \
+ $(LIBANJUTA_CFLAGS) \
$(GTK_CFLAGS) \
+ $(GLIB_CFLAGS) \
-I$(srcdir)/include \
-DGTK -DSCI_LEXER -DUSE_XIM
+
AM_CXXFLAGS = -DGTK -DSCI_LEXER -DUSE_XIM
include $(srcdir)/lexers.make
@@ -72,6 +75,7 @@
$(LEXER_SRCS)
libanjuta_scintilla_la_LIBADD = \
+ $(LIBANJUTA_LIBS) \
$(GLIB_LIBS) \
$(GTK_LIBS)
Added: trunk/plugins/scintilla/style-editor.c
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/style-editor.c Wed Apr 8 22:31:22 2009
@@ -0,0 +1,1032 @@
+/*
+ style-editor.c
+ Copyright (C) 2000 Naba Kumar <gnome.org>
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <ctype.h>
+#include <gnome.h>
+#include <glade/glade.h>
+
+#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/anjuta-debug.h>
+
+#include "text_editor.h"
+#include "style-editor.h"
+
+#define string_assign(dest, src) g_free ((*dest)); (*dest) = g_strdup ((src));
+#define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-editor-scintilla.glade"
+
+gchar *hilite_style[] = {
+ "Normal <Default>", "style.anjuta.normal",
+ "White space", "style.anjuta.whitespace",
+ "Comments", "style.anjuta.comment",
+ "Numbers", "style.anjuta.number",
+ "Operators","style.anjuta.operator",
+ "Keywords", "style.anjuta.keyword",
+ "System Keywords", "style.anjuta.syskeyword",
+ "Local Keywords", "style.anjuta.localkeyword",
+ "Additional Keywords", "style.anjuta.extrakeyword",
+ "Characters", "style.anjuta.char",
+ "Strings", "style.anjuta.string",
+ "Raw Strings", "style.anjuta.raws",
+ "Regular Expression", "style.anjuta.regex",
+ "Unclosed Strings", "style.anjuta.unclosed",
+ "Preprocessor Directives", "style.anjuta.preprocessor",
+ "Errors", "style.anjuta.error",
+ "Identifiers (Not C Style)", "style.anjuta.identifier",
+ "Definitions (Not C Style)", "style.anjuta.definition",
+ "Functions (Not C Style)", "style.anjuta.function",
+ "Attribute (Not C Style)", "style.anjuta.attribute",
+ "Matched Braces", "style.anjuta.matchbrace",
+ "Incomplete Brace", "style.anjuta.singlebrace",
+ "Control Characters", "style.anjuta.controlchar",
+ "Line Numbers", "style.anjuta.linenumber",
+ "Indentation Guides", "style.anjuta.indentguide",
+ NULL, NULL
+};
+
+typedef struct _StyleData StyleData;
+
+struct _StyleData
+{
+ gchar *item;
+ gchar *font;
+ gint size;
+ gboolean bold, italics, underlined;
+ gchar *fore, *back;
+ gboolean eolfilled;
+
+ gboolean font_use_default;
+ gboolean attrib_use_default;
+ gboolean fore_use_default;
+ gboolean back_use_default;
+};
+
+struct _StyleEditorPriv
+{
+ /* Widgets */
+ GtkWidget *dialog;
+ GtkWidget *hilite_item_combo;
+ GtkWidget *font_picker;
+ GtkWidget *font_bold_check;
+ GtkWidget *font_italics_check;
+ GtkWidget *font_underlined_check;
+ GtkWidget *fore_colorpicker;
+ GtkWidget *back_colorpicker;
+ GtkWidget *font_use_default_check;
+ GtkWidget *font_attrib_use_default_check;
+ GtkWidget *fore_color_use_default_check;
+ GtkWidget *back_color_use_default_check;
+ GtkWidget *caret_fore_color;
+ GtkWidget *selection_fore_color;
+ GtkWidget *selection_back_color;
+ GtkWidget *calltip_back_color;
+
+ /* Data */
+ StyleData *default_style;
+ StyleData *current_style;
+};
+
+static gchar *
+style_data_get_string (StyleData * sdata)
+{
+ gchar *tmp, *str;
+
+ g_return_val_if_fail (sdata != NULL, NULL);
+
+ str = NULL;
+ if ((sdata->font) && strlen (sdata->font) && sdata->font_use_default == FALSE)
+ {
+ str = g_strconcat ("font:", sdata->font, NULL);
+ }
+ if (sdata->size > 0 && sdata->font_use_default == FALSE)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str =
+ g_strdup_printf ("%s,size:%d", tmp,
+ sdata->size);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup_printf ("size:%d", sdata->size);
+
+ }
+ if (sdata->attrib_use_default == FALSE)
+ {
+ if (sdata->bold)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",bold", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("bold");
+ }
+ else
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",notbold", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("notbold");
+ }
+ if (sdata->italics)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",italics", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("italics");
+ }
+ else
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",notitalics", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("notitalics");
+ }
+ if (sdata->underlined)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",underlined", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("underlined");
+ }
+ else
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str =
+ g_strconcat (tmp, ",notunderlined",
+ NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("notunderlined");
+ }
+ if (sdata->eolfilled)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",eolfilled", NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("eolfilled");
+ }
+ else
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str =
+ g_strconcat (tmp, ",noteolfilled",
+ NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strdup ("noteolfilled");
+ }
+ }
+ if (sdata->fore_use_default == FALSE)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",fore:", sdata->fore, NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strconcat ("fore:", sdata->fore, NULL);
+ }
+ if (sdata->back_use_default == FALSE)
+ {
+ tmp = str;
+ if (tmp)
+ {
+ str = g_strconcat (tmp, ",back:", sdata->back, NULL);
+ g_free (tmp);
+ }
+ else
+ str = g_strconcat ("back:", sdata->back, NULL);
+ }
+ if (str == NULL)
+ str = g_strdup ("");
+ return str;
+}
+
+static void
+style_data_set_font (StyleData * sdata, const gchar *font)
+{
+ PangoFontDescription *desc;
+ const gchar *font_family;
+
+ g_return_if_fail (sdata);
+
+ desc = pango_font_description_from_string (font);
+ font_family = pango_font_description_get_family(desc);
+ string_assign (&sdata->font, font_family);
+
+ /* Change to lower case */
+ if (sdata->font)
+ {
+ gchar *s = sdata->font;
+ while(*s)
+ {
+ *s = tolower(*s);
+ s++;
+ }
+ }
+ pango_font_description_free (desc);
+}
+
+static void
+style_data_set_font_size_from_pango (StyleData * sdata, const gchar *font)
+{
+ PangoFontDescription *desc;
+
+ g_return_if_fail (sdata);
+
+ desc = pango_font_description_from_string (font);
+ sdata->size = pango_font_description_get_size (desc) / PANGO_SCALE;
+ pango_font_description_free (desc);
+}
+
+static void
+style_data_set_fore (StyleData * sdata, const gchar *fore)
+{
+ g_return_if_fail (sdata);
+ string_assign (&sdata->fore, fore);
+}
+
+static void
+style_data_set_back (StyleData * sdata, const gchar *back)
+{
+ g_return_if_fail (sdata);
+ string_assign (&sdata->back, back);
+}
+
+static void
+style_data_set_item (StyleData * sdata, const gchar *item)
+{
+ g_return_if_fail (sdata);
+ string_assign (&sdata->item, item);
+}
+
+static StyleData *
+style_data_new (void)
+{
+ StyleData *sdata;
+ sdata = g_new0 (StyleData, 1);
+
+ sdata->font = g_strdup ("");
+ sdata->size = 12;
+ sdata->font_use_default = TRUE;
+ sdata->attrib_use_default = TRUE;
+ sdata->fore_use_default = TRUE;
+ sdata->back_use_default = TRUE;
+ style_data_set_fore (sdata, "#000000"); /* Black */
+ style_data_set_back (sdata, "#FFFFFF"); /* White */
+ return sdata;
+}
+
+static void
+style_data_destroy (StyleData * sdata)
+{
+ if (!sdata)
+ return;
+ if (sdata->item)
+ g_free (sdata->item);
+ if (sdata->font)
+ g_free (sdata->font);
+ if (sdata->fore)
+ g_free (sdata->fore);
+ if (sdata->back)
+ g_free (sdata->back);
+ g_free (sdata);
+}
+
+static StyleData *
+style_data_new_parse (gchar * style_string)
+{
+ gchar *val, *opt;
+ StyleData *style_data;
+
+ style_data = style_data_new ();
+ if (!style_data)
+ return NULL;
+
+ val = (style_string != NULL)? g_strdup (style_string) : NULL;
+ opt = val;
+ while (opt)
+ {
+ gchar *cpComma, *colon;
+
+ cpComma = strchr (opt, ',');
+ if (cpComma)
+ *cpComma = '\0';
+ colon = strchr (opt, ':');
+ if (colon)
+ *colon++ = '\0';
+ if (0 == strcmp (opt, "italics"))
+ {
+ style_data->italics = TRUE;
+ style_data->attrib_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "notitalics"))
+ {
+ style_data->italics = FALSE;
+ style_data->attrib_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "bold"))
+ {
+ style_data->bold = TRUE;
+ style_data->attrib_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "notbold"))
+ {
+ style_data->bold = FALSE;
+ style_data->attrib_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "font"))
+ {
+ style_data_set_font (style_data, colon);
+ style_data->font_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "fore"))
+ {
+ style_data_set_fore (style_data, colon);
+ style_data->fore_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "back"))
+ {
+ style_data_set_back (style_data, colon);
+ style_data->back_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "size"))
+ {
+ style_data->size = atoi (colon);
+ style_data->font_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "eolfilled"))
+ style_data->eolfilled = TRUE;
+ if (0 == strcmp (opt, "noteolfilled"))
+ style_data->eolfilled = FALSE;
+ if (0 == strcmp (opt, "underlined"))
+ {
+ style_data->underlined = TRUE;
+ style_data->attrib_use_default = FALSE;
+ }
+ if (0 == strcmp (opt, "notunderlined"))
+ {
+ style_data->underlined = FALSE;
+ style_data->fore_use_default = FALSE;
+ }
+ if (cpComma)
+ opt = cpComma + 1;
+ else
+ opt = NULL;
+ }
+ if (val)
+ g_free (val);
+ return style_data;
+}
+
+static void
+on_use_default_font_toggled (GtkToggleButton * tb, gpointer data)
+{
+ StyleEditor *p;
+ gchar* font_name;
+ gboolean state;
+
+ g_return_if_fail (data);
+ p = data;
+
+ gtk_widget_set_sensitive (p->priv->font_picker, TRUE);
+ state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb));
+ if (state)
+ {
+ font_name = g_strdup_printf ("%s %d",
+ p->priv->default_style->font,
+ p->priv->default_style->size);
+ }
+ else
+ {
+ if (p->priv->current_style->font &&
+ strlen (p->priv->current_style->font))
+ {
+ font_name = g_strdup_printf ("%s %d",
+ p->priv->current_style->font,
+ p->priv->current_style->size);
+ }
+ else
+ {
+ font_name = g_strdup_printf ("%s %d",
+ p->priv->default_style->font,
+ p->priv->default_style->size);
+ }
+ }
+ gtk_widget_set_sensitive (p->priv->font_picker, !state);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (p->priv->font_picker),
+ font_name);
+ g_free(font_name);
+}
+
+static void
+on_use_default_attrib_toggled (GtkToggleButton * tb, gpointer data)
+{
+ StyleEditor *p;
+
+ g_return_if_fail (data);
+ p = data;
+ gtk_widget_set_sensitive (p->priv->font_bold_check, TRUE);
+ gtk_widget_set_sensitive (p->priv->font_italics_check, TRUE);
+ gtk_widget_set_sensitive (p->priv->font_underlined_check, TRUE);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb)))
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_bold_check),
+ p->priv->default_style->bold);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_italics_check),
+ p->priv->default_style->italics);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->
+ font_underlined_check),
+ p->priv->default_style->underlined);
+ gtk_widget_set_sensitive (p->priv->font_bold_check, FALSE);
+ gtk_widget_set_sensitive (p->priv->font_italics_check,
+ FALSE);
+ gtk_widget_set_sensitive (p->priv->font_underlined_check,
+ FALSE);
+ }
+ else
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_bold_check),
+ p->priv->current_style->bold);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_italics_check),
+ p->priv->current_style->italics);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->
+ font_underlined_check),
+ p->priv->current_style->underlined);
+ }
+}
+
+static void
+on_use_default_fore_toggled (GtkToggleButton * tb, gpointer data)
+{
+ StyleEditor *p;
+ GdkColor color;
+
+ g_return_if_fail (data);
+ p = data;
+
+ gtk_widget_set_sensitive (p->priv->fore_colorpicker, TRUE);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb)))
+ {
+ gdk_color_parse (p->priv->default_style->fore, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (p->priv->fore_colorpicker),
+ &color);
+ gtk_widget_set_sensitive (p->priv->fore_colorpicker, FALSE);
+ }
+ else
+ {
+ gdk_color_parse (p->priv->current_style->fore, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (p->priv->fore_colorpicker),
+ &color);
+ }
+}
+
+static void
+on_use_default_back_toggled (GtkToggleButton * tb, gpointer data)
+{
+ StyleEditor *p;
+ GdkColor color;
+
+ g_return_if_fail (data);
+ p = data;
+ gtk_widget_set_sensitive (p->priv->back_colorpicker, TRUE);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb)))
+ {
+ gdk_color_parse (p->priv->current_style->back, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (p->priv->back_colorpicker),
+ &color);
+ gtk_widget_set_sensitive (p->priv->back_colorpicker, FALSE);
+ }
+ else
+ {
+ gdk_color_parse (p->priv->default_style->back, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (p->priv->back_colorpicker),
+ &color);
+ }
+}
+
+static void
+on_hilite_style_entry_changed (GtkEditable * editable, gpointer user_data)
+{
+ StyleEditor *p;
+ const gchar *style_item;
+
+ g_return_if_fail (user_data);
+ p = user_data;
+
+ style_item = gtk_entry_get_text (GTK_ENTRY (editable));
+ if (!style_item || strlen (style_item) <= 0)
+ return;
+ if (p->priv->current_style)
+ {
+ GdkColor color;
+ gchar *str;
+ const gchar *font;
+
+ font = gtk_font_button_get_font_name (GTK_FONT_BUTTON
+ (p->priv->font_picker));
+ if (font)
+ {
+ style_data_set_font (p->priv->current_style, font);
+ style_data_set_font_size_from_pango (p->priv->current_style, font);
+ }
+ else
+ {
+ style_data_set_font (p->priv->current_style,
+ p->priv->default_style->font);
+ p->priv->current_style->size = p->priv->default_style->size;
+ }
+
+ p->priv->current_style->bold =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_bold_check));
+ p->priv->current_style->italics =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_italics_check));
+ p->priv->current_style->underlined =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_underlined_check));
+ p->priv->current_style->eolfilled =
+ (strcmp (style_item, hilite_style[1]) == 0);
+
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (p->priv->fore_colorpicker),
+ &color);
+ str = anjuta_util_string_from_color (color.red,
+ color.green,
+ color.blue);
+ style_data_set_fore (p->priv->current_style, str);
+ g_free (str);
+
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (p->priv->back_colorpicker),
+ &color);
+ str = anjuta_util_string_from_color (color.red,
+ color.green,
+ color.blue);
+ style_data_set_back (p->priv->current_style, str);
+ g_free (str);
+
+ p->priv->current_style->font_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_use_default_check));
+ p->priv->current_style->attrib_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_attrib_use_default_check));
+ p->priv->current_style->fore_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->fore_color_use_default_check));
+ p->priv->current_style->back_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (p->priv->back_color_use_default_check));
+ }
+ p->priv->current_style =
+ g_object_get_data (G_OBJECT (p->priv->dialog),
+ style_item);
+
+ g_return_if_fail (p->priv->current_style);
+
+ /* We need to first toggle then set active to work properly */
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON
+ (p->priv->font_use_default_check));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_use_default_check),
+ p->priv->current_style->font_use_default);
+
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON
+ (p->priv->font_attrib_use_default_check));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->font_attrib_use_default_check),
+ p->priv->current_style->attrib_use_default);
+
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON
+ (p->priv->fore_color_use_default_check));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->fore_color_use_default_check),
+ p->priv->current_style->fore_use_default);
+
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON
+ (p->priv->back_color_use_default_check));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (p->priv->back_color_use_default_check),
+ p->priv->current_style->back_use_default);
+}
+
+static void
+sync_from_props (StyleEditor *se)
+{
+ gint i;
+ gchar *str;
+
+ g_return_if_fail (se);
+ /* Never hurts to use g_object_*_data as temp hash buffer */
+ for (i = 0;; i += 2)
+ {
+ StyleData *sdata;
+
+ if (hilite_style[i] == NULL)
+ break;
+ str = sci_prop_get_expanded (se->props, hilite_style[i + 1]);
+ sdata = style_data_new_parse (str);
+ /* DEBUG_PRINT ("Parsing %s => %s", hilite_style[i + 1], str); */
+ if (str)
+ g_free (str);
+
+ style_data_set_item (sdata, hilite_style[i]);
+ g_object_set_data_full (G_OBJECT (se->priv->dialog),
+ hilite_style[i], sdata,
+ (GtkDestroyNotify)style_data_destroy);
+ }
+ se->priv->default_style =
+ gtk_object_get_data (GTK_OBJECT (se->priv->dialog),
+ hilite_style[0]);
+ se->priv->current_style = NULL;
+
+ on_hilite_style_entry_changed (GTK_EDITABLE (GTK_COMBO
+ (se->priv->hilite_item_combo)->entry), se);
+
+ str = sci_prop_get (se->props, CARET_FORE_COLOR);
+ if(str)
+ {
+ GdkColor color;
+
+ gdk_color_parse (str, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->caret_fore_color),
+ &color);
+ g_free (str);
+ }
+ else
+ {
+ GdkColor color;
+
+ gdk_color_parse ("#000000", &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->caret_fore_color),
+ &color);
+ }
+
+ str = sci_prop_get (se->props, CALLTIP_BACK_COLOR);
+ if(str)
+ {
+ GdkColor color;
+
+ gdk_color_parse (str, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->calltip_back_color),
+ &color);
+ g_free (str);
+ }
+ else
+ {
+ GdkColor color;
+
+ gdk_color_parse ("#E6D6B6", &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->calltip_back_color),
+ &color);
+ }
+
+ str = sci_prop_get (se->props, SELECTION_FORE_COLOR);
+ if(str)
+ {
+ GdkColor color;
+
+ gdk_color_parse (str, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_fore_color),
+ &color);
+ g_free (str);
+ }
+ else
+ {
+ GdkColor color;
+
+ gdk_color_parse ("#FFFFFF", &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_fore_color),
+ &color);
+ }
+
+ str = sci_prop_get (se->props, SELECTION_BACK_COLOR);
+ if(str)
+ {
+ GdkColor color;
+
+ gdk_color_parse (str, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_back_color),
+ &color);
+ g_free (str);
+ }
+ else
+ {
+ GdkColor color;
+
+ gdk_color_parse ("#000000", &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_back_color),
+ &color);
+ }
+}
+
+static void
+set_one_color (PropsID props, gchar *key, GtkWidget *picker)
+{
+ GdkColor color;
+ gchar *str;
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (picker), &color);
+ str = anjuta_util_string_from_color (color.red,
+ color.green,
+ color.blue);
+ if(str)
+ {
+ sci_prop_set_with_key (props, key, str);
+ g_free (str);
+ }
+}
+
+static void
+sync_to_props (StyleEditor *se)
+{
+ gint i;
+ gchar *str;
+
+ g_return_if_fail (se);
+ /* Sync the current item */
+ on_hilite_style_entry_changed (GTK_EDITABLE (GTK_COMBO
+ (se->priv->hilite_item_combo)->entry), se);
+
+ /* Transfer to props */
+ for (i = 0;; i += 2)
+ {
+ StyleData *sdata;
+
+ if (hilite_style[i] == NULL)
+ break;
+ sdata =
+ gtk_object_get_data (GTK_OBJECT (se->priv->dialog),
+ hilite_style[i]);
+ str = style_data_get_string (sdata);
+ if (str)
+ {
+ sci_prop_set_with_key (se->props, hilite_style[i + 1], str);
+ g_free (str);
+ }
+ }
+ set_one_color (se->props, CARET_FORE_COLOR,
+ se->priv->caret_fore_color);
+
+ set_one_color (se->props, CALLTIP_BACK_COLOR,
+ se->priv->calltip_back_color);
+
+ set_one_color (se->props, SELECTION_FORE_COLOR,
+ se->priv->selection_fore_color);
+
+ set_one_color (se->props, SELECTION_BACK_COLOR,
+ se->priv->selection_back_color);
+}
+
+static void
+apply_styles (StyleEditor *se)
+{
+ FILE *ofile;
+ gchar *filename;
+
+ sync_to_props (se);
+ filename = anjuta_util_get_user_config_file_path ("scintilla","editor-style.properties",NULL);
+ ofile = fopen (filename, "w");
+ if (!ofile) {
+ DEBUG_PRINT ("Could not open %s for writing", filename);
+ } else {
+ style_editor_save (se, ofile);
+ fclose (ofile);
+ g_free (filename);
+ }
+ anjuta_preferences_set_int (se->prefs, DISABLE_SYNTAX_HILIGHTING, 1);
+ anjuta_preferences_set_int (se->prefs, DISABLE_SYNTAX_HILIGHTING, 0);
+}
+
+static void
+on_response (GtkWidget *dialog, gint res, StyleEditor *se)
+{
+ g_return_if_fail (se);
+
+ switch (res)
+ {
+ case GTK_RESPONSE_APPLY:
+ apply_styles (se);
+ return;
+ case GTK_RESPONSE_OK:
+ apply_styles (se);
+ case GTK_RESPONSE_CANCEL:
+ style_editor_hide (se);
+ return;
+ }
+}
+
+static void
+on_delete_event (GtkWidget *dialog, GdkEvent *event, StyleEditor *se)
+{
+ g_return_if_fail (se);
+ style_editor_hide (se);
+}
+
+static void
+create_style_editor_gui (StyleEditor * se)
+{
+ GladeXML *gxml;
+ GtkWidget *pref_dialog;
+ GList *list = NULL;
+ gint i;
+
+ g_return_if_fail (se);
+ g_return_if_fail (se->priv->dialog == NULL);
+
+ gxml = glade_xml_new (GLADE_FILE, "style_editor_dialog", NULL);
+ se->priv->dialog = glade_xml_get_widget (gxml, "style_editor_dialog");
+ gtk_widget_show (se->priv->dialog);
+ se->priv->font_picker = glade_xml_get_widget (gxml, "font");
+ se->priv->hilite_item_combo = glade_xml_get_widget (gxml, "combo");
+ se->priv->font_bold_check = glade_xml_get_widget (gxml, "bold");
+ se->priv->font_italics_check = glade_xml_get_widget (gxml, "italic");
+ se->priv->font_underlined_check = glade_xml_get_widget (gxml, "underlined");
+ se->priv->fore_colorpicker = glade_xml_get_widget (gxml, "fore_color");
+ se->priv->back_colorpicker = glade_xml_get_widget (gxml, "back_color");
+ se->priv->font_use_default_check = glade_xml_get_widget (gxml, "font_default");
+ se->priv->font_attrib_use_default_check = glade_xml_get_widget (gxml, "attributes_default");
+ se->priv->fore_color_use_default_check = glade_xml_get_widget (gxml, "fore_default");
+ se->priv->back_color_use_default_check = glade_xml_get_widget (gxml, "back_default");
+ se->priv->caret_fore_color = glade_xml_get_widget (gxml, "caret");
+ se->priv->calltip_back_color = glade_xml_get_widget (gxml, "calltip");
+ se->priv->selection_fore_color = glade_xml_get_widget (gxml, "selection_fore");
+ se->priv->selection_back_color = glade_xml_get_widget (gxml, "selection_back");
+
+ for (i = 0;; i += 2)
+ {
+ if (hilite_style[i] == NULL)
+ break;
+ list = g_list_append (list, hilite_style[i]);
+ }
+ gtk_combo_set_popdown_strings (GTK_COMBO (se->priv->hilite_item_combo), list);
+ g_list_free (list);
+
+ pref_dialog = anjuta_preferences_get_dialog (se->prefs);
+ gtk_window_set_transient_for (GTK_WINDOW (se->priv->dialog),
+ GTK_WINDOW (pref_dialog));
+
+ g_signal_connect (G_OBJECT (GTK_COMBO(se->priv->hilite_item_combo)->entry),
+ "changed", G_CALLBACK (on_hilite_style_entry_changed),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->font_use_default_check),
+ "toggled", G_CALLBACK (on_use_default_font_toggled),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->font_attrib_use_default_check),
+ "toggled", G_CALLBACK (on_use_default_attrib_toggled),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->fore_color_use_default_check),
+ "toggled", G_CALLBACK (on_use_default_fore_toggled),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->back_color_use_default_check),
+ "toggled", G_CALLBACK (on_use_default_back_toggled),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->dialog),
+ "delete_event", G_CALLBACK (on_delete_event),
+ se);
+ g_signal_connect (G_OBJECT (se->priv->dialog),
+ "response", G_CALLBACK (on_response),
+ se);
+ g_object_unref (gxml);
+}
+
+StyleEditor *
+style_editor_new (AnjutaPreferences *prefs)
+{
+ StyleEditor *se;
+ se = g_new0 (StyleEditor, 1);
+ se->priv = g_new0 (StyleEditorPriv, 1);
+ se->props = text_editor_get_props ();
+ se->priv->dialog = NULL;
+ se->prefs = prefs;
+ return se;
+}
+
+void style_editor_destroy (StyleEditor *se)
+{
+ g_return_if_fail (se);
+ if (se->priv->dialog)
+ gtk_widget_destroy (se->priv->dialog);
+ g_free (se->priv);
+ g_free (se);
+}
+
+void style_editor_show (StyleEditor *se)
+{
+ g_return_if_fail (se);
+ if (se->priv->dialog)
+ return;
+ create_style_editor_gui (se);
+ sync_from_props (se);
+}
+
+void style_editor_hide (StyleEditor *se)
+{
+ g_return_if_fail (se);
+ g_return_if_fail (se->priv->dialog);
+ gtk_widget_destroy (se->priv->dialog);
+ se->priv->dialog = NULL;
+}
+
+void
+style_editor_save (StyleEditor *se, FILE *fp)
+{
+ gint i;
+ gchar *str;
+
+ for (i = 0;; i += 2)
+ {
+ if (hilite_style[i] == NULL)
+ break;
+ str = sci_prop_get (se->props, hilite_style[i + 1]);
+ if (str)
+ {
+ fprintf (fp, "%s=%s\n", hilite_style[i + 1], str);
+ g_free (str);
+ }
+ /* else
+ fprintf (fp, "%s=\n", hilite_style[i + 1]); */
+ }
+ str = sci_prop_get (se->props, CARET_FORE_COLOR);
+ if(str)
+ {
+ fprintf (fp, "%s=%s\n", CARET_FORE_COLOR, str);
+ g_free (str);
+ }
+
+ str = sci_prop_get (se->props, CALLTIP_BACK_COLOR);
+ if(str)
+ {
+ fprintf (fp, "%s=%s\n", CALLTIP_BACK_COLOR, str);
+ g_free (str);
+ }
+
+ str = sci_prop_get (se->props, SELECTION_FORE_COLOR);
+ if(str)
+ {
+ fprintf (fp, "%s=%s\n", SELECTION_FORE_COLOR, str);
+ g_free (str);
+ }
+
+ str = sci_prop_get (se->props, SELECTION_BACK_COLOR);
+ if(str)
+ {
+ fprintf (fp, "%s=%s\n", SELECTION_BACK_COLOR, str);
+ g_free (str);
+ }
+}
Added: trunk/plugins/scintilla/style-editor.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/style-editor.h Wed Apr 8 22:31:22 2009
@@ -0,0 +1,56 @@
+/*
+ style-editor.h
+ Copyright (C) 2000 Naba Kumar <gnome.org>
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _STYLE_EDITOR_H_
+#define _STYLE_EDITOR_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libanjuta/anjuta-preferences.h>
+#include "properties.h"
+
+typedef struct _StyleEditor StyleEditor;
+typedef struct _StyleEditorPriv StyleEditorPriv;
+
+struct _StyleEditor
+{
+ /*
+ PropsID props_global;
+ PropsID props_local;
+ PropsID props_session;
+ */
+ PropsID props;
+ StyleEditorPriv *priv;
+ AnjutaPreferences *prefs;
+};
+
+StyleEditor *
+style_editor_new (AnjutaPreferences *prefs);
+
+void style_editor_destroy (StyleEditor *se);
+
+void style_editor_show (StyleEditor *se);
+
+void style_editor_hide (StyleEditor *se);
+
+void style_editor_save (StyleEditor *se, FILE *stream);
+
+#endif
Added: trunk/plugins/scintilla/text-editor-iterable.c
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/text-editor-iterable.c Wed Apr 8 22:31:22 2009
@@ -0,0 +1,735 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * text-editor-iterable.c
+ * Copyright (C) 2000 Kh. Naba Kumar Singh
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-iterable.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-editor-cell.h>
+#include <libanjuta/interfaces/ianjuta-editor-cell-style.h>
+
+#define GTK
+#undef PLAT_GTK
+#define PLAT_GTK 1
+
+#include <gtk/gtk.h>
+#include "Scintilla.h"
+#include "ScintillaWidget.h"
+#include "properties.h"
+#include "text-editor-iterable.h"
+
+#define TEXT_CELL_FONT_BODY_DEFAULT "courier"
+#define TEXT_CELL_FONT_HEADER_DEFAULT "helvetica"
+#define TEXT_CELL_FONT_SIZE_BODY_DEFAULT 10
+#define TEXT_CELL_FONT_SIZE_HEADER_DEFALT 10
+#define TEXT_CELL_FONT_SIZE_NUMBERS_DEFAULT 6
+#define TEXT_CELL_MAX_STYLES 256
+#define TEXT_CELL_LINENUMBER_STYLE 33
+#define TEXT_CELL_DEFAULT_TEXT_STYLE 32
+#define TEXT_CELL_LINENUM_PADDING '0'
+
+static void text_editor_cell_class_init(TextEditorCellClass *klass);
+static void text_editor_cell_instance_init(TextEditorCell *sp);
+static void text_editor_cell_finalize(GObject *object);
+
+static gpointer parent_class;
+
+typedef struct _CellStyle
+{
+ gchar *font_desc;
+
+ gchar *font_name;
+ gboolean italics;
+ gboolean bold;
+ gint size;
+
+ GdkColor fore_color;
+ GdkColor back_color;
+
+} CellStyle;
+
+struct _TextEditorCellPrivate {
+ TextEditor *editor;
+
+ /* byte position in editor */
+ gint position;
+
+ /* Character position */
+ /* gint char_position; */
+
+ /* Styles cache */
+ CellStyle* styles_pool[TEXT_CELL_MAX_STYLES];
+};
+
+/* Style processing */
+
+static const CellStyle* text_editor_cell_get_style (TextEditorCell *cell, gint style);
+
+static void
+cell_style_destroy (CellStyle *pis) {
+ if (pis) {
+ if (pis->font_desc) g_free (pis->font_desc);
+ if (pis->font_name) g_free (pis->font_name);
+ g_free(pis);
+ }
+}
+
+static int
+IntFromHexDigit(const char ch) {
+ if (isdigit(ch))
+ return ch - '0';
+ else if (ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 10;
+ else if (ch >= 'a' && ch <= 'f')
+ return ch - 'a' + 10;
+ else
+ return 0;
+}
+
+static void
+string_to_color (const char *val, GdkColor* color)
+{
+ /* g_print ("Color = %s\n", val); */
+ color->red = IntFromHexDigit(val[1]) * 16 + IntFromHexDigit(val[2]);
+ color->green = IntFromHexDigit(val[3]) * 16 + IntFromHexDigit(val[4]);
+ color->blue = IntFromHexDigit(val[5]) * 16 + IntFromHexDigit(val[6]);
+}
+
+static void
+cell_style_load_font (CellStyle *pis)
+{
+ gchar *font_desc, *tmp;
+ gint size = 12;
+
+ g_return_if_fail (pis->font_name);
+
+ font_desc = g_strdup (pis->font_name);
+ if (pis->bold)
+ {
+ tmp = font_desc;
+ font_desc = g_strconcat (tmp, " Bold", NULL);
+ g_free (tmp);
+ }
+ if (pis->italics)
+ {
+ tmp = font_desc;
+ font_desc = g_strconcat (tmp, " Italic", NULL);
+ g_free (tmp);
+ }
+ if (pis->size > 0)
+ {
+ size = pis->size;
+ tmp = font_desc;
+ font_desc = g_strdup_printf ("%s %d", tmp, pis->size);
+ g_free (tmp);
+ }
+ g_free (pis->font_desc);
+ pis->font_desc = font_desc;
+}
+
+static void
+cell_style_init (CellStyle *pis, PropsID prop, gchar* lang, guint style)
+{
+ gchar *style_key, *style_string, *val, *opt;
+
+ style_key = g_strdup_printf ("style.%s.%0d", lang, style);
+ style_string = sci_prop_get_expanded (prop, style_key);
+ g_free (style_key);
+ if (!style_string) return;
+
+ val = g_strdup(style_string);
+ opt = val;
+
+ while (opt) {
+ char *cpComma, *colon;
+
+ cpComma = strchr(opt, ',');
+ if (cpComma)
+ *cpComma = '\0';
+ colon = strchr(opt, ':');
+ if (colon)
+ *colon++ = '\0';
+
+ if (0 == strcmp(opt, "italics"))
+ pis->italics = TRUE;
+ if (0 == strcmp(opt, "notitalics"))
+ pis->italics = FALSE;
+ if (0 == strcmp(opt, "bold"))
+ pis->bold = TRUE;
+ if (0 == strcmp(opt, "notbold"))
+ pis->bold = FALSE;
+ if (0 == strcmp(opt, "font")) {
+ g_free (pis->font_name);
+ pis->font_name = g_strdup(colon);
+ }
+ if (0 == strcmp(opt, "fore"))
+ string_to_color(colon, &pis->fore_color);
+ if (0 == strcmp(opt, "back"))
+ string_to_color(colon, &pis->back_color);
+ if (0 == strcmp(opt, "size"))
+ pis->size = atoi(colon);
+ if (cpComma)
+ opt = cpComma + 1;
+ else
+ opt = 0;
+ }
+ g_free(val);
+ g_free(style_string);
+}
+
+static CellStyle*
+cell_style_new (PropsID prop, gchar* lang, guint style, gint font_zoom_factor)
+{
+ CellStyle* pis;
+
+ g_return_val_if_fail (prop > 0, NULL);
+ g_return_val_if_fail (style < 256, NULL);
+
+ pis = g_new0 (CellStyle, 1);
+
+ pis->font_name = g_strdup(TEXT_CELL_FONT_BODY_DEFAULT);
+ pis->bold = FALSE;
+ pis->italics = FALSE;
+ pis->size = TEXT_CELL_FONT_SIZE_BODY_DEFAULT;
+
+ /* Black */
+ pis->fore_color.red = 0;
+ pis->fore_color.green = 0;
+ pis->fore_color.blue = 0;
+
+ /* White */
+ pis->back_color.red = (gushort)(-1);
+ pis->back_color.green = (gushort)(-1);
+ pis->back_color.blue = (gushort)(-1);
+
+ /* Set default style first */
+ cell_style_init (pis, prop, "*", 32);
+ if (lang && strlen(lang) > 0) {
+ cell_style_init (pis, prop, lang, 32);
+ }
+ /* Then the specific style */
+ cell_style_init (pis, prop, "*", style);
+ if (lang && strlen(lang) > 0) {
+ cell_style_init (pis, prop, lang, style);
+ }
+
+ pis->size += font_zoom_factor;
+
+ cell_style_load_font (pis);
+ return pis;
+}
+
+static const CellStyle*
+text_editor_cell_get_style (TextEditorCell *cell, gint style)
+{
+ CellStyle* pis;
+
+ pis = cell->priv->styles_pool[style];
+
+ if (!pis)
+ {
+ gchar* language; /* should it be freed ?*/
+ language = (gchar*) aneditor_command(cell->priv->editor->editor_id,
+ ANE_GETLANGUAGE,0, 0);
+ cell_style_new (cell->priv->editor->props_base,
+ language, style, cell->priv->editor->zoom_factor);
+ cell->priv->styles_pool[style] = pis;
+ }
+ if (!pis && style != TEXT_CELL_DEFAULT_TEXT_STYLE) {
+ return text_editor_cell_get_style (cell, TEXT_CELL_DEFAULT_TEXT_STYLE);
+ }
+ return pis;
+}
+
+
+/* TextEditorCell implementation */
+
+static void
+text_editor_cell_class_init (TextEditorCellClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = text_editor_cell_finalize;
+}
+
+static void
+text_editor_cell_instance_init (TextEditorCell *obj)
+{
+ obj->priv = g_new0(TextEditorCellPrivate, 1);
+ /* Initialize private members, etc. */
+}
+
+static void
+text_editor_cell_finalize (GObject *object)
+{
+ gint i;
+ TextEditorCell *cobj;
+ cobj = TEXT_EDITOR_CELL(object);
+
+ g_object_unref (cobj->priv->editor);
+
+ for (i = 0; i < TEXT_CELL_MAX_STYLES; i++)
+ {
+ if (cobj->priv->styles_pool[i])
+ cell_style_destroy (cobj->priv->styles_pool[i]);
+ }
+ g_free(cobj->priv);
+ if (G_OBJECT_CLASS(parent_class)->finalize)
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+TextEditorCell *
+text_editor_cell_new (TextEditor* editor, gint position)
+{
+ TextEditorCell *obj;
+
+ g_return_val_if_fail (IS_TEXT_EDITOR (editor), NULL);
+ g_return_val_if_fail (position >= 0, NULL);
+
+ obj = TEXT_EDITOR_CELL(g_object_new(TYPE_TEXT_EDITOR_CELL, NULL));
+
+ g_object_ref (editor);
+ obj->priv->editor = editor;
+ text_editor_cell_set_position (obj, position);
+ return obj;
+}
+
+TextEditor*
+text_editor_cell_get_editor (TextEditorCell *cell)
+{
+ g_return_val_if_fail (IS_TEXT_EDITOR_CELL(cell), NULL);
+ return cell->priv->editor;
+}
+
+void
+text_editor_cell_set_position (TextEditorCell *cell, gint position)
+{
+ guchar ch;
+ g_return_if_fail (IS_TEXT_EDITOR_CELL(cell));
+ g_return_if_fail (position >= 0);
+
+ cell->priv->position = position;
+
+ /* Ensure that utf character is properly aligned */
+ ch = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETCHARAT,
+ position, 0);
+ /* DEBUG_PRINT ("Iterator position set at %d where char '%c' is found", position, ch); */
+ if ((ch >= 0x80) && (ch < (0x80 + 0x40)))
+ {
+ /* un-aligned. Align it */
+ cell->priv->position = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONBEFORE,
+ position,
+ 0);
+ }
+}
+
+gint
+text_editor_cell_get_position (TextEditorCell *cell)
+{
+ g_return_val_if_fail (IS_TEXT_EDITOR_CELL(cell), -1);
+ return cell->priv->position;
+}
+
+/* IAnjutaIterable implementation */
+
+static gchar*
+icell_get_character (IAnjutaEditorCell* icell, GError** e)
+{
+ gint position_end;
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell);
+ position_end = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONAFTER,
+ cell->priv->position, 0);
+ return (gchar*) scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETTEXT, cell->priv->position,
+ position_end);
+}
+
+static gint
+icell_get_length (IAnjutaEditorCell* icell, GError** e)
+{
+ gint position_end;
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell);
+ position_end = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONAFTER,
+ cell->priv->position, 0);
+ return position_end - cell->priv->position;
+}
+
+static gchar
+icell_get_char (IAnjutaEditorCell* icell, gint index, GError** e)
+{
+ gint c;
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell);
+ c = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETCHARAT, cell->priv->position, 0);
+ return (gchar) (c);
+}
+
+static IAnjutaEditorAttribute
+icell_get_attribute (IAnjutaEditorCell *icell, GError **e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell);
+ IAnjutaEditorAttribute attrib = IANJUTA_EDITOR_TEXT;
+ TextEditorAttrib text_attrib =
+ text_editor_get_attribute (cell->priv->editor, cell->priv->position);
+ switch (text_attrib)
+ {
+ case TEXT_EDITOR_ATTRIB_TEXT:
+ attrib = IANJUTA_EDITOR_TEXT;
+ break;
+ case TEXT_EDITOR_ATTRIB_COMMENT:
+ attrib = IANJUTA_EDITOR_COMMENT;
+ break;
+ case TEXT_EDITOR_ATTRIB_KEYWORD:
+ attrib = IANJUTA_EDITOR_KEYWORD;
+ break;
+ case TEXT_EDITOR_ATTRIB_STRING:
+ attrib = IANJUTA_EDITOR_STRING;
+ break;
+ }
+ return attrib;
+}
+
+static void
+icell_iface_init (IAnjutaEditorCellIface* iface)
+{
+ iface->get_character = icell_get_character;
+ iface->get_char = icell_get_char;
+ iface->get_attribute = icell_get_attribute;
+ iface->get_length = icell_get_length;
+}
+
+static gchar*
+icell_style_get_font_description (IAnjutaEditorCellStyle* icell_style, GError ** e)
+{
+ gint style;
+ const CellStyle *cell_style;
+
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell_style);
+ style = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETSTYLEAT, cell->priv->position, 0);
+ cell_style = text_editor_cell_get_style (cell, style);
+
+ return g_strdup (cell_style->font_desc);
+}
+
+static gchar*
+icell_style_get_color (IAnjutaEditorCellStyle* icell_style, GError ** e)
+{
+ gint style;
+ const CellStyle *cell_style;
+
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell_style);
+ style = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETSTYLEAT, cell->priv->position, 0);
+ cell_style = text_editor_cell_get_style (cell, style);
+
+ return anjuta_util_string_from_color (cell_style->fore_color.red,
+ cell_style->fore_color.green,
+ cell_style->fore_color.blue);
+}
+
+static gchar*
+icell_style_get_background_color (IAnjutaEditorCellStyle* icell_style, GError ** e)
+{
+ gint style;
+ const CellStyle *cell_style;
+
+ TextEditorCell* cell = TEXT_EDITOR_CELL(icell_style);
+ style = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETSTYLEAT, cell->priv->position, 0);
+ cell_style = text_editor_cell_get_style (cell, style);
+
+ return anjuta_util_string_from_color (cell_style->back_color.red,
+ cell_style->back_color.green,
+ cell_style->back_color.blue);
+}
+
+static void
+icell_style_iface_init (IAnjutaEditorCellStyleIface* iface)
+{
+ iface->get_font_description = icell_style_get_font_description;
+ iface->get_color = icell_style_get_color;
+ iface->get_background_color = icell_style_get_background_color;
+}
+
+/* IAnjutaIterable implementation */
+
+static gboolean
+iiter_first (IAnjutaIterable* iter, GError** e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+ cell->priv->position = 0;
+ return TRUE;
+}
+
+static gboolean
+iiter_next (IAnjutaIterable* iter, GError** e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+ gint old_position;
+
+ old_position = cell->priv->position;
+ cell->priv->position = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONAFTER, old_position,
+ 0);
+ if (old_position == cell->priv->position)
+ return FALSE;
+ return TRUE;
+}
+
+static gboolean
+iiter_previous (IAnjutaIterable* iter, GError** e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+ /*
+ gint saved_pos = cell->priv->position;
+ */
+
+ if (cell->priv->position <= 0)
+ {
+ return FALSE;
+ }
+ cell->priv->position = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONBEFORE,
+ cell->priv->position,
+ 0);
+ /*
+ DEBUG_PRINT ("Iterator position changed from %d to %d", saved_pos,
+ cell->priv->position);
+ */
+ return TRUE;
+}
+
+static gboolean
+iiter_last (IAnjutaIterable* iter, GError** e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+ cell->priv->position =
+ scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETLENGTH, 0, 0);
+ return TRUE;
+}
+
+static void
+iiter_foreach (IAnjutaIterable* iter, GFunc callback, gpointer data, GError** e)
+{
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+ gint saved;
+
+ /* Save current position */
+ saved = cell->priv->position;
+ cell->priv->position = 0;
+ while (ianjuta_iterable_next (iter, NULL))
+ {
+ (*callback)(cell, data);
+ }
+
+ /* Restore current position */
+ cell->priv->position = saved;
+}
+
+static gboolean
+iiter_set_position (IAnjutaIterable* iter, gint position, GError** e)
+{
+ gboolean within_range = TRUE;
+ gint new_byte_position = 0;
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+
+ if (position > 0)
+ {
+ const gchar *buffer;
+ glong length;
+
+ buffer = (const gchar *)scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla), SCI_GETCHARACTERPOINTER, 0, 0);
+ length = g_utf8_strlen (buffer, -1);
+
+ if (position < length)
+ {
+ gchar *pos;
+
+ pos = g_utf8_offset_to_pointer (buffer, position);
+ new_byte_position = pos - buffer;
+ }
+ else
+ {
+ position = -1;
+ within_range = FALSE;
+ }
+ }
+
+ if (position < 0)
+ {
+ /* Set to end-iter (length of the doc) */
+ new_byte_position =
+ scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETLENGTH, 0, 0);
+ }
+
+ cell->priv->position = new_byte_position;
+ DEBUG_PRINT ("Editor byte position set at: %d", cell->priv->position);
+ return within_range;
+}
+
+static gint
+iiter_get_position (IAnjutaIterable* iter, GError** e)
+{
+ gint char_position = 0;
+
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+
+ /* FIXME: Find a more optimal solution */
+ if (cell->priv->position > 0)
+ {
+ gchar *data =
+ (gchar *) aneditor_command (TEXT_EDITOR
+ (cell->priv->editor)->editor_id,
+ ANE_GETTEXTRANGE, 0,
+ cell->priv->position);
+ char_position = g_utf8_strlen (data, -1);
+ g_free (data);
+ }
+ DEBUG_PRINT ("Byte pos = %d, char position = %d", cell->priv->position,
+ char_position);
+ return char_position;
+}
+
+static gint
+iiter_get_length (IAnjutaIterable* iter, GError** e)
+{
+ gint byte_length;
+
+ TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
+
+ /* FIXME: Find a more optimal solution */
+ byte_length = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_GETLENGTH, 0, 0);
+ if (byte_length > 0)
+ {
+ gchar *data;
+ gint char_length;
+
+ data = (gchar *) aneditor_command (TEXT_EDITOR
+ (cell->priv->editor)->editor_id,
+ ANE_GETTEXTRANGE, 0, byte_length);
+ char_length = g_utf8_strlen (data, -1);
+ g_free (data);
+ return char_length;
+ }
+ return 0;
+}
+
+static IAnjutaIterable *
+iiter_clone (IAnjutaIterable *iter, GError **e)
+{
+ TextEditorCell *src = TEXT_EDITOR_CELL (iter);
+ TextEditorCell *cell = text_editor_cell_new (src->priv->editor,
+ src->priv->position);
+ return IANJUTA_ITERABLE (cell);
+}
+
+static void
+iiter_assign (IAnjutaIterable *iter, IAnjutaIterable *src_iter, GError **e)
+{
+ TextEditorCell *cell = TEXT_EDITOR_CELL (iter);
+ TextEditorCell *src = TEXT_EDITOR_CELL (src_iter);
+ cell->priv->editor = src->priv->editor;
+ cell->priv->position = src->priv->position;
+}
+
+static gint
+iiter_compare (IAnjutaIterable *iter, IAnjutaIterable *iter2, GError **e)
+{
+ gint delta;
+ TextEditorCell *cell = TEXT_EDITOR_CELL (iter);
+ TextEditorCell *cell2 = TEXT_EDITOR_CELL (iter2);
+ delta = cell->priv->position - cell2->priv->position;
+ return (delta == 0)? 0 : ((delta > 0)? 1 : -1);
+}
+
+static gint
+iiter_diff (IAnjutaIterable *iter, IAnjutaIterable *iter2, GError **e)
+{
+ gint diff = 0;
+ TextEditorCell *cell = TEXT_EDITOR_CELL (iter);
+ TextEditorCell *cell2 = TEXT_EDITOR_CELL (iter2);
+
+ if (cell->priv->position == cell2->priv->position)
+ {
+ return 0;
+ }
+
+ /* FIXME: Find more optimal solution */
+ /* Iterate until we reach larger iter position */
+ if (cell->priv->position > cell2->priv->position)
+ {
+ gint byte_position = cell2->priv->position;
+ while (byte_position < cell->priv->position)
+ {
+ byte_position =
+ scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONAFTER, byte_position, 0);
+ diff--;
+ }
+ }
+ else
+ {
+ gint byte_position = cell->priv->position;
+ while (byte_position < cell2->priv->position)
+ {
+ byte_position =
+ scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+ SCI_POSITIONAFTER, byte_position, 0);
+ diff++;
+ }
+ }
+ return diff;
+}
+
+static void
+iiter_iface_init(IAnjutaIterableIface* iface)
+{
+ iface->first = iiter_first;
+ iface->next = iiter_next;
+ iface->previous = iiter_previous;
+ iface->last = iiter_last;
+ iface->foreach = iiter_foreach;
+ iface->set_position = iiter_set_position;
+ iface->get_position = iiter_get_position;
+ iface->get_length = iiter_get_length;
+ iface->clone = iiter_clone;
+ iface->assign = iiter_assign;
+ iface->compare = iiter_compare;
+ iface->diff = iiter_diff;
+}
+
+ANJUTA_TYPE_BEGIN(TextEditorCell, text_editor_cell, G_TYPE_OBJECT);
+ANJUTA_TYPE_ADD_INTERFACE(icell, IANJUTA_TYPE_EDITOR_CELL);
+ANJUTA_TYPE_ADD_INTERFACE(icell_style, IANJUTA_TYPE_EDITOR_CELL_STYLE);
+ANJUTA_TYPE_ADD_INTERFACE(iiter, IANJUTA_TYPE_ITERABLE);
+ANJUTA_TYPE_END;
Modified: trunk/plugins/scintilla/text_editor.c
==============================================================================
--- trunk/plugins/scintilla/text_editor.c (original)
+++ trunk/plugins/scintilla/text_editor.c Wed Apr 8 22:31:22 2009
@@ -25,11 +25,9 @@
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
-#include <stdlib.h>
#include <ctype.h>
#include <gio/gio.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
+#include <gnome.h>
#include <errno.h>
#include <libanjuta/resources.h>
@@ -132,7 +130,7 @@
te->props_base = 0;
te->first_time_expose = TRUE;
te->encoding = NULL;
- te->notify_ids = NULL;
+ te->gconf_notify_ids = NULL;
te->hover_tip_on = FALSE;
te->last_saved_content = NULL;
te->force_not_saved = FALSE;
@@ -614,10 +612,10 @@
te->editor_id = 0;
te->views = NULL;
}
- if (te->notify_ids)
+ if (te->gconf_notify_ids)
{
text_editor_prefs_finalize (te);
- te->notify_ids = NULL;
+ te->gconf_notify_ids = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -673,7 +671,7 @@
{
/* If syntax highlighting is disabled ... */
if (override_by_pref &&
- anjuta_preferences_get_bool (ANJUTA_PREFERENCES (te->preferences),
+ anjuta_preferences_get_int (ANJUTA_PREFERENCES (te->preferences),
DISABLE_SYNTAX_HILIGHTING))
{
aneditor_command (editor_id, ANE_SETHILITE, (glong) "plain.txt", 0);
@@ -1408,7 +1406,7 @@
/* DEBUG_PRINT ("File size and loaded size not matching"); */
}
dos_filter =
- anjuta_preferences_get_bool (ANJUTA_PREFERENCES (te->preferences),
+ anjuta_preferences_get_int (ANJUTA_PREFERENCES (te->preferences),
DOS_EOL_CHECK);
/* Set editor mode */
@@ -1530,7 +1528,7 @@
}
/* Strip trailing spaces */
- strip = anjuta_preferences_get_bool (te->preferences,
+ strip = anjuta_preferences_get_int (te->preferences,
STRIP_TRAILING_SPACES);
if (strip)
{
@@ -1542,7 +1540,7 @@
data[size] = '\n';
++ size;
}
- dos_filter = anjuta_preferences_get_bool (te->preferences,
+ dos_filter = anjuta_preferences_get_int (te->preferences,
DOS_EOL_CHECK);
editor_mode = scintilla_send_message (SCINTILLA (te->scintilla),
SCI_GETEOLMODE, 0, 0);
@@ -1609,7 +1607,7 @@
scintilla_send_message (SCINTILLA (te->scintilla),
SCI_EMPTYUNDOBUFFER, 0, 0);
text_editor_set_hilite_type (te, NULL);
- if (anjuta_preferences_get_bool (te->preferences, FOLD_ON_OPEN))
+ if (anjuta_preferences_get_int (te->preferences, FOLD_ON_OPEN))
{
aneditor_command (te->editor_id, ANE_CLOSE_FOLDALL, 0, 0);
}
@@ -2062,8 +2060,8 @@
text_editor_set_line_number_width (TextEditor* te)
{
/* Set line numbers with according to file size */
- if (anjuta_preferences_get_bool_with_default(te->preferences,
- "margin.linenumber.visible", FALSE))
+ if (anjuta_preferences_get_int_with_default(te->preferences,
+ "margin.linenumber.visible", 0))
{
int lines, line_number_width;
gchar* line_number;
Added: trunk/plugins/scintilla/text_editor.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/text_editor.h Wed Apr 8 22:31:22 2009
@@ -0,0 +1,312 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * text_editor.h
+ * Copyright (C) 2000 Kh. Naba Kumar Singh
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _TEXT_EDITOR_H_
+#define _TEXT_EDITOR_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gio/gio.h>
+#include <libanjuta/anjuta-preferences.h>
+#include <libanjuta/anjuta-shell.h>
+
+#include "aneditor.h"
+
+#include <libanjuta/anjuta-status.h>
+#include <libanjuta/anjuta-encodings.h>
+
+#define TEXT_EDITOR_FIND_SCOPE_WHOLE 1
+#define TEXT_EDITOR_FIND_SCOPE_CURRENT 2
+#define TEXT_EDITOR_FIND_SCOPE_SELECTION 3
+
+G_BEGIN_DECLS
+
+#define TYPE_TEXT_EDITOR (text_editor_get_type ())
+#define TEXT_EDITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_TEXT_EDITOR, TextEditor))
+#define TEXT_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TYPE_TEXT_EDITOR, TextEditorClass))
+#define IS_TEXT_EDITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_TEXT_EDITOR))
+#define IS_TEXT_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_TEXT_EDITOR))
+
+typedef enum _TextEditorAttrib
+{
+ TEXT_EDITOR_ATTRIB_TEXT,
+ TEXT_EDITOR_ATTRIB_COMMENT,
+ TEXT_EDITOR_ATTRIB_KEYWORD,
+ TEXT_EDITOR_ATTRIB_STRING
+} TextEditorAttrib;
+
+typedef struct _TextEditor TextEditor;
+typedef struct _TextEditorClass TextEditorClass;
+
+struct _TextEditor
+{
+ GtkVBox parent;
+
+ gchar *filename;
+ gchar *uri;
+ GFileMonitor *monitor;
+
+ AnjutaStatus *status;
+ AnjutaShell *shell;
+
+ /* File extension that will be used to force hilite type */
+ gchar *force_hilite;
+
+ glong current_line;
+
+ AnjutaPreferences *preferences;
+
+ /* Editor ID and widget for AnEditor */
+ AnEditorID editor_id;
+ AnEditorID editor_id_split;
+ GtkWidget *scintilla;
+ GtkWidget *vbox;
+ GList *views;
+
+ /* Properties set ID in the preferences */
+ gint props_base;
+
+ /* Something to stop unecessary signalings */
+ gint freeze_count;
+
+ /* First time exposer */
+ gboolean first_time_expose;
+
+ /* File encoding */
+ const AnjutaEncoding *encoding;
+
+ /* Popup menu widget */
+ GtkWidget *popup_menu;
+
+ /* Gconf notify IDs */
+ GList* gconf_notify_ids;
+
+ /* Current zoom factor */
+ gint zoom_factor;
+
+ /* message area widget */
+ GtkWidget *message_area;
+
+ /* Last saved content for comparision on external modifications on
+ * the file. The content is copied here during file saves.
+ */
+ gchar *last_saved_content;
+
+ /* Set buffer as modified until next save */
+ gboolean force_not_saved;
+
+ gboolean hover_tip_on;
+};
+
+struct _TextEditorClass
+{
+ GtkVBoxClass parent_class;
+};
+
+GType text_editor_get_type (void);
+
+/* New instance of TextEditor */
+GtkWidget* text_editor_new (AnjutaStatus *status, AnjutaPreferences * pr, AnjutaShell* shell, const gchar *uri,
+ const gchar *tab_name);
+
+/* Freeze and thaw editor */
+void text_editor_freeze (TextEditor * te);
+void text_editor_thaw (TextEditor * te);
+
+/* Set context pop up menu */
+void text_editor_set_popup_menu (TextEditor *te, GtkWidget *popup_menu);
+
+/*
+ * Sets the custom (forced) highlight style for the editor. Pass a dummy file
+ * name (with extension) to force particular highlight style. This function
+ * does not actualy rehighlight the editor, but only sets the highlight type
+ * which will be used in subsequent call to text_editor_hil().
+ */
+void text_editor_set_hilite_type (TextEditor * te, const gchar *file_extension);
+
+/*
+ * (Re) highlights the Editor. The 'force' parameter is used to tell if the
+ * preferences setting for 'Disable highlight' should not be considered.
+ * If force == FALSE, there will be no highlight if 'Disable highlight' is
+ * set ON.
+ */
+void text_editor_hilite (TextEditor *te, gboolean force);
+
+/*
+ * Set the zoom factor. Zoom factor basically increases or decreases the
+ * text font size by a factor of (2*zfac)
+ */
+void text_editor_set_zoom_factor (TextEditor * te, gint zfac);
+
+/* Get text attribute of the character at given position */
+TextEditorAttrib text_editor_get_attribute (TextEditor *te, gint position);
+
+/* Undo or redo last action */
+void text_editor_undo (TextEditor * te);
+void text_editor_redo (TextEditor * te);
+
+/* wrap flag only applies when scope == TEXT_EDITOR_FIND_CURRENT_POS */
+glong
+text_editor_find (TextEditor * te, const gchar * str, gint scope,
+ gboolean forward, gboolean regexp, gboolean ignore_case,
+ gboolean whole_word, gboolean wrap);
+
+/* Replaces current selection with given string */
+void text_editor_replace_selection (TextEditor * te, const gchar * r_str);
+
+/* Various editor information */
+guint text_editor_get_total_lines (TextEditor * te);
+glong text_editor_get_current_position (TextEditor * te);
+guint text_editor_get_current_lineno (TextEditor * te);
+guint text_editor_get_position_lineno (TextEditor * te, gint position);
+guint text_editor_get_current_column (TextEditor * te);
+guint text_editor_get_line_from_position (TextEditor * te, glong pos);
+gchar* text_editor_get_selection (TextEditor * te);
+gboolean text_editor_get_overwrite (TextEditor * te);
+glong text_editor_get_selection_start (TextEditor * te);
+glong text_editor_get_selection_end (TextEditor * te);
+gboolean text_editor_has_selection (TextEditor * te);
+gboolean text_editor_is_saved (TextEditor * te);
+
+/* Jump to various locations */
+gboolean text_editor_goto_point (TextEditor * te, glong num);
+gboolean text_editor_goto_line (TextEditor * te, glong num,
+ gboolean mark, gboolean ensure_visible);
+gint text_editor_goto_block_start (TextEditor* te);
+gint text_editor_goto_block_end (TextEditor* te);
+
+/* Save or load file */
+gboolean text_editor_load_file (TextEditor * te);
+gboolean text_editor_save_file (TextEditor * te, gboolean update);
+void text_editor_set_saved (TextEditor *te, gboolean saved);
+
+void text_editor_update_controls (TextEditor * te);
+gboolean text_editor_save_yourself (TextEditor * te, FILE * stream);
+gboolean text_editor_recover_yourself (TextEditor * te, FILE * stream);
+
+/* Autoformats code using 'indent' program */
+void text_editor_autoformat (TextEditor * te);
+
+/* Markers and indicators */
+void text_editor_set_line_marker (TextEditor * te, glong line);
+gint text_editor_set_marker (TextEditor * te, glong line, gint marker);
+gboolean text_editor_is_marker_set (TextEditor* te, glong line, gint marker);
+void text_editor_delete_marker (TextEditor* te, glong line, gint marker);
+void text_editor_delete_marker_all (TextEditor *te, gint marker);
+gint text_editor_line_from_handle (TextEditor* te, gint marker_handle);
+gint text_editor_get_bookmark_line (TextEditor* te, const glong nLineStart);
+gint text_editor_get_num_bookmarks (TextEditor* te);
+gint text_editor_set_indicator (TextEditor *te, gint start, gint end,
+ gint indicator);
+gboolean text_editor_can_undo (TextEditor *te);
+gboolean text_editor_can_redo (TextEditor *te);
+
+gchar* text_editor_get_word_before_carat (TextEditor *te);
+
+/* Get currect word near by cursor location */
+gchar* text_editor_get_current_word (TextEditor *te);
+
+/* Updates linewidth according to total line numbers */
+void text_editor_set_line_number_width (TextEditor* te);
+
+/* Grab focus */
+void text_editor_grab_focus (TextEditor *te);
+
+/* Select the function block where the cursor is content */
+void text_editor_function_select(TextEditor *te);
+
+/* Get the global properties set */
+gint text_editor_get_props (void);
+
+/* Set busy cursor on Editor window */
+void text_editor_set_busy (TextEditor *te, gboolean state);
+
+/* Multiple views addition and removal */
+void text_editor_add_view (TextEditor *te);
+void text_editor_remove_view (TextEditor *te);
+
+/* Show/hide hover tips */
+void text_editor_show_hover_tip (TextEditor *te, gint position, const gchar *info);
+void text_editor_hide_hover_tip (TextEditor *te);
+
+/* Direct editor commands to AnEditor and Scintilla */
+void text_editor_command(TextEditor *te, gint command,
+ glong wparam, glong lparam);
+void text_editor_scintilla_command (TextEditor *te, gint command,
+ glong wparam, glong lparam);
+
+/*
+ * Conversion from scintilla line number to TextEditor line
+ * number representation
+ */
+#define linenum_text_editor_to_scintilla(x) (x-1)
+#define linenum_scintilla_to_text_editor(x) (x+1)
+
+/* Editor preferences */
+#define DISABLE_SYNTAX_HILIGHTING "disable.syntax.hilighting"
+#define SAVE_AUTOMATIC "save.automatic"
+/*
+#define INDENT_AUTOMATIC "indent.automatic"
+*/
+#define USE_TABS "use.tabs"
+#define BRACES_CHECK "braces.check"
+#define DOS_EOL_CHECK "editor.doseol"
+#define WRAP_BOOKMARKS "editor.wrapbookmarks"
+#define TAB_SIZE "tabsize"
+#define INDENT_SIZE "indent.size"
+/*
+#define INDENT_OPENING "indent.opening"
+#define INDENT_CLOSING "indent.closing"
+*/
+#define INDENT_MAINTAIN "indent.maintain"
+
+#define TAB_INDENTS "tab.indents"
+#define BACKSPACE_UNINDENTS "backspace.unindents"
+#define AUTOSAVE_TIMER "autosave.timer"
+#define SAVE_SESSION_TIMER "save.session.timer"
+
+#define AUTOFORMAT_DISABLE "autoformat.disable"
+#define AUTOFORMAT_STYLE "autoformat.style"
+#define AUTOFORMAT_LIST_STYLE "autoformat.list.style"
+#define AUTOFORMAT_OPTS "autoformat.opts"
+
+#define FOLD_SYMBOLS "fold.symbols"
+#define FOLD_UNDERLINE "fold.underline"
+
+#define STRIP_TRAILING_SPACES "strip.trailing.spaces"
+#define FOLD_ON_OPEN "fold.on.open"
+#define CARET_FORE_COLOR "caret.fore"
+#define CALLTIP_BACK_COLOR "calltip.back"
+#define SELECTION_FORE_COLOR "selection.fore"
+#define SELECTION_BACK_COLOR "selection.back"
+
+#define VIEW_LINENUMBERS_MARGIN "margin.linenumber.visible"
+#define VIEW_MARKER_MARGIN "margin.marker.visible"
+#define VIEW_FOLD_MARGIN "margin.fold.visible"
+#define VIEW_INDENTATION_GUIDES "view.indentation.guides"
+#define VIEW_WHITE_SPACES "view.whitespace"
+#define VIEW_EOL "view.eol"
+#define VIEW_LINE_WRAP "view.line.wrap"
+#define EDGE_COLUMN "edge.column"
+#define TEXT_ZOOM_FACTOR "text.zoom.factor"
+
+G_END_DECLS
+
+#endif
Added: trunk/plugins/scintilla/text_editor_cbs.c
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/text_editor_cbs.c Wed Apr 8 22:31:22 2009
@@ -0,0 +1,282 @@
+/*
+ * text_editor_cbs.
+ * Copyright (C) 2000 Kh. Naba Kumar Singh
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gnome.h>
+#include <ctype.h>
+
+#include <libanjuta/resources.h>
+#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/anjuta-debug.h>
+
+#include "text_editor.h"
+#include "text_editor_cbs.h"
+#include "text-editor-iterable.h"
+
+#define GTK
+#undef PLAT_GTK
+#define PLAT_GTK 1
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "ScintillaWidget.h"
+
+gboolean
+on_text_editor_scintilla_focus_in (GtkWidget* scintilla, GdkEvent *event,
+ TextEditor *te)
+{
+ GList *node;
+
+ node = te->views;
+ while (node)
+ {
+ if (aneditor_get_widget (GPOINTER_TO_INT (node->data)) == scintilla)
+ {
+ DEBUG_PRINT ("%s", "Switching editor view ...");
+ te->editor_id = GPOINTER_TO_INT (node->data);
+ te->scintilla = aneditor_get_widget (te->editor_id);
+ break;
+ }
+ node = g_list_next (node);
+ }
+ return FALSE;
+}
+
+gboolean
+on_text_editor_text_buttonpress_event (GtkWidget * widget,
+ GdkEventButton * event,
+ gpointer user_data)
+{
+ TextEditor *te = user_data;
+ gtk_widget_grab_focus (GTK_WIDGET (te->scintilla));
+ return FALSE;
+}
+
+gboolean
+on_text_editor_text_keyrelease_event (GtkWidget * widget,
+ GdkEventKey * event,
+ gpointer user_data)
+{
+ if (event->keyval == GDK_BackSpace)
+ {
+ TextEditor *te = user_data;
+ g_signal_emit_by_name(G_OBJECT(te), "backspace");
+ }
+ return FALSE;
+}
+
+gboolean
+on_text_editor_text_event (GtkWidget * widget,
+ GdkEvent * event, gpointer user_data)
+{
+ TextEditor *te = TEXT_EDITOR (user_data);
+ GdkEventButton *bevent;
+
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
+ if (((GdkEventButton *) event)->button != 3)
+ return FALSE;
+ if (!text_editor_has_selection (te))
+ {
+ /* Move cursor to set breakpoints at correct line (#530689) */
+ glong pos;
+ gint x = (gint)((GdkEventButton *) event)->x;
+ gint y = (gint)((GdkEventButton *) event)->y;
+
+ pos = scintilla_send_message (SCINTILLA (te->scintilla), SCI_POSITIONFROMPOINT, x, y);
+ if (pos >= 0)
+ {
+ scintilla_send_message (SCINTILLA (te->scintilla), SCI_GOTOPOS, pos, 0);
+ }
+ }
+ bevent = (GdkEventButton *) event;
+ bevent->button = 1;
+ gtk_menu_popup (GTK_MENU (te->popup_menu),
+ NULL, NULL, NULL, NULL,
+ bevent->button, bevent->time);
+ return TRUE;
+}
+
+static void
+scintilla_uri_dropped (TextEditor *te, const char *uri)
+{
+ GtkWidget *parent;
+ GtkSelectionData tmp;
+
+ tmp.data = (guchar *) uri;
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (te));
+ if (parent)
+ g_signal_emit_by_name (G_OBJECT (parent), "drag_data_received",
+ NULL, 0, 0, &tmp, 0, 0);
+ return;
+}
+
+gboolean timerclick = FALSE;
+
+static gboolean
+click_timeout (TextEditor *te)
+{
+ gint line = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (te),
+ "marker_line"));
+
+ /* If not second clic after timeout : Single Click */
+ if (timerclick)
+ {
+ timerclick = FALSE;
+ /* Emit (single) clicked signal */
+ g_signal_emit_by_name (G_OBJECT (te), "marker_clicked", FALSE, line);
+ }
+ return FALSE;
+}
+
+void
+on_text_editor_scintilla_notify (GtkWidget * sci, gint wParam, gpointer lParam,
+ gpointer data)
+{
+ TextEditor *te;
+ struct SCNotification *nt;
+ gint line, position, autoc_sel;
+
+ te = data;
+ if (te->freeze_count != 0)
+ return;
+ nt = lParam;
+ switch (nt->nmhdr.code)
+ {
+ case SCN_URIDROPPED:
+ scintilla_uri_dropped(te, nt->text);
+ break;
+ case SCN_SAVEPOINTREACHED:
+ g_signal_emit_by_name(G_OBJECT (te), "update_save_ui");
+ break;
+ case SCN_SAVEPOINTLEFT:
+ g_signal_emit_by_name(G_OBJECT (te), "update_save_ui");
+ //FIXME:
+ // anjuta_update_title ();
+ // update_main_menubar ();
+ text_editor_update_controls (te);
+ return;
+ case SCN_UPDATEUI:
+ te->current_line = text_editor_get_current_lineno (te);
+ g_signal_emit_by_name(G_OBJECT (te), "update_ui");
+ return;
+
+ case SCN_CHARADDED:
+ {
+ position = text_editor_get_current_position (te) - 1;
+ TextEditorCell *position_iter = text_editor_cell_new (te, position);
+ te->current_line = text_editor_get_current_lineno (te);
+ g_signal_emit_by_name(G_OBJECT (te), "char-added", position_iter,
+ (gchar)nt->ch);
+ g_object_unref (position_iter);
+ }
+ return;
+ case SCN_AUTOCSELECTION:
+ case SCN_USERLISTSELECTION:
+ autoc_sel = (gint) scintilla_send_message (SCINTILLA (te->scintilla),
+ SCI_AUTOCGETCURRENT,
+ 0, 0);
+ scintilla_send_message (SCINTILLA (te->scintilla),
+ SCI_AUTOCCANCEL, 0, 0);
+ g_signal_emit_by_name (te, "assist-chosen", autoc_sel);
+ return;
+ case SCN_MODIFIED:
+ if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))
+ {
+ TextEditorCell *position_iter =
+ text_editor_cell_new (te, nt->position);
+ gboolean added = nt->modificationType & SC_MOD_INSERTTEXT;
+ g_signal_emit_by_name (G_OBJECT (te), "changed", position_iter,
+ added, nt->length, nt->linesAdded,
+ nt->text);
+ g_object_unref (position_iter);
+ }
+ return;
+ case SCN_MARGINCLICK:
+ line = text_editor_get_line_from_position (te, nt->position);
+ if (nt->margin == 1) /* Bookmarks and Breakpoints margin */
+ {
+ /* if second click before timeout : Double click */
+ if (timerclick)
+ {
+ timerclick = FALSE;
+ text_editor_goto_line (te, line, -1, TRUE);
+ aneditor_command (te->editor_id, ANE_BOOKMARK_TOGGLE, 0, 0);
+ /* Emit (double) clicked signal */
+ g_signal_emit_by_name (G_OBJECT (te), "marker_clicked",
+ TRUE, line);
+ }
+ else
+ {
+ timerclick = TRUE;
+ g_object_set_data (G_OBJECT (te), "marker_line",
+ GINT_TO_POINTER (line));
+ /* Timeout after 400ms */
+ /* If 2 clicks before the timeout ==> Single Click */
+ g_timeout_add (400, (void*) click_timeout, te);
+ }
+ }
+ return;
+ case SCN_DWELLSTART:
+ {
+ TextEditorCell* cell = nt->position < 0 ? NULL : text_editor_cell_new (te, nt->position);
+ g_signal_emit_by_name (te, "hover-over", cell);
+ if (cell) g_object_unref (cell);
+ return;
+ }
+
+ case SCN_DWELLEND:
+ {
+ TextEditorCell* cell = nt->position < 0 ? NULL : text_editor_cell_new (te, nt->position);
+
+ text_editor_hide_hover_tip (te);
+ g_signal_emit_by_name (te, "hover-leave", cell);
+ if (cell) g_object_unref (cell);
+ return;
+ }
+
+/* case SCEN_SETFOCUS:
+ case SCEN_KILLFOCUS:
+ case SCN_STYLENEEDED:
+ case SCN_DOUBLECLICK:
+ case SCN_MODIFIED:
+ case SCN_NEEDSHOWN:
+*/
+ default:
+ return;
+ }
+}
+
+void
+on_text_editor_scintilla_size_allocate (GtkWidget * widget,
+ GtkAllocation * allocation,
+ gpointer data)
+{
+ TextEditor *te;
+ te = data;
+ g_return_if_fail (te != NULL);
+
+ if (te->first_time_expose == FALSE)
+ return;
+
+ te->first_time_expose = FALSE;
+ text_editor_goto_line (te, te->current_line, FALSE, FALSE);
+}
Added: trunk/plugins/scintilla/text_editor_cbs.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scintilla/text_editor_cbs.h Wed Apr 8 22:31:22 2009
@@ -0,0 +1,52 @@
+/*
+ text_editor_cbs.h
+ Copyright (C) 2003 Naba Kumar
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#ifndef _TEXT_EDITOR_CBS_H_
+#define _TEXT_EDITOR_CBS_H_
+
+#include <gnome.h>
+#include "text_editor.h"
+
+gboolean
+on_text_editor_scintilla_focus_in (GtkWidget* scintilla, GdkEvent *event,
+ TextEditor *te);
+gboolean
+on_text_editor_text_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+gboolean
+on_text_editor_text_buttonpress_event (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data);
+
+gboolean
+on_text_editor_text_keyrelease_event (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer user_data);
+
+void
+on_text_editor_scintilla_notify(GtkWidget* sci, gint wParam,
+ gpointer lParam, gpointer data);
+
+void
+on_text_editor_scintilla_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data);
+
+#endif
Modified: trunk/plugins/scintilla/text_editor_prefs.c
==============================================================================
--- trunk/plugins/scintilla/text_editor_prefs.c (original)
+++ trunk/plugins/scintilla/text_editor_prefs.c Wed Apr 8 22:31:22 2009
@@ -20,6 +20,9 @@
#include <libanjuta/anjuta-preferences.h>
#include <libanjuta/anjuta-debug.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+
#include "properties.h"
#include "text_editor_prefs.h"
#include "text_editor_cbs.h"
@@ -62,7 +65,7 @@
}
static void
-pref_notify (GConfClient *gclient, guint cnxn_id,
+pref_gconf_notify (GConfClient *gclient, guint cnxn_id,
GConfEntry *entry, gpointer user_data)
{
PrefPassedData *pd = (PrefPassedData*)user_data;
@@ -87,17 +90,6 @@
return val;
}
-static gint
-set_n_get_prop_bool (TextEditor *te, const gchar *key)
-{
- gboolean val;
- AnjutaPreferences *pr;
- pr = te->preferences;
- val = anjuta_preferences_get_bool (pr, key);
- sci_prop_set_int_with_key (text_editor_get_props (), key, val);
- return val;
-}
-
static gchar *
set_n_get_prop_string (TextEditor *te, const gchar *key)
{
@@ -110,10 +102,8 @@
}
static void
-on_notify_disable_hilite (AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_disable_hilite (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
@@ -123,14 +113,12 @@
}
static void
-on_notify_zoom_factor(AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_zoom_factor (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gint zoom_factor;
-
+
te = TEXT_EDITOR (user_data);
zoom_factor = set_n_get_prop_int (te, TEXT_ZOOM_FACTOR);
text_editor_set_zoom_factor (te, zoom_factor);
@@ -138,211 +126,222 @@
}
static void
-on_notify_tab_size (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_tab_size (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gint tab_size;
-
+
te = TEXT_EDITOR (user_data);
tab_size = set_n_get_prop_int (te, TAB_SIZE);
text_editor_command (te, ANE_SETTABSIZE, tab_size, 0);
}
static void
-on_notify_use_tab_for_indentation(AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_use_tab_for_indentation (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean use_tabs;
-
+
te = TEXT_EDITOR (user_data);
use_tabs = set_n_get_prop_int (te, USE_TABS);
text_editor_command (te, ANE_SETUSETABFORINDENT, use_tabs, 0);
// text_editor_scintilla_command (te, SCI_SETTABWIDTH, use_tabs, 0);
}
+#if 0
static void
-on_notify_indent_size (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_automatic_indentation (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
- gint indent_size;
+ gboolean indent_automatic;
+
+ te = TEXT_EDITOR (user_data);
+ indent_automatic = set_n_get_prop_int (te, INDENT_AUTOMATIC);
+ text_editor_command (te, ANE_SETAUTOINDENTATION, indent_automatic, 0);
+}
+#endif
+static void
+on_gconf_notify_indent_size (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
+{
+ TextEditor *te;
+ gint indent_size;
+
te = TEXT_EDITOR (user_data);
indent_size = set_n_get_prop_int (te, INDENT_SIZE);
text_editor_command (te, ANE_SETINDENTSIZE, indent_size, 0);
}
static void
-on_notify_wrap_bookmarks(AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_wrap_bookmarks (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, WRAP_BOOKMARKS);
text_editor_command (te, ANE_SETWRAPBOOKMARKS, state, 0);
}
static void
-on_notify_braces_check (AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_braces_check (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, BRACES_CHECK);
text_editor_command (te, ANE_SETINDENTBRACESCHECK, state, 0);
}
+#if 0
static void
-on_notify_indent_maintain (AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_indent_opening (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
+
+ te = TEXT_EDITOR (user_data);
+ state = set_n_get_prop_int (te, INDENT_OPENING);
+ text_editor_command (te, ANE_SETINDENTOPENING, state, 0);
+}
+static void
+on_gconf_notify_indent_closing (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
+{
+ TextEditor *te;
+ gboolean state;
+
+ te = TEXT_EDITOR (user_data);
+ state = set_n_get_prop_int (te, INDENT_CLOSING);
+ text_editor_command (te, ANE_SETINDENTCLOSING, state, 0);
+}
+
+#endif
+
+static void
+on_gconf_notify_indent_maintain (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
+{
+ TextEditor *te;
+ gboolean state;
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, INDENT_MAINTAIN);
text_editor_command (te, ANE_SETINDENTMAINTAIN, state, 0);
}
static void
-on_notify_tab_indents (AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_tab_indents (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, TAB_INDENTS);
text_editor_command (te, ANE_SETTABINDENTS, state, 0);
}
static void
-on_notify_backspace_unindents (AnjutaPreferences* prefs,
- const gchar* key,
- gboolean value,
- gpointer user_data)
+on_gconf_notify_backspace_unindents (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, BACKSPACE_UNINDENTS);
text_editor_command (te, ANE_SETBACKSPACEUNINDENTS, state, 0);
}
static void
-on_notify_view_eols (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_eols (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_EOL);
text_editor_command (te, ANE_VIEWEOL, state, 0);
}
static void
-on_notify_view_whitespaces (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_whitespaces (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_WHITE_SPACES);
text_editor_command (te, ANE_VIEWSPACE, state, 0);
}
static void
-on_notify_view_linewrap (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_linewrap (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_LINE_WRAP);
text_editor_command (te, ANE_LINEWRAP, state, 0);
}
static void
-on_notify_view_indentation_guides (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_indentation_guides (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_INDENTATION_GUIDES);
text_editor_command (te, ANE_VIEWGUIDES, state, 0);
}
static void
-on_notify_view_folds (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_folds (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_FOLD_MARGIN);
text_editor_command (te, ANE_FOLDMARGIN, state, 0);
}
static void
-on_notify_view_markers (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_markers (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_MARKER_MARGIN);
text_editor_command (te, ANE_SELMARGIN, state, 0);
}
static void
-on_notify_view_linenums (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_view_linenums (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, VIEW_LINENUMBERS_MARGIN);
text_editor_command (te, ANE_LINENUMBERMARGIN, state, 0);
@@ -350,14 +349,12 @@
}
static void
-on_notify_fold_symbols (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_fold_symbols (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gchar *symbols;
-
+
te = TEXT_EDITOR (user_data);
symbols = set_n_get_prop_string (te, FOLD_SYMBOLS);
text_editor_command (te, ANE_SETFOLDSYMBOLS, (long)symbols, 0);
@@ -365,37 +362,33 @@
}
static void
-on_notify_fold_underline (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_fold_underline (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gboolean state;
-
+
te = TEXT_EDITOR (user_data);
state = set_n_get_prop_int (te, FOLD_UNDERLINE);
text_editor_command (te, ANE_SETFOLDUNDERLINE, state, 0);
}
static void
-on_notify_edge_column (AnjutaPreferences* prefs,
- const gchar* key,
- gint value,
- gpointer user_data)
+on_gconf_notify_edge_column (GConfClient *gclient, guint cnxn_id,
+ GConfEntry *entry, gpointer user_data)
{
TextEditor *te;
gint size;
-
+
te = TEXT_EDITOR (user_data);
size = set_n_get_prop_int (te, EDGE_COLUMN);
text_editor_command (te, ANE_SETEDGECOLUMN, size, 0);
}
-#define REGISTER_NOTIFY(key, func, type) \
- notify_id = anjuta_preferences_notify_add_##type (te->preferences, \
+#define REGISTER_NOTIFY(key, func) \
+ notify_id = anjuta_preferences_notify_add (te->preferences, \
key, func, te, NULL); \
- te->notify_ids = g_list_prepend (te->notify_ids, \
+ te->gconf_notify_ids = g_list_prepend (te->gconf_notify_ids, \
GUINT_TO_POINTER (notify_id));
void
@@ -408,68 +401,76 @@
set_n_get_prop_int (te, TAB_SIZE);
set_n_get_prop_int (te, TEXT_ZOOM_FACTOR);
set_n_get_prop_int (te, INDENT_SIZE);
- set_n_get_prop_bool (te, USE_TABS);
- set_n_get_prop_bool (te, DISABLE_SYNTAX_HILIGHTING);
- set_n_get_prop_bool (te, WRAP_BOOKMARKS);
- set_n_get_prop_bool (te, BRACES_CHECK);
-
+ set_n_get_prop_int (te, USE_TABS);
+ set_n_get_prop_int (te, DISABLE_SYNTAX_HILIGHTING);
+ /* set_n_get_prop_int (te, INDENT_AUTOMATIC); */
+ set_n_get_prop_int (te, WRAP_BOOKMARKS);
+ set_n_get_prop_int (te, BRACES_CHECK);
+ /*
+ set_n_get_prop_int (te, INDENT_OPENING);
+ set_n_get_prop_int (te, INDENT_CLOSING);
+ */
/* This one is special */
- val = set_n_get_prop_bool (te, INDENT_MAINTAIN);
+ val = set_n_get_prop_int (te, INDENT_MAINTAIN);
if (val)
sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", 1);
else
- sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", 0);
+ sci_prop_set_with_key (te->props_base, INDENT_MAINTAIN".*", "");
- set_n_get_prop_bool (te, TAB_INDENTS);
- set_n_get_prop_bool (te, BACKSPACE_UNINDENTS);
+ set_n_get_prop_int (te, TAB_INDENTS);
+ set_n_get_prop_int (te, BACKSPACE_UNINDENTS);
- set_n_get_prop_bool (te, VIEW_EOL);
- set_n_get_prop_bool (te, VIEW_LINE_WRAP);
- set_n_get_prop_bool (te, VIEW_WHITE_SPACES);
- set_n_get_prop_bool (te, VIEW_INDENTATION_GUIDES);
- set_n_get_prop_bool (te, VIEW_FOLD_MARGIN);
- set_n_get_prop_bool (te, VIEW_MARKER_MARGIN);
- set_n_get_prop_bool (te, VIEW_LINENUMBERS_MARGIN);
+ set_n_get_prop_int (te, VIEW_EOL);
+ set_n_get_prop_int (te, VIEW_LINE_WRAP);
+ set_n_get_prop_int (te, VIEW_WHITE_SPACES);
+ set_n_get_prop_int (te, VIEW_INDENTATION_GUIDES);
+ set_n_get_prop_int (te, VIEW_FOLD_MARGIN);
+ set_n_get_prop_int (te, VIEW_MARKER_MARGIN);
+ set_n_get_prop_int (te, VIEW_LINENUMBERS_MARGIN);
g_free (set_n_get_prop_string (te, FOLD_SYMBOLS));
- set_n_get_prop_bool (te, FOLD_UNDERLINE);
+ set_n_get_prop_int (te, FOLD_UNDERLINE);
set_n_get_prop_int (te, EDGE_COLUMN);
/* Register gconf notifications */
- REGISTER_NOTIFY (TAB_SIZE, on_notify_tab_size, int);
- REGISTER_NOTIFY (TEXT_ZOOM_FACTOR, on_notify_zoom_factor, int);
- REGISTER_NOTIFY (INDENT_SIZE, on_notify_indent_size, int);
- REGISTER_NOTIFY (USE_TABS, on_notify_use_tab_for_indentation, bool);
- REGISTER_NOTIFY (DISABLE_SYNTAX_HILIGHTING, on_notify_disable_hilite, bool);
- /* REGISTER_NOTIFY (INDENT_AUTOMATIC, on_notify_automatic_indentation); */
- REGISTER_NOTIFY (WRAP_BOOKMARKS, on_notify_wrap_bookmarks, bool);
- REGISTER_NOTIFY (BRACES_CHECK, on_notify_braces_check, bool);
- REGISTER_NOTIFY (INDENT_MAINTAIN, on_notify_indent_maintain, bool);
- REGISTER_NOTIFY (TAB_INDENTS, on_notify_tab_indents, bool);
- REGISTER_NOTIFY (BACKSPACE_UNINDENTS, on_notify_backspace_unindents, bool);
- REGISTER_NOTIFY (VIEW_EOL, on_notify_view_eols, bool);
- REGISTER_NOTIFY (VIEW_LINE_WRAP, on_notify_view_linewrap, bool);
- REGISTER_NOTIFY (VIEW_WHITE_SPACES, on_notify_view_whitespaces, bool);
- REGISTER_NOTIFY (VIEW_INDENTATION_GUIDES, on_notify_view_indentation_guides, bool);
- REGISTER_NOTIFY (VIEW_FOLD_MARGIN, on_notify_view_folds, bool);
- REGISTER_NOTIFY (VIEW_MARKER_MARGIN, on_notify_view_markers, bool);
- REGISTER_NOTIFY (VIEW_LINENUMBERS_MARGIN, on_notify_view_linenums, bool);
- REGISTER_NOTIFY (FOLD_SYMBOLS, on_notify_fold_symbols, bool);
- REGISTER_NOTIFY (FOLD_UNDERLINE, on_notify_fold_underline, bool);
- REGISTER_NOTIFY (EDGE_COLUMN, on_notify_edge_column, int);
+ REGISTER_NOTIFY (TAB_SIZE, on_gconf_notify_tab_size);
+ REGISTER_NOTIFY (TEXT_ZOOM_FACTOR, on_gconf_notify_zoom_factor);
+ REGISTER_NOTIFY (INDENT_SIZE, on_gconf_notify_indent_size);
+ REGISTER_NOTIFY (USE_TABS, on_gconf_notify_use_tab_for_indentation);
+ REGISTER_NOTIFY (DISABLE_SYNTAX_HILIGHTING, on_gconf_notify_disable_hilite);
+ /* REGISTER_NOTIFY (INDENT_AUTOMATIC, on_gconf_notify_automatic_indentation); */
+ REGISTER_NOTIFY (WRAP_BOOKMARKS, on_gconf_notify_wrap_bookmarks);
+ REGISTER_NOTIFY (BRACES_CHECK, on_gconf_notify_braces_check);
+ /*
+ REGISTER_NOTIFY (INDENT_OPENING, on_gconf_notify_indent_opening);
+ REGISTER_NOTIFY (INDENT_CLOSING, on_gconf_notify_indent_closing);
+ */
+ REGISTER_NOTIFY (INDENT_MAINTAIN, on_gconf_notify_indent_maintain);
+ REGISTER_NOTIFY (TAB_INDENTS, on_gconf_notify_tab_indents);
+ REGISTER_NOTIFY (BACKSPACE_UNINDENTS, on_gconf_notify_backspace_unindents);
+ REGISTER_NOTIFY (VIEW_EOL, on_gconf_notify_view_eols);
+ REGISTER_NOTIFY (VIEW_LINE_WRAP, on_gconf_notify_view_linewrap);
+ REGISTER_NOTIFY (VIEW_WHITE_SPACES, on_gconf_notify_view_whitespaces);
+ REGISTER_NOTIFY (VIEW_INDENTATION_GUIDES, on_gconf_notify_view_indentation_guides);
+ REGISTER_NOTIFY (VIEW_FOLD_MARGIN, on_gconf_notify_view_folds);
+ REGISTER_NOTIFY (VIEW_MARKER_MARGIN, on_gconf_notify_view_markers);
+ REGISTER_NOTIFY (VIEW_LINENUMBERS_MARGIN, on_gconf_notify_view_linenums);
+ REGISTER_NOTIFY (FOLD_SYMBOLS, on_gconf_notify_fold_symbols);
+ REGISTER_NOTIFY (FOLD_UNDERLINE, on_gconf_notify_fold_underline);
+ REGISTER_NOTIFY (EDGE_COLUMN, on_gconf_notify_edge_column);
}
void
text_editor_prefs_finalize (TextEditor *te)
{
GList *node;
- node = te->notify_ids;
+ node = te->gconf_notify_ids;
while (node)
{
anjuta_preferences_notify_remove (te->preferences,
GPOINTER_TO_UINT (node->data));
node = g_list_next (node);
}
- g_list_free (te->notify_ids);
- te->notify_ids = NULL;
+ g_list_free (te->gconf_notify_ids);
+ te->gconf_notify_ids = NULL;
}
Modified: trunk/plugins/valgrind/Makefile.in
==============================================================================
--- trunk/plugins/valgrind/Makefile.in (original)
+++ trunk/plugins/valgrind/Makefile.in Wed Apr 8 22:31:22 2009
@@ -161,16 +161,19 @@
EXTRA_CFLAGS = @EXTRA_CFLAGS@
FGREP = @FGREP@
GCONFTOOL = @GCONFTOOL@
+GCONF_REQUIRED = @GCONF_REQUIRED@
GCONF_SCHEMAS_INSTALL_FALSE = @GCONF_SCHEMAS_INSTALL_FALSE@
GCONF_SCHEMAS_INSTALL_TRUE = @GCONF_SCHEMAS_INSTALL_TRUE@
GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@
GCONF_SCHEMA_FILE_DIR = @GCONF_SCHEMA_FILE_DIR@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_REQUIRED = @GLIB_REQUIRED@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GRAPHVIZ_CFLAGS = @GRAPHVIZ_CFLAGS@
GRAPHVIZ_LIBS = @GRAPHVIZ_LIBS@
GREP = @GREP@
+GTK_REQUIRED = @GTK_REQUIRED@
HAVE_GRAPHVIZ_FALSE = @HAVE_GRAPHVIZ_FALSE@
HAVE_GRAPHVIZ_TRUE = @HAVE_GRAPHVIZ_TRUE@
HAVE_PLUGIN_SCINTILLA_FALSE = @HAVE_PLUGIN_SCINTILLA_FALSE@
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]