Permalink
Browse files

Added us layout table for Kana.

  • Loading branch information...
1 parent 3800c47 commit d5fd7c7277ca7116181e35a325a1234ded7368c2 @fujiwarat committed Oct 19, 2012
Showing with 195 additions and 8 deletions.
  1. +7 −2 engine/kana.py
  2. +48 −0 engine/tables.py
  3. +112 −3 setup/anthyprefs.py.in
  4. +28 −3 setup/main.py
View
@@ -30,6 +30,7 @@
class KanaSegment(segment.Segment):
_prefs = None
+ _kana_typing_rule_method = 'jp'
_kana_typing_rule_section = None
def __init__(self, enchars=u'', jachars=u''):
@@ -45,7 +46,8 @@ def _init_kana_typing_rule(cls, prefs):
return
method = prefs.get_value('kana_typing_rule', 'method')
if method == None:
- method = 'default'
+ method = 'jp'
+ cls._kana_typing_rule_method = method
cls._kana_typing_rule_section = 'kana_typing_rule/' + method
if cls._kana_typing_rule_section not in prefs.sections():
cls._kana_typing_rule_section = None
@@ -86,7 +88,10 @@ def append(self, enchar):
return []
if self._jachars:
text = self._jachars + enchar
- jachars = kana_voiced_consonant_rule.get(text, None)
+ if self._kana_typing_rule_method == 'us':
+ jachars = kana_voiced_consonant_us_rule.get(text, None)
+ else:
+ jachars = kana_voiced_consonant_rule.get(text, None)
if jachars:
self._enchars = self._enchars + enchar
self._jachars = jachars
View
@@ -529,6 +529,54 @@
u'ほ[' : u'',
}
+kana_voiced_consonant_us_rule = {
+ u'か[' : u'',
+ u'き[' : u'',
+ u'く[' : u'',
+ u'け[' : u'',
+ u'こ[' : u'',
+ u'さ[' : u'',
+ u'し[' : u'',
+ u'す[' : u'',
+ u'せ[' : u'',
+ u'そ[' : u'',
+ u'た[' : u'',
+ u'ち[' : u'',
+ u'つ[' : u'',
+ u'て[' : u'',
+ u'と[' : u'',
+ u'は[' : u'',
+ u'ひ[' : u'',
+ u'ふ[' : u'',
+ u'へ[' : u'',
+ u'ほ[' : u'',
+ u'か{' : u'',
+ u'き{' : u'',
+ u'く{' : u'',
+ u'け{' : u'',
+ u'こ{' : u'',
+ u'さ{' : u'',
+ u'し{' : u'',
+ u'す{' : u'',
+ u'せ{' : u'',
+ u'そ{' : u'',
+ u'た{' : u'',
+ u'ち{' : u'',
+ u'つ{' : u'',
+ u'て{' : u'',
+ u'と{' : u'',
+ u'は{' : u'',
+ u'ひ{' : u'',
+ u'ふ{' : u'',
+ u'へ{' : u'',
+ u'ほ{' : u'',
+ u'は]' : u'',
+ u'ひ]' : u'',
+ u'ふ]' : u'',
+ u'へ]' : u'',
+ u'ほ]' : u'',
+}
+
#hiragana, katakana, half_katakana
hiragana_katakana_table = {
u'' : (u'', u''),
View
@@ -544,11 +544,11 @@ _config = {
},
'kana_typing_rule': {
- 'method': 'default',
+ 'method': 'jp',
'newkeys': [],
},
- 'kana_typing_rule/default': {
+ 'kana_typing_rule/jp': {
# no modifiers keys
'1' : 'ぬ',
'2' : 'ふ',
@@ -613,7 +613,7 @@ _config = {
'(' : 'ゅ',
')' : 'ょ',
'~' : 'を',
- '=' : '',
+ '=' : '',
'|' : 'ー',
'Q' : 'た',
@@ -660,6 +660,115 @@ _config = {
'¥' : 'ー',
},
+ 'kana_typing_rule/us': {
+ # no modifiers keys
+ '`' : 'ろ',
+ '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' : 'も',
+ ',' : 'ね',
+ '.' : 'る',
+ '/' : 'め',
+
+ # shift modifiered keys
+ '~' : 'ろ',
+ '!' : 'ぬ',
+ '@' : 'ふ',
+ '#' : 'ぁ',
+ '$' : 'ぅ',
+ '%' : 'ぇ',
+ '^' : 'ぉ',
+ '&' : 'ゃ',
+ '*' : 'ゅ',
+ '(' : 'ょ',
+ ')' : 'を',
+ '_' : 'ー',
+ '+' : 'ゑ',
+
+ 'Q' : 'た',
+ 'W' : 'て',
+ 'E' : 'ぃ',
+ 'R' : 'す',
+ 'T' : 'ヵ',
+ 'Y' : 'ん',
+ 'U' : 'な',
+ 'I' : 'に',
+ 'O' : 'ら',
+ 'P' : 'せ',
+ '{' : '「',
+
+ '}' : '」',
+
+ '|' : 'む',
+
+ 'A' : 'ち',
+ 'S' : 'と',
+ 'D' : 'し',
+ 'F' : 'ゎ',
+ 'G' : 'き',
+ 'H' : 'く',
+ 'J' : 'ま',
+ 'K' : 'の',
+ 'L' : 'り',
+ ':' : 'れ',
+ '"' : 'ヶ',
+
+ 'Z' : 'っ',
+ 'X' : 'さ',
+ 'C' : 'そ',
+ 'V' : 'ゐ',
+ 'B' : 'こ',
+ 'M' : 'も',
+ 'N' : 'み',
+ '<' : '、',
+ '>' : '。',
+
+ '?' : '・',
+ },
'thumb': {
'keyboard_layout_mode': True,
'keyboard_layout': 0,
View
@@ -427,6 +427,12 @@ def __show_dialog_custom_key_table_extention(self, mode):
entry_left.show()
label_right.show()
entry_right.show()
+ elif mode == 'kana':
+ hbox_combo.show()
+ label_left.hide()
+ entry_left.hide()
+ label_right.hide()
+ entry_right.hide()
else:
hbox_combo.hide()
label_left.hide()
@@ -494,7 +500,8 @@ def __run_dialog_custom_key_table(self, mode):
dlg.set_title(_("Customize Kana Key Table"))
label.set_label(_("_Kana Key Table:"))
label_output.set_label(_("_Output Chars"))
- list_labels = [['default', _("Default")]]
+ list_labels = [['jp', _("Japanese Keyboard Layout")],
+ ['us', _("U.S. Keyboard Layout")]]
self.__show_dialog_custom_key_table_extention(mode)
elif mode == 'thumb':
dlg.set_title(_("Customize Thumb Shift Key Table"))
@@ -530,7 +537,7 @@ def __run_dialog_custom_key_table(self, mode):
if mode == 'kana':
method = prefs.get_value('kana_typing_rule', 'method')
if method == None:
- method = 'default'
+ method = 'jp'
tv = self.__get_kana_treeview_custom_key_table(method)
if mode == 'thumb':
method = prefs.get_value('thumb_typing_rule', 'method')
@@ -539,7 +546,15 @@ def __run_dialog_custom_key_table(self, mode):
tv = self.__get_thumb_treeview_custom_key_table(method)
self.__connect_dialog_custom_key_table_buttons(mode)
- combobox.set_active(0)
+
+ id = 0
+ # thumb uses all tables so the default is always 0.
+ if mode != 'thumb':
+ for index, labels in enumerate(list_labels):
+ if labels[0] == method:
+ id = index
+ break
+ combobox.set_active(id)
combobox.connect('changed', self.on_cb_custom_key_table_changed, mode)
id = dlg.run()
@@ -995,6 +1010,12 @@ def on_selection_changed(self, widget, id):
set_sensitive(name, flg)
def on_selection_custom_key_table_changed(self, widget, id):
+ l, i = widget.get_selected()
+ # if 'combobox_custom_key_table' is changed,
+ # 'treeview_custom_key_table' also receives this signal
+ # but no selection.
+ if i == None:
+ return
button = self.__builder.get_object('button_remove_custom_key')
button.set_sensitive(True)
@@ -1054,6 +1075,7 @@ def on_cb_keymap_changed(self, widget, id):
self.__builder.get_object('btn_apply').set_sensitive(True)
def on_cb_custom_key_table_changed(self, widget, user_data):
+ prefs = self.prefs
tv = self.__builder.get_object('treeview_custom_key_table')
mode = user_data
id = widget.get_active()
@@ -1067,8 +1089,11 @@ def on_cb_custom_key_table_changed(self, widget, user_data):
if mode == 'romaji':
tv = self.__get_romaji_treeview_custom_key_table(method)
elif mode == 'kana':
+ prefs.set_value('kana_typing_rule', 'method', method)
+ self.__builder.get_object('btn_apply').set_sensitive(True)
tv = self.__get_kana_treeview_custom_key_table(method)
elif mode == 'thumb':
+ # thumb uses all tables so do not save the method.
tv = self.__get_thumb_treeview_custom_key_table(method)
def on_sb_changed(self, widget):

0 comments on commit d5fd7c7

Please sign in to comment.