Revision: 4204
http://geany.svn.sourceforge.net/geany/?rev=4204&view=rev
Author: ntrel
Date: 2009-09-17 17:37:13 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
Remove queue.[hc] - use GQueue instead of GeanyQueue.
Beep if there are no more snippet positions.
Limit length of snippet positions queue to 20.
Modified Paths:
--------------
trunk/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/editor.c
trunk/wscript
Removed Paths:
-------------
trunk/src/queue.c
trunk/src/queue.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/ChangeLog 2009-09-17 17:37:13 UTC (rev 4204)
@@ -6,6 +6,11 @@
* src/utils.c, src/utils.h:
Add foreach_dir() API macro.
Update API docs for utils_get_file_list().
+ * wscript, src/queue.c, src/editor.c, src/Makefile.am, src/queue.h,
+ po/POTFILES.in:
+ Remove queue.[hc] - use GQueue instead of GeanyQueue.
+ Beep if there are no more snippet positions.
+ Limit length of snippet positions queue to 20.
2009-09-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/po/POTFILES.in 2009-09-17 17:37:13 UTC (rev 4204)
@@ -26,7 +26,6 @@
src/prefs.c
src/printing.c
src/project.c
-src/queue.c
src/sciwrappers.c
src/search.c
src/socket.c
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/src/Makefile.am 2009-09-17 17:37:13 UTC (rev 4204)
@@ -36,7 +36,6 @@
prefs.c prefs.h \
printing.c printing.h \
project.c project.h \
- queue.c queue.h \
sciwrappers.c sciwrappers.h \
search.c search.h \
socket.c socket.h \
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/src/editor.c 2009-09-17 17:37:13 UTC (rev 4204)
@@ -59,7 +59,6 @@
#include "keybindings.h"
#include "project.h"
#include "projectprivate.h"
-#include "queue.h"
/* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */
@@ -67,7 +66,7 @@
static GHashTable *snippet_hash = NULL;
-static GeanyQueue *snippet_queue = NULL;
+static GQueue *snippet_offsets = NULL;
static gint snippet_cursor_insert_pos;
/* holds word under the mouse or keyboard cursor */
@@ -107,7 +106,7 @@
void editor_snippets_free(void)
{
g_hash_table_destroy(snippet_hash);
- queue_destroy(snippet_queue);
+ g_queue_free(snippet_offsets);
}
@@ -122,7 +121,7 @@
GKeyFile *userconfig = g_key_file_new();
GHashTable *tmp;
- snippet_queue = queue_init();
+ snippet_offsets = g_queue_new();
sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, "snippets.conf", NULL);
userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "snippets.conf", NULL);
@@ -2173,11 +2172,11 @@
ScintillaObject *sci = editor->sci;
gint current_pos = sci_get_current_position(sci);
- if (snippet_queue)
+ if (snippet_offsets && !g_queue_is_empty(snippet_offsets))
{
gint offset;
- snippet_queue = queue_delete(snippet_queue, (gpointer*)&offset, FALSE);
+ offset = (gint)g_queue_pop_head(snippet_offsets);
if (current_pos > snippet_cursor_insert_pos)
snippet_cursor_insert_pos = offset + current_pos;
else
@@ -2185,6 +2184,10 @@
sci_set_current_position(sci, snippet_cursor_insert_pos, FALSE);
}
+ else
+ {
+ utils_beep();
+ }
}
@@ -2197,7 +2200,7 @@
gssize cur_index = -1;
gint ft_id = FILETYPE_ID(editor->document->file_type);
GHashTable *specials;
- GeanyQueue *temp_list;
+ GList *temp_list = NULL;
const GeanyIndentPrefs *iprefs;
gsize indent_size;
gint cursor_steps, old_cursor = 0;
@@ -2212,7 +2215,6 @@
return FALSE;
}
- temp_list = queue_init();
iprefs = editor_get_indent_prefs(editor);
read_indent(editor, pos);
indent_size = strlen(indent);
@@ -2282,7 +2284,7 @@
if (i++ > 0)
{
cursor_steps += (nl_count * indent_size);
- queue_append(temp_list, GINT_TO_POINTER(cursor_steps - old_cursor));
+ temp_list = g_list_append(temp_list, GINT_TO_POINTER(cursor_steps - old_cursor));
}
else
{
@@ -2295,10 +2297,22 @@
utils_string_replace_all(pattern, "%newline%", editor_get_eol_char(editor));
utils_string_replace_all(pattern, "%ws%", whitespace);
g_free(whitespace);
- /* We create a new list, where the cursor positions for the most recent
- * parsed snipped come first, followed by the remaining positions */
- if (temp_list->data)
- snippet_queue = queue_concat_copy(temp_list, snippet_queue);
+ /* We put the cursor positions for the most recent
+ * parsed snippet first, followed by any remaining positions */
+ i = 0;
+ if (temp_list)
+ {
+ GList *node;
+
+ foreach_list(node, temp_list)
+ g_queue_push_nth(snippet_offsets, node->data, i++);
+
+ /* limit length of queue */
+ while (g_queue_get_length(snippet_offsets) > 20)
+ g_queue_pop_tail(snippet_offsets);
+
+ g_list_free(temp_list);
+ }
if (cur_index < 0)
cur_index = pattern->len;
Deleted: trunk/src/queue.c
===================================================================
--- trunk/src/queue.c 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/src/queue.c 2009-09-17 17:37:13 UTC (rev 4204)
@@ -1,144 +0,0 @@
-/*
- * queue.c - this file is part of Geany, a fast and lightweight IDE
- *
- * Copyright 2009 kugel. aka Thomas Martitz <thomas47(at)arcor(dot)de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- */
-
-/* WARNING: Do not use this in new code, use GQueue or GList instead - this code may be
- * removed.
- *
- * This provides a simple single linked list, with some functions to modify it.
- * Being a queue, you can append data only to the end of the list, and retrieve
- * data from the beginning. Only the first node is directly visible, but with the foreach
- * functions you can iterate through the entire list.
- */
-
-
-#include "geany.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "queue.h"
-
-
-/* Allocates memory for queue_start, and sets next and data members to NULL */
-GeanyQueue *queue_init(void)
-{
- return g_new0(GeanyQueue, 1);
-}
-
-
-/* Returns true if q_node is the last node in a queue */
-static gboolean queue_is_last_node(const GeanyQueue *q_node)
-{
- return (q_node->next == NULL);
-}
-
-
-/* Appends a data in a new node at the end of the lst */
-void queue_append(GeanyQueue *queue_start, gpointer data)
-{
- GeanyQueue *temp, *next;
-
- if (queue_start == NULL || data == NULL)
- return;
-
- if (queue_start->data == NULL)
- {
- queue_start->data = data;
- return;
- }
-
- temp = g_new0(GeanyQueue, 1);
- temp->data = data;
- temp->next = NULL;
-
- next = queue_start;
- while (! queue_is_last_node(next))
- next = next->next;
- next->next = temp;
-}
-
-
-/* Removes and frees the first node in queue_start, and writes the data of the
- * removed node into data.
- * Returns a pointer to the new first item */
-GeanyQueue *queue_delete(GeanyQueue *queue_start, gpointer *data, const gboolean free_data)
-{
- GeanyQueue *ret;
-
- if (NULL == queue_start)
- return NULL;
-
- if (data != NULL)
- *data = queue_start->data;
-
- if (free_data)
- g_free(queue_start->data);
-
- ret = queue_start->next;
- g_free(queue_start);
-
- return ret;
-}
-
-
-/* Removes and frees the entire queue staring at queue_start */
-void queue_destroy(GeanyQueue *queue_start)
-{
- while ((queue_start = queue_delete(queue_start, NULL, FALSE)));
-}
-
-
-typedef void (*ForeachFunc) (GeanyQueue *queue_start, gpointer data);
-
-/* Iterates through param, and calls func with the node queue_start and each node in param */
-static void queue_foreach_data_2(GeanyQueue *queue_start, ForeachFunc func, GeanyQueue *param)
-{
- GeanyQueue *temp = param;
-
- if (! queue_start || ! param)
- return;
-
- do
- {
- (*func) (queue_start, (temp->data));
- }
- while ((temp = temp->next));
-}
-
-
-/* Copies the data of each node in q1, then the data of each node in q2 to a newly
- * created queue, using queue_append. Frees q1 and q2.
- * Returns a pointer to the created queue. */
-GeanyQueue *queue_concat_copy(GeanyQueue *q1, GeanyQueue *q2)
-{
- /* q1 + q2 = q3 *
- * ->1->2 + ->4->5->6 = 4->5->6->1->2 */
- GeanyQueue *ret = queue_init();
-
- queue_foreach_data_2(ret, queue_append, q1);
- queue_foreach_data_2(ret, queue_append, q2);
-
- queue_destroy(q1);
- queue_destroy(q2);
-
- return ret;
-}
-
Deleted: trunk/src/queue.h
===================================================================
--- trunk/src/queue.h 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/src/queue.h 2009-09-17 17:37:13 UTC (rev 4204)
@@ -1,48 +0,0 @@
-/*
- * queue.h - this file is part of Geany, a fast and lightweight IDE
- *
- * Copyright 2009 kugel. aka Thomas Martitz <thomas47(at)arcor(dot)de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- */
-
-/* WARNING: Do not use this in new code, use GQueue or GList instead - this code may be
- * removed. */
-
-#ifndef __QUEUE_H__
-#define __QUEUE_H__
-
-
-typedef struct _GeanyQueue
-{
- gpointer data;
- struct _GeanyQueue *next;
-} GeanyQueue;
-
-
-GeanyQueue *queue_init(void);
-
-void queue_append(GeanyQueue *queue_start, gpointer data);
-
-GeanyQueue *queue_delete(GeanyQueue *queue_start, gpointer *data, const gboolean free_data);
-
-GeanyQueue *queue_concat_copy(GeanyQueue *q1, GeanyQueue *q2);
-
-void queue_destroy(GeanyQueue *queue_start);
-
-
-#endif /* __QUEUE_H__ */
Modified: trunk/wscript
===================================================================
--- trunk/wscript 2009-09-17 16:47:45 UTC (rev 4203)
+++ trunk/wscript 2009-09-17 17:37:13 UTC (rev 4204)
@@ -109,7 +109,7 @@
'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
- 'src/queue.c', 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
+ 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
'src/symbols.c',
'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/treeviews.c',
'src/ui_utils.c', 'src/utils.c' ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4203
http://geany.svn.sourceforge.net/geany/?rev=4203&view=rev
Author: ntrel
Date: 2009-09-17 16:47:45 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
Add foreach_dir() API macro.
Update API docs for utils_get_file_list().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-17 16:39:11 UTC (rev 4202)
+++ trunk/ChangeLog 2009-09-17 16:47:45 UTC (rev 4203)
@@ -3,6 +3,9 @@
* plugins/filebrowser.c:
Free file list memory whilst iterating the list.
Minor formatting fixes.
+ * src/utils.c, src/utils.h:
+ Add foreach_dir() API macro.
+ Update API docs for utils_get_file_list().
2009-09-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2009-09-17 16:39:11 UTC (rev 4202)
+++ trunk/src/utils.c 2009-09-17 16:47:45 UTC (rev 4203)
@@ -1342,23 +1342,30 @@
/**
- * Gets a sorted list of files from the specified directory.
- * Locale encoding is expected for path and used for the file list. The list and the data
- * in the list should be freed after use.
+ * Gets a sorted list of files from the specified directory.
+ * Locale encoding is expected for @a path and used for the file list. The list and the data
+ * in the list should be freed after use, e.g.:
+ * @code
+ * g_slist_foreach(list, (GFunc) g_free, NULL);
+ * g_slist_free(list); @endcode
*
- * @param path The path of the directory to scan, in locale encoding.
- * @param length The location to store the number of non-@c NULL data items in the list,
- * unless @c NULL.
- * @param error The is the location for storing a possible error, or @c NULL.
+ * @note If you don't want sorted filenames you should use the foreach_dir() macro instead -
+ * it's more efficient and perhaps easier to use than freeing the list and its contents.
*
- * @return A newly allocated list or @c NULL if no files found. The list and its data should be
- * freed when no longer needed.
+ * @param path The path of the directory to scan, in locale encoding.
+ * @param length The location to store the number of non-@c NULL data items in the list,
+ * unless @c NULL.
+ * @param error The location for storing a possible error, or @c NULL.
+ *
+ * @return A newly allocated list or @c NULL if no files found. The list and its data should be
+ * freed when no longer needed.
**/
GSList *utils_get_file_list(const gchar *path, guint *length, GError **error)
{
GSList *list = NULL;
guint len = 0;
GDir *dir;
+ const gchar *filename;
if (error)
*error = NULL;
@@ -1370,12 +1377,8 @@
if (dir == NULL)
return NULL;
- while (1)
+ foreach_dir(filename, dir)
{
- const gchar *filename = g_dir_read_name(dir);
- if (filename == NULL)
- break;
-
list = g_slist_insert_sorted(list, g_strdup(filename), (GCompareFunc) utils_str_casecmp);
len++;
}
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2009-09-17 16:39:11 UTC (rev 4202)
+++ trunk/src/utils.h 2009-09-17 16:47:45 UTC (rev 4203)
@@ -91,7 +91,15 @@
#define foreach_slist(node, list) \
foreach_list(node, list)
+/** Iterates through each unsorted filename in a @c GDir.
+ * @param filename (@c const @c gchar*) locale-encoded filename, without path. Do not modify or free.
+ * @param dir @c GDir created with @c g_dir_open(). Call @c g_dir_close() afterwards.
+ * @see utils_get_file_list() if you want a sorted list.
+ * @since Geany 0.19. */
+#define foreach_dir(filename, dir)\
+ for ((filename) = g_dir_read_name(dir); (filename) != NULL; (filename) = g_dir_read_name(dir))
+
void utils_open_browser(const gchar *uri);
gint utils_get_line_endings(const gchar* buffer, glong size);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4198
http://geany.svn.sourceforge.net/geany/?rev=4198&view=rev
Author: ntrel
Date: 2009-09-16 14:05:14 +0000 (Wed, 16 Sep 2009)
Log Message:
-----------
Note the documentation files use (4) spaces for indentation.
Modified Paths:
--------------
trunk/HACKING
Modified: trunk/HACKING
===================================================================
--- trunk/HACKING 2009-09-16 13:56:58 UTC (rev 4197)
+++ trunk/HACKING 2009-09-16 14:05:14 UTC (rev 4198)
@@ -159,6 +159,8 @@
Style
^^^^^
* We use a tab width of 4 and indent completely with tabs not spaces.
+ Note the documentation files use (4) spaces instead, so you may want
+ to use the 'Detect from file' indent pref.
* Use the multiline comment ``/* */`` to comment small blocks of code,
functions descriptions or longer explanations of code, etc. C++ single
line comments will cause portability issues. The more comments are in
@@ -197,7 +199,7 @@
{
gint foo, bar; /* variables can go on the same line */
gchar *ptr; /* pointer symbol must go next to variable name, not type */
- gchar *another; /* pointers should go on separate lines */
+ gchar *another; /* pointers should normally go on separate lines */
if (foo)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4197
http://geany.svn.sourceforge.net/geany/?rev=4197&view=rev
Author: ntrel
Date: 2009-09-16 13:56:58 +0000 (Wed, 16 Sep 2009)
Log Message:
-----------
Don't move the cursor when reloading.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-16 12:23:50 UTC (rev 4196)
+++ trunk/ChangeLog 2009-09-16 13:56:58 UTC (rev 4197)
@@ -4,6 +4,8 @@
Make Goto Tag commands use the current selection if present (useful
for selecting part of a tag or for ReST section names with spaces
in).
+ * src/document.c:
+ Don't move the cursor when reloading.
2009-09-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2009-09-16 12:23:50 UTC (rev 4196)
+++ trunk/src/document.c 2009-09-16 13:56:58 UTC (rev 4197)
@@ -1234,7 +1234,7 @@
document_check_disk_status(doc, TRUE); /* force a file changed check */
}
}
- if (reload || (!reload && doc == NULL))
+ if (reload || doc == NULL)
{ /* doc possibly changed */
display_filename = utils_str_middle_truncate(utf8_filename, 100);
@@ -1290,9 +1290,6 @@
doc->priv->line_count = sci_get_line_count(doc->editor->sci);
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0);
- /* set the cursor position according to pos, cl_options.goto_line and cl_options.goto_column */
- pos = set_cursor_position(doc->editor, pos);
-
if (! reload)
{
@@ -1346,6 +1343,8 @@
* based on a configurable interval */
/*g_timeout_add(10000, auto_update_tag_list, doc);*/
+ /* set the cursor position according to pos, cl_options.goto_line and cl_options.goto_column */
+ pos = set_cursor_position(doc->editor, pos);
/* now bring the file in front */
editor_goto_pos(doc->editor, pos, FALSE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.