summaryrefslogtreecommitdiff
path: root/git-gui/lib
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2008-02-29 21:22:52 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-02-29 21:22:52 -0800
commitdfb9a34ababeee98a9f241636c1fe6e98c754f7a (patch)
treee2a8f43ec4ad0220a6f3511e75d0c7ae8c960e6a /git-gui/lib
parentMerge branch 'maint' (diff)
parentMerge branch 'maint' (diff)
downloadtgif-dfb9a34ababeee98a9f241636c1fe6e98c754f7a.tar.xz
Merge branch 'master' of git://repo.or.cz/git-gui
* 'master' of git://repo.or.cz/git-gui: git-gui: fix typo in lib/spellcheck.tcl git-gui: Shorten Aspell version strings to just Aspell version number git-gui: Gracefully display non-aspell version errors to users git-gui: Catch and display aspell startup failures to the user git-gui: Only bind the spellcheck popup suggestion hook once git-gui: Remove explicit references to 'aspell' in message strings git-gui: Ensure all spellchecker 'class' variables are initialized git-gui: Update German translation. git-gui: (i18n) Add newly added translation strings to template.
Diffstat (limited to 'git-gui/lib')
-rw-r--r--git-gui/lib/about.tcl3
-rw-r--r--git-gui/lib/spellcheck.tcl75
2 files changed, 62 insertions, 16 deletions
diff --git a/git-gui/lib/about.tcl b/git-gui/lib/about.tcl
index 47be8eb97a..241ab892cd 100644
--- a/git-gui/lib/about.tcl
+++ b/git-gui/lib/about.tcl
@@ -41,7 +41,8 @@ proc do_about {} {
append v "Tcl version $tcl_patchLevel"
append v ", Tk version $tk_patchLevel"
}
- if {[info exists ui_comm_spell]} {
+ if {[info exists ui_comm_spell]
+ && [$ui_comm_spell version] ne {}} {
append v "\n"
append v [$ui_comm_spell version]
}
diff --git a/git-gui/lib/spellcheck.tcl b/git-gui/lib/spellcheck.tcl
index 7f018e4009..9be748683c 100644
--- a/git-gui/lib/spellcheck.tcl
+++ b/git-gui/lib/spellcheck.tcl
@@ -1,27 +1,31 @@
-# git-gui spellchecking support through aspell
+# git-gui spellchecking support through ispell/aspell
# Copyright (C) 2008 Shawn Pearce
class spellcheck {
-field s_fd {} ; # pipe to aspell
-field s_version ; # aspell version string
-field s_lang ; # current language code
+field s_fd {} ; # pipe to ispell/aspell
+field s_version {} ; # ispell/aspell version string
+field s_lang {} ; # current language code
+field s_prog aspell; # are we actually old ispell?
+field s_failed 0 ; # is $s_prog bogus and not working?
field w_text ; # text widget we are spelling
field w_menu ; # context menu for the widget
field s_menuidx 0 ; # last index of insertion into $w_menu
-field s_i ; # timer registration for _run callbacks
+field s_i {} ; # timer registration for _run callbacks
field s_clear 0 ; # did we erase mispelled tags yet?
field s_seen [list] ; # lines last seen from $w_text in _run
field s_checked [list] ; # lines already checked
-field s_pending [list] ; # [$line $data] sent to aspell
+field s_pending [list] ; # [$line $data] sent to ispell/aspell
field s_suggest ; # array, list of suggestions, keyed by misspelling
constructor init {pipe_fd ui_text ui_menu} {
set w_text $ui_text
set w_menu $ui_menu
+ array unset s_suggest
+ bind_button3 $w_text [cb _popup_suggest %X %Y @%x,%y]
_connect $this $pipe_fd
return $this
}
@@ -33,14 +37,53 @@ method _connect {pipe_fd} {
-translation lf
if {[gets $pipe_fd s_version] <= 0} {
- close $pipe_fd
- error [mc "Not connected to aspell"]
+ if {[catch {close $pipe_fd} err]} {
+
+ # Eh? Is this actually ispell choking on aspell options?
+ #
+ if {$s_prog eq {aspell}
+ && [regexp -nocase {^Usage: } $err]
+ && ![catch {
+ set pipe_fd [open [list | $s_prog -v] r]
+ gets $pipe_fd s_version
+ close $pipe_fd
+ }]
+ && $s_version ne {}} {
+ if {{@(#) } eq [string range $s_version 0 4]} {
+ set s_version [string range $s_version 5 end]
+ }
+ set s_failed 1
+ error_popup [strcat \
+ [mc "Unsupported spell checker"] \
+ ":\n\n$s_version"]
+ set s_version {}
+ return
+ }
+
+ regsub -nocase {^Error: } $err {} err
+ if {$s_fd eq {}} {
+ error_popup [strcat [mc "Spell checking is unavailable"] ":\n\n$err"]
+ } else {
+ error_popup [strcat \
+ [mc "Invalid spell checking configuration"] \
+ ":\n\n$err\n\n" \
+ [mc "Reverting dictionary to %s." $s_lang]]
+ }
+ } else {
+ error_popup [mc "Spell checker silently failed on startup"]
+ }
+ return
}
+
if {{@(#) } ne [string range $s_version 0 4]} {
- close $pipe_fd
- error [strcat [mc "Unrecognized aspell version"] ": $s_version"]
+ catch {close $pipe_fd}
+ error_popup [strcat [mc "Unrecognized spell checker"] ":\n\n$s_version"]
+ return
}
set s_version [string range $s_version 5 end]
+ regexp \
+ {International Ispell Version .* \(but really (Aspell .*?)\)$} \
+ $s_version _junk s_version
puts $pipe_fd ! ; # enable terse mode
puts $pipe_fd {$$cr master} ; # fetch the language
@@ -65,7 +108,6 @@ method _connect {pipe_fd} {
$w_text tag conf misspelled \
-foreground red \
-underline 1
- bind_button3 $w_text [cb _popup_suggest %X %Y @%x,%y]
array unset s_suggest
set s_seen [list]
@@ -75,7 +117,7 @@ method _connect {pipe_fd} {
}
method lang {{n {}}} {
- if {$n ne {} && $s_lang ne $n} {
+ if {$n ne {} && $s_lang ne $n && !$s_failed} {
set spell_cmd [list |]
lappend spell_cmd aspell
lappend spell_cmd --master=$n
@@ -88,7 +130,10 @@ method lang {{n {}}} {
}
method version {} {
- return "$s_version, $s_lang"
+ if {$s_version ne {}} {
+ return "$s_version, $s_lang"
+ }
+ return {}
}
method stop {} {
@@ -333,11 +378,11 @@ method _read {} {
fconfigure $s_fd -block 1
if {[eof $s_fd]} {
if {![catch {close $s_fd} err]} {
- set err [mc "unexpected eof from aspell"]
+ set err [mc "Unexpected EOF from spell checker"]
}
catch {after cancel $s_i}
$w_text tag remove misspelled 1.0 end
- error_popup [strcat "Spell Checker Failed" "\n\n" $err]
+ error_popup [strcat [mc "Spell Checker Failed"] "\n\n" $err]
return
}
fconfigure $s_fd -block 0