From b2a82979e125de3026f7fa6292fe9b127308028f Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 17 Sep 2015 09:34:54 +0200 Subject: [PATCH] Can now move to next/previous tab using key-shortcuts. --- src/config.cc | 3 ++- src/files.h | 7 ++++--- src/menu.cc | 3 +++ src/window.cc | 15 ++++++++++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/config.cc b/src/config.cc index f503c30..f67cdbe 100644 --- a/src/config.cc +++ b/src/config.cc @@ -5,8 +5,8 @@ #include "files.h" #include "sourcefile.h" #include "singletons.h" +#include -#include //TODO: remove using namespace std; //TODO: remove MainConfig::MainConfig() { @@ -97,6 +97,7 @@ void MainConfig::update_config_file() { return; } catch(const std::exception &e) { + std::cerr << "Error reading json-file: " << e.what() << std::endl; cfg_ok=false; } cfg_ok&=check_config_file(default_cfg); diff --git a/src/files.h b/src/files.h index 0748c9d..0c03913 100644 --- a/src/files.h +++ b/src/files.h @@ -52,8 +52,6 @@ const std::string configjson = " \"save_as\": \"s\",\n" " \"preferences\": \"comma\",\n" " \"quit\": \"q\",\n" -" \"split_window\": \"s\",\n" -" \"close_tab\": \"w\",\n" " \"edit_copy\": \"c\",\n" " \"edit_cut\": \"x\",\n" " \"edit_paste\": \"v\",\n" @@ -70,7 +68,10 @@ const std::string configjson = " \"compile\": \"Return\",\n" " \"run_command\": \"Return\",\n" " \"kill_last_running\": \"Escape\",\n" -" \"force_kill_last_running\": \"Escape\"\n" +" \"force_kill_last_running\": \"Escape\",\n" +" \"next_tab\": \"Right\",\n" +" \"previous_tab\": \"Left\",\n" +" \"close_tab\": \"w\"\n" " },\n" " \"project\": {\n" #ifdef _WIN32 diff --git a/src/menu.cc b/src/menu.cc index 348bd39..e1b27da 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -61,6 +61,9 @@ Menu::Menu() { " \n" " \n" " \n" + " \n" + " \n" + " \n" " \n" " \n" " \n" diff --git a/src/window.cc b/src/window.cc index a347f92..a24214c 100644 --- a/src/window.cc +++ b/src/window.cc @@ -355,6 +355,19 @@ void Window::create_menu() { Singleton::info()->set_text(""); } }); + menu.action_group->add(Gtk::Action::create("WindowNextTab", "Next Tab"), Gtk::AccelKey(menu.key_map["next_tab"]), [this]() { + if(notebook.get_current_page()!=-1) { + notebook.open(notebook.get_view((notebook.get_current_page()+1)%notebook.size())->file_path); + } + }); + menu.action_group->add(Gtk::Action::create("WindowPreviousTab", "Previous Tab"), Gtk::AccelKey(menu.key_map["previous_tab"]), [this]() { + if(notebook.get_current_page()!=-1) { + int previous_page=notebook.get_current_page()-1; + if(previous_page<0) + previous_page=notebook.size()-1; + notebook.open(notebook.get_view(previous_page)->file_path); + } + }); menu.action_group->add(Gtk::Action::create("HelpAbout", "About"), [this] () { about.show(); about.present(); @@ -366,7 +379,7 @@ bool Window::on_key_press_event(GdkEventKey *event) { entry_box.hide(); } #ifdef __APPLE__ //For Apple's Command-left, right, up, down keys - else if((event->state & GDK_META_MASK)>0) { + else if((event->state & GDK_META_MASK)>0 && (event->state & GDK_MOD1_MASK)==0) { if(event->keyval==GDK_KEY_Left) { event->keyval=GDK_KEY_Home; event->state=event->state & GDK_SHIFT_MASK;