[ibus-typing-booster] release-1.3.0: Improve code to handle the left and right arrow keys (26c36bf)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : release-1.3.0
>---------------------------------------------------------------
commit 26c36bf4438c6b29b66a84a3743ef23dc90fa069
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 11:27:02 2015 +0100
Improve code to handle the left and right arrow keys
Control-arrow-left and control-arrow-right should also commit when the
end of the pre��dit string is reached, otherwise this is inconsistent
with the behaviour of arrow-left and arrow-right, I think.
I.e. now the first Control-arrow-left moves the cursor to the left of the
pre��dit, another Control-arrow-left commits and sends a Control-arrow-left
to the application.
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 74 ++++++++++---------------
1 files changed, 30 insertions(+), 44 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index a876265..6242b58 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -295,18 +295,6 @@ class editor(object):
'NFC', transliterated_string_up_to_cursor)
return len(transliterated_string_up_to_cursor)
- def control_arrow_left (self):
- '''
- Move cursor to the beginning of the typed string
- '''
- self._typed_string_cursor = 0
-
- def control_arrow_right (self):
- '''
- Move cursor to the end of the typed string
- '''
- self._typed_string_cursor = len(self._typed_string)
-
def append_candidate_to_lookup_table(self, phrase=u'', user_freq=0):
'''append candidate to lookup_table'''
if not phrase:
@@ -1050,22 +1038,6 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if (key.val in (IBus.KEY_Left, IBus.KEY_KP_Left)
- and key.state & IBus.ModifierType.CONTROL_MASK):
- if self._editor.is_empty():
- return False
- self._editor.control_arrow_left()
- self._update_ui()
- return True
-
- if (key.val in (IBus.KEY_Right, IBus.KEY_KP_Right)
- and key.state & IBus.ModifierType.CONTROL_MASK):
- if self._editor.is_empty():
- return False
- self._editor.control_arrow_right()
- self._update_ui()
- return True
-
if (key.val == IBus.KEY_BackSpace
and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
@@ -1155,17 +1127,26 @@ class tabengine (IBus.Engine):
IBus.KEY_Left, IBus.KEY_KP_Left):
if self._editor.is_empty():
return False
- if key.val in (IBus.KEY_Right, IBus.KEY_KP_Right):
- if (self._editor._typed_string_cursor
- < len(self._editor._typed_string)):
+ if (key.val in (IBus.KEY_Right, IBus.KEY_KP_Right)
+ and (self._editor._typed_string_cursor
+ < len(self._editor._typed_string))):
+ if key.state & IBus.ModifierType.CONTROL_MASK:
+ # Move cursor to the end of the typed string
+ self._editor._typed_string_cursor = len(
+ self._editor._typed_string)
+ else:
self._editor._typed_string_cursor += 1
- self._update_ui()
- return True
- if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left):
- if self._editor._typed_string_cursor > 0:
+ self._update_ui()
+ return True
+ if (key.val in (IBus.KEY_Left, IBus.KEY_KP_Left)
+ and self._editor._typed_string_cursor > 0):
+ if key.state & IBus.ModifierType.CONTROL_MASK:
+ # Move cursor to the beginning of the typed string
+ self._editor._typed_string_cursor = 0
+ else:
self._editor._typed_string_cursor -= 1
- self._update_ui()
- return True
+ self._update_ui()
+ return True
input_phrase = self._editor.get_transliterated_string()
if not input_phrase:
return False
@@ -1187,14 +1168,19 @@ class tabengine (IBus.Engine):
if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left):
# After committing, the cursor is at the right side of
# the committed string. When the string has been
- # committed because of arrow-left, the cursor has
- # to be moved to the left side of the string. This
- # should be done in a way which works even when
- # surrounding text is not supported. We can do it by
- # forwarding as many arrow-left events to the application
- # as the committed string has characters:
+ # committed because of arrow-left or
+ # control-arrow-left, the cursor has to be moved to
+ # the left side of the string. This should be done in
+ # a way which works even when surrounding text is not
+ # supported. We can do it by forwarding as many
+ # arrow-left events to the application as the
+ # committed string has characters. Because it might
+ # have been control-arrow-left, we need to clear the
+ # CONTROL_MASK:
for c in commit_string:
- self.forward_key_event(key.val, key.code, key.state)
+ self.forward_key_event(
+ key.val, key.code,
+ key.state & ~IBus.ModifierType.CONTROL_MASK)
# Forward the key event which triggered the commit here
# and return True instead of trying to pass that key event
# to the application by returning False. Doing it by
8 years, 5 months
[ibus-typing-booster] release-1.3.0: Use Msymbols instead of just characters when transliterating and storing the typed input (e7c0aed)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : release-1.3.0
>---------------------------------------------------------------
commit e7c0aed01e92fc219ddea0314e1348f85dfb499b
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 18:24:51 2015 +0100
Use Msymbols instead of just characters when transliterating and storing the typed input
Resolves: rhbz#772665 - [RFE] Need support for AltGr mappings
See: https://bugzilla.redhat.com/show_bug.cgi?id=772665
Resolves: rhbz#1051405 - inscript2 layouts are not supported in ibus-typing-booster
See: https://bugzilla.redhat.com/show_bug.cgi?id=1051405
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 62 +++++++++++++------------
1 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 5f3b66a..169e37b 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -946,15 +946,13 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(list(token))
self._update_ui()
return True
- if (key.val >= 32
- and (not (key.state & IBus.ModifierType.CONTROL_MASK))):
- typed_character = IBus.keyval_to_unicode(key.val)
+ if key.val >= 32 and not key.control:
# 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
# avoid completion and commit something immediately:
- if (typed_character
- and unicodedata.category(typed_character)
+ if (len(key.msymbol) == 1
+ and unicodedata.category(key.msymbol)
in itb_util.categories_to_trigger_immediate_commit):
if not self._editor.trans_m17n_mode:
# Do not just pass the character through,
@@ -963,7 +961,7 @@ class tabengine (IBus.Engine):
# between the ���.��� and the previous word and this is
# done in commit_string().
self.commit_string(
- typed_character, input_phrase = typed_character)
+ key.msymbol, input_phrase = key.msymbol)
return True
# If transliteration is used, we may need to
# handle a punctuation or symbol character. For
@@ -972,11 +970,11 @@ class tabengine (IBus.Engine):
# therefore we cannot just pass it through. Just
# add it to the input so far and see what comes
# next:
- self._editor.insert_string_at_cursor(list(typed_character))
+ self._editor.insert_string_at_cursor([key.msymbol])
self._update_ui()
return True
if (self._use_digits_as_select_keys
- and typed_character
+ and key.msymbol
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
@@ -995,7 +993,7 @@ class tabengine (IBus.Engine):
# want ���3��� to be converted to ���������. So we try
# to transliterate and commit the result:
transliterated_digit = self._editor.trans.transliterate(
- list(typed_character))
+ [key.msymbol])
self.commit_string(
transliterated_digit, input_phrase=transliterated_digit)
return True
@@ -1033,8 +1031,7 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if (key.val == IBus.KEY_BackSpace
- and key.state & IBus.ModifierType.CONTROL_MASK):
+ if key.val == IBus.KEY_BackSpace and key.control:
if self._editor.is_empty():
return False
self._editor.remove_string_before_cursor()
@@ -1048,8 +1045,7 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if (key.val == IBus.KEY_Delete
- and key.state & IBus.ModifierType.CONTROL_MASK):
+ if key.val == IBus.KEY_Delete and key.control:
if self._editor.is_empty():
return False
self._editor.remove_string_after_cursor()
@@ -1063,8 +1059,16 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- # Commit or remove a candidate:
- if self._editor.get_candidates():
+ # Select a candidate to commit or remove:
+ if self._editor.get_candidates() and not key.mod1 and not key.mod5:
+ # key.mod1 (= Alt) and key.mod5 (= AltGr) should not be set
+ # here because:
+ #
+ # - in case of the digits these are used for input, not to select
+ # (e.g. mr-inscript2 transliterates AltGr-4 to ���������)
+ #
+ # - in case of the F1-F9 keys I want to reserve the Alt and AltGr
+ # modifiers for possible future extensions.
index = -1
if self._use_digits_as_select_keys:
if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9:
@@ -1074,7 +1078,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):
+ if key.control:
# Remove the candidate from the user database
res = self._editor.remove_candidate_from_user_database(
index)
@@ -1125,7 +1129,7 @@ class tabengine (IBus.Engine):
if (key.val in (IBus.KEY_Right, IBus.KEY_KP_Right)
and (self._editor._typed_string_cursor
< len(self._editor._typed_string))):
- if key.state & IBus.ModifierType.CONTROL_MASK:
+ if key.control:
# Move cursor to the end of the typed string
self._editor._typed_string_cursor = len(
self._editor._typed_string)
@@ -1135,7 +1139,7 @@ class tabengine (IBus.Engine):
return True
if (key.val in (IBus.KEY_Left, IBus.KEY_KP_Left)
and self._editor._typed_string_cursor > 0):
- if key.state & IBus.ModifierType.CONTROL_MASK:
+ if key.control:
# Move cursor to the beginning of the typed string
self._editor._typed_string_cursor = 0
else:
@@ -1190,19 +1194,18 @@ class tabengine (IBus.Engine):
self.forward_key_event(key.val, key.code, key.state)
return True
- if IBus.keyval_to_unicode(key.val):
+ if key.unicode:
if self._editor.is_empty():
# first key typed, we will try to complete something now
# get the context if possible
self.get_context()
- typed_character = IBus.keyval_to_unicode(key.val)
- self._editor.insert_string_at_cursor(list(typed_character))
- if (typed_character
- and unicodedata.category(typed_character)
+ self._editor.insert_string_at_cursor([key.msymbol])
+ if (len(key.msymbol) == 1
+ and unicodedata.category(key.msymbol)
in itb_util.categories_to_trigger_immediate_commit):
input_phrase = self._editor.get_transliterated_string()
if (input_phrase
- and input_phrase[-1] == typed_character
+ and input_phrase[-1] == key.msymbol
and not self._editor.trans_m17n_mode):
self.commit_string(
input_phrase + u' ', input_phrase = input_phrase)
@@ -1211,12 +1214,11 @@ class tabengine (IBus.Engine):
# 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���.
+ # The unicode character for this key is apparently the empty
+ # string. 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
[ibus-typing-booster] release-1.3.0: Add an is_ascii() utility function (a2f95b5)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : release-1.3.0
>---------------------------------------------------------------
commit a2f95b5e55ad1e4c060af9e2e3e25999a86e1bbe
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Tue Dec 15 16:32:40 2015 +0100
Add an is_ascii() utility function
>---------------------------------------------------------------
ibus-typing-booster/engine/itb_util.py | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/ibus-typing-booster/engine/itb_util.py b/ibus-typing-booster/engine/itb_util.py
index b901db1..9cbc76b 100755
--- a/ibus-typing-booster/engine/itb_util.py
+++ b/ibus-typing-booster/engine/itb_util.py
@@ -3,7 +3,7 @@
#
# ibus-typing-booster - The Tables engine for IBus
#
-# Copyright (c) 2013 Mike FABIAN <mfabian(a)redhat.com>
+# Copyright (c) 2013-2015 Mike FABIAN <mfabian(a)redhat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -65,3 +65,30 @@ def tokenize(text):
tokens.append(strip_token(s))
return tokens
+def is_ascii(text):
+ '''Checks whether all characters in text are ASCII characters
+
+ Returns ���True��� if the text is all ASCII, ���False��� if not.
+
+ :param text: The text to check
+ :type text: string
+ :rtype: bool
+
+ Examples:
+
+ >>> is_ascii('Abc')
+ True
+
+ >>> is_ascii('Na��ve')
+ False
+ '''
+ try:
+ text.encode('ascii')
+ except UnicodeEncodeError:
+ return False
+ else:
+ return True
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
8 years, 5 months
[ibus-typing-booster] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: Remove some Python2 compatibility stuff (13a9adf)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : release-1.3.0
>---------------------------------------------------------------
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] release-1.3.0: 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 : release-1.3.0
>---------------------------------------------------------------
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