Glib Regex?




	Has any thought/effort been put into wrapping GNU regex.c in the
Glib style?

	My GtkEtextBuffer object is about 98% done (minus
testing/debugging--I haven't even tried compiling it yet).  I decided to
put in a simple g_strcmp()-based search function into the API so the
keybindings for things like "next word", "previous line", etc. would be
easy to implement.

	Here is the prototype for that simple search function:
/********************************************************/
/**
 * gtk_etext_buffer_find:
 * @buf: The #GtkEtextBuffer you wish to search in
 * @search_text: The string you wish to search for
 * @start_pos: The position to start the search from
 * @forward: The direction you wish to search
 * 
 * This function lets you do a (very) simple g_strcmp() search for a particular
 * string.  This is useful for things like keybindings (it makes it easy
 * to find the previous space (" ") if you want to move to the beginning or
 * end of the previous word, for example) or if you want to move to the last
 * paragraph by searching for "\n\n" or some such thing.
 * Preconditions: @buf should be valid and non-NULL.
 * Postconditions: none.
 * 
 * Returns: The position that @search_text is found at, or -1 if it's not found.
 */
gint gtk_etext_buffer_find              (GtkEtextBuffer *buf,
				         const gchar *search_text,
					 guint start_pos,
					 gboolean forward);
/********************************************************/

	I think regex-based searches are a feature that many applications
would want, so I'm considering adding some kind of regex-based search to
the GtkEtextBuffer API.  However, I don't want to do that unless there is
a Glib wrapper for GNU regex.

	So: Has this come up before?  Has any work been done?  Would there
be a problem with adding regexes to Glib?  I might be willing to do it if
people are interested.

	As an aside, does anyone know if GNU regex compiles on the win32
platform?

Thanks,
Derek Simkowiak
dereks@kd-dev.com



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