Index: libzvt/libzvt/libzvt.h
===================================================================
RCS file: /sgnome/cvsroots/sun-gnome/libzvt/libzvt/libzvt.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 libzvt.h
--- libzvt/libzvt/libzvt.h	16 Oct 2002 18:27:06 -0000	1.1.1.1
+++ libzvt/libzvt/libzvt.h	2 Dec 2002 18:33:32 -0000
@@ -316,6 +316,11 @@ void	     zvt_term_draw_text			(ZvtTerm 
 						 int offx, int offy,
 						 GdkGC *fgc,
 						 int dofill, int overstrike);
+
+gchar*	     zvt_term_get_utf8_from_line	 (struct vt_line* line);
+gint	     zvt_term_get_char_index_from_column (gchar* utf8_ptr, gint column_index); 
+gint	     zvt_term_get_column_from_char_index (gchar* utf8_ptr, gint char_index);
+
 #endif
 void	     zvt_term_scroll		       (ZvtTerm *term, int n);
 void         zvt_term_set_font_name            (ZvtTerm *term, char *name);
Index: libzvt/libzvt/update.c
===================================================================
RCS file: /sgnome/cvsroots/sun-gnome/libzvt/libzvt/update.c,v
retrieving revision 1.2
diff -u -p -r1.2 update.c
--- libzvt/libzvt/update.c	13 Nov 2002 16:29:15 -0000	1.2
+++ libzvt/libzvt/update.c	2 Dec 2002 18:33:32 -0000
@@ -940,6 +940,54 @@ void vt_fix_selection(struct _vtx *vx)
     /* scan back over word chars */
     d(printf("startx = %d %p-> \n", sx, s->data));
 
+#ifdef HAS_I18N
+    /*
+     * vt_in_wordclass is not appropriate for i18n.
+     * should rely on pango to detect Unicode word break
+     * like gtk widget. (should fix zvt-accesible.c, too)
+     */
+    {
+      PangoContext *context = gdk_pango_context_get();
+      PangoLayout *layout = pango_layout_new(context);
+      PangoLogAttr *log_attrs;
+      gchar* utf8_ptr;
+      gint utf8_len;
+      gint n_attrs;
+      gint start_char_index, word_start, word_end;
+
+      /* get utf8 string with null terminate from vt_line */
+      utf8_ptr = zvt_term_get_utf8_from_line (s);
+      utf8_len = g_utf8_strlen (utf8_ptr, -1);
+
+      /* setup pango layout to do language sensitive word breaking */
+      pango_context_set_language (context, gtk_get_default_language ());
+      pango_layout_set_text (layout, utf8_ptr, strlen (utf8_ptr));
+      pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
+
+      /* caluculate character position from column index */
+      start_char_index = zvt_term_get_char_index_from_column (utf8_ptr, sx);
+
+      /* detect word start */
+      word_start = start_char_index;
+      while (word_start > 0
+	     && !log_attrs[word_start].is_word_start
+	     && !log_attrs[word_start].is_word_end)
+	word_start--;
+
+      /* detect word end */
+      word_end = start_char_index + 1;
+      while (word_end < utf8_len
+	     && !log_attrs[word_end].is_word_end
+	     && !log_attrs[word_end].is_word_start)
+	word_end++;
+
+      sx = zvt_term_get_column_from_char_index (utf8_ptr, word_start);
+      ex = zvt_term_get_column_from_char_index (utf8_ptr, word_end);
+
+      g_free (log_attrs);
+      g_free (utf8_ptr);
+    }
+#else    
     if (ex==sx && ex<e->width && sy==ey)
       ex++;
 
@@ -970,7 +1018,7 @@ void vt_fix_selection(struct _vtx *vx)
         while ((ex<e->width) && 
 	     ( (vt_in_wordclass(vx, e->data[ex]))))
   	ex++;
-
+#endif /* HAS_I18N */
     break;
   case VT_SELTYPE_CHAR:
   default:
Index: libzvt/libzvt/zvti18n.c
===================================================================
RCS file: /sgnome/cvsroots/sun-gnome/libzvt/libzvt/zvti18n.c,v
retrieving revision 1.2
diff -u -p -r1.2 zvti18n.c
--- libzvt/libzvt/zvti18n.c	30 Oct 2002 18:19:25 -0000	1.2
+++ libzvt/libzvt/zvti18n.c	2 Dec 2002 18:33:33 -0000
@@ -902,4 +902,87 @@ zvt_term_set_pango_font (ZvtTerm *term,
 
 }
 
+/**
+ * zvt_term_get_utf8_from_line:
+ * @line: pointer to struct vt_line
+ *
+ * retruns allocated utf8 string with null terminate from vt_line data
+ */
+gchar*
+zvt_term_get_utf8_from_line (struct vt_line *line)
+{
+  gint i, utf8_len, expand_index = 0;
+
+  gchar *utf8_buf = g_malloc (line->width * 4);
+  for (i = 0; i < line->width; i++) {
+    gunichar uc = line->data[i] & VTATTR_DATAMASK;
+    if (uc == 0 && !(line->data[i] & VTATTR_UTF16_HALF)) {
+      utf8_len = 1;
+      utf8_buf[expand_index] = ' ';
+    } else if (uc == '\t') {
+      utf8_len = 1;
+      utf8_buf[expand_index] = ' ';
+    } else {
+      if (line->data[i] & VTATTR_UTF16_HALF) {
+	uc = (((uc << 16) & 0xffff0000) | (line->data[++i] & VTATTR_DATAMASK));
+      }
+      utf8_len = g_unichar_to_utf8 (uc, &(utf8_buf[expand_index]));
+    }
+    expand_index += utf8_len;
+  }
+  utf8_buf[expand_index] = '\0';
+  return utf8_buf;
+}
+
+/**
+ * zvt_term_get_char_index_from_column:
+ * @column_index: column index
+ *
+ * returns char index corresponds to column index
+ * character index and column is not same as one wide character occupy two columns
+ */
+gint
+zvt_term_get_char_index_from_column (gchar *utf8_ptr, gint column_index)
+{
+  gint i, char_count = 0;
+
+  gchar *tmp = utf8_ptr;
+
+  for (i = 0; i < column_index; i++) {
+    gunichar uc = g_utf8_get_char (utf8_ptr);
+    utf8_ptr = g_utf8_next_char (utf8_ptr);
+    if (zvt_localechar_iswide (uc)) {
+      i++;
+    }
+    char_count++;
+  }
+
+  return char_count;
+}
+
+/**
+ * zvt_term_get_column_from_char_index:
+ * @char_index: character index
+ *
+ * returns column index corresponds to character index of line
+ * character index and column is not same as one wide character occupy two columns
+ */
+gint
+zvt_term_get_column_from_char_index (gchar *utf8_ptr, gint char_index)
+{
+  gint i, column_count = 0;
+
+  gchar *tmp = utf8_ptr;
+
+  for (i = 0; i < char_index; i++) {
+    gunichar uc = g_utf8_get_char (utf8_ptr);
+    utf8_ptr = g_utf8_next_char (utf8_ptr);
+    if (zvt_localechar_iswide (uc)) {
+      column_count++;
+    }
+    column_count++;
+  }
+
+  return column_count;
+}
 #endif /* HAS_I18N */
