1 /* CANNA interface -*- coding: euc-jp -*-
3 Copyright (C) 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc.
6 This file is part of XEmacs.
8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with XEmacs; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* Synched up with: Mule 2.3. Not in FSF. */
25 /* Japanese comments were translated 2000-12-06 by Stephen Turnbull
26 <stephen@xemacs.org>. I haven't verified that the Japanese comments
27 were correct. YMMV, NO WARRANTY, not even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (^^;;; as the
33 Authors: Akira Kon (kon@uxd.fc.nec.co.jp)
34 Ichiro Hirakura (hirakura@uxd.fc.nec.co.jp)
36 Functions defined in this file are
41 Length of converted string if no error occurs.
42 Error string if error occurs.
44 Convert a key input to a set of strings. The
45 strings contain both well-formed string and a
46 intermediate result to show the translation
47 information to a user. converted strings are
48 stored in specific variables.
52 List of the following things:
53 - list of keys to toggle Japanese-mode
55 - list of warning messages
57 Initialize ``canna'', which is a kana-to-kanji
58 converter for GNU Emacs. The first arg
59 specifies if inserting space character between
60 BUNSETSU when candidates are displayed. The
61 second arg specifies server. The third arg
62 specifies a file which will be used as a
63 customization description. If nil is
64 specified for each arg, the default value will
69 list of warning messages
71 finalize ``canna'', which is a kana-to-kanji
72 converter for GNU Emacs. This cause to write
73 miscellaneous informations to kana-to-kanji
76 (canna-touroku-string string)
78 String to register to a dictionary.
80 The same thing returns as canna-key-proc does.
82 Register Kanji words into kana-to-kanji
83 conversion dictionary.
85 (canna-set-width width)
87 Column width of the place where the candidates
88 of kana-to-kanji conversion will be shown.
92 Set status-line width information, which is
93 used to display kanji candidates.
95 (canna-change-mode num)
97 The mode number of Canna.
99 The same thing returns as canna-key-proc does.
101 Change Japanese pre-edit mode.
103 (canna-store-yomi yomi roma)
105 ``Yomi'' to be stored.
107 ``Romaji'' which corresponds to the ``Yomi''.
109 The same thing returns as canna-key-proc does.
111 Store yomi characters as a YOMI of
112 kana-to-kanji conversion.
114 (canna-do-function num ch)
116 A function number to be called.
118 A character will be specified in order to feed
119 the character to the function if the function
120 needs a input character.
122 The same thing returns as canna-key-proc does.
124 Do specified function at current mode.
130 List of warning messages.
132 Parse customize string.
136 A string which indicate the current mode.
138 Get current mode string.
140 Functions below are used for KKCP compatible library. These
141 functions provides a base kana-to-kanji conversion system for EGG.
142 These functions may be used when users want to change the engine
143 from Wnn to Canna without changing user interface of Japanese input.
147 (canna-bunsetu-henkou)
148 (canna-henkan-kakutei)
158 #include "file-coding.h"
162 #include "canna/jrkanji.h"
163 #include "canna/RK.h"
165 #include "iroha/jrkanji.h"
166 #include "iroha/RK.h"
168 extern char *jrKanjiError;
170 /* #### is this global really necessary? */
171 #define KEYTOSTRSIZE 2048
172 static unsigned char key_buffer[KEYTOSTRSIZE];
173 static char **warning;
175 static int canna_empty_info, canna_through_info;
176 static int canna_underline;
177 static int canna_inhibit_hankakukana;
179 static Lisp_Object Vcanna_kakutei_string;
180 static Lisp_Object Vcanna_kakutei_yomi;
181 static Lisp_Object Vcanna_kakutei_romaji;
182 static Lisp_Object Vcanna_henkan_string;
183 static Fixnum canna_henkan_length;
184 static Fixnum canna_henkan_revPos;
185 static Fixnum canna_henkan_revLen;
186 static Lisp_Object Vcanna_ichiran_string;
187 static Fixnum canna_ichiran_length;
188 static Fixnum canna_ichiran_revPos;
189 static Fixnum canna_ichiran_revLen;
190 static Lisp_Object Vcanna_mode_string;
192 static int IRCP_context;
194 static Lisp_Object storeResults (unsigned char *, int, jrKanjiStatus *);
195 static Lisp_Object kanjiYomiList (int, int);
196 static Lisp_Object CANNA_mode_keys (void);
199 static void m2c (unsigned char *, int, unsigned char *);
200 static Lisp_Object mule_make_string (unsigned char *, int);
201 static int mule_strlen (unsigned char *, int);
202 static void count_char (unsigned char *,int, int, int, Fixnum *, Fixnum *, Fixnum *);
203 #define make_string mule_make_string
206 /* Lisp functions definition */
208 DEFUN ("canna-key-proc", Fcanna_key_proc, 1, 1, 0, /*
209 Translate a key input to a set of strings. The strings contain both
210 well-formed string and intermediate result to show the translation
211 information to a user. Converted strings are stored in specific
219 CHECK_CHAR_COERCE_INT (ch);
220 len = jrKanjiString (0, XCHAR (ch), key_buffer, KEYTOSTRSIZE, &ks);
221 return storeResults (key_buffer, len, &ks);
225 storeResults (unsigned char *buf, int len, jrKanjiStatus *ks)
227 Lisp_Object val = Qnil;
230 { /* Error detected */
231 val = make_string ((unsigned char*) jrKanjiError, strlen (jrKanjiError));
235 /* ³ÎÄꤷ¤¿Ê¸»úÎó (the confirmed string) */
236 Vcanna_kakutei_string = make_string (buf, len);
237 val = make_int (len);
238 /* ³ÎÄꤷ¤¿Ê¸»úÎó¤ÎÆɤߤξðÊó...
239 (info about the reading of the confirmed string) */
240 Vcanna_kakutei_yomi = Vcanna_kakutei_romaji = Qnil;
241 if (ks->info & KanjiYomiInfo)
243 unsigned char *p = buf + len + 1;
244 int yomilen = strlen (p);
246 if (len + yomilen + 1 < KEYTOSTRSIZE)
250 Vcanna_kakutei_yomi = make_string (p, yomilen); /* Æɤß
253 yomilen2 = strlen (p);
254 if (len + yomilen + yomilen2 + 2 < KEYTOSTRSIZE)
256 Vcanna_kakutei_romaji = make_string (p, yomilen2);
257 /* ¥í¡¼¥Þ»ú (romanization) */
263 /* ¸õÊäɽ¼¨¤Îʸ»úÎó¤Ç¤¹¡£
264 (string for displaying candidate translations) */
265 Vcanna_henkan_string = Qnil;
268 Vcanna_henkan_string = make_string (ks->echoStr, ks->length);
270 canna_henkan_length = ks->length;
271 canna_henkan_revPos = ks->revPos;
272 canna_henkan_revLen = ks->revLen;
273 #else /* CANNA_MULE */
276 canna_henkan_length = mule_strlen (ks->echoStr,ks->length);
277 canna_henkan_revPos = mule_strlen (ks->echoStr,ks->revPos);
278 canna_henkan_revLen = mule_strlen (ks->echoStr+ks->revPos,
283 count_char (ks->echoStr, ks->length, ks->revPos, ks->revLen,
284 &canna_henkan_length, &canna_henkan_revPos,
285 &canna_henkan_revLen);
287 #endif /* CANNA_MULE */
290 /* °ìÍ÷¤Î¾ðÊó (information about the echo area menu) */
291 Vcanna_ichiran_string = Qnil;
292 if (ks->info & KanjiGLineInfo && ks->gline.length >= 0)
294 Vcanna_ichiran_string = make_string (ks->gline.line,
297 canna_ichiran_length = ks->gline.length;
298 canna_ichiran_revPos = ks->gline.revPos;
299 canna_ichiran_revLen = ks->gline.revLen;
300 #else /* CANNA_MULE */
301 count_char (ks->gline.line, ks->gline.length,
302 ks->gline.revPos, ks->gline.revLen,
303 &canna_ichiran_length,
304 &canna_ichiran_revPos, &canna_ichiran_revLen);
305 #endif /* CANNA_MULE */
308 /* ¥â¡¼¥É¤Î¾ðÊó (mode information) */
309 Vcanna_mode_string = Qnil;
310 if (ks->info & KanjiModeInfo)
312 Vcanna_mode_string = make_string (ks->mode, strlen (ks->mode));
315 /* ¤½¤Î¾¤Î¾ðÊó (other information) */
316 canna_empty_info = (ks->info & KanjiEmptyInfo) ? 1 : 0;
317 canna_through_info = (ks->info & KanjiThroughInfo) ? 1 : 0;
323 DEFUN ("canna-set-bunsetsu-kugiri", Fcanna_set_bunsetsu, 0, 1, 0, /*
324 This function sets the clause separator.
325 If non-nil value is specified, the white space separator will be used.
326 No separator will be used otherwise.
330 int kugiri; /* ʸÀá¶èÀÚ¤ê¤ò¤¹¤ë¤«¡© (display clause separator?) */
332 kugiri = NILP (num) ? 0 : 1;
334 jrKanjiControl (0, KC_SETBUNSETSUKUGIRI, (char *) kugiri);
339 /* For whatever reason, calling Fding directly from libCanna loses */
343 Fding (Qnil, Qnil, Qnil);
346 DEFUN ("canna-initialize", Fcanna_initialize, 0, 3, 0, /*
347 Initialize ``canna'', which is a kana-to-kanji converter for GNU Emacs.
348 The first arg specifies if inserting space character between BUNSETSU when
349 candidates are displayed.
350 The second arg specifies server.
351 The third arg specifies a file which will be used as a customization
353 If nil is specified for each arg, the default value will be used.
355 (num, server, rcfile))
359 unsigned char **p, **q;
361 int kugiri; /* ʸÀá¶èÀÚ¤ê¤ò¤¹¤ë¤«¡© (display clause separator?) */
373 kugiri = (kugiri == 1) ? 1 : 0;
378 jrKanjiControl (0, KC_SETSERVERNAME, (char *) 0);
382 char servername[256];
384 CHECK_STRING (server);
385 strncpy (servername, XSTRING_DATA (server), XSTRING_LENGTH (server));
386 servername[XSTRING_LENGTH (server)] = '\0';
387 jrKanjiControl (0, KC_SETSERVERNAME, servername);
392 jrKanjiControl (0, KC_SETINITFILENAME, (char *) 0);
398 CHECK_STRING (rcfile);
399 strncpy (rcname, XSTRING_DATA (rcfile), XSTRING_LENGTH (rcfile));
400 rcname[XSTRING_LENGTH (rcfile)] = '\0';
401 jrKanjiControl (0, KC_SETINITFILENAME, rcname);
404 warning = (char **) 0;
407 #endif /* nec_ews_svr4 */
408 res = jrKanjiControl (0, KC_INITIALIZE, (char *)&warning);
411 #endif /* nec_ews_svr4 */
415 for (p = q = (unsigned char **) warning ; *q ; q++)
420 val = Fcons (make_string (*q, strlen (*q)), val);
423 val = Fcons (val, Qnil);
427 val = Fcons (make_string ((unsigned char*) jrKanjiError,
428 strlen (jrKanjiError)), val);
429 /* ¥¤¥Ë¥·¥ã¥é¥¤¥º¤Ç¼ºÇÔ¤·¤¿¾ì¹ç¡£ (on initialization failure) */
430 return Fcons (Qnil, val);
434 extern void (*jrBeepFunc) (void);
436 jrBeepFunc = call_Fding;
440 wcKanjiControl (0, KC_SETAPPNAME, "nemacs");
441 #else /* CANNA_MULE */
442 wcKanjiControl (0, KC_SETAPPNAME, "mule");
443 #endif /* CANNA_MULE */
444 #endif /* KC_SETAPPNAME */
446 jrKanjiControl (0, KC_SETBUNSETSUKUGIRI, (char *) kugiri);
447 jrKanjiControl (0, KC_SETWIDTH, (char *) 78);
449 jrKanjiControl (0, KC_INHIBITHANKAKUKANA, (char *) 1);
451 /* mule ¤À¤Ã¤¿¤éȾ³Ñ¥«¥¿¥«¥Ê¤â»È¤¨¤ë
452 (Mule can use half-width katakana) */
453 if (canna_inhibit_hankakukana)
454 jrKanjiControl (0, KC_INHIBITHANKAKUKANA, (char *) 1);
456 jrKanjiControl (0, KC_YOMIINFO, (char *) 2); /* ¢¨£²: ¥í¡¼¥Þ»ú¤Þ¤ÇÊÖ¤¹
459 val = Fcons (Qnil, val);
460 return Fcons (CANNA_mode_keys (), val);
464 DEFUN ("canna-finalize", Fcanna_finalize, 0, 0, 0, /*
465 finalize ``canna'', which is a kana-to-kanji converter for GNU Emacs.
466 This cause to write miscellaneous informations to kana-to-kanji dictionary.
473 jrKanjiControl (0, KC_FINALIZE, (char *)&warning);
478 for (p = (unsigned char**) warning ; *p ; p++)
480 val = Fcons (make_string (*p, strlen (*p)), val);
483 val = Fcons (val, Qnil);
488 DEFUN ("canna-touroku-string", Fcanna_touroku_string, 1, 1, 0, /*
489 Register Kanji words into kana-to-kanji conversion dictionary.
493 jrKanjiStatusWithValue ksv;
498 unsigned char cbuf[4096];
502 ksv.buffer = (unsigned char *) key_buffer;
503 ksv.bytes_buffer = KEYTOSTRSIZE;
505 ks.echoStr = XSTRING_DATA (str);
506 ks.length = XSTRING_LENGTH (str);
507 #else /* CANNA_MULE */
508 m2c (XSTRING_DATA (str), XSTRING_LENGTH (str), cbuf);
510 ks.length = strlen (cbuf);
511 #endif /* CANNA_MULE */
513 len = jrKanjiControl (0, KC_DEFINEKANJI, (char *)&ksv);
514 val = storeResults (key_buffer, ksv.val, ksv.ks);
518 DEFUN ("canna-set-width", Fcanna_set_width, 1, 1, 0, /*
519 Set status-line width information, which is used to display
526 jrKanjiControl (0, KC_SETWIDTH, (char *) XINT (num));
530 DEFUN ("canna-change-mode", Fcanna_change_mode, 1, 1, 0, /*
531 Change Japanese pre-edit mode.
535 jrKanjiStatusWithValue ksv;
541 ksv.buffer = (unsigned char *) key_buffer;
542 ksv.bytes_buffer = KEYTOSTRSIZE;
544 ksv.val = XINT (num);
545 jrKanjiControl (0, KC_CHANGEMODE, (char *)&ksv);
546 val = storeResults (key_buffer, ksv.val, ksv.ks);
551 CANNA_mode_keys (void)
553 #define CANNAWORKBUFSIZE 32
554 char xxx[CANNAWORKBUFSIZE];
558 n = jrKanjiControl (0, KC_MODEKEYS, xxx);
560 for (i = n ; i > 0 ;)
563 /* !!#### something fucked here */
564 val = Fcons (make_char ((int)(0xFF & (unsigned char) xxx[i])), val);
569 DEFUN ("canna-store-yomi", Fcanna_store_yomi, 1, 2, 0, /*
570 Store yomi characters as a YOMI of kana-to-kanji conversion.
574 jrKanjiStatusWithValue ksv;
579 strncpy (key_buffer, XSTRING_DATA (yomi), XSTRING_LENGTH (yomi));
580 ks.length = XSTRING_LENGTH (yomi);
581 key_buffer[ks.length] = '\0';
582 #else /* CANNA_MULE */
583 m2c (XSTRING_DATA (yomi), XSTRING_LENGTH (yomi), key_buffer);
584 ks.length = strlen (key_buffer);
585 #endif /* CANNA_MULE */
596 strncpy (key_buffer + XSTRING_LENGTH (yomi) + 1, XSTRING_DATA (roma),
597 XSTRING_LENGTH (roma));
598 key_buffer[XSTRING_LENGTH (yomi) + 1 + XSTRING_LENGTH (roma)] = '\0';
599 ks.mode = (unsigned char *)(key_buffer + XSTRING_LENGTH (yomi) + 1);
600 #else /* CANNA_MULE */
601 ks.mode = (unsigned char *)(key_buffer + ks.length + 1);
602 m2c (XSTRING_DATA (roma), XSTRING_LENGTH (roma), ks.mode);
603 #endif /* CANNA_MULE */
606 ks.echoStr = (unsigned char *) key_buffer;
607 ksv.buffer = (unsigned char *) key_buffer; /* ÊÖÃÍÍÑ (return value) */
608 ksv.bytes_buffer = KEYTOSTRSIZE;
611 jrKanjiControl (0, KC_STOREYOMI, (char *)&ksv);
613 return storeResults (key_buffer, ksv.val, ksv.ks);
616 DEFUN ("canna-do-function", Fcanna_do_function, 1, 2, 0, /*
617 Do specified function at current mode.
621 jrKanjiStatusWithValue ksv;
634 *key_buffer = XCHAR (ch);
637 ksv.buffer = (unsigned char *) key_buffer;
638 ksv.bytes_buffer = KEYTOSTRSIZE;
640 ksv.val = XINT (num);
641 jrKanjiControl (0, KC_DO, (char *) &ksv);
642 val = storeResults (key_buffer, ksv.val, ksv.ks);
646 DEFUN ("canna-parse", Fcanna_parse, 1, 1, 0, /*
647 Parse customize string.
658 strncpy (key_buffer, XSTRING_DATA (str), XSTRING_LENGTH (str));
659 key_buffer[XSTRING_LENGTH (str)] = '\0';
660 #else /* CANNA_MULE */
661 m2c (XSTRING_DATA (str), XSTRING_LENGTH (str), key_buffer);
662 #endif /* CANNA_MULE */
663 p = (unsigned char**) key_buffer;
664 n = jrKanjiControl (0, KC_PARSE, (char *) &p);
669 val = Fcons (make_string (p[n], strlen (p[n])), val);
674 DEFUN ("canna-query-mode", Fcanna_query_mode, 0, 0, 0, /*
675 Get current mode string.
679 unsigned char buf[256];
681 jrKanjiControl (0, KC_QUERYMODE, buf);
682 return make_string (buf, strlen (buf));
686 * Functions following this line are for KKCP interface compatible
687 * library. These functions may be used by MILK system.
690 #define RKBUFSIZE 1024
692 static unsigned char yomibuf[RKBUFSIZE];
693 static short kugiri[RKBUFSIZE / 2];
696 confirmContext (void)
698 if (IRCP_context < 0)
702 if ((context = jrKanjiControl (0, KC_GETCONTEXT, (char *) 0)) == -1)
706 IRCP_context = context;
712 byteLen (int bun, int len)
714 int i = 0, offset = 0, ch;
716 if (0 <= bun && bun < RKBUFSIZE)
718 offset = kugiri[bun];
721 while (len-- > 0 && (ch = (int) yomibuf[offset + i]))
732 DEFUN ("canna-henkan-begin", Fcanna_henkan_begin, 1, 1, 0, /*
733 Return the result of kana-to-kanji conversion.
734 Clause separator is set.
741 if (confirmContext () == 0)
746 strncpy (yomibuf, XSTRING_DATA (yomi), XSTRING_LENGTH (yomi));
747 yomibuf[XSTRING_LENGTH (yomi)] = '\0';
748 nbun = RkBgnBun (IRCP_context, XSTRING_DATA (yomi), XSTRING_LENGTH (yomi),
749 (RK_XFER << RK_XFERBITS) | RK_KFER);
750 #else /* CANNA_MULE */
751 m2c (XSTRING_DATA (yomi), XSTRING_LENGTH (yomi), yomibuf);
752 nbun = RkBgnBun (IRCP_context, (char *) yomibuf, strlen (yomibuf),
753 (RK_XFER << RK_XFERBITS) | RK_KFER);
754 #endif /* CANNA_MULE */
756 return kanjiYomiList (IRCP_context, nbun);
760 kanjiYomiList (int context, int nbun)
762 Lisp_Object val, res = Qnil;
763 unsigned char RkBuf[RKBUFSIZE];
766 for (i = nbun ; i > 0 ; )
770 len = RkGetKanji (context, RkBuf, RKBUFSIZE);
771 val = make_string (RkBuf, len);
772 len = RkGetYomi (context, RkBuf, RKBUFSIZE);
773 res = Fcons (Fcons (val, make_string (RkBuf, len)), res);
774 if (i < RKBUFSIZE / 2)
779 for (i = 0, total = 0 ; i < nbun ; i++)
781 int temp = kugiri[i];
788 DEFUN ("canna-henkan-next", Fcanna_henkan_next, 1, 1, 0, /*
789 Return the list of candidates.
794 unsigned char *p, RkBuf[RKBUFSIZE];
795 Lisp_Object res = Qnil, endp;
797 CHECK_INT (bunsetsu);
798 if (confirmContext () == 0)
802 RkGoTo (IRCP_context, XINT (bunsetsu));
803 len = RkGetKanjiList (IRCP_context, RkBuf, RKBUFSIZE);
805 for (i = 0 ; i < len ; i++)
810 endp = res = Fcons (make_string (p, slen), Qnil);
814 endp = XCDR (res) = Fcons (make_string (p, slen), Qnil);
821 DEFUN ("canna-bunsetu-henkou", Fcanna_bunsetu_henkou, 2, 2, 0, /*
822 Specify the length of a clause.
828 CHECK_INT (bunsetsu);
831 nbun = XINT (bunsetsu);
832 if (confirmContext () == 0)
836 RkGoTo (IRCP_context, nbun);
837 len = byteLen (nbun, XINT (bunlen));
838 return kanjiYomiList (IRCP_context, RkResize (IRCP_context, len));
841 DEFUN ("canna-henkan-kakutei", Fcanna_henkan_kakutei, 2, 2, 0, /*
848 if (confirmContext () == 0)
853 RkGoTo (IRCP_context, nbun);
855 nkouho = XINT(kouho);
856 RkXfer (IRCP_context, nkouho);
860 DEFUN ("canna-henkan-end", Fcanna_henkan_end, 0, 0, 0, /*
865 if (confirmContext () == 0)
869 RkEndBun (IRCP_context, 1); /* ³Ø½¬¤Ï¤¤¤Ä¤Ç¤â¹Ô¤Ã¤ÆÎɤ¤¤â¤Î¤Ê¤Î¤«¡©
870 (is it OK to invoke learning function
871 at arbitrary times?) */
875 DEFUN ("canna-henkan-quit", Fcanna_henkan_quit, 0, 0, 0, /*
880 if (confirmContext () == 0)
884 RkEndBun (IRCP_context, 0);
888 /* variables below this line is constants of Canna */
890 static Fixnum canna_mode_AlphaMode;
891 static Fixnum canna_mode_EmptyMode;
892 static Fixnum canna_mode_KigoMode;
893 static Fixnum canna_mode_YomiMode;
894 static Fixnum canna_mode_JishuMode;
895 static Fixnum canna_mode_TankouhoMode;
896 static Fixnum canna_mode_IchiranMode;
897 static Fixnum canna_mode_YesNoMode;
898 static Fixnum canna_mode_OnOffMode;
899 #ifdef CANNA_MODE_AdjustBunsetsuMode
900 static Fixnum canna_mode_AdjustBunsetsuMode;
902 #ifdef CANNA_MODE_ChikujiYomiMode
903 static Fixnum canna_mode_ChikujiYomiMode;
904 static Fixnum canna_mode_ChikujiTanMode;
907 static Fixnum canna_mode_HenkanMode;
908 #ifdef CANNA_MODE_HenkanNyuryokuMode
909 static Fixnum canna_mode_HenkanNyuryokuMode;
911 #ifdef CANNA_MODE_ZenHiraHenkanMode
912 static Fixnum canna_mode_ZenHiraHenkanMode;
913 #ifdef CANNA_MODE_HanHiraHenkanMode
914 static Fixnum canna_mode_HanHiraHenkanMode;
916 static Fixnum canna_mode_ZenKataHenkanMode;
917 static Fixnum canna_mode_HanKataHenkanMode;
918 static Fixnum canna_mode_ZenAlphaHenkanMode;
919 static Fixnum canna_mode_HanAlphaHenkanMode;
921 static Fixnum canna_mode_ZenHiraKakuteiMode;
922 #ifdef CANNA_MODE_HanHiraKakuteiMode
923 static Fixnum canna_mode_HanHiraKakuteiMode;
925 static Fixnum canna_mode_ZenKataKakuteiMode;
926 static Fixnum canna_mode_HanKataKakuteiMode;
927 static Fixnum canna_mode_ZenAlphaKakuteiMode;
928 static Fixnum canna_mode_HanAlphaKakuteiMode;
929 static Fixnum canna_mode_HexMode;
930 static Fixnum canna_mode_BushuMode;
931 static Fixnum canna_mode_ExtendMode;
932 static Fixnum canna_mode_RussianMode;
933 static Fixnum canna_mode_GreekMode;
934 static Fixnum canna_mode_LineMode;
935 static Fixnum canna_mode_ChangingServerMode;
936 static Fixnum canna_mode_HenkanMethodMode;
937 static Fixnum canna_mode_DeleteDicMode;
938 static Fixnum canna_mode_TourokuMode;
939 static Fixnum canna_mode_TourokuEmptyMode;
940 static Fixnum canna_mode_TourokuHinshiMode;
941 static Fixnum canna_mode_TourokuDicMode;
942 static Fixnum canna_mode_QuotedInsertMode;
943 static Fixnum canna_mode_BubunMuhenkanMode;
944 static Fixnum canna_mode_MountDicMode;
946 static Fixnum canna_fn_SelfInsert;
947 static Fixnum canna_fn_FunctionalInsert;
948 static Fixnum canna_fn_QuotedInsert;
949 static Fixnum canna_fn_JapaneseMode;
950 static Fixnum canna_fn_AlphaMode;
951 static Fixnum canna_fn_HenkanNyuryokuMode;
952 static Fixnum canna_fn_Forward;
953 static Fixnum canna_fn_Backward;
954 static Fixnum canna_fn_Next;
955 static Fixnum canna_fn_Prev;
956 static Fixnum canna_fn_BeginningOfLine;
957 static Fixnum canna_fn_EndOfLine;
958 static Fixnum canna_fn_DeleteNext;
959 static Fixnum canna_fn_DeletePrevious;
960 static Fixnum canna_fn_KillToEndOfLine;
961 static Fixnum canna_fn_Henkan;
962 static Fixnum canna_fn_Kakutei;
963 static Fixnum canna_fn_Extend;
964 static Fixnum canna_fn_Shrink;
965 #ifdef CANNA_FN_AdjustBunsetsu
966 static Fixnum canna_fn_AdjustBunsetsu;
968 static Fixnum canna_fn_Quit;
969 static Fixnum canna_fn_ConvertAsHex;
970 static Fixnum canna_fn_ConvertAsBushu;
971 static Fixnum canna_fn_KouhoIchiran;
972 static Fixnum canna_fn_BubunMuhenkan;
973 static Fixnum canna_fn_Zenkaku;
974 static Fixnum canna_fn_Hankaku;
975 static Fixnum canna_fn_ToUpper;
976 static Fixnum canna_fn_Capitalize;
977 static Fixnum canna_fn_ToLower;
978 static Fixnum canna_fn_Hiragana;
979 static Fixnum canna_fn_Katakana;
980 static Fixnum canna_fn_Romaji;
981 #ifdef CANNA_FN_BaseHiragana
982 static Fixnum canna_fn_BaseHiragana;
983 static Fixnum canna_fn_BaseKatakana;
984 static Fixnum canna_fn_BaseEisu;
985 static Fixnum canna_fn_BaseZenkaku;
986 static Fixnum canna_fn_BaseHankaku;
987 static Fixnum canna_fn_BaseKana;
988 static Fixnum canna_fn_BaseKakutei;
989 static Fixnum canna_fn_BaseHenkan;
990 static Fixnum canna_fn_BaseHiraKataToggle;
991 static Fixnum canna_fn_BaseZenHanToggle;
992 static Fixnum canna_fn_BaseKanaEisuToggle;
993 static Fixnum canna_fn_BaseKakuteiHenkanToggle;
994 static Fixnum canna_fn_BaseRotateForward;
995 static Fixnum canna_fn_BaseRotateBackward;
997 static Fixnum canna_fn_ExtendMode;
998 static Fixnum canna_fn_Touroku;
999 static Fixnum canna_fn_HexMode;
1000 static Fixnum canna_fn_BushuMode;
1001 static Fixnum canna_fn_KigouMode;
1002 #ifdef CANNA_FN_Mark
1003 static Fixnum canna_fn_Mark;
1005 #ifdef CANNA_FN_TemporalMode
1006 static Fixnum canna_fn_TemporalMode;
1009 static Fixnum canna_key_Nfer;
1010 static Fixnum canna_key_Xfer;
1011 static Fixnum canna_key_Up;
1012 static Fixnum canna_key_Left;
1013 static Fixnum canna_key_Right;
1014 static Fixnum canna_key_Down;
1015 static Fixnum canna_key_Insert;
1016 static Fixnum canna_key_Rollup;
1017 static Fixnum canna_key_Rolldown;
1018 static Fixnum canna_key_Home;
1019 static Fixnum canna_key_Help;
1020 static Fixnum canna_key_KP_Key;
1021 static Fixnum canna_key_Shift_Nfer;
1022 static Fixnum canna_key_Shift_Xfer;
1023 static Fixnum canna_key_Shift_Up;
1024 static Fixnum canna_key_Shift_Left;
1025 static Fixnum canna_key_Shift_Right;
1026 static Fixnum canna_key_Shift_Down;
1027 static Fixnum canna_key_Cntrl_Nfer;
1028 static Fixnum canna_key_Cntrl_Xfer;
1029 static Fixnum canna_key_Cntrl_Up;
1030 static Fixnum canna_key_Cntrl_Left;
1031 static Fixnum canna_key_Cntrl_Right;
1032 static Fixnum canna_key_Cntrl_Down;
1034 Lisp_Object VCANNA; /* by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1038 syms_of_mule_canna (void)
1040 DEFSUBR (Fcanna_key_proc);
1041 DEFSUBR (Fcanna_initialize);
1042 DEFSUBR (Fcanna_finalize);
1043 DEFSUBR (Fcanna_touroku_string);
1044 DEFSUBR (Fcanna_set_width);
1045 DEFSUBR (Fcanna_change_mode);
1046 DEFSUBR (Fcanna_store_yomi);
1047 DEFSUBR (Fcanna_do_function);
1048 DEFSUBR (Fcanna_parse);
1049 DEFSUBR (Fcanna_query_mode);
1050 DEFSUBR (Fcanna_set_bunsetsu);
1052 DEFSUBR (Fcanna_henkan_begin);
1053 DEFSUBR (Fcanna_henkan_next);
1054 DEFSUBR (Fcanna_bunsetu_henkou);
1055 DEFSUBR (Fcanna_henkan_kakutei);
1056 DEFSUBR (Fcanna_henkan_end);
1057 DEFSUBR (Fcanna_henkan_quit);
1061 vars_of_mule_canna (void)
1063 DEFVAR_LISP ("CANNA", &VCANNA); /* hir@nec, 1992.5.21 */
1064 VCANNA = Qt; /* hir@nec, 1992.5.21 */
1066 DEFVAR_LISP ("canna-kakutei-string", &Vcanna_kakutei_string /*
1069 Vcanna_kakutei_string = Qnil;
1071 DEFVAR_LISP ("canna-kakutei-yomi", &Vcanna_kakutei_yomi /*
1074 Vcanna_kakutei_yomi = Qnil;
1076 DEFVAR_LISP ("canna-kakutei-romaji", &Vcanna_kakutei_romaji /*
1079 Vcanna_kakutei_romaji = Qnil;
1081 DEFVAR_LISP ("canna-henkan-string", &Vcanna_henkan_string /*
1084 Vcanna_henkan_string = Qnil;
1086 DEFVAR_INT ("canna-henkan-length", &canna_henkan_length /*
1089 canna_henkan_length = 0;
1091 DEFVAR_INT ("canna-henkan-revpos", &canna_henkan_revPos /*
1094 canna_henkan_revPos = 0;
1096 DEFVAR_INT ("canna-henkan-revlen", &canna_henkan_revLen /*
1099 canna_henkan_revLen = 0;
1101 DEFVAR_LISP ("canna-ichiran-string", &Vcanna_ichiran_string /*
1104 Vcanna_ichiran_string = Qnil;
1106 DEFVAR_INT ("canna-ichiran-length", &canna_ichiran_length /*
1109 canna_ichiran_length = 0;
1111 DEFVAR_INT ("canna-ichiran-revpos", &canna_ichiran_revPos /*
1114 canna_ichiran_revPos = 0;
1116 DEFVAR_INT ("canna-ichiran-revlen", &canna_ichiran_revLen /*
1119 canna_ichiran_revLen = 0;
1121 DEFVAR_LISP ("canna-mode-string", &Vcanna_mode_string /*
1124 Vcanna_mode_string = Qnil;
1126 DEFVAR_BOOL ("canna-empty-info", &canna_empty_info /*
1129 canna_empty_info = 0;
1131 DEFVAR_BOOL ("canna-through-info", &canna_through_info /*
1134 canna_through_info = 0;
1136 DEFVAR_BOOL ("canna-underline", &canna_underline /*
1139 canna_underline = 0;
1141 DEFVAR_BOOL ("canna-inhibit-hankakukana", &canna_inhibit_hankakukana /*
1144 canna_inhibit_hankakukana = 0;
1146 DEFVAR_INT ("canna-mode-alpha-mode", &canna_mode_AlphaMode /*
1149 canna_mode_AlphaMode = IROHA_MODE_AlphaMode;
1151 DEFVAR_INT ("canna-mode-empty-mode", &canna_mode_EmptyMode /*
1154 canna_mode_EmptyMode = IROHA_MODE_EmptyMode;
1156 DEFVAR_INT ("canna-mode-kigo-mode", &canna_mode_KigoMode /*
1159 canna_mode_KigoMode = IROHA_MODE_KigoMode;
1161 DEFVAR_INT ("canna-mode-yomi-mode", &canna_mode_YomiMode /*
1164 canna_mode_YomiMode = IROHA_MODE_YomiMode;
1166 DEFVAR_INT ("canna-mode-jishu-mode", &canna_mode_JishuMode /*
1169 canna_mode_JishuMode = IROHA_MODE_JishuMode;
1171 DEFVAR_INT ("canna-mode-tankouho-mode", &canna_mode_TankouhoMode /*
1174 canna_mode_TankouhoMode = IROHA_MODE_TankouhoMode;
1176 DEFVAR_INT ("canna-mode-ichiran-mode", &canna_mode_IchiranMode /*
1179 canna_mode_IchiranMode = IROHA_MODE_IchiranMode;
1181 DEFVAR_INT ("canna-mode-yes-no-mode", &canna_mode_YesNoMode /*
1184 canna_mode_YesNoMode = IROHA_MODE_YesNoMode;
1186 DEFVAR_INT ("canna-mode-on-off-mode", &canna_mode_OnOffMode /*
1189 canna_mode_OnOffMode = IROHA_MODE_OnOffMode;
1191 #ifdef CANNA_MODE_AdjustBunsetsuMode
1192 DEFVAR_INT ("canna-mode-adjust-bunsetsu-mode",
1193 &canna_mode_AdjustBunsetsuMode /*
1196 canna_mode_AdjustBunsetsuMode = CANNA_MODE_AdjustBunsetsuMode;
1198 #ifdef CANNA_MODE_ChikujiYomiMode
1199 DEFVAR_INT ("canna-mode-chikuji-yomi-mode", &canna_mode_ChikujiYomiMode /*
1202 canna_mode_ChikujiYomiMode = CANNA_MODE_ChikujiYomiMode;
1204 DEFVAR_INT ("canna-mode-chikuji-bunsetsu-mode",
1205 &canna_mode_ChikujiTanMode /*
1208 canna_mode_ChikujiTanMode = CANNA_MODE_ChikujiTanMode;
1211 DEFVAR_INT ("canna-mode-henkan-mode", &canna_mode_HenkanMode /*
1214 canna_mode_HenkanMode = IROHA_MODE_HenkanMode;
1216 #ifdef CANNA_MODE_HenkanNyuryokuMode
1217 DEFVAR_INT ("canna-mode-henkan-nyuuryoku-mode",
1218 &canna_mode_HenkanNyuryokuMode /*
1221 canna_mode_HenkanNyuryokuMode = CANNA_MODE_HenkanNyuryokuMode;
1223 #ifdef CANNA_MODE_ZenHiraHenkanMode
1224 DEFVAR_INT ("canna-mode-zen-hira-henkan-mode",
1225 &canna_mode_ZenHiraHenkanMode /*
1228 canna_mode_ZenHiraHenkanMode = CANNA_MODE_ZenHiraHenkanMode;
1229 #ifdef CANNA_MODE_HanHiraHenkanMode
1230 DEFVAR_INT ("canna-mode-han-hira-henkan-mode",
1231 &canna_mode_HanHiraHenkanMode /*
1234 canna_mode_HanHiraHenkanMode = CANNA_MODE_HanHiraHenkanMode;
1236 DEFVAR_INT ("canna-mode-zen-kata-henkan-mode",
1237 &canna_mode_ZenKataHenkanMode /*
1240 canna_mode_ZenKataHenkanMode = CANNA_MODE_ZenKataHenkanMode;
1242 DEFVAR_INT ("canna-mode-han-kata-henkan-mode",
1243 &canna_mode_HanKataHenkanMode /*
1246 canna_mode_HanKataHenkanMode = CANNA_MODE_HanKataHenkanMode;
1248 DEFVAR_INT ("canna-mode-zen-alpha-henkan-mode",
1249 &canna_mode_ZenAlphaHenkanMode /*
1252 canna_mode_ZenAlphaHenkanMode = CANNA_MODE_ZenAlphaHenkanMode;
1254 DEFVAR_INT ("canna-mode-han-alpha-henkan-mode",
1255 &canna_mode_HanAlphaHenkanMode /*
1258 canna_mode_HanAlphaHenkanMode = CANNA_MODE_HanAlphaHenkanMode;
1260 DEFVAR_INT ("canna-mode-zen-hira-kakutei-mode",
1261 &canna_mode_ZenHiraKakuteiMode /*
1264 canna_mode_ZenHiraKakuteiMode = IROHA_MODE_ZenHiraKakuteiMode;
1265 #ifdef CANNA_MODE_HanHiraKakuteiMode
1266 DEFVAR_INT ("canna-mode-han-hira-kakutei-mode",
1267 &canna_mode_HanHiraKakuteiMode /*
1270 canna_mode_HanHiraKakuteiMode = CANNA_MODE_HanHiraKakuteiMode;
1272 DEFVAR_INT ("canna-mode-zen-kata-kakutei-mode",
1273 &canna_mode_ZenKataKakuteiMode /*
1276 canna_mode_ZenKataKakuteiMode = IROHA_MODE_ZenKataKakuteiMode;
1278 DEFVAR_INT ("canna-mode-han-kata-kakutei-mode",
1279 &canna_mode_HanKataKakuteiMode /*
1282 canna_mode_HanKataKakuteiMode = IROHA_MODE_HanKataKakuteiMode;
1284 DEFVAR_INT ("canna-mode-zen-alpha-kakutei-mode",
1285 &canna_mode_ZenAlphaKakuteiMode /*
1288 canna_mode_ZenAlphaKakuteiMode = IROHA_MODE_ZenAlphaKakuteiMode;
1290 DEFVAR_INT ("canna-mode-han-alpha-kakutei-mode",
1291 &canna_mode_HanAlphaKakuteiMode /*
1294 canna_mode_HanAlphaKakuteiMode = IROHA_MODE_HanAlphaKakuteiMode;
1296 DEFVAR_INT ("canna-mode-hex-mode", &canna_mode_HexMode /*
1299 canna_mode_HexMode = IROHA_MODE_HexMode;
1301 DEFVAR_INT ("canna-mode-bushu-mode", &canna_mode_BushuMode /*
1304 canna_mode_BushuMode = IROHA_MODE_BushuMode;
1306 DEFVAR_INT ("canna-mode-extend-mode", &canna_mode_ExtendMode /*
1309 canna_mode_ExtendMode = IROHA_MODE_ExtendMode;
1311 DEFVAR_INT ("canna-mode-russian-mode", &canna_mode_RussianMode /*
1314 canna_mode_RussianMode = IROHA_MODE_RussianMode;
1316 DEFVAR_INT ("canna-mode-greek-mode", &canna_mode_GreekMode /*
1319 canna_mode_GreekMode = IROHA_MODE_GreekMode;
1321 DEFVAR_INT ("canna-mode-line-mode", &canna_mode_LineMode /*
1324 canna_mode_LineMode = IROHA_MODE_LineMode;
1326 DEFVAR_INT ("canna-mode-changing-server-mode",
1327 &canna_mode_ChangingServerMode /*
1330 canna_mode_ChangingServerMode = IROHA_MODE_ChangingServerMode;
1332 DEFVAR_INT ("canna-mode-henkan-method-mode",
1333 &canna_mode_HenkanMethodMode /*
1336 canna_mode_HenkanMethodMode = IROHA_MODE_HenkanMethodMode;
1338 DEFVAR_INT ("canna-mode-delete-dic-mode", &canna_mode_DeleteDicMode /*
1341 canna_mode_DeleteDicMode = IROHA_MODE_DeleteDicMode;
1343 DEFVAR_INT ("canna-mode-touroku-mode", &canna_mode_TourokuMode /*
1346 canna_mode_TourokuMode = IROHA_MODE_TourokuMode;
1348 DEFVAR_INT ("canna-mode-touroku-empty-mode",
1349 &canna_mode_TourokuEmptyMode /*
1352 canna_mode_TourokuEmptyMode = IROHA_MODE_TourokuEmptyMode;
1354 DEFVAR_INT ("canna-mode-touroku-hinshi-mode",
1355 &canna_mode_TourokuHinshiMode /*
1358 canna_mode_TourokuHinshiMode = IROHA_MODE_TourokuHinshiMode;
1360 DEFVAR_INT ("canna-mode-touroku-dic-mode", &canna_mode_TourokuDicMode /*
1363 canna_mode_TourokuDicMode = IROHA_MODE_TourokuDicMode;
1365 DEFVAR_INT ("canna-mode-quoted-insert-mode",
1366 &canna_mode_QuotedInsertMode /*
1369 canna_mode_QuotedInsertMode = IROHA_MODE_QuotedInsertMode;
1371 DEFVAR_INT ("canna-mode-bubun-muhenkan-mode",
1372 &canna_mode_BubunMuhenkanMode /*
1375 canna_mode_BubunMuhenkanMode = IROHA_MODE_BubunMuhenkanMode;
1377 DEFVAR_INT ("canna-mode-mount-dic-mode", &canna_mode_MountDicMode /*
1380 canna_mode_MountDicMode = IROHA_MODE_MountDicMode;
1382 DEFVAR_INT ("canna-func-self-insert", &canna_fn_SelfInsert /*
1385 canna_fn_SelfInsert = IROHA_FN_SelfInsert;
1387 DEFVAR_INT ("canna-func-functional-insert", &canna_fn_FunctionalInsert /*
1390 canna_fn_FunctionalInsert = IROHA_FN_FunctionalInsert;
1392 DEFVAR_INT ("canna-func-quoted-insert", &canna_fn_QuotedInsert /*
1395 canna_fn_QuotedInsert = IROHA_FN_QuotedInsert;
1397 DEFVAR_INT ("canna-func-japanese-mode", &canna_fn_JapaneseMode /*
1400 canna_fn_JapaneseMode = IROHA_FN_JapaneseMode;
1402 DEFVAR_INT ("canna-func-alpha-mode", &canna_fn_AlphaMode /*
1405 canna_fn_AlphaMode = IROHA_FN_AlphaMode;
1407 DEFVAR_INT ("canna-func-henkan-nyuryoku-mode",
1408 &canna_fn_HenkanNyuryokuMode /*
1411 canna_fn_HenkanNyuryokuMode = IROHA_FN_HenkanNyuryokuMode;
1413 DEFVAR_INT ("canna-func-forward", &canna_fn_Forward /*
1416 canna_fn_Forward = IROHA_FN_Forward;
1418 DEFVAR_INT ("canna-func-backward", &canna_fn_Backward /*
1421 canna_fn_Backward = IROHA_FN_Backward;
1423 DEFVAR_INT ("canna-func-next", &canna_fn_Next /*
1426 canna_fn_Next = IROHA_FN_Next;
1428 DEFVAR_INT ("canna-func-previous", &canna_fn_Prev /*
1431 canna_fn_Prev = IROHA_FN_Prev;
1433 DEFVAR_INT ("canna-func-beginning-of-line", &canna_fn_BeginningOfLine /*
1436 canna_fn_BeginningOfLine = IROHA_FN_BeginningOfLine;
1438 DEFVAR_INT ("canna-func-end-of-line", &canna_fn_EndOfLine /*
1441 canna_fn_EndOfLine = IROHA_FN_EndOfLine;
1443 DEFVAR_INT ("canna-func-delete-next", &canna_fn_DeleteNext /*
1446 canna_fn_DeleteNext = IROHA_FN_DeleteNext;
1448 DEFVAR_INT ("canna-func-delete-previous", &canna_fn_DeletePrevious /*
1451 canna_fn_DeletePrevious = IROHA_FN_DeletePrevious;
1453 DEFVAR_INT ("canna-func-kill-to-end-of-line", &canna_fn_KillToEndOfLine /*
1456 canna_fn_KillToEndOfLine = IROHA_FN_KillToEndOfLine;
1458 DEFVAR_INT ("canna-func-henkan", &canna_fn_Henkan /*
1461 canna_fn_Henkan = IROHA_FN_Henkan;
1463 DEFVAR_INT ("canna-func-kakutei", &canna_fn_Kakutei /*
1466 canna_fn_Kakutei = IROHA_FN_Kakutei;
1468 DEFVAR_INT ("canna-func-extend", &canna_fn_Extend /*
1471 canna_fn_Extend = IROHA_FN_Extend;
1473 DEFVAR_INT ("canna-func-shrink", &canna_fn_Shrink /*
1476 canna_fn_Shrink = IROHA_FN_Shrink;
1478 #ifdef CANNA_FN_AdjustBunsetsu
1479 DEFVAR_INT ("canna-func-adjust-bunsetsu", &canna_fn_AdjustBunsetsu /*
1482 canna_fn_AdjustBunsetsu = CANNA_FN_AdjustBunsetsu;
1484 DEFVAR_INT ("canna-func-quit", &canna_fn_Quit /*
1487 canna_fn_Quit = IROHA_FN_Quit;
1489 DEFVAR_INT ("canna-func-convert-as-hex", &canna_fn_ConvertAsHex /*
1492 canna_fn_ConvertAsHex = IROHA_FN_ConvertAsHex;
1494 DEFVAR_INT ("canna-func-convert-as-bushu", &canna_fn_ConvertAsBushu /*
1497 canna_fn_ConvertAsBushu = IROHA_FN_ConvertAsBushu;
1499 DEFVAR_INT ("canna-func-kouho-ichiran", &canna_fn_KouhoIchiran /*
1502 canna_fn_KouhoIchiran = IROHA_FN_KouhoIchiran;
1504 DEFVAR_INT ("canna-func-bubun-muhenkan", &canna_fn_BubunMuhenkan /*
1507 canna_fn_BubunMuhenkan = IROHA_FN_BubunMuhenkan;
1509 DEFVAR_INT ("canna-func-zenkaku", &canna_fn_Zenkaku /*
1512 canna_fn_Zenkaku = IROHA_FN_Zenkaku;
1514 DEFVAR_INT ("canna-func-hankaku", &canna_fn_Hankaku /*
1517 canna_fn_Hankaku = IROHA_FN_Hankaku;
1519 DEFVAR_INT ("canna-func-to-upper", &canna_fn_ToUpper /*
1522 canna_fn_ToUpper = IROHA_FN_ToUpper;
1524 DEFVAR_INT ("canna-func-capitalize", &canna_fn_Capitalize /*
1527 canna_fn_Capitalize = IROHA_FN_Capitalize;
1529 DEFVAR_INT ("canna-func-to-lower", &canna_fn_ToLower /*
1532 canna_fn_ToLower = IROHA_FN_ToLower;
1534 DEFVAR_INT ("canna-func-hiragana", &canna_fn_Hiragana /*
1537 canna_fn_Hiragana = IROHA_FN_Hiragana;
1539 DEFVAR_INT ("canna-func-katakana", &canna_fn_Katakana /*
1542 canna_fn_Katakana = IROHA_FN_Katakana;
1544 DEFVAR_INT ("canna-func-romaji", &canna_fn_Romaji /*
1547 canna_fn_Romaji = IROHA_FN_Romaji;
1549 #ifdef CANNA_FN_BaseHiragana
1550 DEFVAR_INT ("canna-func-base-hiragana", &canna_fn_BaseHiragana /*
1553 canna_fn_BaseHiragana = CANNA_FN_BaseHiragana;
1555 DEFVAR_INT ("canna-func-base-katakana", &canna_fn_BaseKatakana /*
1558 canna_fn_BaseKatakana = CANNA_FN_BaseKatakana;
1560 DEFVAR_INT ("canna-func-base-eisu", &canna_fn_BaseEisu /*
1563 canna_fn_BaseEisu = CANNA_FN_BaseEisu;
1565 DEFVAR_INT ("canna-func-base-zenkaku", &canna_fn_BaseZenkaku /*
1568 canna_fn_BaseZenkaku = CANNA_FN_BaseZenkaku;
1570 DEFVAR_INT ("canna-func-base-hankaku", &canna_fn_BaseHankaku /*
1573 canna_fn_BaseHankaku = CANNA_FN_BaseHankaku;
1575 DEFVAR_INT ("canna-func-base-kana", &canna_fn_BaseKana /*
1578 canna_fn_BaseKana = CANNA_FN_BaseKana;
1580 DEFVAR_INT ("canna-func-base-kakutei", &canna_fn_BaseKakutei /*
1583 canna_fn_BaseKakutei = CANNA_FN_BaseKakutei;
1585 DEFVAR_INT ("canna-func-base-henkan", &canna_fn_BaseHenkan /*
1588 canna_fn_BaseHenkan = CANNA_FN_BaseHenkan;
1590 DEFVAR_INT ("canna-func-base-hiragana-katakana-toggle",
1591 &canna_fn_BaseHiraKataToggle /*
1594 canna_fn_BaseHiraKataToggle = CANNA_FN_BaseHiraKataToggle;
1596 DEFVAR_INT ("canna-func-base-zenkaku-hankaku-toggle",
1597 &canna_fn_BaseZenHanToggle /*
1600 canna_fn_BaseZenHanToggle = CANNA_FN_BaseZenHanToggle;
1602 DEFVAR_INT ("canna-func-base-kana-eisu-toggle",
1603 &canna_fn_BaseKanaEisuToggle /*
1606 canna_fn_BaseKanaEisuToggle = CANNA_FN_BaseKanaEisuToggle;
1608 DEFVAR_INT ("canna-func-base-kakutei-henkan-toggle",
1609 &canna_fn_BaseKakuteiHenkanToggle /*
1612 canna_fn_BaseKakuteiHenkanToggle = CANNA_FN_BaseKakuteiHenkanToggle;
1614 DEFVAR_INT ("canna-func-base-rotate-forward",
1615 &canna_fn_BaseRotateForward /*
1618 canna_fn_BaseRotateForward = CANNA_FN_BaseRotateForward;
1620 DEFVAR_INT ("canna-func-base-rotate-backward",
1621 &canna_fn_BaseRotateBackward /*
1624 canna_fn_BaseRotateBackward = CANNA_FN_BaseRotateBackward;
1627 DEFVAR_INT ("canna-func-extend-mode", &canna_fn_ExtendMode /*
1630 canna_fn_ExtendMode = IROHA_FN_ExtendMode;
1632 DEFVAR_INT ("canna-func-touroku", &canna_fn_Touroku /*
1635 canna_fn_Touroku = IROHA_FN_Touroku;
1637 DEFVAR_INT ("canna-func-hex-mode", &canna_fn_HexMode /*
1640 canna_fn_HexMode = IROHA_FN_HexMode;
1642 DEFVAR_INT ("canna-func-bushu-mode", &canna_fn_BushuMode /*
1645 canna_fn_BushuMode = IROHA_FN_BushuMode;
1647 DEFVAR_INT ("canna-func-kigo-mode", &canna_fn_KigouMode /*
1650 canna_fn_KigouMode = IROHA_FN_KigouMode;
1652 #ifdef CANNA_FN_Mark
1653 DEFVAR_INT ("canna-func-mark", &canna_fn_Mark /*
1656 canna_fn_Mark = CANNA_FN_Mark;
1658 #ifdef CANNA_FN_TemporalMode
1659 DEFVAR_INT ("canna-func-temporal-mode", &canna_fn_TemporalMode /*
1662 canna_fn_TemporalMode = CANNA_FN_TemporalMode;
1665 DEFVAR_INT ("canna-key-nfer", &canna_key_Nfer /*
1668 canna_key_Nfer = IROHA_KEY_Nfer;
1670 DEFVAR_INT ("canna-key-xfer", &canna_key_Xfer /*
1673 canna_key_Xfer = IROHA_KEY_Xfer;
1675 DEFVAR_INT ("canna-key-up", &canna_key_Up /*
1678 canna_key_Up = IROHA_KEY_Up;
1680 DEFVAR_INT ("canna-key-left", &canna_key_Left /*
1683 canna_key_Left = IROHA_KEY_Left;
1685 DEFVAR_INT ("canna-key-right", &canna_key_Right /*
1688 canna_key_Right = IROHA_KEY_Right;
1690 DEFVAR_INT ("canna-key-down", &canna_key_Down /*
1693 canna_key_Down = IROHA_KEY_Down;
1695 DEFVAR_INT ("canna-key-insert", &canna_key_Insert /*
1698 canna_key_Insert = IROHA_KEY_Insert;
1700 DEFVAR_INT ("canna-key-rollup", &canna_key_Rollup /*
1703 canna_key_Rollup = IROHA_KEY_Rollup;
1705 DEFVAR_INT ("canna-key-rolldown", &canna_key_Rolldown /*
1708 canna_key_Rolldown = IROHA_KEY_Rolldown;
1710 DEFVAR_INT ("canna-key-home", &canna_key_Home /*
1713 canna_key_Home = IROHA_KEY_Home;
1715 DEFVAR_INT ("canna-key-help", &canna_key_Help /*
1718 canna_key_Help = IROHA_KEY_Help;
1720 DEFVAR_INT ("canna-key-kp-key", &canna_key_KP_Key /*
1723 canna_key_KP_Key = IROHA_KEY_KP_Key;
1725 DEFVAR_INT ("canna-key-shift-nfer", &canna_key_Shift_Nfer /*
1728 canna_key_Shift_Nfer = IROHA_KEY_Shift_Nfer;
1730 DEFVAR_INT ("canna-key-shift-xfer", &canna_key_Shift_Xfer /*
1733 canna_key_Shift_Xfer = IROHA_KEY_Shift_Xfer;
1735 DEFVAR_INT ("canna-key-shift-up", &canna_key_Shift_Up /*
1738 canna_key_Shift_Up = IROHA_KEY_Shift_Up;
1740 DEFVAR_INT ("canna-key-shift-left", &canna_key_Shift_Left /*
1743 canna_key_Shift_Left = IROHA_KEY_Shift_Left;
1745 DEFVAR_INT ("canna-key-shift-right", &canna_key_Shift_Right /*
1748 canna_key_Shift_Right = IROHA_KEY_Shift_Right;
1750 DEFVAR_INT ("canna-key-shift-down", &canna_key_Shift_Down /*
1753 canna_key_Shift_Down = IROHA_KEY_Shift_Down;
1755 DEFVAR_INT ("canna-key-control-nfer", &canna_key_Cntrl_Nfer /*
1758 canna_key_Cntrl_Nfer = IROHA_KEY_Cntrl_Nfer;
1760 DEFVAR_INT ("canna-key-control-xfer", &canna_key_Cntrl_Xfer /*
1763 canna_key_Cntrl_Xfer = IROHA_KEY_Cntrl_Xfer;
1765 DEFVAR_INT ("canna-key-control-up", &canna_key_Cntrl_Up /*
1768 canna_key_Cntrl_Up = IROHA_KEY_Cntrl_Up;
1770 DEFVAR_INT ("canna-key-control-left", &canna_key_Cntrl_Left /*
1773 canna_key_Cntrl_Left = IROHA_KEY_Cntrl_Left;
1775 DEFVAR_INT ("canna-key-control-right", &canna_key_Cntrl_Right /*
1778 canna_key_Cntrl_Right = IROHA_KEY_Cntrl_Right;
1780 DEFVAR_INT ("canna-key-control-down", &canna_key_Cntrl_Down /*
1783 canna_key_Cntrl_Down = IROHA_KEY_Cntrl_Down;
1785 Fprovide(intern("CANNA"));
1789 /* To handle MULE internal code and EUC.
1790 I assume CANNA can handle only Japanese EUC. */
1792 /* EUC multibyte string to MULE internal string */
1795 c2mu (unsigned char *cp, int l, unsigned char *mp)
1797 unsigned char ch, *ep = cp+l;
1801 while ((cp < ep) && (ch = *cp++))
1803 if (ch == ISO_CODE_SS2)
1805 chr = (*cp++) + MIN_CHAR_HALFWIDTH_KATAKANA - 0x20;
1807 else if (ch == ISO_CODE_SS3)
1810 chr = MAKE_CHAR (Vcharset_japanese_jisx0212,
1811 ch & 0x7f, (*cp++) & 0x7f);
1815 chr = MAKE_CHAR (Vcharset_japanese_jisx0208,
1816 ch & 0x7f, (*cp++) & 0x7f);
1826 else if ( chr <= 0x7ff )
1828 *mp++ = (chr >> 6) | 0xc0;
1829 *mp++ = (chr & 0x3f) | 0x80;
1831 else if ( chr <= 0xffff )
1833 *mp++ = (chr >> 12) | 0xe0;
1834 *mp++ = ((chr >> 6) & 0x3f) | 0x80;
1835 *mp++ = (chr & 0x3f) | 0x80;
1837 else if ( chr <= 0x1fffff )
1839 *mp++ = (chr >> 18) | 0xf0;
1840 *mp++ = ((chr >> 12) & 0x3f) | 0x80;
1841 *mp++ = ((chr >> 6) & 0x3f) | 0x80;
1842 *mp++ = (chr & 0x3f) | 0x80;
1844 else if ( chr <= 0x3ffffff )
1846 *mp++ = (chr >> 24) | 0xf8;
1847 *mp++ = ((chr >> 18) & 0x3f) | 0x80;
1848 *mp++ = ((chr >> 12) & 0x3f) | 0x80;
1849 *mp++ = ((chr >> 6) & 0x3f) | 0x80;
1850 *mp++ = (chr & 0x3f) | 0x80;
1854 *mp++ = (chr >> 30) | 0xfc;
1855 *mp++ = ((chr >> 24) & 0x3f) | 0x80;
1856 *mp++ = ((chr >> 18) & 0x3f) | 0x80;
1857 *mp++ = ((chr >> 12) & 0x3f) | 0x80;
1858 *mp++ = ((chr >> 6) & 0x3f) | 0x80;
1859 *mp++ = (chr & 0x3f) | 0x80;
1863 while ((cp < ep) && (ch = *cp))
1865 if ((unsigned char) ch == ISO_CODE_SS2)
1867 *mp++ = LEADING_BYTE_KATAKANA_JISX0201;
1870 else if ((unsigned char) ch == ISO_CODE_SS3)
1872 *mp++ = LEADING_BYTE_JAPANESE_JISX0212;
1878 *mp++ = LEADING_BYTE_JAPANESE_JISX0208;
1887 /* MULE internal string to EUC multibyte string */
1890 m2c (unsigned char *mp, int l, unsigned char *cp)
1892 unsigned char ch, *ep = mp + l;
1898 while ((mp < ep) && (ch = *mp++))
1906 else if ( ch >= 0xf8 )
1911 else if ( ch >= 0xf0 )
1916 else if ( ch >= 0xe0 )
1921 else if ( ch >= 0xc0 )
1931 for( ; len > 0; len-- )
1934 chr = ( chr << 6 ) | ( ch & 0x3f );
1943 = charset_code_point (Vcharset_japanese_jisx0208,
1946 *cp++ = (code >> 8) | 0x80;
1947 *cp++ = (code & 0xFF) | 0x80;
1950 = charset_code_point (Vcharset_katakana_jisx0201,
1953 *cp++ = ISO_CODE_SS2;
1954 *cp++ = code | 0x80;
1957 = charset_code_point (Vcharset_japanese_jisx0212,
1960 *cp++ = ISO_CODE_SS3;
1961 *cp++ = (code >> 8) | 0x80;
1962 *cp++ = (code & 0xFF) | 0x80;
1968 case LEADING_BYTE_KATAKANA_JISX0201:
1969 *cp++ = ISO_CODE_SS2;
1972 case LEADING_BYTE_JAPANESE_JISX0212:
1973 *cp++ = ISO_CODE_SS3;
1974 case LEADING_BYTE_JAPANESE_JISX0208:
1989 /* make_string after converting EUC string to MULE internal string */
1991 mule_make_string (unsigned char *p, int l)
1993 unsigned char cbuf[4096];
1996 return (make_string (cbuf,strlen (cbuf)));
1999 /* return the MULE internal string length of EUC string */
2000 /* Modified by sb to return a character count not byte count. */
2002 mule_strlen (unsigned char *p, int l)
2004 unsigned char ch, *cp = p;
2007 while ((cp < p + l) && (ch = *cp))
2009 if ((unsigned char) ch == ISO_CODE_SS2)
2014 else if ((unsigned char) ch == ISO_CODE_SS3)
2033 /* count number of characters */
2035 count_char (unsigned char *p, int len, int pos, int rev,
2036 Fixnum *clen, Fixnum *cpos, Fixnum *crev)
2038 unsigned char *q = p;
2040 *clen = *cpos = *crev = 0;
2041 if (len == 0) return;
2046 if (*q++ & 0x80) q++;
2048 while (q < p + pos + rev)
2052 if (*q++ & 0x80) q++;
2057 if (*q++ & 0x80) q++;
2060 #endif /* CANNA_MULE */