eric4.QScintilla.SpellChecker
Module implementing the spell checker for the editor component.
The spell checker is based on pyenchant.
Global Attributes
Classes
SpellChecker |
Class implementing a pyenchant based spell checker. |
Functions
SpellChecker
Class implementing a pyenchant based spell checker.
Derived from
QObject
Class Attributes
_spelling_dict |
_spelling_lang |
Methods
SpellChecker |
Constructor |
__checkDocumentPart |
Private method to check some part of the document. |
__getNextWord |
Private method to get the next word in the text after the given position. |
__incrementalCheck |
Private method to check the document incrementally. |
__iter__ |
Private method to create an iterator. |
__next__ |
Private method to advance to the next error. |
_getDict |
Protected classmethod to get a new dictionary. |
add |
Public method to add a word to the personal word list. |
checkCurrentPage |
Private method to check the currently visible page. |
checkDocument |
Public method to check the complete document |
checkDocumentIncrementally |
Public method to check the document incrementally. |
checkLines |
Public method to check some lines of text. |
checkSelection |
Private method to check the current selection. |
checkWord |
Public method to check the word at position pos. |
clearAll |
Public method to clear all spelling markers. |
getAvailableLanguages |
Public classmethod to get all available languages. |
getContext |
Public method to get the context of a faulty word. |
getError |
Public method to get information about the last error found. |
getLanguage |
Public method to get the current language. |
getSuggestions |
Public method to get suggestions for the given word. |
ignoreAlways |
Public method to tell the checker, to always ignore the given word or the current word. |
initCheck |
Public method to initialize a spell check. |
isAvailable |
Public classmethod to check, if spellchecking is available. |
next |
Public method to advance to the next error. |
remove |
Public method to add a word to the personal exclude list. |
replace |
Public method to tell the checker to replace the current word with the replacement string. |
replaceAlways |
Public method to tell the checker to always replace the current word with the replacement string. |
setDefaultLanguage |
Public classmethod to set the default language. |
setLanguage |
Public method to set the current language. |
setMinimumWordSize |
Public method to set the minimum word size. |
stopIncrementalCheck |
Public method to stop an incremental check. |
SpellChecker (Constructor)
SpellChecker(editor, indicator, defaultLanguage = None, checkRegion = None)
Constructor
- editor
-
reference to the editor object (QScintilla.Editor)
- indicator
-
spell checking indicator
- defaultLanguage=
-
the language to be used as the default (string).
The string should be in language locale format (e.g. en_US, de).
- checkRegion=
-
reference to a function to check for a valid region
SpellChecker.__checkDocumentPart
__checkDocumentPart(startPos, endPos)
Private method to check some part of the document.
- startPos
-
position to start at (integer)
- endPos
-
position to end at (integer)
SpellChecker.__getNextWord
__getNextWord(pos, endPosition)
Private method to get the next word in the text after the given position.
- pos
-
position to start word extraction (integer)
- endPosition
-
position to stop word extraction (integer)
- Returns:
-
tuple of three values (the extracted word (string),
start position (integer), end position (integer))
SpellChecker.__incrementalCheck
__incrementalCheck()
Private method to check the document incrementally.
SpellChecker.__iter__
__iter__()
Private method to create an iterator.
SpellChecker.__next__
__next__()
Private method to advance to the next error.
SpellChecker._getDict
_getDict(lang, pwl = "", pel = "")
Protected classmethod to get a new dictionary.
- lang
-
the language to be used as the default (string).
The string should be in language locale format (e.g. en_US, de).
- pwl=
-
name of the personal/project word list (string)
- pel=
-
name of the personal/project exclude list (string)
- Returns:
-
reference to the dictionary (enchant.Dict)
SpellChecker.add
add(word = None)
Public method to add a word to the personal word list.
- word
-
word to add (string or QString)
SpellChecker.checkCurrentPage
checkCurrentPage()
Private method to check the currently visible page.
SpellChecker.checkDocument
checkDocument()
Public method to check the complete document
SpellChecker.checkDocumentIncrementally
checkDocumentIncrementally()
Public method to check the document incrementally.
SpellChecker.checkLines
checkLines(firstLine, lastLine)
Public method to check some lines of text.
- firstLine
-
line number of first line to check (integer)
- lastLine
-
line number of last line to check (integer)
SpellChecker.checkSelection
checkSelection()
Private method to check the current selection.
SpellChecker.checkWord
checkWord(pos, atEnd = False)
Public method to check the word at position pos.
- pos
-
position to check at (integer)
- atEnd=
-
flag indicating the position is at the end of the word
to check (boolean)
SpellChecker.clearAll
clearAll()
Public method to clear all spelling markers.
SpellChecker.getAvailableLanguages
getAvailableLanguages()
Public classmethod to get all available languages.
- Returns:
-
list of available languages (list of strings)
SpellChecker.getContext
getContext(wordStart, wordEnd)
Public method to get the context of a faulty word.
- wordStart
-
the starting position of the word (integer)
- wordEnd
-
the ending position of the word (integer)
- Returns:
-
tuple of the leading and trailing context (QString, QString)
SpellChecker.getError
getError()
Public method to get information about the last error found.
- Returns:
-
tuple of last faulty word (QString), starting position of the
faulty word (integer) and ending position of the faulty word (integer)
SpellChecker.getLanguage
getLanguage()
Public method to get the current language.
- Returns:
-
current language in language locale format (string)
SpellChecker.getSuggestions
getSuggestions(word)
Public method to get suggestions for the given word.
- word
-
word to get suggestions for (string or QString)
- Returns:
-
list of suggestions (list of strings)
SpellChecker.ignoreAlways
ignoreAlways(word = None)
Public method to tell the checker, to always ignore the given word
or the current word.
- word
-
word to be ignored (string or QString)
SpellChecker.initCheck
initCheck(startPos, endPos)
Public method to initialize a spell check.
- startPos
-
position to start at (integer)
- endPos
-
position to end at (integer)
- Returns:
-
flag indicating successful initialization (boolean)
SpellChecker.isAvailable
isAvailable()
Public classmethod to check, if spellchecking is available.
- Returns:
-
flag indicating availability (boolean)
SpellChecker.next
next()
Public method to advance to the next error.
- Returns:
-
self
SpellChecker.remove
remove(word)
Public method to add a word to the personal exclude list.
- word
-
word to add (string or QString)
SpellChecker.replace
replace(replacement)
Public method to tell the checker to replace the current word with
the replacement string.
- replacement
-
replacement string (string or QString)
SpellChecker.replaceAlways
replaceAlways(replacement)
Public method to tell the checker to always replace the current word
with the replacement string.
- replacement
-
replacement string (string or QString)
SpellChecker.setDefaultLanguage
setDefaultLanguage(language)
Public classmethod to set the default language.
- language
-
the language to be used as the default (string).
The string should be in language locale format (e.g. en_US, de).
SpellChecker.setLanguage
setLanguage(language, pwl = "", pel = "")
Public method to set the current language.
- language
-
the language to be used as the default (string).
The string should be in language locale format (e.g. en_US, de).
- pwl=
-
name of the personal/project word list (string)
- pel=
-
name of the personal/project exclude list (string)
SpellChecker.setMinimumWordSize
setMinimumWordSize(size)
Public method to set the minimum word size.
- size
-
minimum word size (integer)
SpellChecker.stopIncrementalCheck
stopIncrementalCheck()
Public method to stop an incremental check.