end
def handle_input c
- if(action = resolve_input c)
- send action
- true
- else
- false
- end
+ action = resolve_input(c) or return false
+ send action
+ true
end
def help_text
s
end.compact.join "\n"
end
+
+ ## helper function
+ def save_to_file fn
+ if File.exists? fn
+ return unless BufferManager.ask_yes_or_no "File exists. Overwrite?"
+ end
+ begin
+ File.open(fn, "w") { |f| yield f }
+ BufferManager.flash "Successfully wrote #{fn}."
+ rescue SystemCallError, IOError => e
+ BufferManager.flash "Error writing to file: #{e.message}"
+ end
+ end
end
end