Revision: 2763
http://geany.svn.sourceforge.net/geany/?rev=2763&view=rev
Author: ntrel
Date: 2008-07-08 03:50:13 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
Note: this breaks the plugin API for editor-related document fields.
Split new GeanyEditor struct type from GeanyDocument fields.
Add GeanyDocument::editor field.
GeanyEditor::document allows access back to document fields.
GeanyEditor::scintilla replaces GeanyDocument::sci.
Modified Paths:
--------------
branches/editor-struct/ChangeLog
branches/editor-struct/src/document.h
branches/editor-struct/src/editor.h
branches/editor-struct/src/plugindata.h
Modified: branches/editor-struct/ChangeLog
===================================================================
--- branches/editor-struct/ChangeLog 2008-07-08 10:42:29 UTC (rev 2762)
+++ branches/editor-struct/ChangeLog 2008-07-08 10:50:13 UTC (rev 2763)
@@ -1,3 +1,13 @@
+2008-07-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/document.h, src/editor.h, src/plugindata.h:
+ Note: this breaks the plugin API for editor-related document fields.
+ Split new GeanyEditor struct type from GeanyDocument fields.
+ Add GeanyDocument::editor field.
+ GeanyEditor::document allows access back to document fields.
+ GeanyEditor::scintilla replaces GeanyDocument::sci.
+
+
2008-07-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* tagmanager/haskell.c:
Modified: branches/editor-struct/src/document.h
===================================================================
--- branches/editor-struct/src/document.h 2008-07-08 10:42:29 UTC (rev 2762)
+++ branches/editor-struct/src/document.h 2008-07-08 10:50:13 UTC (rev 2763)
@@ -82,30 +82,20 @@
gchar *encoding;
/** Internally used flag to indicate whether the file of this %document has a byte-order-mark. */
gboolean has_bom;
+ struct GeanyEditor *editor; /**< The editor widget associated with the document. */
/** The filetype for this %document, it's only a reference to one of the elements of the global
* filetypes array. */
GeanyFiletype *file_type;
/** TMWorkObject object for this %document. */
TMWorkObject *tm_file;
- /** The Scintilla object for this %document. */
- ScintillaObject *sci;
/** Whether this %document is read-only. */
gboolean readonly;
/** Whether this %document has been changed since it was last saved. */
gboolean changed;
- /** %Document-specific line wrapping setting. */
- gboolean line_wrapping;
- /** %Document-specific indentation setting. */
- gboolean auto_indent;
- /** Percentage to scroll view by on paint, if positive. */
- gfloat scroll_percent;
/** Time of the last disk check. */
time_t last_check;
/** Modification time of this %document on disk. */
time_t mtime;
- /** %Document-specific indentation setting. */
- gboolean use_tabs;
- gboolean line_breaking; /**< Whether to split long lines as you type. */
/** The link-dereferenced, locale-encoded file name.
* If non-NULL, this indicates the file once existed on disk (not just as an
* unsaved document with a filename set).
Modified: branches/editor-struct/src/editor.h
===================================================================
--- branches/editor-struct/src/editor.h 2008-07-08 10:42:29 UTC (rev 2762)
+++ branches/editor-struct/src/editor.h 2008-07-08 10:50:13 UTC (rev 2763)
@@ -99,6 +99,21 @@
extern GeanyEditorPrefs editor_prefs;
+/** Editor-owned fields for each document. */
+typedef struct GeanyEditor
+{
+ GeanyDocument *document; /**< The document associated with the editor. */
+ ScintillaObject *scintilla; /**< The Scintilla editor @c GtkWidget. */
+ gboolean line_wrapping; /**< @c TRUE if line wrapping is enabled. */
+ gboolean auto_indent; /**< @c TRUE if auto-indentation is enabled. */
+ /** Percentage to scroll view by on paint, if positive. */
+ gfloat scroll_percent;
+ gboolean use_tabs; /**< @c TRUE if tabs are used for indentation. */
+ gboolean line_breaking; /**< Whether to split long lines as you type. */
+}
+GeanyEditor;
+
+
typedef struct
{
gchar *current_word; /* holds word under the mouse or keyboard cursor */
Modified: branches/editor-struct/src/plugindata.h
===================================================================
--- branches/editor-struct/src/plugindata.h 2008-07-08 10:42:29 UTC (rev 2762)
+++ branches/editor-struct/src/plugindata.h 2008-07-08 10:50:13 UTC (rev 2763)
@@ -36,12 +36,12 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
-static const gint api_version = 75;
+static const gint api_version = 76;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 40;
+static const gint abi_version = 41;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2762
http://geany.svn.sourceforge.net/geany/?rev=2762&view=rev
Author: ntrel
Date: 2008-07-08 03:42:29 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
Create branch to split out a GeanyEditor struct type for use in editor.c with fields from GeanyDocument.
Added Paths:
-----------
branches/editor-struct/
Copied: branches/editor-struct (from rev 2761, trunk)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2760
http://geany.svn.sourceforge.net/geany/?rev=2760&view=rev
Author: ntrel
Date: 2008-07-07 06:08:07 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
Rename plugin-symbols.c pluginsymbols.c.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/Makefile.am
trunk/doc/plugins.dox
Added Paths:
-----------
trunk/doc/pluginsymbols.c
Removed Paths:
-------------
trunk/doc/plugin-symbols.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-07-07 11:38:15 UTC (rev 2759)
+++ trunk/ChangeLog 2008-07-07 13:08:07 UTC (rev 2760)
@@ -5,6 +5,8 @@
* src/editor.c:
Make line breaking work with multi-line comment completion and
'Newline strips trailing spaces' pref.
+ * doc/plugin-symbols.c, doc/Makefile.am, doc/plugins.dox:
+ Rename plugin-symbols.c pluginsymbols.c.
2008-07-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2008-07-07 11:38:15 UTC (rev 2759)
+++ trunk/doc/Makefile.am 2008-07-07 13:08:07 UTC (rev 2760)
@@ -1,7 +1,7 @@
man_MANS=geany.1
DOCDIR = $(DESTDIR)$(docdir)
IMAGE_FILES = images/*.png
-EXTRA_DIST = geany.html geany.css geany.txt geany.1 plugins.dox plugin-symbols.c \
+EXTRA_DIST = geany.html geany.css geany.txt geany.1 plugins.dox pluginsymbols.c \
$(srcdir)/$(IMAGE_FILES)
pdf: geany.txt
Deleted: trunk/doc/plugin-symbols.c
===================================================================
--- trunk/doc/plugin-symbols.c 2008-07-07 11:38:15 UTC (rev 2759)
+++ trunk/doc/plugin-symbols.c 2008-07-07 13:08:07 UTC (rev 2760)
@@ -1,94 +0,0 @@
-/*
- * plugin-symbols.c - this file is part of Geany, a fast and lightweight IDE
- *
- * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
- * Copyright 2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
- *
- * 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.
- *
- * $Id$
- */
-
-/* Note: this file is for Doxygen only. */
-
-/**
- * @file plugin-symbols.c
- * Symbols declared from within plugins.
- *
- * Geany looks for these symbols (arrays, pointers and functions) when initializing
- * plugins. Some of them are optional, i.e. they can be omitted; others are required
- * and must be defined. Some symbols should only be declared using specific macros in
- * @link plugindata.h @endlink.
- */
-
-/** Use the PLUGIN_VERSION_CHECK() macro instead. Required by Geany. */
-gint plugin_version_check(gint);
-
-/** Use the PLUGIN_SET_INFO() macro to define it. Required by Geany.
- * This function is called before the plugin is initialized, so Geany
- * can read the plugin's name.
- * @param info The data struct which should be initialized by this function. */
-void plugin_set_info(PluginInfo *info);
-
-/** Basic information about a plugin, which is set in plugin_set_info(). */
-const PluginInfo* plugin_info;
-
-/** Geany owned data pointers.
- * Example: @c assert(geany_data->app->configdir != NULL); */
-const GeanyData* geany_data;
-
-/** Geany owned function pointers, split into groups.
- * Example: @c geany_functions->p_document->new_file(NULL, NULL, NULL);
- *
- * Note: Usually plugins would use the pluginmacros.h file and just call:
- * @c p_document->new_file(NULL, NULL, NULL); */
-const GeanyFunctions* geany_functions;
-
-/** Plugin owned fields, including flags. */
-PluginFields* plugin_fields;
-
-/** An array for connecting GeanyObject events, which should be terminated with
- * @c {NULL, NULL, FALSE, NULL}. See @link signals Signal documentation @endlink. */
-PluginCallback plugin_callbacks[];
-
-/** Most plugins should use the PLUGIN_KEY_GROUP() macro to define it. However,
- * its fields are not read until after plugin_init() is called for the plugin, so it
- * is possible to setup a variable number of keybindings, e.g. based on the
- * plugin's configuration file settings.
- * - The @c name field must not be empty or match Geany's default group name.
- * - The @c label field is set by Geany after plugin_init() is called to the name of the
- * plugin.
- * @note This is a single element array for implementation reasons,
- * but you can treat it like a pointer. */
-KeyBindingGroup plugin_key_group[1];
-
-
-/** Called before showing the plugin preferences dialog to let the user set some basic
- * plugin configuration options. Can be omitted when not needed.
- * @param dialog The plugin preferences dialog widget - this should only be used to
- * connect the @c "response" signal. If settings should be read from the dialog, the
- * reponse will be either @c GTK_RESPONSE_OK or @c GTK_RESPONSE_APPLY.
- * @return A container widget holding preference widgets. */
-GtkWidget* plugin_configure(GtkDialog *dialog);
-
-/** Called after loading the plugin.
- * @param data The same as #geany_data. */
-void plugin_init(GeanyData *data);
-
-/** Called before unloading the plugin. Required for normal plugins - it should undo
- * everything done in plugin_init() - e.g. destroy menu items, free memory. */
-void plugin_cleanup();
-
Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox 2008-07-07 11:38:15 UTC (rev 2759)
+++ trunk/doc/plugins.dox 2008-07-07 13:08:07 UTC (rev 2760)
@@ -42,7 +42,7 @@
*
* Other pages:
* - @link plugindata.h Main Datatypes and Macros @endlink
- * - @link plugin-symbols.c Plugin Symbols @endlink
+ * - @link pluginsymbols.c Plugin Symbols @endlink
* - @link pluginmacros.h Optional Macros @endlink
* - @link signals Plugin Signals @endlink
*
@@ -192,7 +192,7 @@
*
* Every plugin must contain some essential symbols unless it won't work. A complete
* list of all necessary and optional symbols can be found in
- * @link plugin-symbols.c Plugin Symbols @endlink.
+ * @link pluginsymbols.c Plugin Symbols @endlink.
* Every plugin should include "geany.h" and "plugindata.h" which provide necessary
* preprocessor macros and other basic information.
* There are two important preprocessor macros which need to be used at the beginning:
Copied: trunk/doc/pluginsymbols.c (from rev 2752, trunk/doc/plugin-symbols.c)
===================================================================
--- trunk/doc/pluginsymbols.c (rev 0)
+++ trunk/doc/pluginsymbols.c 2008-07-07 13:08:07 UTC (rev 2760)
@@ -0,0 +1,94 @@
+/*
+ * pluginsymbols.c - this file is part of Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * Copyright 2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/* Note: this file is for Doxygen only. */
+
+/**
+ * @file pluginsymbols.c
+ * Symbols declared from within plugins.
+ *
+ * Geany looks for these symbols (arrays, pointers and functions) when initializing
+ * plugins. Some of them are optional, i.e. they can be omitted; others are required
+ * and must be defined. Some symbols should only be declared using specific macros in
+ * @link plugindata.h @endlink.
+ */
+
+/** Use the PLUGIN_VERSION_CHECK() macro instead. Required by Geany. */
+gint plugin_version_check(gint);
+
+/** Use the PLUGIN_SET_INFO() macro to define it. Required by Geany.
+ * This function is called before the plugin is initialized, so Geany
+ * can read the plugin's name.
+ * @param info The data struct which should be initialized by this function. */
+void plugin_set_info(PluginInfo *info);
+
+/** Basic information about a plugin, which is set in plugin_set_info(). */
+const PluginInfo* plugin_info;
+
+/** Geany owned data pointers.
+ * Example: @c assert(geany_data->app->configdir != NULL); */
+const GeanyData* geany_data;
+
+/** Geany owned function pointers, split into groups.
+ * Example: @c geany_functions->p_document->new_file(NULL, NULL, NULL);
+ *
+ * Note: Usually plugins would use the pluginmacros.h file and just call:
+ * @c p_document->new_file(NULL, NULL, NULL); */
+const GeanyFunctions* geany_functions;
+
+/** Plugin owned fields, including flags. */
+PluginFields* plugin_fields;
+
+/** An array for connecting GeanyObject events, which should be terminated with
+ * @c {NULL, NULL, FALSE, NULL}. See @link signals Signal documentation @endlink. */
+PluginCallback plugin_callbacks[];
+
+/** Most plugins should use the PLUGIN_KEY_GROUP() macro to define it. However,
+ * its fields are not read until after plugin_init() is called for the plugin, so it
+ * is possible to setup a variable number of keybindings, e.g. based on the
+ * plugin's configuration file settings.
+ * - The @c name field must not be empty or match Geany's default group name.
+ * - The @c label field is set by Geany after plugin_init() is called to the name of the
+ * plugin.
+ * @note This is a single element array for implementation reasons,
+ * but you can treat it like a pointer. */
+KeyBindingGroup plugin_key_group[1];
+
+
+/** Called before showing the plugin preferences dialog to let the user set some basic
+ * plugin configuration options. Can be omitted when not needed.
+ * @param dialog The plugin preferences dialog widget - this should only be used to
+ * connect the @c "response" signal. If settings should be read from the dialog, the
+ * reponse will be either @c GTK_RESPONSE_OK or @c GTK_RESPONSE_APPLY.
+ * @return A container widget holding preference widgets. */
+GtkWidget* plugin_configure(GtkDialog *dialog);
+
+/** Called after loading the plugin.
+ * @param data The same as #geany_data. */
+void plugin_init(GeanyData *data);
+
+/** Called before unloading the plugin. Required for normal plugins - it should undo
+ * everything done in plugin_init() - e.g. destroy menu items, free memory. */
+void plugin_cleanup();
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2759
http://geany.svn.sourceforge.net/geany/?rev=2759&view=rev
Author: ntrel
Date: 2008-07-07 04:38:15 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
Make line breaking work with multi-line comment completion and
'Newline strips trailing spaces' pref.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-07-07 11:09:23 UTC (rev 2758)
+++ trunk/ChangeLog 2008-07-07 11:38:15 UTC (rev 2759)
@@ -2,6 +2,9 @@
* tagmanager/haskell.c:
Fix infinite loop when parsing datatypes (fixes #2011356).
+ * src/editor.c:
+ Make line breaking work with multi-line comment completion and
+ 'Newline strips trailing spaces' pref.
2008-07-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-07-07 11:09:23 UTC (rev 2758)
+++ trunk/src/editor.c 2008-07-07 11:38:15 UTC (rev 2759)
@@ -339,13 +339,30 @@
c = sci_get_char_at(sci, --pos);
if (c == GDK_space)
{
- gint indent_size = sci_get_line_indentation(sci, line);
+ gint col, len, diff;
+ const gchar *eol = editor_get_eol_char(doc);
/* break the line after the space */
- sci_insert_text(sci, pos + 1, editor_get_eol_char(doc));
+ sci_insert_text(sci, pos + 1, eol);
+ line++;
- if (doc->auto_indent)
- sci_set_line_indentation(sci, line + 1, indent_size);
+ /* remember distance from end of line (we use column position in case
+ * the previous line gets altered, such as removing trailing spaces). */
+ pos = sci_get_current_position(sci);
+ len = sci_get_line_length(sci, line);
+ col = sci_get_col_from_position(sci, pos);
+ diff = len - col;
+
+ /* set position as if user had pressed return */
+ pos = sci_get_position_from_line(sci, line);
+ sci_set_current_position(sci, pos, FALSE);
+ /* add indentation, comment multilines, etc */
+ on_new_line_added(doc);
+
+ /* correct cursor position (might not be at line end) */
+ pos = sci_get_position_from_line(sci, line);
+ pos += sci_get_line_length(sci, line) - diff;
+ sci_set_current_position(sci, pos, FALSE);
return;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.