def xapian; Index.instance.instance_variable_get :@xapian; end
def ferret; Index.instance.instance_variable_get :@index; end
+ def special_methods; methods - Object.methods end
## files that won't cause problems when reloaded
## TODO expand this list / convert to blacklist
end
true
end
+
+ def clear_hooks
+ HookManager.clear
+ nil
+ end
end
class ConsoleMode < LogMode
+ register_keymap do |k|
+ k.add :run, "Restart evaluation", 'e'
+ end
+
def initialize
super
- @binding = Console.new(self).instance_eval { binding }
+ @console = Console.new self
+ @binding = @console.instance_eval { binding }
end
def execute cmd
end
def prompt
- BufferManager.ask :console, "eval: "
+ BufferManager.ask :console, ">> "
end
def run
+ self << <<EOS
+Sup v#{VERSION} console session started.
+Available extra commands: #{(@console.special_methods) * ", "}
+Ctrl-G stops evaluation; 'e' restarts it.
+
+EOS
while true
- cmd = prompt or return
- execute cmd
+ if(cmd = prompt)
+ execute cmd
+ else
+ self << "Console session ended."
+ break
+ end
end
end
end