Revision: 2284
Updated Code
at February 12, 2007 10:51 by gtcaz
Updated Code
#!/usr/bin/env ruby -w # By Geoff Cheshire <[email protected]> require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog" selection = STDIN.read IO.popen("aspell -a", 'w+') do |aspell| aspell.puts(selection) aspell.close_write aspell.each do |check| if check =~ /^\&/ data, raw_suggestions = check.split(":") signal, original, count, offset = data.split suggestions = "" raw_suggestions.split(', ').each { |s| suggestions += "\"#{s.chomp}\" " } choice=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "There are #{count} suggestions for '#{original}':" \ --string-output \ --items #{suggestions} \ --button1 "Replace" --button2 "Skip" --button3 "Add to dictionary") # No room for a "Cancel" button button, replacement = choice.split(" ", 2) replacement.chomp! case button when "Replace" selection.gsub!(/#{original}/, replacement) # Replace done globally; all instances of original replaced when "Add" `echo -e "*#{original}\n#" | aspell -a` `"#{COCOA_DIALOG}" ok-msgbox \ --text "Added '#{original}' to your personal dictionary." \ --no-cancel --timeout 2` end end end end print selection
Revision: 2283
Updated Code
at January 30, 2007 00:30 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.1.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end selection = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = selection.match(/\w+'?\w*/)[0] result = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none].split("\n")[1].split case result[0] when '*' TextMate.exit_discard if result[0] == "*" when '#' print "#{word} did not appear in the dictionary, but there are no suggestions." TextMate.exit_show_tool_tip when '&' suggestions = result[4..result.length].join(" ").delete(",") choice=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "There are #{result[2]} suggestions for '#{result[1]}':" \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel" --button3 "Add to dictionary") button, replacement = choice.split case button when "Replace" print selection.gsub(/^#{word}/, replacement) exit when "Add" `echo -e "*#{word}\n#" | aspell -a` print "Added '#{word}' to your personal dictionary." TextMate.exit_show_tool_tip end end TextMate.exit_discard
Revision: 2282
Updated Code
at January 30, 2007 00:29 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end selection = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = selection.match(/\w+'?\w*/)[0] result = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none].split("\n")[1].split case result[0] when '*' TextMate.exit_discard if result[0] == "*" when '#' print "#{word} did not appear in the dictionary, but there are no suggestions." TextMate.exit_show_tool_tip when '&' suggestions = result[4..result.length].join(" ").delete(",") choice=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "There are #{result[2]} suggestions for '#{result[1]}':" \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel" --button3 "Add to dictionary") button, replacement = choice.split case button when "Replace" print selection.gsub(/^#{word}/, replacement) exit when "Add" `echo -e "*#{word}\n#" | aspell -a` print "Added '#{word}' to your personal dictionary." TextMate.exit_show_tool_tip end end TextMate.exit_discard
Revision: 2281
Updated Code
at January 30, 2007 00:20 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end word = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = word.match(/\w+'?\w*/)[0] result = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none].split("\n")[1].split case result[0] when '*' TextMate.exit_discard if result[0] == "*" when '#' print "#{word} did not appear in the dictionary, but there are no suggestions." TextMate.exit_show_tool_tip when '&' suggestions = result[4..result.length].join(" ").delete(",") choice=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "There are #{result[2]} suggestions for '#{result[1]}':" \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel" --button3 "Add to dictionary") button, replacement = choice.split case button when "Replace" print replacement exit when "Add" `echo -e "*#{word}\n#" | aspell -a` print "Added '#{word}' to your personal dictionary." TextMate.exit_show_tool_tip end end TextMate.exit_discard
Revision: 2280
Updated Code
at January 29, 2007 23:36 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end word = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = word.match(/\w+'?\w*/)[0] suggestions = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none|tail -n3|cut -f2 -d:|tr -d ,].rstrip TextMate.exit_discard if suggestions == "*" result=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "Suggestions for '#{word}'." \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel" --button3 "Add to dictionary") button, replacement = result.split case button when "Replace" print replacement exit when "Add" `echo -e "*#{word}\n#" | aspell -a` print "Added '#{word}' to your personal dictionary." TextMate.exit_show_tool_tip end TextMate.exit_discard
Revision: 2279
Updated Code
at January 29, 2007 22:33 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end word = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = word.match(/\w+'?\w*/)[0] suggestions = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none|tail -n3|cut -f2 -d:|tr -d ,].rstrip TextMate.exit_discard if suggestions == "*" result=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "Suggestions for '#{word}'." \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel") button, replacement = result.split TextMate.exit_discard unless "Replace" == button print replacement
Revision: 2278
Updated Code
at January 29, 2007 22:31 by gtcaz
Updated Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell and wxCocoaDialog installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" # Test for aspell unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end word = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" # Test for wxCocoaDialog unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = word.match(/\w+'?\w*/)[0] suggestions = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none|tail -n3|cut -f2 -d:|tr -d ,].rstrip TextMate.exit_discard if suggestions == "*" result=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "Suggestions for '#{word}'." \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel") button, replacement = result.split TextMate.exit_discard unless "Replace" == button print replacement
Revision: 2277
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 29, 2007 22:27 by gtcaz
Initial Code
#!/usr/bin/ruby # Offers spelling alternatives for current word. # You MUST have aspell installed for this to work. # Ruby version for e By Geoff Cheshire # Based on work from Haris Skiadas (http://skiadas.dcostanet.net) # Version 2.0 require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" # Test for aspell unless File.exists?("/usr/bin/aspell") print "Error: You must install aspell via the cygwin installer prior to running this command." TextMate.exit_show_tool_tip end word = STDIN.read COCOA_DIALOG = "#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.exe" # Test for wxCocoaDialog unless File.exists?(COCOA_DIALOG) print "Error: #{COCOA_DIALOG} not found. Please install wxCocoaDialog." TextMate.exit_show_tool_tip end word = word.match(/\w+'?\w*/)[0] suggestions = %x[aspell <<<#{word.gsub(/'/, "\\\\\\0")} -a --mode=none|tail -n3|cut -f2 -d:|tr -d ,].rstrip TextMate.exit_discard if suggestions == "*" result=%x("#{COCOA_DIALOG}" dropdown \ --title "Misspelled Word" \ --text "Suggestions for '#{word}'." \ --string-output \ --items #{suggestions.gsub(/'/, "\\\\\\0")} \ --button1 "Replace" --button2 "Cancel") button, replacement = result.split TextMate.exit_discard unless "Replace" == button print replacement
Initial URL
Initial Description
Requires aspell and wxCocoaDialog. Now checks all of your selection for misspellings. Known issues: * e doesn't see contractions as a "word", so you must select things like can't, won't, etc. or the command won't see the whole word. * Duplicate misspelled words are not handled well. Replacements are done globally, yet you'll be asked for each occurrence. Place in the Text bundle I named the command: Spell check word/selection Save: Nothing Input: Selected Text or Word Output: Replace Selected Text Key Equivalent: Ctrl-; Scope Selector: {Blank}
Initial Title
Super Simple Speller v3
Initial Tags
command, ruby
Initial Language
Ruby