class WordsController < ApplicationController def filechoices? false end #depending on the toggle, either all words containing the #chars with or without other chars intervening are offered #as choices def start_choices @text=get_text.strip lw=last_word(@text) if lw.empty? [] else if session[:toggle] rx_str=lw else rx_str=lw.split("").join(".*") end rx=Regexp.new(rx_str,Regexp::IGNORECASE) # logger.info("words rx:"+rx_str) ac=get_matching_words(get_words_dir,rx) -[lw] if ac.size > MaxWords ac=ac[0..MaxWords] end ac end end def get_title "replace '#{last_word(get_text)}' with word:" end def extras # @displayed=rx_str @text=get_text end #the selected word replaces the last word def selected(st) @text=get_text.strip if last_word(@text) @text.gsub!(/\w+$/,st) #replace the "regex" with the selected word else @text << " " << st end session[:text]=@text + " " session[:start_choices]= nil end #toggles session[:toggle] def backspace session[:toggle]= session[:toggle]? nil:1 session[:choices]= nil redirect_to :action => "index" end end