1 #include "gcin.h"
2 #include "pho.h"
3 #include "config.h"
4 #if GCIN_i18n_message
5 #include <libintl.h>
6 #endif
7 #include "gst.h"
8 #include "tsin.h"
9
10 static gboolean b_pinyin;
11 #if !GCIN_SVR
12 PIN_JUYIN *pin_juyin;
13 int pin_juyinN;
14 PHOKBM phkbm;
15 PHO_ST poo;
16 TSIN_ST tss;
17 extern int text_pho_N;
18
key_typ_pho(phokey_t phokey,u_char rtyp_pho[])19 void key_typ_pho(phokey_t phokey, u_char rtyp_pho[])
20 {
21 }
22 #endif
23
phokey2pinyin(phokey_t k)24 char *phokey2pinyin(phokey_t k)
25 {
26 static char tt[32];
27 phokey_t tonemask = 7;
28 phokey_t notone = k & ~tonemask;
29
30
31 int i;
32 for(i=0; i < pin_juyinN; i++) {
33 if (notone == pin_juyin[i].key)
34 break;
35 }
36
37 if (notone && i==pin_juyinN) {
38 // prph(k);
39 strcpy(tt, "??");
40 } else {
41 static char tone[2];
42 tone[0] = (k & tonemask) + '0';
43 strcpy(tt, pin_juyin[i].pinyin);
44
45 if (tone[0]=='1')
46 tone[0]='5';
47
48 if (tone[0]!='0')
49 strcat(tt, tone);
50 }
51
52 return tt;
53 }
54
55 void load_pin_juyin();
56
is_pinyin_kbm()57 gboolean is_pinyin_kbm()
58 {
59 #if 0
60 char kbm_str[32];
61 get_gcin_conf_fstr(PHONETIC_KEYBOARD, kbm_str, "zo-asdf");
62 #endif
63
64 #if 1
65 b_pinyin = strstr(pho_kbm_name, "pinyin") != NULL;
66 #else
67 b_pinyin = 1;
68 #endif
69
70 if (b_pinyin)
71 load_pin_juyin();
72 return b_pinyin;
73 }
74
75
pinyin2phokey(char * s)76 phokey_t pinyin2phokey(char *s)
77 {
78 char *p = s;
79 while (*p && *p!=' ')
80 p++;
81 int len = p - s;
82 char tone = s[len-1];
83
84 if (tone<'1' || tone > '5')
85 tone = 0;
86 else {
87 tone -= '0';
88 if (tone==5)
89 tone = 1;
90 }
91
92 if (len==1 && tone)
93 return tone;
94
95 // dbg("'%s' '%d'\n", s, tone);
96
97 int mlen = tone ? len-1:len;
98
99 char t[16];
100
101 memcpy(t, s, mlen);
102 t[mlen]=0;
103
104 int i;
105 for(i=0; i < pin_juyinN; i++) {
106 if (!strcmp(pin_juyin[i].pinyin, t)) {
107 return (pin_juyin[i].key | tone);
108 }
109 }
110
111 return 0;
112 }
113