Difference between revisions of "SpellChecker plugin"
m (Added example.) |
m |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Code::Blocks Contrib Plugins]] | [[Category:Code::Blocks Contrib Plugins]] | ||
− | |||
{{Infobox_Plugin| | {{Infobox_Plugin| | ||
name = SpellChecker | | name = SpellChecker | | ||
Line 10: | Line 9: | ||
=Introduction= | =Introduction= | ||
− | A plugin to check the spelling of strings and comments. The spelling gets checked during typing. Additionally a thesaurus is provided. Both may be accessed on-demand by selecting the word in question, then choosing either ''Spelling...'' or ''Thesaurus...'' | + | A plugin to check the spelling of strings and comments. The spelling gets checked during typing. Additionally a thesaurus is provided. Both may be accessed on-demand by selecting the word in question, then choosing either ''Spelling...'' or ''Thesaurus...'' from the ''Edit'' menu (the operation can be bound to a hot-key via the [[Keyboard Shortcuts plugin]]). The context menu (right click the word) provides spelling suggestions. |
Line 33: | Line 32: | ||
'''Path settings, Bitmaps''' | '''Path settings, Bitmaps''' | ||
:(Optional) The plugin is looking in this path for the flags to show in the status bar. | :(Optional) The plugin is looking in this path for the flags to show in the status bar. | ||
+ | |||
+ | '''Note''': You can use Macros in the above three path settings, such as | ||
+ | <code>$(CODEBLOCKS)/share/codeblocks/SpellChecker</code>. | ||
+ | See [[Variable expansion]] for more details. This is quite convenient if you use portable C::B. | ||
==Dictionaries== | ==Dictionaries== | ||
Line 43: | Line 46: | ||
I understand on Windows, Firefox and Thunderbird also install compatible dictionary files. These can be found in... | I understand on Windows, Firefox and Thunderbird also install compatible dictionary files. These can be found in... | ||
− | '''C:\Program Files\Mozilla Firefox\dictionaries''' or '''C:\Program Files\Mozilla Thunderbird\dictionaries''' | + | '''C:\Program Files\Mozilla Firefox\dictionaries''' or '''C:\Program Files\Mozilla Thunderbird\dictionaries'''. |
+ | In addition, both OpenOffice.org and LibreOffice install dictionary files to | ||
+ | '''C:\Program Files\''(Open/Libre)''Office\share\extensions\dict-*'''. | ||
The Google Chrome browser also installs dictionaries, but they are '''.bdic''' format and the Code::Blocks spell checker plugin will not work with them. | The Google Chrome browser also installs dictionaries, but they are '''.bdic''' format and the Code::Blocks spell checker plugin will not work with them. | ||
Line 53: | Line 58: | ||
Example: If the dictionary files (for one language) are "en_GB.aff" and "en_GB.dic" the files used for the thesaurus are "th_en_GB.idx" and "th_en_GB.dat". | Example: If the dictionary files (for one language) are "en_GB.aff" and "en_GB.dic" the files used for the thesaurus are "th_en_GB.idx" and "th_en_GB.dat". | ||
− | On my Linux system I found thesaurus files already installed in '''/usr/share/myspell/dicts''' and '''/usr/share/mythes'''. Again, don't move the files. Set the spell checker to use the files from | + | On my Linux system I found thesaurus files already installed in '''/usr/share/myspell/dicts''' and '''/usr/share/mythes'''. Again, don't move the files. Set the spell checker to use the files from their current location. |
+ | |||
+ | On Windows, if either OpenOffice.org or LibreOffice is installed, they often include thesaurus files in | ||
+ | '''C:\Program Files\''(Open/Libre)''Office\share\extensions\dict-*'''. | ||
==Bitmaps (flags)== | ==Bitmaps (flags)== | ||
Line 63: | Line 71: | ||
Only text with specific styles gets checked (for example only comments and strings). Styles are automatically set by Scintilla (CodeBlocks editing component). | Only text with specific styles gets checked (for example only comments and strings). Styles are automatically set by Scintilla (CodeBlocks editing component). | ||
− | The file '''OnlineSpellChecking.xml''' contains a list with indices of the styles to check. The indices differ for different programming-languages so the file contains a list for every programming-language. To add styles, look for the name of the programming-language and the indices in the corresponding [ | + | The file '''OnlineSpellChecking.xml''' contains a list with indices of the styles to check. The indices differ for different programming-languages so the file contains a list for every programming-language. To add styles, look for the name of the programming-language and the indices in the corresponding '''[[Creating a custom lexer for Code::Blocks editor#Lexers|lexer_*.xml]]''' file and add this information to the file OnlineSpellChecking.xml. |
+ | |||
+ | For example, to check the spelling in bash shell scripts (<tt>*.sh</tt> files), add the line: | ||
− | + | <source lang="xml" enclose="div"> | |
− | + | <Language name="Bash" index="2,5,6" /> | |
+ | </source> |
Latest revision as of 21:49, 17 March 2012
Introduction
A plugin to check the spelling of strings and comments. The spelling gets checked during typing. Additionally a thesaurus is provided. Both may be accessed on-demand by selecting the word in question, then choosing either Spelling... or Thesaurus... from the Edit menu (the operation can be bound to a hot-key via the Keyboard Shortcuts plugin). The context menu (right click the word) provides spelling suggestions.
Configuration
Configuration is in the menu Settings > Editor. The spell check option are about half way down the list on the left.
The meaning of the controls are:
Enable online spell checker
- Enable or disable the spell checker.
Language
- The language used for spell checking and the thesaurus is selected by choosing a dictionary. This can also be changed in the status bar.
Path settings, Dictionaries
- The plugin is looking in this path for the dictionary files.
Path settings, Thesauri
- The plugin is looking in this path for the files needed by the thesaurus.
Path settings, Bitmaps
- (Optional) The plugin is looking in this path for the flags to show in the status bar.
Note: You can use Macros in the above three path settings, such as
$(CODEBLOCKS)/share/codeblocks/SpellChecker
.
See Variable expansion for more details. This is quite convenient if you use portable C::B.
Dictionaries
SpellChecker uses a library called hunspell. Hunspell is the spell checker of OpenOffice.org, Mozilla Firefox and other projects. Dictionaries available for those applications are compatible with this plugin.
Open Office provides a collection of dictionaries for several languages and dialects to download. The OOo 3.x extensions (*.oxt) are compressed archives which can be opened with your favourite archiver (for example 7-Zip or File Roller). Copy the .aff file and the .dic file to the directory configured in 'Path settings, Dictionaries' (see above).
If you're running Linux you've probably already got compatible dictionaries installed. Look in /usr/share/hunspell or my choice is /usr/share/myspell/dicts. The reason I like the myspell files is they already include thesaurus files which are named correctly to work with the thesaurus, and everything is all in one location. Don't copy these files. Just point the spell checker to where the files are already located.
I understand on Windows, Firefox and Thunderbird also install compatible dictionary files. These can be found in... C:\Program Files\Mozilla Firefox\dictionaries or C:\Program Files\Mozilla Thunderbird\dictionaries. In addition, both OpenOffice.org and LibreOffice install dictionary files to C:\Program Files\(Open/Libre)Office\share\extensions\dict-*.
The Google Chrome browser also installs dictionaries, but they are .bdic format and the Code::Blocks spell checker plugin will not work with them.
Thesaurus files
The files for the thesaurus are also available from OOo, like the dictionaries. Copy the thesaurus files (th_*.dat and th_*.idx) to the directory configured in 'Path settings, Thesauri' (see above) and rename them to match the name of the dictionary but prepend "th_" and let the extension as is.
Example: If the dictionary files (for one language) are "en_GB.aff" and "en_GB.dic" the files used for the thesaurus are "th_en_GB.idx" and "th_en_GB.dat".
On my Linux system I found thesaurus files already installed in /usr/share/myspell/dicts and /usr/share/mythes. Again, don't move the files. Set the spell checker to use the files from their current location.
On Windows, if either OpenOffice.org or LibreOffice is installed, they often include thesaurus files in C:\Program Files\(Open/Libre)Office\share\extensions\dict-*.
Bitmaps (flags)
The bitmap of the actually selected language is shown in the status bar. If no bitmap is found, the name of the language is shown. The bitmap must be a PNG image. Choose a flag from the famfamfam_flag_icons and copy it to the directory configured in 'Path settings, Bitmaps' (see above) and rename it to match the name of the dictionary but let the extension png.
Example: If the dictionary files (for one language) are "en_GB.aff" and "en_GB.dic" the the bitmap is named "en_GB.png" .
Styles to check
Only text with specific styles gets checked (for example only comments and strings). Styles are automatically set by Scintilla (CodeBlocks editing component).
The file OnlineSpellChecking.xml contains a list with indices of the styles to check. The indices differ for different programming-languages so the file contains a list for every programming-language. To add styles, look for the name of the programming-language and the indices in the corresponding lexer_*.xml file and add this information to the file OnlineSpellChecking.xml.
For example, to check the spelling in bash shell scripts (*.sh files), add the line:
<Language name="Bash" index="2,5,6" />