Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1861
diff -u -r1.1861 ChangeLog
--- ChangeLog	28 Aug 2003 18:49:38 -0000	1.1861
+++ ChangeLog	1 Sep 2003 10:31:44 -0000
@@ -1,3 +1,18 @@
+2003-9-1  Maxx Cao  <maxx.cao@sun.com>
+
+	* gtkhtml.c (focus): reset selection when focus moved
+	(move_selection):  add consideration for caret mode
+	(command): handle selection command for caret mode
+	
+	* htmlengine-edit-cursor.c (clip_cursor): fixed some calculation
+	error
+	
+	* htmlengine-edit.c (html_engine_set_mark): consider caret mode
+	
+	* htmlengine.c (html_engine_draw_real): consider caret mode
+	
+	* htmlselection.c (remove_mark): consider caret mode
+
 2003-08-28  Larry Ewing  <lewing@ximian.com>
 
 	* gtkhtml.c (drag_data_received): add back some missing logic.
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.532
diff -u -r1.532 gtkhtml.c
--- gtkhtml.c	28 Aug 2003 18:49:39 -0000	1.532
+++ gtkhtml.c	1 Sep 2003 10:31:51 -0000
@@ -2166,6 +2166,13 @@
 		return rv;
 	}
 
+	/* Reset selection. */
+	if (e->shift_selection || e->mark) {
+		html_engine_disable_selection (e);
+		html_engine_edit_selection_updater_schedule (e->selection_updater);
+		e->shift_selection = FALSE;
+	}
+
 	if (html_engine_focus (e, direction) && e->focus_object) {
 		HTMLObject *cur, *obj = html_engine_get_focus_object (e);
 		gint x1, y1, x2, y2, xo, yo;
@@ -4060,7 +4067,7 @@
 	gboolean rv;
 	gint amount;
 
-	if (!html_engine_get_editable (html->engine))
+	if (!html_engine_get_editable (html->engine) && !html->engine->caret_mode)
 		return FALSE;
 
 	html->engine->shift_selection = TRUE;
@@ -4205,6 +4212,23 @@
 	case GTK_HTML_COMMAND_COPY:
 		gtk_html_copy (html);
 		break;
+
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_UP:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_DOWN:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_LEFT:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_RIGHT:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_BOL:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_EOL:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_BOD:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_EOD:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_PAGEUP:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_PAGEDOWN:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_PREV_WORD:
+	case GTK_HTML_COMMAND_MODIFY_SELECTION_NEXT_WORD:
+		if (html->engine->caret_mode || html_engine_get_editable(e))
+			rv = move_selection (html, com_type);
+		break;
+
 	default:
 		html->binding_handled = FALSE;
 	}
@@ -4453,20 +4477,6 @@
 	case GTK_HTML_COMMAND_PARAGRAPH_STYLE_ITEMALPHA:
 		gtk_html_set_paragraph_style (html, GTK_HTML_PARAGRAPH_STYLE_ITEMALPHA);
 		break;
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_UP:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_DOWN:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_LEFT:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_RIGHT:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_BOL:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_EOL:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_BOD:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_EOD:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_PAGEUP:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_PAGEDOWN:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_PREV_WORD:
-	case GTK_HTML_COMMAND_MODIFY_SELECTION_NEXT_WORD:
-		rv = move_selection (html, com_type);
-		break;
 	case GTK_HTML_COMMAND_SELECT_WORD:
 		gtk_html_select_word (html);
 		break;
Index: htmlengine-edit-cursor.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cursor.c,v
retrieving revision 1.24
diff -u -r1.24 htmlengine-edit-cursor.c
--- htmlengine-edit-cursor.c	10 Jul 2003 16:33:34 -0000	1.24
+++ htmlengine-edit-cursor.c	1 Sep 2003 10:31:51 -0000
@@ -100,10 +100,10 @@
 	if (*x1 > x + width || *y1 > y + height || *x2 < x || *y2 < y)
 		return FALSE;
 
-	*x1 = CLAMP (*x1, x, x + width -1);
-	*x2 = CLAMP (*x2, x, x + width -1);
-	*y1 = CLAMP (*y1, y, y + height -1);
-	*y2 = CLAMP (*y2, y, y + height -1);
+	*x1 = CLAMP (*x1, x, x + width);
+	*x2 = CLAMP (*x2, x, x + width);
+	*y1 = CLAMP (*y1, y, y + height);
+	*y2 = CLAMP (*y2, y, y + height);
 
 	return TRUE;
 }
Index: htmlengine-edit.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit.c,v
retrieving revision 1.99
diff -u -r1.99 htmlengine-edit.c
--- htmlengine-edit.c	31 Jul 2003 09:40:59 -0000	1.99
+++ htmlengine-edit.c	1 Sep 2003 10:31:52 -0000
@@ -92,7 +92,7 @@
 {
 	g_return_if_fail (e != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (e));
-	g_return_if_fail (e->editable);
+	g_return_if_fail (e->editable || e->caret_mode);
 
 	if (e->mark != NULL)
 		html_engine_unselect_all (e);
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.568
diff -u -r1.568 htmlengine.c
--- htmlengine.c	12 Aug 2003 22:36:54 -0000	1.568
+++ htmlengine.c	1 Sep 2003 10:31:56 -0000
@@ -4816,7 +4816,7 @@
 	}
 	html_painter_end (e->painter);
 	
-	if (e->editable)
+	if (e->editable || e->caret_mode)
 		html_engine_draw_cursor_in_area (e, x1, y1, x2 - x1, y2 - y1);
 
 	e->expose = FALSE;
Index: htmlselection.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlselection.c,v
retrieving revision 1.26
diff -u -r1.26 htmlselection.c
--- htmlselection.c	6 Nov 2002 09:15:24 -0000	1.26
+++ htmlselection.c	1 Sep 2003 10:31:57 -0000
@@ -242,7 +242,7 @@
 static void
 remove_mark (HTMLEngine *e)
 {
-	if (e->editable) {
+	if (e->editable || e->caret_mode) {
 		if (e->mark == NULL)
 			return;
 
