SF.net SVN: geany:[4204] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Sep 17 17:37:14 UTC 2009
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.
More information about the Commits
mailing list