From 84682b7590b6fddd3f476066a2111d7093d9d12a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 8 Sep 2011 14:32:36 +0000 Subject: [PATCH] Add a buffer command to switch between existing buffers --- src/main.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.cc b/src/main.cc index b76effcf..e0a6f877 100644 --- a/src/main.cc +++ b/src/main.cc @@ -195,6 +195,18 @@ void quit(const CommandParameters& params) quit_requested = true; } +void show_buffer(const CommandParameters& params) +{ + if (params.size() != 1) + throw wrong_argument_count(); + + Buffer* buffer = BufferManager::instance().get_buffer(params[0]); + if (not buffer) + print_status("buffer " + params[0] + " does not exists"); + else + current_window = buffer->get_or_create_window(); +} + CommandManager command_manager; void do_command() @@ -290,6 +302,7 @@ int main() command_manager.register_command(std::vector{ "e", "edit" }, edit); command_manager.register_command(std::vector{ "q", "quit" }, quit); command_manager.register_command(std::vector{ "w", "write" }, write_buffer); + command_manager.register_command(std::vector{ "b", "buffer" }, show_buffer); try {