git/lib
Shawn O. Pearce 95b002eeb3 git-gui: Automatically spell check commit messages as the user types
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>
2008-02-12 02:35:18 -05:00
..
about.tcl git-gui: Automatically spell check commit messages as the user types 2008-02-12 02:35:18 -05:00
blame.tcl git-gui: fix typo in lib/blame.tcl 2007-09-27 22:12:49 -04:00
branch.tcl git-gui: Always use absolute path to all git executables 2007-07-09 01:17:09 -04:00
branch_checkout.tcl Mark strings for translation. 2007-09-02 16:54:48 +01:00
branch_create.tcl Mark strings for translation. 2007-09-02 16:54:48 +01:00
branch_delete.tcl Mark strings for translation. 2007-09-02 16:54:48 +01:00
branch_rename.tcl git-gui: Paper bag fix missing translated strings 2007-09-14 01:51:18 -04:00
browser.tcl Merge branch 'maint' 2007-09-16 23:15:21 -04:00
checkout_op.tcl git-gui: (i18n) Fix a bunch of still untranslated strings. 2008-02-03 21:25:29 -05:00
choose_font.tcl git-gui: Disable native platform text selection in "lists" 2007-09-16 23:12:19 -04:00
choose_repository.tcl git-gui: Allow 'Create New Repository' on existing directories 2008-01-16 01:14:42 -05:00
choose_rev.tcl git-gui: Work around random missing scrollbar in revision list 2008-01-22 23:37:15 -05:00
class.tcl git-gui: Fix window manager problems on ion3 2007-08-20 00:38:13 -04:00
commit.tcl git-gui: (i18n) Fix a bunch of still untranslated strings. 2008-02-03 21:25:29 -05:00
console.tcl Merge branch 'maint' 2007-10-20 20:43:36 -04:00
database.tcl git-gui: add some strings to translation 2007-09-13 20:43:26 -04:00
date.tcl git-gui: Localize commit/author dates when displaying them 2007-09-10 01:54:16 -04:00
diff.tcl git-gui: Refresh file status description after hunk application 2008-01-16 01:29:39 -05:00
encoding.tcl git-gui: Translate standard encoding names to Tcl ones 2007-07-19 01:27:17 -04:00
error.tcl git-gui: Consolidate hook execution code into a single function 2008-01-20 22:45:38 -05:00
git-gui.ico git-gui: Improve the application icon on Windows. 2007-12-02 23:05:10 -05:00
index.tcl git-gui: (i18n) Fix a bunch of still untranslated strings. 2008-02-03 21:25:29 -05:00
logo.tcl git-gui: Refactor Henrik Nyh's logo into its own procedure 2007-10-10 01:12:15 -04:00
merge.tcl git-gui: (i18n) Fix a bunch of still untranslated strings. 2008-02-03 21:25:29 -05:00
option.tcl git-gui: Automatically spell check commit messages as the user types 2008-02-12 02:35:18 -05:00
remote.tcl git-gui: Consolidate the Fetch and Push menus into a Remote menu 2007-10-10 01:12:17 -04:00
remote_branch_delete.tcl git-gui: add some strings to translation 2007-09-13 20:43:26 -04:00
shortcut.tcl git-gui: Use proper Windows shortcuts instead of bat files 2007-10-12 23:07:58 -04:00
spellcheck.tcl git-gui: Automatically spell check commit messages as the user types 2008-02-12 02:35:18 -05:00
status_bar.tcl Merge branch 'maint' 2007-10-20 20:43:36 -04:00
transport.tcl git-gui: Allow forced push into remote repository 2007-10-03 00:21:50 -04:00
win32.tcl git-gui: Use proper Windows shortcuts instead of bat files 2007-10-12 23:07:58 -04:00
win32_shortcut.js git-gui: Use proper Windows shortcuts instead of bat files 2007-10-12 23:07:58 -04:00