Merge branch 'dr/ru' into pu
[gitweb.git] / lib / spellcheck.tcl
index 9be748683ce101821a91bf9461ccadfd58c8adf1..538d61c792defa7a8e19736039fa5a9af630125c 100644 (file)
@@ -14,7 +14,7 @@ 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_clear        0 ; # did we erase mispelled tags yet?
+field s_clear        0 ; # did we erase misspelled 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 ispell/aspell
@@ -80,17 +80,23 @@ method _connect {pipe_fd} {
                error_popup [strcat [mc "Unrecognized spell checker"] ":\n\n$s_version"]
                return
        }
-       set s_version [string range $s_version 5 end]
+       set s_version [string range [string trim $s_version] 5 end]
        regexp \
                {International Ispell Version .* \(but really (Aspell .*?)\)$} \
                $s_version _junk s_version
+       regexp {^Aspell (\d)+\.(\d+)} $s_version _junk major minor
 
        puts $pipe_fd !             ; # enable terse mode
-       puts $pipe_fd {$$cr master} ; # fetch the language
-       flush $pipe_fd
 
-       gets $pipe_fd s_lang
-       regexp {[/\\]([^/\\]+)\.[^\.]+$} $s_lang _ s_lang
+       # fetch the language
+       if {$major > 0 || ($major == 0 && $minor >= 60)} {
+               puts $pipe_fd {$$cr master}
+               flush $pipe_fd
+               gets $pipe_fd s_lang
+               regexp {[/\\]([^/\\]+)\.[^\.]+$} $s_lang _ s_lang
+       } else {
+               set s_lang {}
+       }
 
        if {$::default_config(gui.spellingdictionary) eq {}
         && [get_config gui.spellingdictionary] eq {}} {
@@ -253,7 +259,7 @@ method _run {} {
                if {$n == $cur_line
                 && ![regexp {^\W$} [$w_text get $cur_pos insert]]} {
 
-                       # If the current word is mispelled remove the tag
+                       # If the current word is misspelled remove the tag
                        # but force a spellcheck later.
                        #
                        set tags [$w_text tag names $cur_pos]
@@ -308,6 +314,7 @@ method _run {} {
 method _read {} {
        while {[gets $s_fd line] >= 0} {
                set lineno [lindex $s_pending 0 0]
+               set line [string trim $line]
 
                if {$s_clear} {
                        $w_text tag remove misspelled "$lineno.0" "$lineno.end"