Пример #1
0
 def check_spelling(text, tlen, fmt, locale, sfmt, store_locale):
     split_ans = []
     ppos = 0
     r, a = dictionaries.recognized, split_ans.append
     for start, length in split_into_words_and_positions(text, lang=locale.langcode):
         if start > ppos:
             a((start - ppos, fmt))
         ppos = start + length
         recognized = r(text[start:ppos], locale)
         if recognized:
             a((length, fmt))
         else:
             if store_locale:
                 s = QTextCharFormat(sfmt)
                 s.setProperty(SPELL_LOCALE_PROPERTY, locale)
                 a((length, s))
             else:
                 a((length, sfmt))
     if ppos < tlen:
         a((tlen - ppos, fmt))
     return split_ans
Пример #2
0
 def check_spelling(text, tlen, fmt, locale, sfmt, store_locale):
     split_ans = []
     ppos = 0
     r, a = dictionaries.recognized, split_ans.append
     for start, length in split_into_words_and_positions(
             text, lang=locale.langcode):
         if start > ppos:
             a((start - ppos, fmt))
         ppos = start + length
         recognized = r(text[start:ppos], locale)
         if recognized:
             a((length, fmt))
         else:
             if store_locale:
                 s = QTextCharFormat(sfmt)
                 s.setProperty(SPELL_LOCALE_PROPERTY, locale)
                 a((length, s))
             else:
                 a((length, sfmt))
     if ppos < tlen:
         a((tlen - ppos, fmt))
     return split_ans
Пример #3
0
 def spell_property(sfmt, locale):
     s = QTextCharFormat(sfmt)
     s.setProperty(SPELL_LOCALE_PROPERTY, locale)
     return s
Пример #4
0
def syntax_text_char_format(*args):
    ans = QTextCharFormat(*args)
    ans.setProperty(SYNTAX_PROPERTY, True)
    return ans
Пример #5
0
 def spell_property(sfmt, locale):
     s = QTextCharFormat(sfmt)
     s.setProperty(SPELL_LOCALE_PROPERTY, locale)
     return s
Пример #6
0
def syntax_text_char_format(*args):
    ans = QTextCharFormat(*args)
    ans.setProperty(SYNTAX_PROPERTY, True)
    return ans