Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# vim:set et sts=4:
# -*- coding: utf-8 -*-
bopomofo = [
"BOPOMOFO_ZERO",
"BOPOMOFO_B",
"BOPOMOFO_P",
"BOPOMOFO_M",
"BOPOMOFO_F",
"BOPOMOFO_D",
"BOPOMOFO_T",
"BOPOMOFO_N",
"BOPOMOFO_L",
"BOPOMOFO_G",
"BOPOMOFO_K",
"BOPOMOFO_H",
"BOPOMOFO_J",
"BOPOMOFO_Q",
"BOPOMOFO_X",
"BOPOMOFO_ZH",
"BOPOMOFO_CH",
"BOPOMOFO_SH",
"BOPOMOFO_R",
"BOPOMOFO_Z",
"BOPOMOFO_C",
"BOPOMOFO_S",
"BOPOMOFO_I",
"BOPOMOFO_U",
"BOPOMOFO_V",
"BOPOMOFO_A",
"BOPOMOFO_O",
"BOPOMOFO_E",
"BOPOMOFO_E2",
"BOPOMOFO_AI",
"BOPOMOFO_EI",
"BOPOMOFO_AO",
"BOPOMOFO_OU",
"BOPOMOFO_AN",
"BOPOMOFO_EN",
"BOPOMOFO_ANG",
"BOPOMOFO_ENG",
"BOPOMOFO_ER",
"BOPOMOFO_TONE_2",
"BOPOMOFO_TONE_3",
"BOPOMOFO_TONE_4",
"BOPOMOFO_TONE_5",
]
bopomofo_keyboard = (
#標準注音鍵盤
(
"1","q","a","z","2","w","s","x","e","d","c","r","f","v","5","t","g","b","y","h","n",
"u","j","m","8","i","k",",","9","o","l",".","0","p",";","/","-",
"6","3","4","7",
),
#精業注音鍵盤
(
"2","w","s","x","3","e","d","c","r","f","v","t","g","b","6","y","h","n","u","j","m",
"-","[","'","8","i","k",",","9","o","l",".","0","p",";","/","=",
"q","a","z","1",
),
#倚天注音鍵盤
(
"b","p","m","f","d","t","n","l","v","k","h","g","7","c",",",".","/","j",";","'","s",
"e","x","u","a","o","r","w","i","q","z","y","8","9","0","-","=",
"2","3","4","1",
),
#IBM注音鍵盤
(
"1","2","3","4","5","6","7","8","9","0","-","q","w","e","r","t","y","u","i","o","p",
"a","s","d","f","g","h","j","k","l",";","z","x","c","v","b","n",
"m",",",".","/",
),
)
def tochar(ch):
if ch == "'" or ch == "\\":
ch = "\\" + ch;
return "'" + ch + "'"
def gen_table():
i = 0
print 'static const guint8'
print 'bopomofo_keyboard[][41][2] = {'
for keyboard in bopomofo_keyboard:
print ' {'
items = []
i=1
for v in keyboard:
items.append ((v,bopomofo[i]));
i += 1
items.sort()
for k,v in items:
print ' { %-4s, %-15s },' % (tochar(k),v)
print ' },'
print '};'
print
if __name__ == "__main__":
gen_table()