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
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
def spell_property(sfmt, locale): s = QTextCharFormat(sfmt) s.setProperty(SPELL_LOCALE_PROPERTY, locale) return s
def syntax_text_char_format(*args): ans = QTextCharFormat(*args) ans.setProperty(SYNTAX_PROPERTY, True) return ans
def spell_property(sfmt, locale): s = QTextCharFormat(sfmt) s.setProperty(SPELL_LOCALE_PROPERTY, locale) return s
def syntax_text_char_format(*args): ans = QTextCharFormat(*args) ans.setProperty(SYNTAX_PROPERTY, True) return ans