Jump to content

Scite4AutoIt SpellChecker using LibreOffice


donnyh13
 Share

Recommended Posts

Greetings all,
While I am working with various projects along the way I often hit a reoccurring frustration of needing to know if I spelled a comment or string correctly, and have often needed to copy my word into a document to spellcheck it and then correct as needed, which feels much like a waste of time.
So, I have finally decided to solve my problem by utilizing Libre Office. After running across a post by GMK, demonstrating his Spell Checker demonstration, I thought I would make my own version. And now that I have this working satisfactorily, I thought I would share it in case others are sitting in a similar spot as I was. I may add features from time to time to this, but it is currently working how I like it. Neither do I claim it works perfectly, but it seems to work pretty good, as best as I can tell.
I will add one note, this add-on is not recommended for those new to modifying their Scite User Properties, or are unaware of where their App Data Scite installation is.

What does this do? This integrates, sort of, Libre Office’s spell checking engine into Scite4Autoit so you can check the spelling of words on the fly using a shortcut combo, and offering suggestions if the word is misspelled. This Add-on also allows you to spellcheck an entire script’s Strings, Comments, and comment blocks for misspelled words, marking them for review. The Script Spell checker skips words with the following in them: . $ # @ _ : / \  
I have added the ability to spell check in other, and/or multiple, languages, though I am limited to my ability to test this, English being my only language.

1.png.dc246bfd61c7f2a10531af66c9ad1569.png

 

2.thumb.png.ab62a6058e4fdcc6a801daae0c3152d9.png

Requirements:

  • Full installation of Scite4AutoIt
  • LibreOffice (Installed version only, portable will not work.)
  • Desired Spell Checking language installed in Libre Office.

Installation

To "Install" this Add-On for Scite4AutoIt, do the following.

  • Navigate to %LocalAppData%\Local\AutoIt v3\SciTE  (You can copy and paste the above into Start search box and push enter)
  • Copy the "Scite4AutoIt_LO_SpellChecker" folder into this directory.
  • Do one of the following, depending on if you already have custom lua scripts present in PersonalTools.lua or not.
  •  
  • If you do not have custom scripts present in PersonalTools.lua,
  •     find in this same directory the file PersonalTools.lua, and rename it to PersonalTools.lua.old
  •     Copy the PersonalTools.lua file from the Add-On folder to the %LocalAppData%\Local\AutoIt v3\SciTE directory.
  •  
  •  If you do have custom scripts present in PersonalTools.lua,
  •     Open the PersonalTools.lua file in the Add-On folder and copy everything in the file below the following entry,
-------------------------------------------------------------------------------
-- required line ... do not remove
PersonalTools = EventClass:new(Common)
-------------------------------------------------------------------------------

 

  •     Paste the contents into the end of the PersonalTools.lua file found in the %LocalAppData%\Local\AutoIt v3\SciTE directory.
  •  
  • Open your SciTEUser.properties file, (go to Scite editor and Select "Options" in the toolbar, Select "Open User Options File".)
  • Copy and paste the following into the SciTEUser.properties File. (If you have previous custom Lua Scripts, you may need to modify the command numbering.)  
#~ Single Word Spell-Check lua Script  
command.name.45.$(au3)=Sp-Check Current Word  
command.mode.45.$(au3)=subsystem:lua,savebefore:no  
command.shortcut.45.$(au3)=Ctrl+Shift+F  
command.45.$(au3)=InvokeTool PersonalTools.SingleWordCheck  
#~  
#~ Entire Script Spell-Check lua Script  
command.name.46.$(au3)=Sp-Check Entire Script  
command.mode.46.$(au3)=subsystem:lua,savebefore:no  
command.shortcut.46.$(au3)=Ctrl+Shift+G  
command.46.$(au3)=InvokeTool PersonalTools.CheckScript  
#~  
#~ Clear Spell Checking Marking lua Script  
command.name.47.$(au3)=Sp-Check Clear  
command.mode.47.$(au3)=subsystem:lua,savebefore:no  
command.shortcut.47.$(au3)=Ctrl+Shift+H  
command.47.$(au3)=InvokeTool PersonalTools.ClearSpChk  
#~

*You may modify any Shortcut key combinations as necessary.*

  • Restart Scite

Ignored Words

You can add words to ignore in the file "Scite4AutoIt_LO_IgnoredWords.ini" that you placed in "%LocalAppData%\Local\AutoIt v3\SciTE\Scite4AutoIt_LO_SpellChecker".

  • ONLY one word per line.
  • No lone punctuation characters please.
  • Words are Case Sensitive.

Properties

- You may set the following properties by pasting the property values in your "User Options" File (from Scite's toolbar go to, Options->Open User Options File), and modifying the value after "="

###Language and Country###

S4A.SpellCheck.Language=en
S4A.SpellCheck.Country=US
  • Language code must be a LOWER CASE two or three character ISO 639 Language Code. You can find a list of these codes online, such as https://iso639-3.sil.org/code_tables/639/data
  • Country code must be an UPPER CASE two character ISO 3166 Country Code. You can find a list of these codes online, such as https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  • YOU MUST HAVE the desired Language installed in Libre Office already for this to work.
  • Default is Language: en, Country: US
  • Also accepts multiple value pairs separated by a semicolon, such as:  
S4A.SpellCheck.Language=en;pl  
S4A.SpellCheck.Country=US;PL
  • Pairs must be equal between Language and Country. And each column must be a valid Language and Country pair. i.e. (en US), (pl PL).
  • The first language/country pair listed is considered your primary language and any words will be checked by it first.
  • Duplicate suggestions are automatically removed, when multiple languages are used.

###Misspelled Word Highlighting###

S4A.SpellCheck.Highlight=0xFF00FF

Modify the misspelled word highlighting.

  • Must be 8 characters long, and contain only a-f, x, and 0-9 and begin with 0x.
  • Highlighting color code is Hex color code of B(lue) G(reen) R(ed) (Not RGB). One way you can obtain this value is by using the value given from the example script provided with AutoIt function _ChooseColor, and selecting the BGR button.
  • Default is 0xFF00FF

###Maximum Suggestions###

S4A.SpellCheck.MaxSuggestions=10

Set the maximum words returned per language/country pairs.

  • Must contain only digits, and be greater than 0.
  • Default is 10.

Notes

This function uses the following Styles for Scite functions.

  • UserList Type: 18
  • Indicator Style: 10

This has been developed using the Scite4AutoIt Beta Version 5, currently being developed by Jos, I tried it in the standard Scite4A release V. 4 and it seems to function properly, except, in the standard Scite release a cmd window appears for a second or two. I seem to be unable to get around this. However it does not appear in the beta release.

I would be happy to hear any suggestions, though I can’t promise prompt help or replies, but will do what I can. I am currently still working on another project, so anything done to this will be sporadic and delayed.

 

Scite4AutoIt_LibreOffice_SpellChecker.zip

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...