[vala] glib-2.0: add string.get_prev_char()



commit b4e884c150100d56636d5cf6be4e5311d62bb718
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Wed Jul 4 21:39:01 2012 +0200

    glib-2.0: add string.get_prev_char()
    
    This is the opposite of string.get_next_char().
    
    There is a difference though, to be more convenient in a loop:
    
    get_next_char() returns the current chararcter, and the next index.
    get_prev_char() returns the previous character, and the previous index.
    
    Fixes bug 655185.

 vapi/glib-2.0.vapi |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 0105881..9405963 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -1005,6 +1005,19 @@ public class string {
 
 	[CCode (cname = "g_utf8_prev_char")]
 	public unowned string prev_char ();
+	[CCode (cname = "g_utf8_prev_char")]
+	static char* utf8_prev_char (char* str);
+	public bool get_prev_char (ref int index, out unichar c) {
+		if (0 < index) {
+			index = (int) (utf8_prev_char ((char*) this + index) - (char*) this);
+			c = utf8_get_char ((char*) this + index);
+			return true;
+		} else {
+			c = 0;
+			return false;
+		}
+	}
+
 	[Deprecated (replacement = "string.length")]
 	[CCode (cname = "strlen")]
 	public long len ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]