Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit c838647f09f4ccbb56dd9d2fca7b5f57486dcdb5
Author: Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>
Date: Thu Oct 1 21:40:16 2015 +0200
add Catalan translations
>---------------------------------------------------------------
ibus-typing-booster/po/LINGUAS | 1 +
.../po/{ibus-typing-booster.pot => ca.po} | 86 +++++++++----------
2 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/ibus-typing-booster/po/LINGUAS b/ibus-typing-booster/po/LINGUAS
index 0eddece..eb56aab 100644
--- a/ibus-typing-booster/po/LINGUAS
+++ b/ibus-typing-booster/po/LINGUAS
@@ -1,3 +1,4 @@
# please keep this list sorted alphabetically
#
+ca
de
diff --git a/ibus-typing-booster/po/ibus-typing-booster.pot b/ibus-typing-booster/po/ca.po
similarity index 54%
copy from ibus-typing-booster/po/ibus-typing-booster.pot
copy to ibus-typing-booster/po/ca.po
index eebb06e..f689f05 100644
--- a/ibus-typing-booster/po/ibus-typing-booster.pot
+++ b/ibus-typing-booster/po/ca.po
@@ -1,153 +1,149 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR Anish Patil <anish.developer(a)gmail.com>
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
+# Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>, 2015. #zanata
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2015-09-24 13:49+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL(a)li.org>\n"
-"Language: \n"
+"POT-Creation-Date: 2013-12-20 11:18+0530\n"
+"PO-Revision-Date: 2015-09-30 09:03-0400\n"
+"Last-Translator: Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>\n"
+"Language-Team: Catalan\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-
-#: engine/hunspell_table.py:550
-msgid "Setup"
-msgstr ""
-
-#: engine/hunspell_table.py:552
-#, python-format
-msgid "Configure ibus-typing-booster “%(name)s”"
-msgstr ""
+"Language: ca\n"
+"X-Generator: Zanata 3.7.2\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#: setup/main.py:89
#, python-format
msgid "Unknown format of engine name: IBUS_ENGINE_NAME=%(name)s"
-msgstr ""
+msgstr "Format desconegut del nom del motor: IBUS_ENGINE_NAME=%(name)s"
#: setup/main.py:94
msgid "IBUS_ENGINE_NAME environment variable is not set."
-msgstr ""
+msgstr "La variable d'entorn IBUS_ENGINE_NAME no està establerta."
#: setup/main.py:98
msgid ""
"Cannot determine the config file for this engine. Please use the --config-"
"file option."
msgstr ""
+"No es pot determinar cap fitxer de configuració per a aquest motor. Si us "
+"plau, utilitzeu l'opció --config-file."
#: setup/main.py:105
#, python-format
msgid "Config file %(file)s does not exist."
-msgstr ""
+msgstr "El fitxer de configuració %(file)s no existeix."
#: setup/main.py:117
msgid "ibus is not running."
-msgstr ""
+msgstr "ibus no s'està executant."
#: setup/main.py:123
#, python-format
msgid "Preferences for ibus-typing-booster \"%(symbol)s\""
-msgstr ""
+msgstr "Preferències per a l'ibus-typing-booster \"%(symbol)s\""
#: setup/main.py:211
msgid "Another instance of this app is already running."
-msgstr ""
+msgstr "Ja s'està executant una altra instància d'aquesta aplicació."
#: setup/main.py:295
msgid "Open File ..."
-msgstr ""
+msgstr "Obre el fitxer..."
#: setup/main.py:312
#, python-format
msgid "Learned successfully from file %(filename)s."
-msgstr ""
+msgstr "S'ha après correctament del fitxer %(filename)s."
#: setup/main.py:319
#, python-format
msgid "Learning from file %(filename)s failed."
-msgstr ""
+msgstr "Ha fallat l'aprenentatge del fitxer %(filename)s."
#: setup/main.py:327
msgid "Are you sure?"
-msgstr ""
+msgstr "Esteu segur?"
#: setup/main.py:334
msgid ""
"Do you really want to delete all language \n"
"data learned from typing or reading files?"
msgstr ""
+"Realment voleu eliminar totes les dades de l'idioma \n"
+"que s'han après de l'escriptura o la lectura de fitxers? "
#: setup/setup.glade:29
msgid "Close"
-msgstr ""
+msgstr "Tanca"
#: setup/setup.glade:77
msgid "Enable suggestions by Tab key"
-msgstr ""
+msgstr "Habilita els suggeriments amb la tecla Tab"
#: setup/setup.glade:101
msgid "Candidate window page size:"
-msgstr ""
+msgstr "Mida de la pàgina de la finestra dels candidats:"
#: setup/setup.glade:137
msgid "Input Method:"
-msgstr ""
+msgstr "Mètode d'entrada:"
#: setup/setup.glade:161
msgid "Display total number of candidates"
-msgstr ""
+msgstr "Mostra el nombre total de candidats"
#: setup/setup.glade:186
msgid "Minimum number of chars for completion:"
-msgstr ""
+msgstr "Nombre màxim de caràcter per a la conclusió:"
#: setup/setup.glade:219
msgid "Input Method Help"
-msgstr ""
+msgstr "Ajuda del mètode d'entrada"
#: setup/setup.glade:258
msgid "Options"
-msgstr ""
+msgstr "Opcions"
#: setup/setup.glade:291
msgid "Install dictionary"
-msgstr ""
+msgstr "Instal·la el diccionari"
#: setup/setup.glade:305
msgid "Install pyhunspell"
-msgstr ""
+msgstr "Instal·la pyhunspell"
#: setup/setup.glade:321
msgid "Learn from text file"
-msgstr ""
+msgstr "Aprèn del fitxer de text"
#: setup/setup.glade:340
msgid "Install the dictionary package for this engine"
-msgstr ""
+msgstr "Instal·la el paquet del diccionari per a aquest motor"
#: setup/setup.glade:350
msgid "Install pyhunspell package to get spellchecking suggestions"
msgstr ""
+"Instal·la el paquet pyhunspell per obtenir els suggeriments de la revisió "
+"ortogràfica"
#: setup/setup.glade:364
msgid "Learn your style by reading a text file"
-msgstr ""
+msgstr "Aprèn el vostre estil amb la lectura d'un fitxer de text"
#: setup/setup.glade:378
msgid ""
"Delete all personal language data learned from typing or from reading files"
msgstr ""
+"Elimina totes les dades de l'idioma personal que s'han après de l'escriptura "
+"o de la lectura de fitxers"
#: setup/setup.glade:389
msgid "Delete learned data"
-msgstr ""
+msgstr "Elimina les dades que s'han après"
#: setup/setup.glade:426
msgid "Dictionaries and personal data"
-msgstr ""
+msgstr "Diccionaris i dades personals"
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit af84cf6a972356d928c730885155c847db87cb13
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Sat Oct 10 20:53:22 2015 +0200
Fix more pylint warnings
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^af84cf6a972356d928c730885155c847db87cb13~1 af84cf6a972356d928c730885155c847db87cb13
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 0c2cfd7c3ebd551cf86fe5c30502af99abaa1fb5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Sep 24 14:11:06 2015 +0200
Fix pylint warnings
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 265 +++++++++++++++++---------
1 files changed, 178 insertions(+), 87 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 598f3a8..1970d89 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -25,7 +25,6 @@ import os
import sys
import string
import unicodedata
-import curses.ascii
import re
from gi.repository import IBus
from gi.repository import GLib
@@ -67,7 +66,10 @@ def variant_to_value(variant):
return variant
def argb(a, r, g, b):
- return ((a & 0xff)<<24) + ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff)
+ return (((a & 0xff)<<24)
+ + ((r & 0xff) << 16)
+ + ((g & 0xff) << 8)
+ + (b & 0xff))
def rgb(r, g, b):
return argb(255, r, g, b)
@@ -129,7 +131,8 @@ class editor(object):
self._current_ime = variant_to_value(self._config.get_value(
self._config_section,
'inputmethod'))
- if self._current_ime == None or not self._current_ime in self._supported_imes:
+ if (self._current_ime == None
+ or not self._current_ime in self._supported_imes):
# There is no ime set in dconf or an unsupported ime, fall
# back to the first of the supported imes:
self._current_ime = self._supported_imes[0]
@@ -140,7 +143,6 @@ class editor(object):
# using m17n transliteration
self.trans_m17n_mode = True
try:
- #self.trans = Translit.Transliterator.get(self._m17ndb, self._current_ime)
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -164,7 +166,8 @@ class editor(object):
self._transliterated_string = self.trans.transliterate(
self._typed_string)[0]
if type(self._transliterated_string) != type(u''):
- self._transliterated_string = self._transliterated_string.decode('UTF-8')
+ 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)
@@ -201,8 +204,9 @@ class editor(object):
def remove_character_before_cursor(self):
'''Remove typed character before cursor'''
if self._typed_string_cursor > 0:
- self._typed_string = self._typed_string[:self._typed_string_cursor-1] \
- +self._typed_string[self._typed_string_cursor:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor-1]
+ +self._typed_string[self._typed_string_cursor:])
self._typed_string_cursor -= 1
self.update_transliterated_string()
self.update_candidates()
@@ -210,8 +214,9 @@ class editor(object):
def remove_character_after_cursor(self):
'''Remove typed character after cursor'''
if self._typed_string_cursor < len(self._typed_string):
- self._typed_string = self._typed_string[:self._typed_string_cursor] \
- +self._typed_string[self._typed_string_cursor+1:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor]
+ +self._typed_string[self._typed_string_cursor+1:])
self.update_transliterated_string()
self.update_candidates()
@@ -260,9 +265,11 @@ class editor(object):
transliterated_string_up_to_cursor = self.trans.transliterate(
self._typed_string[:self._typed_string_cursor])[0]
if type(transliterated_string_up_to_cursor) != type(u''):
- transliterated_string_up_to_cursor = transliterated_string_up_to_cursor.decode('UTF-8')
+ transliterated_string_up_to_cursor = (
+ transliterated_string_up_to_cursor.decode('UTF-8'))
else:
- transliterated_string_up_to_cursor = self._typed_string[:self._typed_string_cursor]
+ transliterated_string_up_to_cursor = (
+ self._typed_string[:self._typed_string_cursor])
if self._current_ime in ['ko-romaja', 'ko-han2']:
transliterated_string_up_to_cursor = unicodedata.normalize(
'NFKD', transliterated_string_up_to_cursor)
@@ -287,7 +294,8 @@ class editor(object):
if not phrase:
return
phrase = unicodedata.normalize('NFC', phrase)
- transliterated_string = unicodedata.normalize('NFC', self._transliterated_string)
+ transliterated_string = unicodedata.normalize(
+ 'NFC', self._transliterated_string)
attrs = IBus.AttrList ()
if not phrase.startswith(transliterated_string):
# this is a candidate which does not start exactly
@@ -295,17 +303,23 @@ class editor(object):
# for a spelling correction:
if debug_level > 0:
phrase = phrase + u' ✓'
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x00,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x00, 0x00), 0, len(phrase)))
elif user_freq > 10:
# this is a frequently used phrase:
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x7f,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x7f, 0x00), 0, len(phrase)))
else:
- # this is a system phrase that has been used less then 10 times or maybe never:
- attrs.append(IBus.attr_foreground_new(rgb(0x00,0x00,0x00), 0, len(phrase)))
+ # this is a system phrase that has been used less
+ # then 10 times or maybe never:
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x00, 0x00, 0x00), 0, len(phrase)))
if debug_level > 0:
phrase += u' ' + str(user_freq)
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00), len(phrase) - len(str(user_freq)), len(phrase)))
+ rgb(0x00, 0xff, 0x00),
+ len(phrase) - len(str(user_freq)),
+ len(phrase)))
text = IBus.Text.new_from_string(phrase)
i = 0
while attrs.get(i) != None:
@@ -320,32 +334,42 @@ class editor(object):
def update_candidates (self):
'''Update lookuptable'''
- if self._typed_string == self._typed_string_when_update_candidates_was_last_called:
- # The input did not change since we came here last, do nothing and leave
- # candidates and lookup table unchanged:
+ if (self._typed_string
+ == self._typed_string_when_update_candidates_was_last_called):
+ # The input did not change since we came here last, do
+ # nothing and leave candidates and lookup table unchanged:
return True
- self._typed_string_when_update_candidates_was_last_called = self._typed_string[:]
+ self._typed_string_when_update_candidates_was_last_called = (
+ self._typed_string[:])
self._lookup_table.clear()
self._lookup_table.set_cursor_visible(False)
self._candidates = []
prefix_length = 0
prefix = u''
if self._transliterated_string:
- stripped_transliterated_string = itb_util.lstrip_token(self._transliterated_string)
+ stripped_transliterated_string = (
+ itb_util.lstrip_token(self._transliterated_string))
if len(stripped_transliterated_string) >= self._min_char_complete:
- prefix_length = len(self._transliterated_string) - len(stripped_transliterated_string)
+ prefix_length = (
+ len(self._transliterated_string)
+ - len(stripped_transliterated_string))
if prefix_length:
prefix = self._transliterated_string[0:prefix_length]
try:
- self._candidates = self.db.select_words(stripped_transliterated_string, p_phrase=self._p_phrase, pp_phrase=self._pp_phrase)
+ self._candidates = self.db.select_words(
+ stripped_transliterated_string,
+ p_phrase=self._p_phrase,
+ pp_phrase=self._pp_phrase)
except:
import traceback
traceback.print_exc()
if self._candidates:
if prefix:
- self._candidates = [(prefix+x[0], x[1]) for x in self._candidates]
+ self._candidates = (
+ [(prefix+x[0], x[1]) for x in self._candidates])
for x in self._candidates:
- self.append_candidate_to_lookup_table(phrase=x[0], user_freq=x[1])
+ self.append_candidate_to_lookup_table(
+ phrase=x[0], user_freq=x[1])
return True
def arrow_down(self):
@@ -421,7 +445,7 @@ class editor(object):
return u''
return self._candidates[index][0]
- def alt_number (self,index):
+ def alt_number (self, index):
'''Remove the phrase selected with Alt+Number from the user database.
The index parameter should start from 0.
@@ -453,7 +477,8 @@ class editor(object):
if len (self._candidates) > real_index:
# this index is valid
can = self._candidates[real_index]
- self.db.remove_phrase(phrase=can[0], database='user_db', commit=True)
+ self.db.remove_phrase(
+ phrase=can[0], database='user_db', commit=True)
# call update_candidates() to get a new SQL query. The
# input has not really changed, therefore we must clear
# the remembered list of transliterated characters to
@@ -473,6 +498,10 @@ class editor(object):
'''Get lookup table'''
return self._lookup_table
+ def get_candidates(self):
+ '''Get list of candidates'''
+ return self._candidates
+
def push_context(self, phrase):
self._pp_phrase = self._p_phrase
self._p_phrase = phrase
@@ -488,11 +517,12 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
- super(tabengine,self).__init__ (connection=bus.get_connection(),object_path=obj_path)
+ super(tabengine, self).__init__(
+ connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
- except:
+ except (TypeError, ValueError):
debug_level = int(0)
self._input_purpose = 0
self._has_input_purpose = False
@@ -516,16 +546,19 @@ class tabengine (IBus.Engine):
if tabengine._page_size > 9:
tabengine._page_size = 9 # maximum page size supported
- self._show_number_of_candidates = variant_to_value(self._config.get_value(
+ self._show_number_of_candidates = variant_to_value(
+ self._config.get_value(
self._config_section,
'shownumberofcandidates'))
if self._show_number_of_candidates == None:
self._show_number_of_candidates = False
- self._icon_dir = '%s%s%s%s' % (os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
- os.path.sep, 'icons', os.path.sep)
+ self._icon_dir = '%s%s%s%s' % (
+ os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
+ os.path.sep, 'icons', os.path.sep)
- self._status = self.db.ime_properties.get('status_prompt').encode('utf8')
+ 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]
@@ -539,6 +572,8 @@ class tabengine (IBus.Engine):
self._tab_enable = False
self._commit_happened_after_focus_in = False
+ self.properties = []
+ self._setup_property = None
self._init_properties()
self.reset ()
@@ -556,11 +591,12 @@ class tabengine (IBus.Engine):
self.properties.append(self._setup_property)
self.register_properties(self.properties)
- def do_property_activate(self, property, prop_state = IBus.PropState.UNCHECKED):
+ def do_property_activate(
+ self, ibus_property, prop_state = IBus.PropState.UNCHECKED):
'''
Handle clicks on properties
'''
- if property == "setup":
+ if ibus_property == "setup":
self._start_setup()
return
@@ -591,7 +627,7 @@ class tabengine (IBus.Engine):
def do_destroy(self):
self.reset ()
self.do_focus_out ()
- super(tabengine,self).destroy()
+ super(tabengine, self).destroy()
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
@@ -602,13 +638,17 @@ class tabengine (IBus.Engine):
def _update_preedit (self):
'''Update Preedit String in UI'''
# editor.get_caret() should also use NFC!
- _str = unicodedata.normalize('NFC', self._editor.get_transliterated_string())
+ _str = unicodedata.normalize(
+ 'NFC', self._editor.get_transliterated_string())
if _str == u'':
- super(tabengine, self).update_preedit_text(IBus.Text.new_from_string(u''), 0, False)
+ super(tabengine, self).update_preedit_text(
+ IBus.Text.new_from_string(u''), 0, False)
else:
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x0e,0x0e,0xa0), 0, len(_str)))
- attrs.append(IBus.attr_underline_new(IBus.AttrUnderline.SINGLE, 0, len(_str)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x0e, 0x0e, 0xa0), 0, len(_str)))
+ attrs.append(IBus.attr_underline_new(
+ IBus.AttrUnderline.SINGLE, 0, len(_str)))
text = IBus.Text.new_from_string(_str)
i = 0
while attrs.get(i) != None:
@@ -618,22 +658,31 @@ class tabengine (IBus.Engine):
attr.get_start_index(),
attr.get_end_index())
i += 1
- super(tabengine, self).update_preedit_text(text, self._editor.get_caret(), True)
+ super(tabengine, self).update_preedit_text(
+ text, self._editor.get_caret(), True)
def _update_aux (self):
'''Update Aux String in UI'''
- aux_string = u'(%d / %d)' % (self._editor._lookup_table.get_cursor_pos() + 1,
- self._editor._lookup_table.get_number_of_candidates())
+ aux_string = u'(%d / %d)' % (
+ self._editor.get_lookup_table().get_cursor_pos() + 1,
+ self._editor.get_lookup_table().get_number_of_candidates())
if aux_string:
# Colours do not work at the moment in the auxiliary text!
# Needs fix in ibus.
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x95,0x15,0xb5),0,len(aux_string)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x95, 0x15, 0xb5),
+ 0,
+ len(aux_string)))
if debug_level > 0:
- context = u' ' + self._editor._pp_phrase + u' ' + self._editor._p_phrase
+ context = (
+ u' ' + self._editor._pp_phrase
+ + u' ' + self._editor._p_phrase)
aux_string += context
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00),len(aux_string)-len(context), len(aux_string)))
+ rgb(0x00, 0xff, 0x00),
+ len(aux_string)-len(context),
+ len(aux_string)))
text = IBus.Text.new_from_string(aux_string)
i = 0
while attrs.get(i) != None:
@@ -644,9 +693,10 @@ class tabengine (IBus.Engine):
attr.get_end_index())
i += 1
visible = True
- if self._editor._lookup_table.get_number_of_candidates() == 0 \
- or self._show_number_of_candidates == False \
- or (self._tab_enable and not self.is_lookup_table_enabled_by_tab):
+ if (self._editor.get_lookup_table().get_number_of_candidates() == 0
+ or self._show_number_of_candidates == False
+ or (self._tab_enable
+ and not self.is_lookup_table_enabled_by_tab)):
visible = False
super(tabengine, self).update_auxiliary_text(text, visible)
else:
@@ -662,7 +712,7 @@ class tabengine (IBus.Engine):
# difference but gnome-shell in f18 will display
# an empty suggestion popup if the number of candidates
# is zero!
- if len(self._editor._candidates) == 0:
+ if len(self._editor.get_candidates()) == 0:
self.hide_lookup_table()
return
if self._tab_enable:
@@ -684,7 +734,8 @@ class tabengine (IBus.Engine):
input_phrase = self._editor.get_transliterated_string()
# commit always in NFC:
commit_phrase = unicodedata.normalize('NFC', commit_phrase)
- super(tabengine,self).commit_text(IBus.Text.new_from_string(commit_phrase))
+ super(tabengine, self).commit_text(
+ IBus.Text.new_from_string(commit_phrase))
self._editor.clear_input()
self._update_ui ()
self._commit_happened_after_focus_in = True
@@ -703,8 +754,9 @@ class tabengine (IBus.Engine):
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, it will
- # show up there only when the next key event is processed:
+ # The commit_phrase is *not* yet in the surrounding text,
+ # it will show up there only when the next key event is
+ # processed:
pattern = re.compile(r'(?P<white_space>[\s]+)$', re.UNICODE)
match = pattern.search(text[:cursor_pos])
if match:
@@ -744,7 +796,9 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return
- tokens = [itb_util.strip_token(x) for x in itb_util.tokenize(text[:cursor_pos])]
+ tokens = ([
+ itb_util.strip_token(x)
+ for x in itb_util.tokenize(text[:cursor_pos])])
if len(tokens):
self._editor._p_phrase = tokens[-1]
if len(tokens) > 1:
@@ -760,7 +814,9 @@ class tabengine (IBus.Engine):
Key Events include Key Press and Key Release,
modifier means Key Pressed
'''
- if self._has_input_purpose and self._input_purpose in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]:
+ if (self._has_input_purpose
+ and self._input_purpose
+ in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]):
return False
key = KeyEvent(keyval, keycode, state)
@@ -799,7 +855,8 @@ class tabengine (IBus.Engine):
if key.val in (IBus.KEY_BackSpace,):
# When the end of a word is reached again by typing backspace,
# try to get that word back into preedit:
- if not (self.client_capabilities & IBus.Capabilite.SURROUNDING_TEXT):
+ if not (self.client_capabilities
+ & IBus.Capabilite.SURROUNDING_TEXT):
return False
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
@@ -814,7 +871,8 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return False
- pattern = re.compile(r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
+ pattern = re.compile(
+ r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
match = pattern.match(text[:cursor_pos])
if not match:
return False
@@ -827,12 +885,15 @@ class tabengine (IBus.Engine):
# back to the application because the whitespace has
# already been deleted.
token = match.group('token')
- self.delete_surrounding_text(-1-len(token),1+len(token))
+ self.delete_surrounding_text(-1-len(token), 1+len(token))
self.get_context()
self._editor.insert_string_at_cursor(token)
self._update_ui()
return True
- if key.val >= 32 and (not (key.state & (IBus.ModifierType.MOD1_MASK | IBus.ModifierType.CONTROL_MASK))):
+ if (key.val >= 32
+ and (not (key.state & (
+ 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')
@@ -840,14 +901,17 @@ class tabengine (IBus.Engine):
# 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) in itb_util.categories_to_trigger_immediate_commit:
+ if (typed_character
+ and unicodedata.category(typed_character)
+ in itb_util.categories_to_trigger_immediate_commit):
if not self._editor.trans_m17n_mode:
# Do not just pass the character through,
# commit it properly. For example if it is a
# “.” we might want to remove whitespace
# between the “.” and the previous word and this is
# done in commit_string().
- self.commit_string(typed_character, input_phrase = typed_character)
+ self.commit_string(
+ typed_character, input_phrase = typed_character)
return True
# If transliteration is used, we may need to
# handle a punctuation or symbol character. For
@@ -859,7 +923,8 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(typed_character)
self._update_ui()
return True
- if typed_character and unicodedata.digit(typed_character, -1) != -1:
+ if (typed_character
+ and unicodedata.digit(typed_character, -1) != -1):
if not self._editor.trans_m17n_mode:
# If a digit has been typed and no transliteration
# is used, we can pass it through
@@ -872,8 +937,10 @@ class tabengine (IBus.Engine):
transliterated_digit = self._editor.trans.transliterate(
typed_character)[0]
if type(transliterated_digit) != type(u''):
- transliterated_digit = transliterated_digit.decode('utf8')
- self.commit_string(transliterated_digit, input_phrase=transliterated_digit)
+ transliterated_digit = (
+ transliterated_digit.decode('utf8'))
+ self.commit_string(
+ transliterated_digit, input_phrase=transliterated_digit)
return True
if key.val == IBus.KEY_Escape:
@@ -897,31 +964,34 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if key.val in self._page_down_keys and self._editor._candidates:
+ if key.val in self._page_down_keys 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._candidates:
+ if key.val in self._page_up_keys and self._editor.get_candidates():
res = self._editor.page_up ()
self._update_ui ()
return res
- if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left) and key.state & IBus.ModifierType.CONTROL_MASK:
+ 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 (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 (key.val == IBus.KEY_BackSpace
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_before_cursor()
@@ -935,7 +1005,8 @@ 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.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_after_cursor()
@@ -949,18 +1020,27 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates and key.state & IBus.ModifierType.CONTROL_MASK:
+ 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._candidates and key.state & IBus.ModifierType.MOD1_MASK:
+ 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._candidates:
- phrase = self._editor.get_string_from_lookup_table_current_page(key.val - IBus.KEY_1)
+ 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
@@ -978,15 +1058,17 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
else:
- if self._editor._candidates:
- phrase = self._editor.get_string_from_lookup_table_cursor_pos()
+ if self._editor.get_candidates():
+ phrase = (
+ self._editor.get_string_from_lookup_table_cursor_pos())
if phrase:
self.commit_string(phrase + u' ')
return True
else:
input_phrase = self._editor.get_transliterated_string()
if input_phrase:
- self.commit_string(input_phrase + u' ', input_phrase = input_phrase)
+ self.commit_string(
+ input_phrase + u' ', input_phrase = input_phrase)
return True
return True
@@ -996,7 +1078,8 @@ class tabengine (IBus.Engine):
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 (self._editor._typed_string_cursor
+ < len(self._editor._typed_string)):
self._editor._typed_string_cursor += 1
self._update_ui()
return True
@@ -1008,7 +1091,7 @@ class tabengine (IBus.Engine):
input_phrase = self._editor.get_transliterated_string()
if not input_phrase:
return False
- if not self._editor._candidates:
+ if not self._editor.get_candidates():
self.commit_string(input_phrase, input_phrase = input_phrase)
return False
phrase = self._editor.get_string_from_lookup_table_cursor_pos()
@@ -1051,10 +1134,15 @@ class tabengine (IBus.Engine):
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
self._editor.insert_string_at_cursor(typed_character)
- if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
+ if (typed_character
+ and unicodedata.category(typed_character)
+ 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 not self._editor.trans_m17n_mode:
- self.commit_string(input_phrase + u' ', input_phrase = input_phrase)
+ if (input_phrase
+ and input_phrase[-1] == typed_character
+ and not self._editor.trans_m17n_mode):
+ self.commit_string(
+ input_phrase + u' ', input_phrase = input_phrase)
self._update_ui()
return True
@@ -1107,7 +1195,7 @@ class tabengine (IBus.Engine):
# effect of comparing the dconf sections case insentively
# in some locales, it would fail for example if Turkish
# locale (tr_TR.UTF-8) is set.
- if sys.version_info >= (3,0,0): # Python3
+ if sys.version_info >= (3, 0, 0): # Python3
return re.sub(r'[_:]', r'-', section).translate(
''.maketrans(
string.ascii_uppercase,
@@ -1119,9 +1207,11 @@ class tabengine (IBus.Engine):
string.ascii_lowercase).decode('ISO-8859-1'))
def __config_value_changed_cb(self, config, section, name, value):
- if self.config_section_normalize(self._config_section) != self.config_section_normalize(section):
+ if (self.config_section_normalize(self._config_section)
+ != self.config_section_normalize(section)):
return
- print("config value %(n)s for engine %(en)s changed" %{'n': name, 'en': self._name})
+ print("config value %(n)s for engine %(en)s changed"
+ %{'n': name, 'en': self._name})
value = variant_to_value(value)
if name == "tabenable":
if value == 1:
@@ -1157,7 +1247,8 @@ class tabengine (IBus.Engine):
if value != 'NoIme':
print("Switching to transliteration using ime=%s" %value)
self._editor.trans_m17n_mode = True
- self._editor.trans = Transliterator.get(self._editor._m17ndb, value)
+ self._editor.trans = Transliterator.get(
+ self._editor._m17ndb, value)
else:
print("Switching off transliteration.")
self._editor.trans_m17n_mode = False