*** empty log message ***
[m17n/m17n-lib.git] / example / mimx-ispell.c
index c81b5fc..39777b7 100644 (file)
@@ -1,4 +1,4 @@
-/* imx-ispell.c -- Input method external module for Ispell.
+/* imx-ispell.c -- Ispell input method external module.        -*- coding: euc-jp; -*-
    Copyright (C) 2003, 2004
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
    Copyright (C) 2003, 2004
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
@@ -21,7 +21,7 @@
    02111-1307, USA.  */
 
 /***en
    02111-1307, USA.  */
 
 /***en
-    @page mimx-ispell external module for the input method <en, ispell>
+    @enpage mimx-ispell external module for the input method <en, ispell>
 
     @section mimx-ispell-description DESCRIPTION
 
 
     @section mimx-ispell-description DESCRIPTION
 
     @section mimx-ispell-seealso See also
     @ref mdbIM
 */
     @section mimx-ispell-seealso See also
     @ref mdbIM
 */
+/***ja
+    @japage mimx-ispell ÆþÎϥ᥽¥Ã¥É <en, ispell> Íѳ°Éô¥â¥¸¥å¡¼¥ë
+
+    @section mimx-ispell-description DESCRIPTION
+
+    ¶¦Í­¥é¥¤¥Ö¥é¥ê mimx-ispell.so ¤ÏÆþÎϥ᥽¥Ã¥É <en, ispell> ¤ËÍѤ¤¤é 
+    ¤ì¤ë³°Éô¥â¥¸¥å¡¼¥ë¤Ç¤¢¤ê¡¢°Ê²¼¤Î´Ø¿ô¤ò export ¤·¤Æ¤¤¤ë¡£
+
+    <ul>
+    <li> init
+
+    ¥é¥¤¥Ö¥é¥ê¤Î½é´ü²½¡£
+
+    <li> fini
+
+    ¥é¥¤¥Ö¥é¥ê¤Î½ªÎ»¡£ 
+
+    <li> ispell_word
+
+    ¸½ºß¤Î preedit ¥Æ¥­¥¹¥È (±Ñʸ) ¤ÎÄÖ¤òÄ´¤Ù¡¢´Ö°ã¤Ã¤Æ¤¤¤ì¤Ð¸õÊä¤Î¥ê 
+    ¥¹¥È¤òÊÖ¤¹¡£
+
+    </ul>
+
+    ¤³¤Î¥×¥í¥°¥é¥à¤Ïm17n ÆþÎϥ᥽¥Ã¥ÉÍѳ°Éô¥â¥¸¥å¡¼¥ë¤Î½ñ¤­Êý¤ò¼¨¤¹¤¿ 
+    ¤á¤Î¤â¤Î¤Ç¤¢¤ê¡¢¼ÂºÝ¤ÎÍøÍѤò°Õ¿Þ¤·¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤¡£
+
+    @section mimx-ispell-seealso »²¾È
+    @ref mdbIM
+*/
 
 #ifndef FOR_DOXYGEN
 
 #include <stdio.h>
 #include <string.h>
 
 #ifndef FOR_DOXYGEN
 
 #include <stdio.h>
 #include <string.h>
-#include <config.h>
 #include <m17n-gui.h>
 
 #ifdef HAVE_ISPELL
 
 static int initialized = 0;
 #include <m17n-gui.h>
 
 #ifdef HAVE_ISPELL
 
 static int initialized = 0;
+static int face_available;
 static MFace *mface_overstrike = NULL;
 
 static MPlist *
 static MFace *mface_overstrike = NULL;
 
 static MPlist *
@@ -83,11 +113,16 @@ init (MPlist *args)
     {
       MFaceHLineProp hline;
 
     {
       MFaceHLineProp hline;
 
-      hline.type = MFACE_HLINE_STRIKE_THROUGH;
-      hline.width = 1;
-      hline.color = msymbol ("black");
-      mface_overstrike = mface ();
-      mface_put_prop (mface_overstrike, Mhline, &hline);
+      face_available = 0;
+      if (m17n_status () == M17N_GUI_INITIALIZED)
+       {
+         face_available = 1;
+         hline.type = MFACE_HLINE_STRIKE_THROUGH;
+         hline.width = 1;
+         hline.color = msymbol ("black");
+         mface_overstrike = mface ();
+         mface_put_prop (mface_overstrike, Mhline, &hline);
+       }
     }
   return NULL;
 }
     }
   return NULL;
 }
@@ -95,7 +130,9 @@ init (MPlist *args)
 MPlist *
 fini (MPlist *args)
 {
 MPlist *
 fini (MPlist *args)
 {
-  if (! --initialized)
+  if (initialized != 0
+      && --initialized == 0
+      && face_available)
     m17n_object_unref (mface_overstrike);
   return NULL;
 }
     m17n_object_unref (mface_overstrike);
   return NULL;
 }
@@ -148,7 +185,8 @@ ispell_word (MPlist *args)
   if (*p == '#')
     {
       mt = mtext_dup (ic->preedit);
   if (*p == '#')
     {
       mt = mtext_dup (ic->preedit);
-      mtext_push_prop (mt, 0, mtext_len (mt), Mface, mface_overstrike);
+      if (face_available)
+       mtext_push_prop (mt, 0, mtext_len (mt), Mface, mface_overstrike);
       mplist_add (actions, Mtext, mt);
       add_action (actions, msymbol ("shift"), Msymbol, init_state);
       m17n_object_unref (mt);
       mplist_add (actions, Mtext, mt);
       add_action (actions, msymbol ("shift"), Msymbol, init_state);
       m17n_object_unref (mt);
@@ -182,7 +220,8 @@ ispell_word (MPlist *args)
       m17n_object_unref (mt);
     }
   mt = mtext_dup (ic->preedit);
       m17n_object_unref (mt);
     }
   mt = mtext_dup (ic->preedit);
-  mtext_push_prop (mt, 0, mtext_len (mt), Mface, mface_overstrike);
+  if (face_available)
+    mtext_push_prop (mt, 0, mtext_len (mt), Mface, mface_overstrike);
   mplist_add (candidates, Mtext, mt);
   m17n_object_unref (mt);
   plist = mplist_add (mplist (), Mplist, candidates);
   mplist_add (candidates, Mtext, mt);
   m17n_object_unref (mt);
   plist = mplist_add (mplist (), Mplist, candidates);