From: handa Date: Fri, 3 Dec 2004 00:09:34 +0000 (+0000) Subject: (face_available): New variable. X-Git-Tag: REL-1-2-0~78 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bce0a381bb5cb4229adc7b84c695a8915ddf4f5e;p=m17n%2Fm17n-lib.git (face_available): New variable. (init): Check if GUI APIs are available or not. If not, set face_available to 0. (fini): Free a face only if face_available is not zero. (ispell_word): Put face property only if available. --- diff --git a/example/mimx-ispell.c b/example/mimx-ispell.c index 7ecf734..7da4c68 100644 --- a/example/mimx-ispell.c +++ b/example/mimx-ispell.c @@ -91,6 +91,7 @@ #ifdef HAVE_ISPELL static int initialized = 0; +static int face_available; static MFace *mface_overstrike = NULL; static MPlist * @@ -113,11 +114,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 +131,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 +186,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 +221,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);