Revision: 1726
http://geany.svn.sourceforge.net/geany/?rev=1726&view=rev
Author: ntrel
Date: 2007-07-19 04:54:02 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
Tidy up plugin code to make their structure more consistent.
Modified Paths:
--------------
trunk/plugins/classbuilder.c
trunk/plugins/demoplugin.c
Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c 2007-07-19 11:49:53 UTC (rev 1725)
+++ trunk/plugins/classbuilder.c 2007-07-19 11:54:02 UTC (rev 1726)
@@ -32,6 +32,29 @@
#include "document.h"
+static PluginData *plugin_data;
+
+#define doc_array plugin_data->doc_array
+// can't use document as a macro because it's currently a typename
+#define documents plugin_data->document
+#define scintilla plugin_data->sci
+#define templates plugin_data->templates
+#define utils plugin_data->utils
+#define ui plugin_data->ui
+
+
+static struct
+{
+ GtkWidget *menu_item;
+}
+local_data;
+
+
+VERSION_CHECK(4)
+
+PLUGIN_INFO(_("Class Builder"), _("Creates source files for new class types."))
+
+
enum
{
GEANY_CLASS_TYPE_CPP,
@@ -77,24 +100,6 @@
} CreateClassDialog;
-static PluginData *plugin_data;
-
-#define doc_array plugin_data->doc_array
-// can't use document as a macro because it's currently a typename
-#define documents plugin_data->document
-#define scintilla plugin_data->sci
-#define templates plugin_data->templates
-#define utils plugin_data->utils
-#define ui plugin_data->ui
-
-
-static struct
-{
- GtkWidget *menu_item;
-}
-local_data;
-
-
static const gchar templates_cpp_class_header[] = "{fileheader}\n\n\
#ifndef {header_guard}\n\
#define {header_guard}\n\
@@ -224,11 +229,6 @@
static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg);
-VERSION_CHECK(4)
-
-PLUGIN_INFO(_("Class Builder"), _("Creates source files for new class types."))
-
-
/* I don't want this to be in the plugin API because it can cause leaks if any pointers
* are NULL -ntrel. */
/* Frees all passed pointers if they are *ALL* non-NULL.
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2007-07-19 11:49:53 UTC (rev 1725)
+++ trunk/plugins/demoplugin.c 2007-07-19 11:54:02 UTC (rev 1726)
@@ -29,7 +29,7 @@
#include "plugindata.h"
-static PluginData *my_data;
+static PluginData *plugin_data;
static struct
{
@@ -53,7 +53,7 @@
GtkWidget *dialog;
dialog = gtk_message_dialog_new(
- GTK_WINDOW(my_data->app->window),
+ GTK_WINDOW(plugin_data->app->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
@@ -71,12 +71,12 @@
{
GtkWidget *demo_item;
- my_data = data; // keep a pointer to the main application fields & functions
+ plugin_data = data; // keep a pointer to the main application fields & functions
// Add an item to the Tools menu
demo_item = gtk_menu_item_new_with_mnemonic(_("_Demo Plugin"));
gtk_widget_show(demo_item);
- gtk_container_add(GTK_CONTAINER(my_data->tools_menu), demo_item);
+ gtk_container_add(GTK_CONTAINER(plugin_data->tools_menu), demo_item);
g_signal_connect(G_OBJECT(demo_item), "activate", G_CALLBACK(item_activate), NULL);
// keep a pointer to the menu item, so we can remove it when the plugin is unloaded
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1725
http://geany.svn.sourceforge.net/geany/?rev=1725&view=rev
Author: ntrel
Date: 2007-07-19 04:49:53 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
Use extern 'app' and 'filetypes' global variables in headers, so that
G_MODULE_BIND_LOCAL can later be used when loading plugins to detect
any unresolved symbols.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/filetypes.c
trunk/src/filetypes.h
trunk/src/geany.h
trunk/src/main.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-19 11:15:42 UTC (rev 1724)
+++ trunk/ChangeLog 2007-07-19 11:49:53 UTC (rev 1725)
@@ -2,6 +2,10 @@
* src/treeviews.c:
Prevent warning when clicking on symbol list parent items.
+ * src/geany.h, src/filetypes.c, src/filetypes.h, src/main.c:
+ Use extern 'app' and 'filetypes' global variables in headers, so that
+ G_MODULE_BIND_LOCAL can later be used when loading plugins to detect
+ any unresolved symbols.
2007-07-18 Nick Treleaven <nick.treleaven(a)btinternet.com>
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2007-07-19 11:15:42 UTC (rev 1724)
+++ trunk/src/filetypes.c 2007-07-19 11:49:53 UTC (rev 1725)
@@ -38,6 +38,9 @@
#include "sciwrappers.h"
+filetype *filetypes[GEANY_MAX_FILE_TYPES];
+
+
/* This is the order of unique ids used in the config file.
* The order must not be changed but can be appended to. */
enum
Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h 2007-07-19 11:15:42 UTC (rev 1724)
+++ trunk/src/filetypes.h 2007-07-19 11:49:53 UTC (rev 1725)
@@ -67,7 +67,7 @@
GEANY_FILETYPES_DOCBOOK,
GEANY_FILETYPES_HTML,
GEANY_FILETYPES_CSS,
-
+
// miscellaneous languages
GEANY_FILETYPES_SQL,
GEANY_FILETYPES_LATEX,
@@ -119,7 +119,7 @@
void (*style_func_ptr) (ScintillaObject*);
} filetype;
-filetype *filetypes[GEANY_MAX_FILE_TYPES];
+extern filetype *filetypes[GEANY_MAX_FILE_TYPES];
// If uid is valid, return corresponding filetype, otherwise NULL.
Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h 2007-07-19 11:15:42 UTC (rev 1724)
+++ trunk/src/geany.h 2007-07-19 11:49:53 UTC (rev 1725)
@@ -182,7 +182,7 @@
GeanyProject *project; // currently active project or NULL if none is open
} MyApp;
-MyApp *app;
+extern MyApp *app;
enum
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-07-19 11:15:42 UTC (rev 1724)
+++ trunk/src/main.c 2007-07-19 11:49:53 UTC (rev 1725)
@@ -79,8 +79,11 @@
#endif
+MyApp *app;
+
CommandLineOptions cl_options; // fields initialised in parse_command_line_options
+
static gboolean debug_mode = FALSE;
static gboolean ignore_global_tags = FALSE;
static gboolean no_msgwin = FALSE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1721
http://geany.svn.sourceforge.net/geany/?rev=1721&view=rev
Author: ntrel
Date: 2007-07-18 05:20:13 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Fix possible segfault when a file is closed and using go forward.
Fix 2 possible memory leaks when files have been closed.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/navqueue.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-18 12:16:07 UTC (rev 1720)
+++ trunk/ChangeLog 2007-07-18 12:20:13 UTC (rev 1721)
@@ -2,6 +2,9 @@
* src/editor.c:
Fix gcc warning, add comment for editor_scroll_to_line().
+ * src/navqueue.c:
+ Fix possible segfault when a file is closed and using go forward.
+ Fix 2 possible memory leaks when files have been closed.
2007-07-17 Nick Treleaven <nick.treleaven(a)btinternet.com>
Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c 2007-07-18 12:16:07 UTC (rev 1720)
+++ trunk/src/navqueue.c 2007-07-18 12:20:13 UTC (rev 1721)
@@ -121,13 +121,13 @@
}
nav_queue_pos = 0;
}
- /// TODO add check to not add an entry if "Go To Defintion" on a definition is used
g_queue_push_head(navigation_queue, npos);
adjust_buttons();
}
-/* line is counted with 1 as the first line, not 0. */
+/* Adds the current document position to the queue before adding the new position.
+ * line is counted with 1 as the first line, not 0. */
gboolean navqueue_append(gint new_idx, gint line)
{
gint old_idx = document_get_cur_idx();
@@ -169,7 +169,7 @@
else
{
/// TODO: add option to re open the file
- g_queue_pop_nth(navigation_queue, nav_queue_pos + 1);
+ g_free(g_queue_pop_nth(navigation_queue, nav_queue_pos + 1));
}
adjust_buttons();
}
@@ -179,7 +179,8 @@
{
filepos *fnext;
- if (nav_queue_pos < 1 || g_queue_get_length(navigation_queue) < 2)
+ if (nav_queue_pos < 1 ||
+ nav_queue_pos > g_queue_get_length(navigation_queue))
return;
// jump forward
@@ -191,7 +192,7 @@
else
{
/// TODO: add option to re open the file
- g_queue_pop_nth(navigation_queue, nav_queue_pos - 1);
+ g_free(g_queue_pop_nth(navigation_queue, nav_queue_pos - 1));
}
adjust_buttons();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1719
http://geany.svn.sourceforge.net/geany/?rev=1719&view=rev
Author: eht16
Date: 2007-07-17 09:27:49 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
Add keybinding for scroll to current line.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.docbook
trunk/src/editor.c
trunk/src/editor.h
trunk/src/keybindings.c
trunk/src/keybindings.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/ChangeLog 2007-07-17 16:27:49 UTC (rev 1719)
@@ -41,6 +41,9 @@
Use GetFullPathName() instead of lrealpath() to get Tagmanager
working on files containing special characters on Windows.
* configure.in: Fix broken configure when using autoconf < 2.60.
+ * doc/geany.docbook, src/editor.c, src/editor.h, src/keybindings.c,
+ src/keybindings.h:
+ Add keybinding for scroll to current line.
2007-07-16 Enrico Tröger <enrico.troeger(a)uvena.de>
Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/doc/geany.docbook 2007-07-17 16:27:49 UTC (rev 1719)
@@ -1973,10 +1973,17 @@
</row>
<row>
<entry>Select current line</entry>
- <entry>Selects the current line under the cursor..
+ <entry>Selects the current line under the cursor.
</entry>
</row>
<row>
+ <entry>Scroll to current line</entry>
+ <entry>Scrolls the current line into the centre of the view.
+ The cursor position and or an existing selection will not
+ be changed.
+ </entry>
+ </row>
+ <row>
<entry>Insert alternative whitespace</entry>
<entry>Inserts a tabulator character when spaces should be used for
indentation and inserts space characters of the amount of a
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/src/editor.c 2007-07-17 16:27:49 UTC (rev 1719)
@@ -160,7 +160,7 @@
* http://scintilla.sourceforge.net/ScintillaDoc.html#LineWrapping */
if (doc_list[idx].scroll_percent > 0.0F)
{
- scroll_to_line(sci, -1, doc_list[idx].scroll_percent);
+ editor_scroll_to_line(sci, -1, doc_list[idx].scroll_percent);
doc_list[idx].scroll_percent = -1.0F; // disable further scrolling
}
#if 0
@@ -2262,7 +2262,7 @@
/* Scroll the view to make line appear at percent_of_view.
* line can be -1 to use the current position. */
-static void scroll_to_line(ScintillaObject *sci, gint line, gfloat percent_of_view)
+void editor_scroll_to_line(ScintillaObject *sci, gint line, gfloat percent_of_view)
{
gint vis1, los, delta;
GtkWidget *wid = GTK_WIDGET(sci);
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/src/editor.h 2007-07-17 16:27:49 UTC (rev 1719)
@@ -147,6 +147,8 @@
void editor_indentation_by_one_space(gint idx, gint pos, gboolean decrease);
+void editor_scroll_to_line(ScintillaObject *sci, gint line, gfloat percent_of_view);
+
void editor_finalize();
#endif
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/src/keybindings.c 2007-07-17 16:27:49 UTC (rev 1719)
@@ -308,6 +308,8 @@
GDK_l, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectline", _("Select current line"));
keys[GEANY_KEYS_EDIT_SELECTPARAGRAPH] = fill(cb_func_edit,
GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("Select current paragraph"));
+ keys[GEANY_KEYS_EDIT_SCROLLTOLINE] = fill(cb_func_edit,
+ GDK_l, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_scrolltoline", _("Scroll to current line"));
keys[GEANY_KEYS_EDIT_INSERTALTWHITESPACE] = fill(cb_func_edit,
0, 0, "edit_insertwhitespace", _("Insert alternative whitespace"));
@@ -1088,6 +1090,9 @@
switch (key_id)
{
+ case GEANY_KEYS_EDIT_SCROLLTOLINE:
+ editor_scroll_to_line(doc_list[idx].sci, -1, 0.5F);
+ break;
case GEANY_KEYS_EDIT_DUPLICATELINE:
on_menu_duplicate_line1_activate(NULL, NULL);
break;
Modified: trunk/src/keybindings.h
===================================================================
--- trunk/src/keybindings.h 2007-07-17 16:11:38 UTC (rev 1718)
+++ trunk/src/keybindings.h 2007-07-17 16:27:49 UTC (rev 1719)
@@ -140,6 +140,7 @@
GEANY_KEYS_EDIT_SELECTWORD,
GEANY_KEYS_EDIT_SELECTLINE,
GEANY_KEYS_EDIT_SELECTPARAGRAPH,
+ GEANY_KEYS_EDIT_SCROLLTOLINE,
GEANY_KEYS_EDIT_INSERTALTWHITESPACE,
GEANY_KEYS_EDIT_AUTOCOMPLETE,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1718
http://geany.svn.sourceforge.net/geany/?rev=1718&view=rev
Author: ntrel
Date: 2007-07-17 09:11:38 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
Add a navigation queue position when clicking on symbol list items.
Prevent duplicates in the navigation queue.
Add navqueue_append() which adds the current document position to the
queue before adding the new position.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/navqueue.c
trunk/src/navqueue.h
trunk/src/treeviews.c
trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-17 15:48:53 UTC (rev 1717)
+++ trunk/ChangeLog 2007-07-17 16:11:38 UTC (rev 1718)
@@ -4,6 +4,11 @@
src/document.h:
Move font & file open/save dialog callbacks to dialogs.c.
Add document_clone() in document.c (for Save As open in new tab).
+ * src/utils.c, src/navqueue.c, src/navqueue.h, src/treeviews.c:
+ Add a navigation queue position when clicking on symbol list items.
+ Prevent duplicates in the navigation queue.
+ Add navqueue_append() which adds the current document position to the
+ queue before adding the new position.
2007-07-17 Enrico Tröger <enrico.troeger(a)uvena.de>
Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c 2007-07-17 15:48:53 UTC (rev 1717)
+++ trunk/src/navqueue.c 2007-07-17 16:11:38 UTC (rev 1718)
@@ -35,10 +35,10 @@
// for the navigation history queue
typedef struct
{
- gchar *file;
+ gchar *file; // this is the tagmanager filename, not document::file_name
/// TODO maybe it is better to work on positions than on lines to be more accurate when
/// switching back or forward, sci_get_position_from_line() could be used for tm_tag lines
- gint line;
+ gint line; // line is counted with 1 as the first line, not 0
} filepos;
GQueue *navigation_queue;
@@ -86,13 +86,29 @@
}
-void navqueue_new_position(gchar *file, gint line)
+static gboolean
+queue_pos_matches(guint queue_pos, const gchar *fname, gint line)
{
+ if (queue_pos < g_queue_get_length(navigation_queue))
+ {
+ filepos *fpos = g_queue_peek_nth(navigation_queue, queue_pos);
+
+ return (utils_str_equal(fpos->file, fname) && fpos->line == line);
+ }
+ return FALSE;
+}
+
+
+void navqueue_new_position(gchar *tm_filename, gint line)
+{
filepos *npos;
guint i;
+ if (queue_pos_matches(nav_queue_pos, tm_filename, line))
+ return; // prevent duplicates
+
npos = g_new0(filepos, 1);
- npos->file = file;
+ npos->file = tm_filename;
npos->line = line;
// if we've jumped to a new position from
@@ -111,6 +127,30 @@
}
+/* line is counted with 1 as the first line, not 0. */
+gboolean navqueue_append(gint new_idx, gint line)
+{
+ gint old_idx = document_get_cur_idx();
+
+ g_return_val_if_fail(DOC_IDX_VALID(old_idx), FALSE);
+ g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE);
+ g_return_val_if_fail(line >= 1, FALSE);
+
+ // first add old file as old position
+ if (doc_list[old_idx].tm_file)
+ {
+ gint cur_line = sci_get_current_line(doc_list[old_idx].sci, -1);
+
+ navqueue_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
+ }
+
+ g_return_val_if_fail(doc_list[new_idx].tm_file, FALSE);
+
+ navqueue_new_position(doc_list[new_idx].tm_file->file_name, line);
+ return TRUE;
+}
+
+
void navqueue_go_back()
{
filepos *fprev;
Modified: trunk/src/navqueue.h
===================================================================
--- trunk/src/navqueue.h 2007-07-17 15:48:53 UTC (rev 1717)
+++ trunk/src/navqueue.h 2007-07-17 16:11:38 UTC (rev 1718)
@@ -29,8 +29,12 @@
void navqueue_free();
-void navqueue_new_position(gchar *file, gint line);
+void navqueue_new_position(gchar *tm_filename, gint line);
+
+gboolean navqueue_append(gint new_idx, gint line);
+
+
void navqueue_go_back();
void navqueue_go_forward();
Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c 2007-07-17 15:48:53 UTC (rev 1717)
+++ trunk/src/treeviews.c 2007-07-17 16:11:38 UTC (rev 1718)
@@ -35,6 +35,7 @@
#include "utils.h"
#include "ui_utils.h"
#include "symbols.h"
+#include "navqueue.h"
enum
@@ -479,7 +480,10 @@
if (string && (strlen(string) > 0))
{
gint idx = document_get_cur_idx();
- utils_goto_line(idx, utils_get_local_tag(idx, string));
+ gint line = utils_get_local_tag(idx, string);
+
+ navqueue_append(idx, line);
+ utils_goto_line(idx, line);
g_free(string);
}
}
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-07-17 15:48:53 UTC (rev 1717)
+++ trunk/src/utils.c 2007-07-17 16:11:38 UTC (rev 1718)
@@ -203,6 +203,7 @@
}
+// line is counted with 1 as the first line, not 0
gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line)
{
gint file_idx = document_find_by_filename(file, is_tm_filename);
@@ -213,6 +214,7 @@
}
+// line is counted with 1 as the first line, not 0
gboolean utils_goto_line(gint idx, gint line)
{
gint page_num;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.