[ibus-typing-booster] master: Some more debug prints to see the modifiers (c2abb0b)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit c2abb0bcbf219165ba1a0aaee1d25320976d6342
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Mon Dec 14 20:02:46 2015 +0100
Some more debug prints to see the modifiers
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 4e470f4..5f02b6f 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -879,6 +879,15 @@ class tabengine (IBus.Engine):
+ "IBus.keyval_to_unicode(%(key.val)s)='%(uc)s'\n"
%{'key.val': key.val,
'uc': IBus.keyval_to_unicode(key.val)})
+ sys.stderr.write(
+ "CONTROL_MASK=%(bit)s\n"
+ %{'bit': key.state & IBus.ModifierType.CONTROL_MASK})
+ sys.stderr.write(
+ "MOD1_MASK=%(bit)s\n"
+ %{'bit': key.state & IBus.ModifierType.MOD1_MASK})
+ sys.stderr.write(
+ "MOD5_MASK=%(bit)s\n"
+ %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
result = self._process_key_event (key)
return result
@@ -1209,10 +1218,6 @@ class tabengine (IBus.Engine):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
- if debug_level > 1:
- sys.stderr.write(
- "MOD5_MASK=%(bit)s\n"
- %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
self._editor.insert_string_at_cursor(list(typed_character))
if (typed_character
and unicodedata.category(typed_character)
8 years, 5 months
[ibus-typing-booster] master: Add ���Renganathan:ta-lk-renganathan��� input method option to ta_IN.conf (27c7f2e)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 27c7f2e412d77e294ef31166a966a005ba20f6d5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 22:59:54 2015 +0100
Add ���Renganathan:ta-lk-renganathan��� input method option to ta_IN.conf
For testing whether an input method using Alt-<key> works as well.
>---------------------------------------------------------------
ibus-typing-booster/hunspell-tables/ta_IN.conf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ibus-typing-booster/hunspell-tables/ta_IN.conf b/ibus-typing-booster/hunspell-tables/ta_IN.conf
index 9362dfb..dbd4c4d 100644
--- a/ibus-typing-booster/hunspell-tables/ta_IN.conf
+++ b/ibus-typing-booster/hunspell-tables/ta_IN.conf
@@ -11,5 +11,5 @@ hunspell_dict = ta_IN.dic
hunspell_dict_package = hunspell-ta
ime_name = Tamil - IN (Hunspell)
symbol = ta-IN
-imes = Enhanced Inscript:ta-inscript2,Inscript:ta-inscript,Phonetic:ta-phonetic,Itrans:ta-itrans,Typewriter:ta-typewriter
+imes = Enhanced Inscript:ta-inscript2,Inscript:ta-inscript,Phonetic:ta-phonetic,Itrans:ta-itrans,Typewriter:ta-typewriter,Renganathan:ta-lk-renganathan
setup = /usr/libexec/ibus-setup-typing-booster --config-file ta_IN.conf
8 years, 5 months
[ibus-typing-booster] master: Add an option to disable whether the digits 1-9 are used as selection keys (f71a842)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit f71a8425013e26cc34f0a0c4e5b3a4b7c98db51a
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 15:31:36 2015 +0100
Add an option to disable whether the digits 1-9 are used as selection keys
Using the digits 1-9 as keys to select a candidate to commit
or to delete the candidate makes it impossible to use these digits
as normal input. This make typing numbers more difficult, they
can only be typed while the pre��dit is empty then. Therefore,
numbers can not use completion when they are needed as select keys.
But the F1-F9 keys are also always available as selection keys.
So it is not an absolute requirment to make the digits 1-9 behave as
selection keys as well. It may be convenient though because the
distance between the 1-9 keys and the fingers is shorter than the
distance between the F1-F9 keys and the fingers.
Therefore, I added this options so the user can decide what is more
important, having the 1-9 keys behave as selection keys or using
them to input numbers.
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 35 +++++++++++--
ibus-typing-booster/setup/main.py | 25 ++++++++++
ibus-typing-booster/setup/setup.glade | 65 +++++++++++++++++---------
3 files changed, 96 insertions(+), 29 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index a77321f..ca727ec 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -579,6 +579,13 @@ class tabengine (IBus.Engine):
if self._show_number_of_candidates == None:
self._show_number_of_candidates = False
+ self._use_digits_as_select_keys = variant_to_value(
+ self._config.get_value(
+ self._config_section,
+ 'usedigitsasselectkeys'))
+ if self._use_digits_as_select_keys == None:
+ self._use_digits_as_select_keys = True
+
self._icon_dir = '%s%s%s%s' % (
os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
os.path.sep, 'icons', os.path.sep)
@@ -969,8 +976,16 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(list(typed_character))
self._update_ui()
return True
- if (typed_character
- and unicodedata.digit(typed_character, -1) != -1):
+ if (self._use_digits_as_select_keys
+ and typed_character
+ in ('1', '2', '3', '4', '5', '6', '7', '8', '9')):
+ # If digits are used as keys to select candidates
+ # it is not possibly to type them while the pre��dit
+ # is non-empty and candidates are displayed.
+ # In that case we have to make it possible to
+ # type digits here where the pre��dit is still empty.
+ # If digits are not used to select candidates, they
+ # can be treated just like any other input keys.
if not self._editor.trans_m17n_mode:
# If a digit has been typed and no transliteration
# is used, we can pass it through
@@ -1052,10 +1067,11 @@ class tabengine (IBus.Engine):
# Commit or remove a candidate:
if self._editor.get_candidates():
index = -1
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9:
- index = key.val - IBus.KEY_1
- if key.val >= IBus.KEY_KP_1 and key.val <= IBus.KEY_KP_9:
- index = key.val - IBus.KEY_KP_1
+ if self._use_digits_as_select_keys:
+ if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9:
+ index = key.val - IBus.KEY_1
+ if key.val >= IBus.KEY_KP_1 and key.val <= IBus.KEY_KP_9:
+ index = key.val - IBus.KEY_KP_1
if key.val >= IBus.KEY_F1 and key.val <= IBus.KEY_F9:
index = key.val - IBus.KEY_F1
if index >= 0 and index < self._page_size:
@@ -1297,6 +1313,13 @@ class tabengine (IBus.Engine):
self._show_number_of_candidates = False
self.reset()
return
+ if name == "usedigitsasselectkeys":
+ if value == True:
+ self._use_digits_as_select_keys = True
+ else:
+ self._use_digits_as_select_keys = False
+ self.reset()
+ return
if name == "inputmethod":
if value in self._editor.get_supported_imes():
self._editor.set_current_ime(value)
diff --git a/ibus-typing-booster/setup/main.py b/ibus-typing-booster/setup/main.py
index 0d661b5..f659ef1 100644
--- a/ibus-typing-booster/setup/main.py
+++ b/ibus-typing-booster/setup/main.py
@@ -181,6 +181,17 @@ class SetupUI:
show_number_of_candidates_checkbox.set_active(True)
show_number_of_candidates_checkbox.connect(
'clicked', event_handler.onShowNumberOfCandidatesCheckbox)
+ use_digits_as_select_keys_checkbox = self.builder.get_object(
+ "use_digits_as_select_keys_checkbox")
+ self.use_digits_as_select_keys = self.variant_to_value(
+ self.config.get_value(
+ self.config_section, 'usedigitsasselectkeys'))
+ if self.use_digits_as_select_keys == None:
+ self.use_digits_as_select_keys = True
+ if self.use_digits_as_select_keys == True:
+ use_digits_as_select_keys_checkbox.set_active(True)
+ use_digits_as_select_keys_checkbox.connect(
+ 'clicked', event_handler.onUseDigitsAsSelectKeysCheckbox)
self.page_size_adjustment = self.builder.get_object(
"page_size_adjustment")
self.page_size = self.variant_to_value(self.config.get_value(
@@ -436,6 +447,20 @@ class EventHandler:
'shownumberofcandidates',
GLib.Variant.new_boolean(False))
+ def onUseDigitsAsSelectKeysCheckbox(self, widget):
+ if widget.get_active():
+ SetupUi.use_digits_as_select_keys = True
+ SetupUi.config.set_value(
+ SetupUi.config_section,
+ 'usedigitsasselectkeys',
+ GLib.Variant.new_boolean(True))
+ else:
+ SetupUi.use_digits_as_select_keys = False
+ SetupUi.config.set_value(
+ SetupUi.config_section,
+ 'usedigitsasselectkeys',
+ GLib.Variant.new_boolean(False))
+
def onPageSizeAdjustmentValueChanged(self, widget):
self.page_size = SetupUi.page_size_adjustment.get_value()
SetupUi.config.set_value(
diff --git a/ibus-typing-booster/setup/setup.glade b/ibus-typing-booster/setup/setup.glade
index 5533b57..9a584f2 100644
--- a/ibus-typing-booster/setup/setup.glade
+++ b/ibus-typing-booster/setup/setup.glade
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.19.0 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="min_char_complete_adjustment">
<property name="lower">1</property>
<property name="upper">9</property>
<property name="step_increment">1</property>
</object>
+ <object class="GtkAdjustment" id="page_size_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">9</property>
+ <property name="step_increment">1</property>
+ </object>
<object class="GtkDialog" id="main_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -68,7 +74,7 @@
<object class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">6</property>
+ <property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
@@ -97,8 +103,8 @@
<object class="GtkLabel" id="page_size_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Candidate window page size:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -123,8 +129,8 @@
</object>
<packing>
<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="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -133,12 +139,12 @@
<object class="GtkLabel" id="input_method_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Input Method:</property>
+ <property name="xalign">0</property>
</object>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -151,8 +157,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options"/>
</packing>
</child>
@@ -208,8 +214,8 @@
</object>
<packing>
<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="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -223,11 +229,29 @@
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="y_options"/>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="use_digits_as_select_keys_checkbox">
+ <property name="label" translatable="yes">Use digits as select keys</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.51999998092651367</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="right_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">GTK_FILL</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -336,20 +360,20 @@
<object class="GtkLabel" id="install_dictionary_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Install the dictionary package for this engine</property>
<property name="wrap">True</property>
<property name="width_chars">20</property>
+ <property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="install_pyhunspell_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Install pyhunspell package to get spellchecking suggestions</property>
<property name="wrap">True</property>
<property name="width_chars">20</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">1</property>
@@ -360,10 +384,10 @@
<object class="GtkLabel" id="learn_from_file_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Learn your style by reading a text file</property>
<property name="wrap">True</property>
<property name="width_chars">20</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">2</property>
@@ -374,10 +398,10 @@
<object class="GtkLabel" id="delete_learned_data_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Delete all personal language data learned from typing or from reading files</property>
<property name="wrap">True</property>
<property name="width_chars">20</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">3</property>
@@ -452,9 +476,4 @@
<action-widget response="0">close_button</action-widget>
</action-widgets>
</object>
- <object class="GtkAdjustment" id="page_size_adjustment">
- <property name="lower">1</property>
- <property name="upper">9</property>
- <property name="step_increment">1</property>
- </object>
</interface>
8 years, 5 months
[ibus-typing-booster] master: Add another test case to m17n_translit.py (3e46d58)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 3e46d587ce5922c2e287f69ff92aa6095ce13745
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 15:51:05 2015 +0100
Add another test case to m17n_translit.py
>---------------------------------------------------------------
ibus-typing-booster/engine/m17n_translit.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/ibus-typing-booster/engine/m17n_translit.py b/ibus-typing-booster/engine/m17n_translit.py
index f56855c..c1de137 100644
--- a/ibus-typing-booster/engine/m17n_translit.py
+++ b/ibus-typing-booster/engine/m17n_translit.py
@@ -198,6 +198,13 @@ class Transliterator:
>>> trans.transliterate(['4', 'G-4'])
'������'
+ AltGr-3 ('G-3') is not used though in Hindi-Inscript2.
+ Therefore, 'G-3' transliterates just as 'G-3':
+
+ >>> trans = Transliterator('hi-inscript2')
+ >>> trans.transliterate(['3', 'G-3'])
+ '���G-3'
+
>>> trans = Transliterator('t-latn-post')
>>> trans.transliterate(list('gru"n'))
'gr��n'
8 years, 5 months
[ibus-typing-booster] master: Don���t use MOD1 (left Alt key) to select a candidate to delete anymore (9e3c953)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 9e3c953efe975289e2ea9a9db4b5a7aa00833c10
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 13:29:35 2015 +0100
Don���t use MOD1 (left Alt key) to select a candidate to delete anymore
The left Alt key will be needed for input for some input methods.
For example, ta-lk-renganathan.mim has stuff like:
((A-4) "���")
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 2924ba4..a77321f 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -941,9 +941,7 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
if (key.val >= 32
- and (not (key.state & (
- IBus.ModifierType.MOD1_MASK
- | IBus.ModifierType.CONTROL_MASK)))):
+ and (not (key.state & IBus.ModifierType.CONTROL_MASK))):
typed_character = IBus.keyval_to_unicode(key.val)
# If the first character typed is a character which is
# very unlikely to be part of a word
@@ -1061,8 +1059,7 @@ class tabengine (IBus.Engine):
if key.val >= IBus.KEY_F1 and key.val <= IBus.KEY_F9:
index = key.val - IBus.KEY_F1
if index >= 0 and index < self._page_size:
- if (key.state & IBus.ModifierType.CONTROL_MASK
- or key.state & IBus.ModifierType.MOD1_MASK):
+ if (key.state & IBus.ModifierType.CONTROL_MASK):
# Remove the candidate from the user database
res = self._editor.remove_candidate_from_user_database(
index)
8 years, 5 months
[ibus-typing-booster] master: Remove some Python2 compatibility stuff (13a9adf)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 13a9adf39339ba2c17bcf5a629ec0d8f9b4585fc
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 12:38:14 2015 +0100
Remove some Python2 compatibility stuff
Python3 is required anyway, we don���t need this anymore
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_suggest.py | 2 --
ibus-typing-booster/engine/hunspell_table.py | 19 -------------------
ibus-typing-booster/engine/tabsqlitedb.py | 14 --------------
3 files changed, 0 insertions(+), 35 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_suggest.py b/ibus-typing-booster/engine/hunspell_suggest.py
index 46e14e5..ce66513 100755
--- a/ibus-typing-booster/engine/hunspell_suggest.py
+++ b/ibus-typing-booster/engine/hunspell_suggest.py
@@ -149,8 +149,6 @@ class Hunspell:
# to match words longer than that just wastes time.
if len(input_phrase) > 40:
return []
- if type(input_phrase) != type(u''):
- input_phrase = input_phrase.decode('utf8')
if debug_level > 1:
sys.stderr.write(
"Hunspell.suggest() input_phrase=%(ip)s\n"
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 6242b58..2924ba4 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -166,9 +166,6 @@ class editor(object):
if self.trans_m17n_mode:
self._transliterated_string = self.trans.transliterate(
self._typed_string)
- if type(self._transliterated_string) != type(u''):
- self._transliterated_string = (
- self._transliterated_string.decode('UTF-8'))
if self._current_ime in ['ko-romaja', 'ko-han2']:
self._transliterated_string = unicodedata.normalize(
'NFKD', self._transliterated_string)
@@ -282,9 +279,6 @@ class editor(object):
if self.trans_m17n_mode:
transliterated_string_up_to_cursor = self.trans.transliterate(
self._typed_string[:self._typed_string_cursor])
- if type(transliterated_string_up_to_cursor) != type(u''):
- transliterated_string_up_to_cursor = (
- transliterated_string_up_to_cursor.decode('UTF-8'))
else:
transliterated_string_up_to_cursor = (
u''.join(self._typed_string[:self._typed_string_cursor]))
@@ -781,8 +775,6 @@ class tabengine (IBus.Engine):
if pattern_sentence_end.search(commit_phrase):
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
- if type(text) != type(u''):
- text = text.decode('UTF-8')
cursor_pos = surrounding_text[1]
anchor_pos = surrounding_text[2]
# The commit_phrase is *not* yet in the surrounding text,
@@ -816,8 +808,6 @@ class tabengine (IBus.Engine):
return
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
- if type(text) != type(u''):
- text = text.decode('UTF-8')
cursor_pos = surrounding_text[1]
anchor_pos = surrounding_text[2]
if not surrounding_text:
@@ -922,8 +912,6 @@ class tabengine (IBus.Engine):
return False
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
- if type(text) != type(u''):
- text = text.decode('UTF-8')
cursor_pos = surrounding_text[1]
anchor_pos = surrounding_text[2]
if not surrounding_text:
@@ -957,8 +945,6 @@ class tabengine (IBus.Engine):
IBus.ModifierType.MOD1_MASK
| IBus.ModifierType.CONTROL_MASK)))):
typed_character = IBus.keyval_to_unicode(key.val)
- if type(typed_character) != type(u''):
- typed_character = typed_character.decode('UTF-8')
# If the first character typed is a character which is
# very unlikely to be part of a word
# (e.g. punctuation, a symbol, ..), we might want to
@@ -998,9 +984,6 @@ class tabengine (IBus.Engine):
# to transliterate and commit the result:
transliterated_digit = self._editor.trans.transliterate(
list(typed_character))
- if type(transliterated_digit) != type(u''):
- transliterated_digit = (
- transliterated_digit.decode('utf8'))
self.commit_string(
transliterated_digit, input_phrase=transliterated_digit)
return True
@@ -1201,8 +1184,6 @@ class tabengine (IBus.Engine):
# get the context if possible
self.get_context()
typed_character = IBus.keyval_to_unicode(key.val)
- if type(typed_character) != type(u''):
- typed_character = typed_character.decode('UTF-8')
self._editor.insert_string_at_cursor(list(typed_character))
if (typed_character
and unicodedata.category(typed_character)
diff --git a/ibus-typing-booster/engine/tabsqlitedb.py b/ibus-typing-booster/engine/tabsqlitedb.py
index fb60c64..89b9364 100755
--- a/ibus-typing-booster/engine/tabsqlitedb.py
+++ b/ibus-typing-booster/engine/tabsqlitedb.py
@@ -458,12 +458,6 @@ class tabsqlitedb:
form of (phrase, user_freq), i.e. returns something like
[(phrase, user_freq), ...]
'''
- if type(input_phrase) != type(u''):
- input_phrase = input_phrase.decode('utf8')
- if type(p_phrase) != type(u''):
- p_phrase = p_phrase.decode('utf8')
- if type(pp_phrase) != type(u''):
- pp_phrase = pp_phrase.decode('utf8')
input_phrase = unicodedata.normalize(
self._normalization_form_internal, input_phrase)
p_phrase = unicodedata.normalize(
@@ -726,14 +720,6 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
input_phrase = phrase
if not phrase:
return
- if type(phrase) != type(u''):
- phrase = phrase.decode('utf8')
- if type(p_phrase) != type(u''):
- p_phrase = p_phrase.decode('utf8')
- if type(pp_phrase) != type(u''):
- pp_phrase = pp_phrase.decode('utf8')
- if type(input_phrase) != type(u''):
- input_phrase = input_phrase.decode('utf8')
phrase = unicodedata.normalize(
self._normalization_form_internal, phrase)
p_phrase = unicodedata.normalize(
8 years, 5 months
[ibus-typing-booster] master: Remove member variables for page up/down keys, these keys are fix anyway (66d44a6)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 66d44a6ad356a13bd2fac0965e018e463d9873b9
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 11:14:10 2015 +0100
Remove member variables for page up/down keys, these keys are fix anyway
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 5f02b6f..a876265 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -604,9 +604,6 @@ class tabengine (IBus.Engine):
self._status = self.db.ime_properties.get(
'status_prompt').encode('utf8')
- self._page_down_keys = [IBus.KEY_Page_Down, IBus.KEY_KP_Page_Down]
- self._page_up_keys = [IBus.KEY_Page_Up, IBus.KEY_KP_Page_Up]
-
self._editor = editor(self._config, self.db)
self.is_lookup_table_enabled_by_tab = False
self._tab_enable = variant_to_value(self._config.get_value (
@@ -1041,12 +1038,14 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if key.val in self._page_down_keys and self._editor.get_candidates():
+ if (key.val in [IBus.KEY_Page_Down, IBus.KEY_KP_Page_Down]
+ and self._editor.get_candidates()):
res = self._editor.page_down()
self._update_ui ()
return res
- if key.val in self._page_up_keys and self._editor.get_candidates():
+ if (key.val in [IBus.KEY_Page_Up, IBus.KEY_KP_Page_Up]
+ and self._editor.get_candidates()):
res = self._editor.page_up ()
self._update_ui ()
return res
8 years, 5 months
[ibus-typing-booster] master: Improve code to select candidates to commit or to remove (ceb4383)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit ceb43832949d6951b887c0e1cf0becbcde8e49c5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Mon Dec 14 18:15:24 2015 +0100
Improve code to select candidates to commit or to remove
Until now only the keys 1-9 were used to select a candidate to commit
or to remove (There was a bug that for candidate lists which showed
fewer than 9 entries, the number keys higher than the number of
candidates shown selected a hidden candidate from the next page of
candidates, this commit fixes this bug as well).
Now the keys F1-F9 are also used to select a candidate to commit or
to remove as well. This is needed because the keys 1-9 are
used as valid input in some input methods.
And the KP_1-KP_9 (number keys on the keypad) are also used
to select a candidate to commit or to remove.
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 56 +++++++++++++------------
1 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index bba3d13..4e470f4 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -466,8 +466,9 @@ class editor(object):
return u''
return self._candidates[index][0]
- def alt_number (self, index):
- '''Remove the phrase selected with Alt+Number from the user database.
+ def remove_candidate_from_user_database (self, index):
+ '''Remove the candidate shown at index in the candidate list
+ from the user database.
The index parameter should start from 0.
@@ -487,7 +488,7 @@ class editor(object):
system phrase from the user database resets its user frequency
to 0 again.
- So the user can always type Alt+Number on a phrase he does not
+ So the user can always try to delete a phrase if he does not
want the phrase to be suggested wich such a high priority, no
matter whether it is a system phrase or a user defined phrase.
'''
@@ -1087,30 +1088,31 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if (key.val >= IBus.KEY_1
- and key.val <= IBus.KEY_9
- and self._editor.get_candidates()
- and key.state & IBus.ModifierType.CONTROL_MASK):
- res = self._editor.alt_number (key.val - IBus.KEY_1)
- self._update_ui ()
- return res
-
- if (key.val >= IBus.KEY_1
- and key.val <= IBus.KEY_9
- and self._editor.get_candidates()
- and key.state & IBus.ModifierType.MOD1_MASK):
- res = self._editor.alt_number (key.val - IBus.KEY_1)
- self._update_ui ()
- return res
-
- if (key.val >= IBus.KEY_1
- and key.val <= IBus.KEY_9
- and self._editor.get_candidates()):
- phrase = self._editor.get_string_from_lookup_table_current_page(
- key.val - IBus.KEY_1)
- if phrase:
- self.commit_string(phrase + u' ')
- return True
+ # Commit or remove a candidate:
+ if self._editor.get_candidates():
+ index = -1
+ if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9:
+ index = key.val - IBus.KEY_1
+ if key.val >= IBus.KEY_KP_1 and key.val <= IBus.KEY_KP_9:
+ index = key.val - IBus.KEY_KP_1
+ if key.val >= IBus.KEY_F1 and key.val <= IBus.KEY_F9:
+ index = key.val - IBus.KEY_F1
+ if index >= 0 and index < self._page_size:
+ if (key.state & IBus.ModifierType.CONTROL_MASK
+ or key.state & IBus.ModifierType.MOD1_MASK):
+ # Remove the candidate from the user database
+ res = self._editor.remove_candidate_from_user_database(
+ index)
+ self._update_ui()
+ return res
+ else:
+ # Commit a candidate:
+ phrase = (
+ self._editor.get_string_from_lookup_table_current_page(
+ index))
+ if phrase:
+ self.commit_string(phrase + u' ')
+ return True
if key.val == IBus.KEY_Tab:
if self._tab_enable:
8 years, 5 months
[ibus-typing-booster] master: Expand the KeyEvent class a bit to make it easier to convert keys to Msymbols (e0934dc)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit e0934dca752b9b6a6bb63de3a8a215b86f95ae14
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 17:36:01 2015 +0100
Expand the KeyEvent class a bit to make it easier to convert keys to Msymbols
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 63 +++++++++++++-------------
1 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index ca727ec..5f3b66a 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -73,9 +73,34 @@ class KeyEvent:
self.val = keyval
self.code = keycode
self.state = state
+ self.name = IBus.keyval_name(self.val)
+ self.unicode = IBus.keyval_to_unicode(self.val)
+ self.msymbol = self.unicode
+ self.control = 0 != self.state & IBus.ModifierType.CONTROL_MASK
+ self.mod1 = 0 != self.state & IBus.ModifierType.MOD1_MASK
+ self.mod5 = 0 != self.state & IBus.ModifierType.MOD5_MASK
+ self.release = 0 != self.state & IBus.ModifierType.RELEASE_MASK
+ if itb_util.is_ascii(self.msymbol):
+ if self.control:
+ self.msymbol = 'C-' + self.msymbol
+ if self.mod1:
+ self.msymbol = 'A-' + self.msymbol
+ if self.mod5:
+ self.msymbol = 'G-' + self.msymbol
def __str__(self):
- return "%s 0x%08x" % (IBus.keyval_name(self.val), self.state)
-
+ return (
+ "val=%s code=%s state=0x%08x name='%s' unicode='%s' msymbol='%s' "
+ % (self.val,
+ self.code,
+ self.state,
+ self.name,
+ self.unicode,
+ self.msymbol)
+ + "control=%s mod1=%s mod5=%s release=%s\n"
+ % (self.control,
+ self.mod1,
+ self.mod5,
+ self.release))
class editor(object):
'''Hold user inputs chars and preedit string'''
@@ -846,30 +871,11 @@ class tabengine (IBus.Engine):
and self._input_purpose
in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]):
return False
- if debug_level > 1:
- sys.stderr.write(
- "do_process_key_event(keyval=%(kv)s, "
- %{'kv': keyval}
- + "keycode=%(kc)s, state=%(st)s)\n"
- %{'kc': keycode, 'st': state})
key = KeyEvent(keyval, keycode, state)
if debug_level > 1:
sys.stderr.write(
- "process_key_event() after KeyEvent() "
- + "key.code=%(key.code)s "
- %{'key.code': key.code}
- + "IBus.keyval_to_unicode(%(key.val)s)='%(uc)s'\n"
- %{'key.val': key.val,
- 'uc': IBus.keyval_to_unicode(key.val)})
- sys.stderr.write(
- "CONTROL_MASK=%(bit)s\n"
- %{'bit': key.state & IBus.ModifierType.CONTROL_MASK})
- sys.stderr.write(
- "MOD1_MASK=%(bit)s\n"
- %{'bit': key.state & IBus.ModifierType.MOD1_MASK})
- sys.stderr.write(
- "MOD5_MASK=%(bit)s\n"
- %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
+ "process_key_event() "
+ "KeyEvent object: %s" % key)
result = self._process_key_event (key)
return result
@@ -890,15 +896,8 @@ class tabengine (IBus.Engine):
if self._editor.is_empty ():
if debug_level > 1:
sys.stderr.write(
- "_process_key_event() self._editor.is_empty ():\n")
- sys.stderr.write(
- "key.val=%(key.val)s "
- %{'key.val': key.val}
- + "IBus.keyval_to_unicode(key.val)='%(keychar)s'\n"
- %{'keychar': IBus.keyval_to_unicode(key.val)})
- sys.stderr.write(
- "IBus.keyval_name(key.val)=%s\n"
- %IBus.keyval_name(key.val))
+ "_process_key_event() self._editor.is_empty(): "
+ "KeyEvent object: %s\n" % key)
# This is the first character typed since the last commit
# there is nothing in the pre��dit yet.
if key.val < 32:
8 years, 5 months
[ibus-typing-booster] master: Add some comments (7ad1d56)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 7ad1d56a46f9b85eaa4345db70cf0c506604a8b0
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Mon Dec 14 17:25:59 2015 +0100
Add some comments
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index d1003d4..121b944 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -1139,6 +1139,7 @@ class tabengine (IBus.Engine):
return True
return True
+ # These keys may trigger a commit:
if key.val in (IBus.KEY_Return, IBus.KEY_KP_Enter, IBus.KEY_space,
IBus.KEY_Right, IBus.KEY_KP_Right,
IBus.KEY_Left, IBus.KEY_KP_Left):
@@ -1229,6 +1230,14 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
+ # What kind of key was this??
+ #
+ # keychar = IBus.keyval_to_unicode(key.val)
+ #
+ # returned no result. And apparently it was not handled as
+ # a select key or other special key either.
+ # So whatever this was, we cannot handle it,
+ # just pass it through to the application by returning ���False���.
return False
def do_focus_in (self):
8 years, 5 months