SF.net SVN: geany:[4385] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Oct 28 16:32:23 UTC 2009
Revision: 4385
http://geany.svn.sourceforge.net/geany/?rev=4385&view=rev
Author: ntrel
Date: 2009-10-28 16:32:22 +0000 (Wed, 28 Oct 2009)
Log Message:
-----------
Add general function sci_get_string() that works with any string
buffer messages that follow the Windows message convention.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
trunk/src/sciwrappers.c
trunk/src/sciwrappers.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-10-28 11:33:11 UTC (rev 4384)
+++ trunk/ChangeLog 2009-10-28 16:32:22 UTC (rev 4385)
@@ -5,6 +5,9 @@
* src/interface.c, src/keybindings.c, src/callbacks.c,
src/callbacks.h, geany.glade:
Add 'Reflow, Transpose, Smart line indent' Edit->Format menu items.
+ * src/sciwrappers.c, src/sciwrappers.h, src/editor.c:
+ Add general function sci_get_string() that works with any string
+ buffer messages that follow the Windows message convention.
2009-10-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2009-10-28 11:33:11 UTC (rev 4384)
+++ trunk/src/editor.c 2009-10-28 16:32:22 UTC (rev 4385)
@@ -4769,17 +4769,6 @@
}
-/* safe way to read Scintilla string into a buffer */
-static gchar *sci_get_string(ScintillaObject *sci, gint msg)
-{
- gint size = SSM(sci, msg, 0, 0) + 1;
- gchar *str = g_malloc(size);
-
- SSM(sci, msg, 0, (sptr_t)str);
- return str;
-}
-
-
gboolean editor_complete_word_part(GeanyEditor *editor)
{
gchar *entry;
@@ -4789,7 +4778,7 @@
if (!SSM(editor->sci, SCI_AUTOCACTIVE, 0, 0))
return FALSE;
- entry = sci_get_string(editor->sci, SCI_AUTOCGETCURRENTTEXT);
+ entry = sci_get_string(editor->sci, SCI_AUTOCGETCURRENTTEXT, 0);
/* if no word part, complete normally */
if (!check_partial_completion(editor, entry))
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2009-10-28 11:33:11 UTC (rev 4384)
+++ trunk/src/sciwrappers.c 2009-10-28 16:32:22 UTC (rev 4385)
@@ -527,18 +527,26 @@
}
+/* safe way to read Scintilla string into new memory.
+ * works with any string buffer messages that follow the Windows message convention. */
+gchar *sci_get_string(ScintillaObject *sci, gint msg, gulong wParam)
+{
+ gint size = SSM(sci, msg, wParam, 0) + 1;
+ gchar *str = g_malloc(size);
+
+ SSM(sci, msg, wParam, (sptr_t)str);
+ str[size - 1] = '\0'; /* ensure termination, needed for SCI_GETLINE */
+ return str;
+}
+
+
/** Get line contents.
* @param sci Scintilla widget.
* @param line_num Line number.
* @return A @c NULL-terminated copy of the line text. */
gchar *sci_get_line(ScintillaObject *sci, gint line_num)
{
- gint len = sci_get_line_length(sci, line_num);
- gchar *linebuf = g_malloc(len + 1);
-
- SSM(sci, SCI_GETLINE, line_num, (sptr_t) linebuf);
- linebuf[len] = '\0';
- return linebuf;
+ return sci_get_string(sci, SCI_GETLINE, line_num);
}
@@ -593,12 +601,7 @@
*/
gchar *sci_get_selection_contents(ScintillaObject *sci)
{
- gint len = sci_get_selected_text_length(sci);
- gchar *selection = g_malloc(len + 1);
-
- SSM(sci, SCI_GETSELTEXT, 0, (sptr_t) selection);
-
- return selection;
+ return sci_get_string(sci, SCI_GETSELTEXT, 0);
}
Modified: trunk/src/sciwrappers.h
===================================================================
--- trunk/src/sciwrappers.h 2009-10-28 11:33:11 UTC (rev 4384)
+++ trunk/src/sciwrappers.h 2009-10-28 16:32:22 UTC (rev 4385)
@@ -28,6 +28,8 @@
#include "ScintillaWidget.h"
+gchar* sci_get_string (ScintillaObject *sci, gint msg, gulong wParam);
+
void sci_set_line_numbers (ScintillaObject *sci, gboolean set, gint extra_width);
void sci_set_mark_long_lines (ScintillaObject *sci, gint type, gint column, const gchar *color);
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