[uim-commit] r806 - trunk/fep

yamamoto at freedesktop.org yamamoto at freedesktop.org
Sun Mar 20 23:28:35 PST 2005


Author: yamamoto
Date: 2005-03-20 23:28:33 -0800 (Sun, 20 Mar 2005)
New Revision: 806

Modified:
   trunk/fep/README.ja
   trunk/fep/callbacks.c
   trunk/fep/callbacks.h
   trunk/fep/draw.c
   trunk/fep/draw.h
   trunk/fep/escseq.c
   trunk/fep/uim-fep.c
Log:
 * fep/: add -D option for a DOS prompt


Modified: trunk/fep/README.ja
===================================================================
--- trunk/fep/README.ja	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/README.ja	2005-03-21 07:28:33 UTC (rev 806)
@@ -156,6 +156,11 @@
         -s¥ª¥×¥·¥ç¥ó¤Ë¤«¤«¤ï¤é¤º¥â¡¼¥Éɽ¼¨¤Ë¤Ï
         backtick¤¬»È¤ï¤ì¤Þ¤¹¡£
 
+  o -D  uim-fep¤Îµ¯Æ°¤Ë¼ºÇÔ¤·¤Æ
+        Report Cursor Position is not available
+        Please try to use with -D option
+        ¤Èɽ¼¨¤µ¤ì¤¿¾ì¹ç¤Ï¡¢µ¯Æ°»þ¤Ë¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¤¯¤À¤µ¤¤¡£
+
   o -e command arg1 arg2 ...
     µ¯Æ°¤¹¤ë¥³¥Þ¥ó¥É¤ò»ØÄꤷ¤Þ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó°Ê¹ß¤Î°ú¿ô¤Ï
     command¤ËÅϤµ¤ì¤Þ¤¹¡£

Modified: trunk/fep/callbacks.c
===================================================================
--- trunk/fep/callbacks.c	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/callbacks.c	2005-03-21 07:28:33 UTC (rev 806)
@@ -58,6 +58,8 @@
 static int s_cursor_no_reverse;
 /* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤ÎÉý */
 static int s_statusline_width;
+/* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤ÎºÇÂçÉý */
+static int s_max_width;
 
 static char *s_commit_str;
 static char *s_statusline_str;
@@ -77,8 +79,6 @@
 static void pushback_cb(void *ptr, int attr, const char *str);
 static void update_cb(void *ptr);
 static void mode_update_cb(void *ptr, int mode);
-static void property_update_cb(void *ptr, const char *str);
-static void property_list_update_cb(void *ptr, const char *str);
 static struct preedit_tag *dup_preedit(struct preedit_tag *p);
 static void make_page_strs(void);
 static int numwidth(int n);
@@ -127,6 +127,10 @@
   s_context = context;
   s_cursor_no_reverse = cursor_no_reverse;
   s_statusline_width = statusline_width;
+  s_max_width = g_win->ws_col;
+  if (s_statusline_width != UNDEFINED && s_statusline_width <= s_max_width) {
+    s_max_width = s_statusline_width;
+  }
   s_commit_str = strdup("");
   s_candidate_str = strdup("");
   s_statusline_str = strdup("");
@@ -136,8 +140,6 @@
   s_preedit = create_preedit();
   uim_set_preedit_cb(s_context, clear_cb, pushback_cb, update_cb);
   uim_set_mode_cb(s_context, mode_update_cb);
-  uim_set_prop_label_update_cb(s_context, property_update_cb);
-  uim_set_prop_list_update_cb(s_context, property_list_update_cb);
   if (status_type != NONE) {
     uim_set_candidate_selector_cb(s_context, activate_cb, select_cb, shift_page_cb, deactivate_cb);
   }
@@ -281,6 +283,13 @@
   return s_mode;
 }
 
+char *get_mode_str(void)
+{
+  char *mode_str = strdup(uim_get_mode_name(s_context, s_mode));
+  strhead(mode_str, s_max_width);
+  return mode_str;
+}
+
 /*
  * ¸õÊä°ìÍ÷¤òɽ¼¨¤¹¤ë¤È¤­¤Ë¸Æ¤Ð¤ì¤ë¡£
  * s_candidate.nr = nr(¸õÊäÁí¿ô)
@@ -434,15 +443,6 @@
   s_mode = mode;
 }
 
-static void property_update_cb(void *ptr, const char *str)
-{
-  debug2(("prop(\"%s\")", str));
-}
-static void property_list_update_cb(void *ptr, const char *str)
-{
-  debug2(("proplist(\"%s\")", str));
-}
-
 /*
  * ¿·¤·¤¤¥×¥ê¥¨¥Ç¥£¥Ã¥È¤òºî¤ê¡¤¥Ý¥¤¥ó¥¿¤òÊÖ¤¹
  */
@@ -492,9 +492,9 @@
 
 /*
  * s_candidate.page_strs = ¥Ú¡¼¥¸Ê¸»úÎó¤ÎÇÛÎó
- * ʸ»úÎó¤ÎÉý¤¬max_width¤ò±Û¤¨¤¿¤È¤­¤Ï¡¢¤Ï¤ß½Ð¤¿¸õÊä¤ò¼¡¤Î¥Ú¡¼¥¸¤Ë°Ü¤¹¡£
+ * ʸ»úÎó¤ÎÉý¤¬s_max_width¤ò±Û¤¨¤¿¤È¤­¤Ï¡¢¤Ï¤ß½Ð¤¿¸õÊä¤ò¼¡¤Î¥Ú¡¼¥¸¤Ë°Ü¤¹¡£
  * 1¤Ä¤·¤«¸õÊ䤬¤Ê¤¯¤Æ¤Ï¤ß½Ð¤¿¤È¤­¤Ï¡¢°Ü¤µ¤Ê¤¤¡£
- * max_width¤ÏüËö¤ÎÉý¤«¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤵ¤ì¤¿ÃÍ
+ * s_max_width¤ÏüËö¤ÎÉý¤«¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤵ¤ì¤¿ÃÍ
  * s_candidate.page2index = ¥Ú¡¼¥¸¤ÎºÇ½é¤Î¸õÊä¤Îindex
  * s_candidate.cand_col = ¸õÊä¤Î°ÌÃÖ
  * s_candidate.nr_pages = ¥Ú¡¼¥¸¤ÎÁí¿ô
@@ -510,12 +510,6 @@
 
   int index;
 
-  int max_width = g_win->ws_col;
-
-  if (s_statusline_width != UNDEFINED && s_statusline_width <= max_width) {
-    max_width = s_statusline_width;
-  }
-
   assert(s_candidate.nr != UNDEFINED);
   assert(s_candidate.limit != UNDEFINED);
   assert(s_candidate.cand_col != NULL);
@@ -544,28 +538,48 @@
       s_candidate.index_col = realloc(s_candidate.index_col, (s_candidate.nr_pages + 1) * sizeof(int));
     }
 
-    if (page_width + cand_width + index_width > max_width && index_in_page != 0) {
+    if (page_width + cand_width + index_width > s_max_width && index_in_page != 0) {
       /* ¤Ï¤ß½Ð¤¿¤Î¤Ç¼¡¤Î¥Ú¡¼¥¸¤Ë°Ü¤¹ */
       index--;
       index_width = strlen("[/]") + numwidth(index + 1) + numwidth(s_candidate.nr);
       next = TRUE;
     } else {
-      if (cand_width + index_width > max_width && index_in_page == 0) {
+
+      s_candidate.cand_col[index] = page_width + cand_label_width + strlen(":");
+
+      if (cand_width + index_width > s_max_width && index_in_page == 0) {
+        /* ¤Ï¤ß½Ð¤¿¤¬¡¢¼¡¤Ë°Ü¤µ¤Ê¤¤ */
         assert(page_width == 0);
-        /* ¤Ï¤ß½Ð¤¿¤¬¡¢¼¡¤Ë°Ü¤µ¤Ê¤¤ */      /* ¥¹¥Ú¡¼¥¹¤ÎÉý¤Î1 */
-        cand_width = max_width - index_width - strlen(" ");
-        cand_width = strhead(cand_str, cand_width);
-        if (cand_label_width > cand_width) {
-          cand_label_width = cand_width;
+        next = TRUE;
+                                                  /* Á´³Ñ1ʸ»ú¤ÎÉý */
+        if (s_max_width >= cand_label_width + strlen(":") + 2 + strlen(" ") + index_width) {
+          /* ¸õÊä + ¥¤¥ó¥Ç¥Ã¥¯¥¹ */
+
+          cand_width = s_max_width - index_width - strlen(" ");
+          cand_width = strhead(cand_str, cand_width);
+          assert(cand_width > cand_label_width);
+          cand_width += strwidth(" ");
+          cand_byte = strlen(cand_str);
+          cand_str[cand_byte++] = ' ';
+          cand_str[cand_byte] = '\0';
+        } else {
+          /* ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ï¤Ê¤· */
+
+          index_width = UNDEFINED;
+          cand_width = s_max_width - strlen(" ");
+          cand_width = strhead(cand_str, cand_width);
+          if (cand_width <= cand_label_width + strlen(":")) {
+            cand_width = 1;
+            strcpy(cand_str, " ");
+            s_candidate.cand_col[index] = UNDEFINED;
+          } else {
+            cand_byte = strlen(cand_str);
+            cand_str[cand_byte++] = ' ';
+            cand_str[cand_byte] = '\0';
+          }
         }
-        cand_width++;
-        cand_byte = strlen(cand_str);
-        cand_str[cand_byte++] = ' ';
-        cand_str[cand_byte] = '\0';
-        next = TRUE;
       }
-                                                                        /* ':' */
-      s_candidate.cand_col[index] = page_width + cand_label_width + strlen(":");
+
       page_width += cand_width;
       page_byte += cand_byte;
       page_str = realloc(page_str, page_byte + 1);
@@ -578,24 +592,24 @@
     }
 
     if (next) {
-      int index_byte = index_width;
-      char *index_str = malloc(index_byte + 1);
-      int i;
-      sprintf(index_str, "[%d/%d]", index + 1, s_candidate.nr);
-      for (i = 0; i < numwidth(index + 1); i++) {
-        index_str[1 + i] = ' ';
+      if (index_width == UNDEFINED) {
+        s_candidate.index_col[s_candidate.nr_pages] = UNDEFINED;
+      } else {
+        int index_byte = index_width;
+        char *index_str = malloc(index_byte + 1);
+        int i;
+        sprintf(index_str, "[%d/%d]", index + 1, s_candidate.nr);
+        for (i = 0; i < numwidth(index + 1); i++) {
+          index_str[1 + i] = ' ';
+        }
+        index_str[i] = '-';
+        assert(page_width + index_width <= s_max_width);
+        s_candidate.index_col[s_candidate.nr_pages] = page_width + strlen("[");
+        page_byte += index_byte;
+        page_str = realloc(page_str, page_byte + 1);
+        strcat(page_str, index_str);
+        free(index_str);
       }
-      index_str[i] = '-';
-      /* ¤è¤Û¤ÉüËö¤ÎÉý¤¬¶¹¤¯¤Ê¤¤¤«¤®¤ê¤Ï¤ß½Ð¤Ê¤¤ */
-      if (page_width + index_width > max_width) {
-        index_width = max_width - page_width;
-        index_width = strhead(index_str, index_width);
-        index_byte = strlen(index_str);
-      }
-      s_candidate.index_col[s_candidate.nr_pages] = page_width + strlen("[");
-      page_byte += index_byte;
-      page_str = realloc(page_str, page_byte + 1);
-      strcat(page_str, index_str);
       s_candidate.page_strs = realloc(s_candidate.page_strs, (s_candidate.nr_pages + 1) * sizeof(char *));
       s_candidate.page_strs[s_candidate.nr_pages] = strdup(page_str);
       s_candidate.nr_pages++; 
@@ -603,7 +617,6 @@
       page_byte = 0;
       page_width = 0;
       index_in_page = 0;
-      free(index_str);
       free(page_str);
       page_str = strdup("");
     }
@@ -683,26 +696,33 @@
   int cand_width;
   /* "[10/20]"¤ÎÉý */
   int index_width;
-  int max_width = g_win->ws_col;
-  /* ±¦Ã¼¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ */
-  int right_edge_cand_index = s_candidate.page + 1 == s_candidate.nr_pages ? s_candidate.nr - 1 : s_candidate.page2index[s_candidate.page + 1] - 1;
-  /* ±¦Ã¼¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎÉý */
-  int right_edge_cand_index_width = numwidth(right_edge_cand_index + 1);
-  /* ¸½ºß¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎÉý */
-  int cand_index_width = numwidth(s_candidate.index + 1);
-  int i;
-  s_index_str = malloc(right_edge_cand_index_width + 1);
-  for (i = 0; i < right_edge_cand_index_width - cand_index_width; i++) {
-    s_index_str[i] = ' ';
-  }
-  s_index_str[i] = '\0';
-  sprintf(s_index_str, "%s%d", s_index_str, s_candidate.index + 1);
 
-  if (s_statusline_width != UNDEFINED && s_statusline_width <= max_width) {
-    max_width = s_statusline_width;
+  if (s_candidate.index_col[s_candidate.page] == UNDEFINED) {
+    s_index_str = strdup("");
+    index_width = 0;
+  } else {
+    /* ±¦Ã¼¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ */
+    int right_edge_cand_index = s_candidate.page + 1 == s_candidate.nr_pages ? s_candidate.nr - 1 : s_candidate.page2index[s_candidate.page + 1] - 1;
+    /* ±¦Ã¼¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎÉý */
+    int right_edge_cand_index_width = numwidth(right_edge_cand_index + 1);
+    /* ¸½ºß¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎÉý */
+    int cand_index_width = numwidth(s_candidate.index + 1);
+    int i;
+    s_index_str = malloc(right_edge_cand_index_width + 1);
+    for (i = 0; i < right_edge_cand_index_width - cand_index_width; i++) {
+      s_index_str[i] = ' ';
+    }
+    s_index_str[i] = '\0';
+    sprintf(s_index_str, "%s%d", s_index_str, s_candidate.index + 1);
+    index_width = strlen("[/]") + numwidth(s_candidate.index + 1) + numwidth(s_candidate.nr);
   }
 
+
   s_candidate_col = s_candidate.cand_col[s_candidate.index];
+  if (s_candidate_col == UNDEFINED) {
+    s_candidate_str = strdup("");
+    return;
+  }
   cand = uim_get_candidate(s_context, s_candidate.index, 0);
   if (uim_candidate_get_cand_str(cand) == NULL) {
     s_candidate_str = strdup("");
@@ -712,16 +732,18 @@
   }
   s_candidate_str = tab2space(uim_candidate_get_cand_str(cand));
   cand_width = strwidth(s_candidate_str);
-  index_width = 3 + numwidth(s_candidate.index + 1) + numwidth(s_candidate.nr);
-  /* ¤è¤Û¤ÉüËö¤ÎÉý¤¬¶¹¤¯¤Ê¤¤¤«¤®¤ê¤Ï¤ß½Ð¤Ê¤¤ */
-  if (s_candidate_col + cand_width + index_width > max_width) {
-    strhead(s_candidate_str, max_width - s_candidate_col - index_width - 1);
+  if (s_candidate_col + cand_width + strlen(" ") + index_width > s_max_width) {
+    strhead(s_candidate_str, s_max_width - s_candidate_col - strlen(" ") - index_width);
   }
   uim_candidate_free(cand);
 }
 
 void callbacks_winch(void)
 {
+  s_max_width = g_win->ws_col;
+  if (s_statusline_width != UNDEFINED && s_statusline_width <= s_max_width) {
+    s_max_width = s_statusline_width;
+  }
   if (s_candidate.nr != UNDEFINED) {
     if (s_candidate.page_strs != NULL) {
       int i;

Modified: trunk/fep/callbacks.h
===================================================================
--- trunk/fep/callbacks.h	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/callbacks.h	2005-03-21 07:28:33 UTC (rev 806)
@@ -60,6 +60,7 @@
 int get_index_col(void);
 struct preedit_tag *get_preedit(void);
 int get_mode(void);
+char *get_mode_str(void);
 void commit_cb(void *ptr, const char *commit_str);
 struct preedit_tag *create_preedit(void);
 void free_preedit(struct preedit_tag *p);

Modified: trunk/fep/draw.c
===================================================================
--- trunk/fep/draw.c	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/draw.c	2005-03-21 07:28:33 UTC (rev 806)
@@ -78,7 +78,6 @@
 static int s_preedit_lines = 0;
 static int s_prev_preedit_lines = 0;
 
-static uim_context s_context;
 /* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤Î¼ïÎà */
 static int s_status_type;
 /* µ¿»÷üËö¥Þ¥¹¥¿¤Î¥Õ¥¡¥¤¥ëµ­½Ò»Ò */
@@ -94,7 +93,7 @@
 /* üËö¥µ¥¤¥º¤¬ÊÑ´¹¤·¤¿¤È¤­TRUE */
 static int s_winch = FALSE;
 static int s_on_the_spot = FALSE;
-static int s_gnu_screen = FALSE;
+static int s_no_report_cursor = FALSE;
 
 static void init_backtick(void);
 static void update_backtick(void);
@@ -122,18 +121,16 @@
 static void print_preedit(struct preedit_tag *p);
 #endif
 
-void init_draw(uim_context context, int on_the_spot, int status_type, int gnu_screen, int master, const char *path_getmode)
+void init_draw(int on_the_spot, int status_type, int no_report_cursor, int master, const char *path_getmode)
 {
-  s_context = context;
   s_status_type = status_type;
   s_master = master;
   s_path_getmode = path_getmode;
   s_preedit = create_preedit();
   s_on_the_spot = on_the_spot;
-  s_gnu_screen = gnu_screen;
+  s_no_report_cursor = no_report_cursor;
   if (s_status_type == BACKTICK) {
     init_backtick();
-    draw_statusline_no_restore();
   }
 }
 
@@ -170,26 +167,11 @@
 
   /* üËö¥µ¥¤¥º¤¬Êѹ¹¤µ¤ì¤¿¤È¤­¤Ïs_head¤òÊѹ¹¤¹¤ë */
   if (s_winch && g_start_preedit) {
-    /* üËö¥µ¥¤¥º¤¬Êѹ¹¤µ¤ì¤ëÁ°¤Î¥«¡¼¥½¥ë°ÌÃÖ */
-    struct point_tag cursor = width2point_char(s_preedit->cursor);
-    /* ¥×¥ê¥¨¥Ç¥£¥Ã¥ÈÀèƬ¤«¤é¤ÎÁêÂаÌÃÖ */
-    int diff_row = cursor.row - s_head.row;
-    int diff_col = cursor.col - s_head.col;
-    /* s_head¤òÊѹ¹ */
-    s_head = get_cursor_position();
-    s_head.row -= diff_row;
-    s_head.col -= diff_col;
-    /* s_head¤¬²èÌ̤«¤é½Ð¤Ê¤¤¤è¤¦¤Ë½¤Àµ */
-    if (s_head.row < 0) {
-      s_head.row = 0;
-    } else if (s_head.row > g_win->ws_row - 1) {
-      s_head.row = g_win->ws_row - 1;
+    if (s_no_report_cursor) {
+      s_preedit->cursor = 0;
+    } else {
+      s_head = get_cursor_position();
     }
-    if (s_head.col < 0) {
-      s_head.col = 0;
-    } else if (s_head.col > g_win->ws_col - 1) {
-      s_head.col = g_win->ws_col - 1;
-    }
   }
 
   prev_preedit = s_preedit;
@@ -207,7 +189,7 @@
   s_save_preedit.width = s_save_preedit.cursor = s_save_preedit.nr_psegs = 0;
 
   /* ¥×¥ê¥¨¥Ç¥£¥Ã¥È¤¬Ìµ¤±¤ì¤Ð¥«¡¼¥½¥ë¤òÌ᤹ */
-  draw_statusline(FALSE, !g_start_preedit, FALSE, FALSE);
+  draw_statusline(FALSE, !g_start_preedit || s_no_report_cursor, FALSE, FALSE);
 
   /* ¥³¥ß¥Ã¥È¤µ¤ì¤¿¤« */
   if (commit_str[0] != '\0') {
@@ -215,7 +197,7 @@
     /* ¥×¥ê¥¨¥Ç¥£¥Ã¥È¤ò¾Ã¤¹É¬Íפ¬¤¢¤ë¤« */
     if (prev_preedit->width > 0) {
       put_cursor_invisible();
-      if (s_gnu_screen) {
+      if (s_no_report_cursor) {
         put_cursor_left(prev_preedit->cursor);
         if (s_on_the_spot) {
           put_delete(prev_preedit->width);
@@ -266,7 +248,7 @@
   if (!g_start_preedit) {
     debug2(("start_preedit()\n"));
     g_start_preedit = TRUE;
-    if (s_gnu_screen) {
+    if (s_no_report_cursor) {
       return;
     }
 
@@ -295,7 +277,7 @@
   debug2(("end_preedit()\n"));
   assert(g_start_preedit);
   g_start_preedit = FALSE;
-  if (s_gnu_screen) {
+  if (s_no_report_cursor) {
     return;
   }
 
@@ -351,18 +333,14 @@
   static char *candidate_str = NULL;
   static int candidate_col = UNDEFINED;
   static int mode = UNDEFINED;
-  static int mode_width = 0;
   static char *index_str = NULL;
   static int index_col = UNDEFINED;
 
-  const char *mode_str;
-
   char *prev_statusline_str;
   int prev_statusline_str_width;
   char *prev_candidate_str;
   int prev_candidate_col;
   int prev_mode;
-  int prev_mode_width;
   char *prev_index_str;
   int prev_index_col;
 
@@ -382,12 +360,10 @@
   prev_candidate_str = candidate_str;
   prev_candidate_col = candidate_col;
   prev_mode = mode;
-  prev_mode_width = mode_width;
   prev_index_str = index_str;
   prev_index_col = index_col;
 
   statusline_str = get_statusline_str();
-  statusline_str_width = strwidth(statusline_str);
   candidate_str = get_candidate_str();
   candidate_col = get_candidate_col();
   mode = get_mode();
@@ -432,18 +408,23 @@
         /* ¸õÊ䤬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤« */
         if (candidate_col != UNDEFINED) {
           int byte_cand = (width2byte(statusline_str, candidate_col))[0];
-          int byte_index = (width2byte(statusline_str, index_col))[0];
+          int byte_index;
           put_uim_str_no_color_len(statusline_str, UPreeditAttr_None, byte_cand);
           put_uim_str_no_color(candidate_str, UPreeditAttr_Reverse);
-          put_uim_str_no_color_len(statusline_str + byte_cand + strlen(candidate_str),
-              UPreeditAttr_None,
-              byte_index - byte_cand - strlen(candidate_str));
-          assert(index_col != UNDEFINED);
-          put_uim_str_no_color(index_str, UPreeditAttr_None);
-          put_uim_str_no_color(statusline_str + byte_index + strlen(index_str), UPreeditAttr_None);
+          if (index_col == UNDEFINED) {
+            put_uim_str_no_color(statusline_str + byte_cand + strlen(candidate_str), UPreeditAttr_None);
+          } else {
+            byte_index = (width2byte(statusline_str, index_col))[0];
+            put_uim_str_no_color_len(statusline_str + byte_cand + strlen(candidate_str),
+                UPreeditAttr_None,
+                byte_index - byte_cand - strlen(candidate_str));
+            put_uim_str_no_color(index_str, UPreeditAttr_None);
+            put_uim_str_no_color(statusline_str + byte_index + strlen(index_str), UPreeditAttr_None);
+          }
         } else {
           put_uim_str_no_color(statusline_str, UPreeditAttr_None);
         }
+        statusline_str_width = strwidth(statusline_str);
         if (draw_background || statusline_str_width < prev_statusline_str_width) {
           put_clear_to_end_of_line();
         }
@@ -525,7 +506,7 @@
     }
 
     if (s_status_type != NONE && statusline_str[0] == '\0') {
-      mode_str = uim_get_mode_name(s_context, mode);
+      char *mode_str = get_mode_str();
       return_if_fail(mode_str != NULL);
       if (s_status_type == LASTLINE) {
         if (restore) {
@@ -534,13 +515,14 @@
         put_cursor_invisible();
         put_goto_lastline(0);
         put_uim_str_no_color(mode_str, UPreeditAttr_None);
-        mode_width = strwidth(mode_str);
-        if (draw_background || prev_mode_width > mode_width) {
+        statusline_str_width = strwidth(mode_str);
+        if (draw_background || prev_statusline_str_width > statusline_str_width) {
           put_clear_to_end_of_line();
         }
       } else if (s_status_type == BACKTICK) {
         strncpy(s_modebuf, mode_str, MODESIZE - 1);
       }
+      free(mode_str);
     }
   }
   free(prev_candidate_str);
@@ -645,7 +627,7 @@
 
   /* preedit == prev_preedit¤Î¤È¤­¤Ï¡¢¥«¡¼¥½¥ë¤Î°ÜÆ°¤À¤± */
   if (eq_width == preedit->width && eq_width == prev_preedit->width && eq_width > 0) {
-    if (s_gnu_screen) {
+    if (s_no_report_cursor) {
       put_move_cur(prev_preedit->cursor, preedit->cursor);
     } else {
       goto_char(preedit->cursor);
@@ -653,23 +635,23 @@
     return;
   }
 
-  if (!s_gnu_screen) {
+  if (!s_no_report_cursor) {
     set_line2width(preedit);
   }
 
   /* ½ÐÎϤ¹¤ë°ÌÃ֤˰ÜÆ° */
-  if (s_gnu_screen) {
+  if (s_no_report_cursor) {
     put_move_cur(prev_preedit->cursor, eq_width);
   } else {
     goto_col(eq_width);
   }
 
   /* Îΰ褬ÊѤï¤Ã¤Æ¤¤¤Ê¤¤¤Î¤ÇÊѹ¹Éôʬ¤À¤±¾å½ñ¤­ */
-  if ((s_gnu_screen && preedit->width == prev_preedit->width) || (!s_gnu_screen && is_eq_region())) {
+  if ((s_no_report_cursor && preedit->width == prev_preedit->width) || (!s_no_report_cursor && is_eq_region())) {
     int eq_width_rev = compare_preedit_rev(preedit, prev_preedit);
     debug2(("eq_width_rev = %d\n", eq_width_rev));
     draw_subpreedit(preedit, eq_width, preedit->width - eq_width_rev);
-    if (s_gnu_screen) {
+    if (s_no_report_cursor) {
       put_move_cur(preedit->width - eq_width_rev, preedit->cursor);
     } else {
       goto_char(preedit->cursor);
@@ -677,12 +659,12 @@
     return;
   }
 
-  if (s_gnu_screen && s_on_the_spot && preedit->width > prev_preedit->width) {
+  if (s_no_report_cursor && s_on_the_spot && preedit->width > prev_preedit->width) {
     put_insert(preedit->width - prev_preedit->width);
   }
   draw_subpreedit(preedit, eq_width, preedit->width);
 
-  if (s_gnu_screen) {
+  if (s_no_report_cursor) {
     if (preedit->width > prev_preedit->width) {
       put_cursor_left(preedit->width - preedit->cursor);
     } else {
@@ -757,7 +739,7 @@
     char *seg_str = p->pseg[i].str;
     int seg_w = strwidth(seg_str);
     if (w + seg_w <= width) {
-      if (s_gnu_screen) {
+      if (s_no_report_cursor) {
         put_uim_str(seg_str, p->pseg[i].attr);
       } else {
         draw_pseg(&(p->pseg[i]), start + w);
@@ -771,7 +753,7 @@
       int byte = byte_width[0];
       int save_char = seg_str[byte];
       seg_str[byte] = '\0';
-      if (s_gnu_screen) {
+      if (s_no_report_cursor) {
         put_uim_str(seg_str, p->pseg[i].attr);
       } else {
         draw_pseg(&(p->pseg[i]), start + w);

Modified: trunk/fep/draw.h
===================================================================
--- trunk/fep/draw.h	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/draw.h	2005-03-21 07:28:33 UTC (rev 806)
@@ -44,7 +44,7 @@
 extern int g_start_preedit;
 extern int g_commit;
 
-void init_draw(uim_context context, int on_the_spot, int status_type, int gnu_screen, int master, const char *path_getmode);
+void init_draw(int on_the_spot, int status_type, int gnu_screen, int master, const char *path_getmode);
 void draw(void);
 void draw_statusline_restore(void);
 void draw_statusline_no_restore(void);

Modified: trunk/fep/escseq.c
===================================================================
--- trunk/fep/escseq.c	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/escseq.c	2005-03-21 07:28:33 UTC (rev 806)
@@ -73,7 +73,7 @@
 /* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤Î¼ïÎà */
 static int s_status_type;
 /* GNU screen ¥â¡¼¥É¤« */
-static int s_gnu_screen;
+static int s_no_report_cursor;
 /* ½é´ü²½¤·¤¿¤éTRUE */
 static int s_init = FALSE;
 /* ¸½ºß¤Î¥«¡¼¥½¥ë°ÌÃÖ */
@@ -158,12 +158,12 @@
 /*
  * termcap/terminfo¤Î¥¨¥ó¥È¥ê¤¬¤¢¤ë¤«³Îǧ¤¹¤ë
  */
-void init_escseq(int use_civis, int use_ins_del, int status_type, int gnu_screen, const struct attribute_tag *attr_uim)
+void init_escseq(int use_civis, int use_ins_del, int status_type, int no_report_cursor, const struct attribute_tag *attr_uim)
 {
   s_use_civis = use_civis;
   s_status_type = status_type;
   s_attr_uim = *attr_uim;
-  s_gnu_screen = gnu_screen;
+  s_no_report_cursor = no_report_cursor;
 
   if (enter_underline_mode == NULL) {
     printf("enter_underline_mode is not available\n");
@@ -198,8 +198,22 @@
       printf("change_scroll_region is not available\n");
       done(EXIT_FAILURE);
     }
+    if (s_no_report_cursor) {
+      if (save_cursor == NULL) {
+        printf("save_cursor is not available.\n");
+        done(EXIT_FAILURE);
+      }
+      if (restore_cursor == NULL) {
+        printf("restore_cursor is not available.\n");
+        done(EXIT_FAILURE);
+      }
+      if (cursor_up == NULL) {
+        printf("cursor_up is not available.\n");
+        done(EXIT_FAILURE);
+      }
+    }
   }
-  if (s_gnu_screen) {
+  if (s_no_report_cursor) {
     if (cursor_left == NULL) {
       printf("cursor_left is not available\n");
       done(EXIT_FAILURE);
@@ -340,7 +354,17 @@
   tios.c_cc[VTIME] = 3;
   tcsetattr(g_win_in, TCSANOW, &tios);
 
-  if (s_gnu_screen) {
+  if (s_no_report_cursor) {
+    if (s_status_type == LASTLINE) {
+      put_cursor_invisible();
+      put_crlf();
+      my_putp(cursor_up);
+      put_save_cursor();
+      put_change_scroll_region(0, g_win->ws_row - 1);
+      put_restore_cursor();
+      put_cursor_normal();
+    }
+    draw_statusline_restore();
     return;
   }
 
@@ -348,6 +372,7 @@
   start_cursor = get_cursor_position();
   if (start_cursor.row == UNDEFINED) {
     printf("Report Cursor Position is not available\r\n");
+    printf("Please try to use with -D option\r\n");
     done(EXIT_FAILURE);
   }
   put_cursor_invisible();
@@ -374,9 +399,7 @@
   if (s_status_type == LASTLINE) {
     put_change_scroll_region(0, g_win->ws_row - 1);
   }
-  if (s_status_type != BACKTICK) {
-    draw_statusline_no_restore();
-  }
+  draw_statusline_no_restore();
   /* ³«»Ï°ÌÃÖ¤ËÌá¤ë */
   put_cursor_address_p(&start_cursor);
   put_cursor_normal();
@@ -428,8 +451,13 @@
 {
   if (!s_save) {
     s_save = TRUE;
-    s_save_cursor = get_cursor_position();
     debug(("<put_save_cursor>"));
+    if (s_no_report_cursor) {
+      my_putp(save_cursor);
+      s_save_cursor = s_cursor;
+    } else {
+      s_save_cursor = get_cursor_position();
+    }
   }
 }
 
@@ -440,8 +468,15 @@
 {
   if (s_save) {
     s_save = FALSE;
-    put_cursor_address_p(&s_save_cursor);
     debug(("<put_restore_cursor>"));
+    if (s_no_report_cursor) {
+      my_putp(restore_cursor);
+      /* DOS¥×¥í¥ó¥×¥È¤Ç¤Ï1²ó¤Îrestore_cursor¤Ç¤ÏÌá¤é¤Ê¤¤ */
+      my_putp(restore_cursor);
+      s_cursor = s_save_cursor;
+    } else {
+      put_cursor_address_p(&s_save_cursor);
+    }
   }
 }
 
@@ -971,7 +1006,7 @@
   change_attr(&s_attr, &s_attr_uim);
 
   s_cursor.col += strwidth(str);
-  assert(s_cursor.col <= g_win->ws_col);
+  assert(s_cursor.col <= g_win->ws_col || s_no_report_cursor);
   write(g_win_out, str, strlen(str));
   debug(("<put_uim_str \"%s\">", str));
 }

Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c	2005-03-21 03:04:21 UTC (rev 805)
+++ trunk/fep/uim-fep.c	2005-03-21 07:28:33 UTC (rev 806)
@@ -121,7 +121,6 @@
 static uim_context s_context;
 /* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤Î¼ïÎà */
 static int s_status_type = DEFAULT_STATUS;
-static int s_gnu_screen = FALSE;
 /* µ¿»÷üËö¤Îmaster¤Î¥Õ¥¡¥¤¥ëµ­½Ò»Ò */
 static int s_master;
 int g_win_in = STDIN_FILENO;
@@ -206,6 +205,8 @@
   int cursor_no_reverse = FALSE;
   int statusline_width = UNDEFINED;
   int on_the_spot = FALSE;
+  int gnu_screen = FALSE;
+  int no_report_cursor = FALSE;
   char *env_buf;
   struct attribute_tag attr_uim = {
     FALSE,     /* underline */
@@ -235,7 +236,7 @@
   init_str();
   engine = get_default_im_name();
 
-  while ((op = getopt(argc, argv, "e:s:u:b:w:t:C:Sciovh")) != -1) {
+  while ((op = getopt(argc, argv, "e:s:u:b:w:t:C:ScioDvh")) != -1) {
     int i;
     switch (op) {
       case 'e':
@@ -265,9 +266,14 @@
         break;
 
       case 'S':
-        s_gnu_screen = TRUE;
+        gnu_screen = TRUE;
+        no_report_cursor = TRUE;
         break;
 
+      case 'D':
+        no_report_cursor = TRUE;
+        break;
+
       case 'u':
         engine = optarg;
         break;
@@ -338,7 +344,7 @@
     attr_uim.background = FALSE;
   }
 
-  if (s_gnu_screen) {
+  if (gnu_screen) {
     s_status_type = BACKTICK;
     s_master = PROC_FILENO;
     g_win_in = WIN_IN_FILENO;
@@ -395,7 +401,7 @@
   }
 
   g_win = get_winsize();
-  if (!s_gnu_screen) {
+  if (!gnu_screen) {
     save_iflag = s_save_tios.c_iflag;
     s_save_tios.c_iflag &= ~ISTRIP;
     child = forkpty(&s_master, NULL, &s_save_tios, g_win);
@@ -423,12 +429,12 @@
     init_sendsocket(sock_path);
   }
   init_agent(engine);
-  if (s_gnu_screen) {
+  if (gnu_screen) {
     uim_set_mode(s_context, 1);
   }
   init_callbacks(s_context, s_status_type, cursor_no_reverse, statusline_width);
-  init_draw(s_context, on_the_spot, s_status_type, s_gnu_screen, s_master, s_path_getmode);
-  init_escseq(use_civis, on_the_spot, s_status_type, s_gnu_screen, &attr_uim);
+  init_draw(on_the_spot, s_status_type, no_report_cursor, s_master, s_path_getmode);
+  init_escseq(use_civis, on_the_spot, s_status_type, no_report_cursor, &attr_uim);
   set_signal_handler();
 
   if (s_path_setmode[0] != '\0' && mkfifo(s_path_setmode, 0600) != -1) {
@@ -941,7 +947,8 @@
       "-c                                        reverse cursor\n"
       "-i                                        use cursor_invisible(civis)\n"
       "-o                                        on the spot\n"
-      "-S                                        GNU screen mode\n",
+      "-S                                        GNU screen mode\n"
+      "-D                                        for DOS prompt\n",
       getenv("SHELL") != NULL ? getenv("SHELL") : "/bin/sh",
       "-h                                        display this help\n"
       "-v                                        display version\n"



More information about the Uim-commit mailing list