Remove all m4/* files.
[m17n/m17n-lib.git] / example / mimx-ispell.c
index 4e89503..daa244f 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
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
 
 #include <stdio.h>
 #include <string.h>
-#include <config.h>
 #include <m17n-gui.h>
 
 #ifdef HAVE_ISPELL
 
 static int initialized = 0;
+static int face_available;
 static MFace *mface_overstrike = NULL;
 
 static MPlist *
@@ -113,11 +113,16 @@ init (MPlist *args)
     {
       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;
 }
@@ -125,7 +130,9 @@ init (MPlist *args)
 MPlist *
 fini (MPlist *args)
 {
-  if (! --initialized)
+  if (initialized != 0
+      && --initialized == 0
+      && face_available)
     m17n_object_unref (mface_overstrike);
   return NULL;
 }
@@ -178,7 +185,8 @@ ispell_word (MPlist *args)
   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);
@@ -212,7 +220,8 @@ ispell_word (MPlist *args)
       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);