changeset 3208:2215aa4fabdb

[gaim-migrate @ 3225] Better detection of words in gtkimhtml selection by Ben Miller committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 05 May 2002 01:06:15 +0000
parents 75912ec1a1cb
children 265a3c9d0557
files ChangeLog src/gtkimhtml.c
diffstat 2 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat May 04 19:06:01 2002 +0000
+++ b/ChangeLog	Sun May 05 01:06:15 2002 +0000
@@ -12,6 +12,7 @@
 	  (Thanks, Ari Pollak)
 	* Added helpful stuff to the Help menu.
 	* Self-aliasing from the account editor.
+	* Better selection in GtkIMHtml (Thanks Ben Miller)
 
 version 0.57 (04/25/2002):
 	* New authorization method for Yahoo!
--- a/src/gtkimhtml.c	Sat May 04 19:06:01 2002 +0000
+++ b/src/gtkimhtml.c	Sun May 05 01:06:15 2002 +0000
@@ -1178,14 +1178,32 @@
 	start = chunk->sel_start;
 	end = chunk->sel_end;
 
-	if (start != chunk->text)
-		while (start > chunk->text && *(start-1) != ' ')
-			start--;
+	if (start != chunk->text) {
+		if (isalnum(*start) || *start == '\'')
+			while (start > chunk->text && 
+			       (isalnum(*(start-1)) || *(start-1) == '\''))
+				start--;
+		else if (isspace(*start))
+			while (start > chunk->text && isspace(*(start-1)))
+				start--;
+		else if (ispunct(*start))
+			while (start > chunk->text && ispunct(*(start-1)))
+				start--;
+	}
 	chunk->sel_start = start;
 
-	if (end != NULL)
-		while (*end != '\0' && *end != ' ')
-			end++;
+	if (end != NULL) {
+		if (isalnum(*end) || *end == '\'')
+			while (*end != '\0' && 
+			       (isalnum(*end) || *end == '\''))
+				end++;
+		else if (isspace(*end))
+			while (*end != '\0' && isspace(*end))
+				end++;
+		else if (ispunct(*end))
+			while (*end != '\0' && ispunct(*end))
+				end++;
+	}
 	chunk->sel_end = end;
 }