Skip to content

Commit

Permalink
Add symbol type feature #150
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwarat committed Nov 24, 2009
1 parent 33ad32c commit 6665dac
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 20 deletions.
24 changes: 16 additions & 8 deletions engine/jastring.py
Expand Up @@ -25,17 +25,23 @@

from segment import unichar_half_to_full

SymbolTable = {}
HalfSymbolTable = {}
for i in range(32, 127):
if not chr(i).isalnum():
SymbolTable[unichar_half_to_full(chr(i))] = chr(i)
HalfSymbolTable[unichar_half_to_full(chr(i))] = chr(i)

NumberTable = {}
HalfNumberTable = {}
for i in range(10):
NumberTable[unichar_half_to_full(str(i))] = str(i)
HalfNumberTable[unichar_half_to_full(str(i))] = str(i)

PeriodTable = {u'。': u'.', u'、': u',', u'。': u'.', u'、': u','}

SymbolTable = {}
SymbolTable[0] = {u'「': u'「', u'」': u'」', u'/': u'/'}
SymbolTable[1] = {u'「': u'「', u'」': u'」', u'/': u'・'}
SymbolTable[2] = {u'「': u'[', u'」': u']', u'/': u'/'}
SymbolTable[3] = {u'「': u'[', u'」': u']', u'/': u'・'}

TYPING_MODE_ROMAJI, \
TYPING_MODE_KANA, \
TYPING_MODE_THUMB_SHIFT = range(3)
Expand Down Expand Up @@ -113,13 +119,15 @@ def move_cursor(self, delta):

def _chk_text(self, s):
period = self._prefs.get_value('common', 'period_style')
symbol = self._prefs.get_value('common', 'half_width_symbol')
number = self._prefs.get_value('common', 'half_width_number')
symbol = self._prefs.get_value('common', 'symbol_style')
half_symbol = self._prefs.get_value('common', 'half_width_symbol')
half_number = self._prefs.get_value('common', 'half_width_number')
ret = ''
for c in s:
c = c if not period else PeriodTable.get(c, c)
c = c if not symbol else SymbolTable.get(c, c)
c = c if not number else NumberTable.get(c, c)
c = c if not symbol else SymbolTable[symbol].get(c, c)
c = c if not half_symbol else HalfSymbolTable.get(c, c)
c = c if not half_number else HalfNumberTable.get(c, c)
ret += c
return ret

Expand Down
1 change: 1 addition & 0 deletions setup/anthyprefs.py
Expand Up @@ -102,6 +102,7 @@ def keys(self, section):
'typing_method': 0,

'period_style': 0,
'symbol_style': 1,
'ten_key_mode': 1,
'behivior_on_focus_out': 0,
'behivior_on_period': 0,
Expand Down
2 changes: 1 addition & 1 deletion setup/main.py
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
self.xml = xml = glade.XML(glade_file)

for name in ['input_mode', 'typing_method',
'period_style', 'ten_key_mode',
'period_style', 'symbol_style', 'ten_key_mode',
'behivior_on_focus_out', 'behivior_on_period',
'half_width_symbol', 'half_width_number', 'half_width_space']:
xml.get_widget(name).set_active(prefs.get_value('common', name))
Expand Down
55 changes: 44 additions & 11 deletions setup/setup.glade
Expand Up @@ -132,7 +132,7 @@ Thumb shift</property>
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
Expand All @@ -149,6 +149,21 @@ Thumb shift</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Symbol Style:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">symbol_style</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
Expand All @@ -158,8 +173,8 @@ Thumb shift</property>
<property name="mnemonic_widget">ten_key_mode</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
Expand All @@ -169,6 +184,24 @@ Thumb shift</property>
<property name="visible">True</property>
<property name="items" translatable="yes">Keep Numpad Codes
Convert Characters
</property>
<signal name="changed" handler="on_cb_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="symbol_style">
<property name="visible">True</property>
<property name="items">&#x300C;&#x300D;&#xFF0F;
&#x300C;&#x300D;&#x30FB;
&#xFF3B;&#xFF3D;&#xFF0F;
&#xFF3B;&#xFF3D;&#x30FB;
</property>
<signal name="changed" handler="on_cb_changed"/>
</widget>
Expand Down Expand Up @@ -203,8 +236,8 @@ Convert Characters
<property name="mnemonic_widget">behivior_on_period</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
Expand All @@ -218,8 +251,8 @@ Convert Characters
<property name="mnemonic_widget">behivior_on_focus_out</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
Expand All @@ -234,8 +267,8 @@ Auto Convert</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
Expand All @@ -251,8 +284,8 @@ Hold
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
Expand Down

0 comments on commit 6665dac

Please sign in to comment.