summaryrefslogtreecommitdiff
path: root/lib/spellcheck.tcl
AgeCommit message (Collapse)Author
2008-02-21git-gui: Only bind the spellcheck popup suggestion hook onceShawn O. Pearce
If we reconnect to the spellchecker there is no reason to resetup the binding for button 3 on our text widget to show the suggestion list (if available). Plus, by moving it out of _connect and into init we can now break out of _connect earlier if there is something wrong with the pipe, for example if the dictionary we were asked to load is not valid. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-21git-gui: Remove explicit references to 'aspell' in message stringsShawn O. Pearce
Users may or may not be using aspell here. About the only thing we are using that is aspell specific (and not supported by ispell or an ispell variant) is some command line options when we start up aspell, and a forced encoding of UTF-8. Both of these can be corrected and/or cleaned up by users through an aspell wrapper script, or through further improvements to git-gui. There is no reason to require our translated strings to reference a specific spell checker, especially if that spell checker implementation is not very suitable for the language being translated. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-21git-gui: Ensure all spellchecker 'class' variables are initializedShawn O. Pearce
If we somehow managed to get our spellchecker instance created but aspell wasn't startable we may not finish _connect and thus may find one or more of our fields was not initialized in the instance. If we have an instance but no version, there is no reason to show a version to the user in our about dialog. We effectively have no spellchecker available. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-17git-gui: (i18n) Add newly added translation strings to template.Christian Stimming
And markup one missing string for translation. Signed-off-by: Christian Stimming <stimming@tuhh.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-14git-gui: Paper bag fix bad string length call in spellcheckerShawn O. Pearce
We don't want the list length, we need the string length. Found due to a bad " character discovered in the text and Tcl throwing 'unmatched open quote in list'. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-12git-gui: Automatically spell check commit messages as the user typesShawn O. Pearce
Many user friendly tools like word processors, email editors and web browsers allow users to spell check the message they are writing as they type it, making it easy to identify a common misspelling of a word and correct it on the fly. We now open a bi-directional pipe to Aspell and feed the message text the user is editing off to the program about once every 300 milliseconds. This is frequent enough that the user sees the results almost immediately, but is not so frequent as to cause significant additional load on the system. If the user has modified the message text during the last 300 milliseconds we delay until the next period, ensuring that we avoid flooding the Aspell process with a lot of text while the user is actively typing their message. We wait to send the current message buffer to Aspell until the user is at a word boundary, thus ensuring that we are not likely to ask for misspelled word detection on a word that the user is actively typing, as most words are misspelled when only partially typed, even if the user has thus far typed it correctly. Misspelled words are highlighted in red and are given an underline, causing the word to stand out from the others in the buffer. This is a very common user interface idiom for displaying misspelled words, but differs from one platform to the next in slight variations. For example the Mac OS X system prefers using a dashed red underline, leaving the word in the original text color. Unfortunately the control that Tk gives us over text display is not powerful enough to handle such formatting so we have to work with the least common denominator. The top suggestions for a misspelling are saved in an array and offered to the user when they right-click (or on the Mac ctrl-click) a misspelled word. Selecting an entry from this menu will replace the misspelling with the correction shown. Replacement is integrated with the undo/redo stack so undoing a replacement will restore the misspelled original text. If Aspell could not be started during git-gui launch we silently eat the error and run without spell checking support. This way users who do not have Aspell in their $PATH can continue to use git-gui, although they will not get the advanced spelling functionality. If Aspell started successfully the version line and language are shown in git-gui's about box, below the Tcl/Tk versions. This way the user can verify the Aspell function has been activated. If Aspell crashes while we are running we inform the user with an error dialog and then disable Aspell entirely for the rest of this git-gui session. This prevents us from fork-bombing the system with Aspell instances that always crash when presented with the current message text, should there be a bug in either Aspell or in git-gui's output to it. We escape all input lines with ^, as recommended by the Aspell manual page, as this allows Aspell to properly ignore any input line that is otherwise looking like a command (e.g. ! to enable terse output). By using this escape however we need to correct all word offsets by -1 as Aspell is apparently considering the ^ escape to be part of the line's character count, but our Tk text widget obviously does not. Available dictionaries are offered in the Options dialog, allowing the user to select the language they want to spellcheck commit messages with for the current repository, as well as the global user setting that all repositories inherit. Special thanks to Adam Flott for suggesting connecting git-gui to Aspell for the purpose of spell checking the commit message, and to Wincent Colaiuta for the idea to wait for a word boundary before passing the message over for checking. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>