Browse Source

Can now move to next/previous tab using key-shortcuts.

merge-requests/365/head
eidheim 10 years ago
parent
commit
b2a82979e1
  1. 3
      src/config.cc
  2. 7
      src/files.h
  3. 3
      src/menu.cc
  4. 15
      src/window.cc

3
src/config.cc

@ -5,8 +5,8 @@
#include "files.h" #include "files.h"
#include "sourcefile.h" #include "sourcefile.h"
#include "singletons.h" #include "singletons.h"
#include <iostream>
#include <iostream> //TODO: remove
using namespace std; //TODO: remove using namespace std; //TODO: remove
MainConfig::MainConfig() { MainConfig::MainConfig() {
@ -97,6 +97,7 @@ void MainConfig::update_config_file() {
return; return;
} }
catch(const std::exception &e) { catch(const std::exception &e) {
std::cerr << "Error reading json-file: " << e.what() << std::endl;
cfg_ok=false; cfg_ok=false;
} }
cfg_ok&=check_config_file(default_cfg); cfg_ok&=check_config_file(default_cfg);

7
src/files.h

@ -52,8 +52,6 @@ const std::string configjson =
" \"save_as\": \"<primary><shift>s\",\n" " \"save_as\": \"<primary><shift>s\",\n"
" \"preferences\": \"<primary>comma\",\n" " \"preferences\": \"<primary>comma\",\n"
" \"quit\": \"<primary>q\",\n" " \"quit\": \"<primary>q\",\n"
" \"split_window\": \"<primary><alt>s\",\n"
" \"close_tab\": \"<primary>w\",\n"
" \"edit_copy\": \"<primary>c\",\n" " \"edit_copy\": \"<primary>c\",\n"
" \"edit_cut\": \"<primary>x\",\n" " \"edit_cut\": \"<primary>x\",\n"
" \"edit_paste\": \"<primary>v\",\n" " \"edit_paste\": \"<primary>v\",\n"
@ -70,7 +68,10 @@ const std::string configjson =
" \"compile\": \"<primary><shift>Return\",\n" " \"compile\": \"<primary><shift>Return\",\n"
" \"run_command\": \"<alt>Return\",\n" " \"run_command\": \"<alt>Return\",\n"
" \"kill_last_running\": \"<primary>Escape\",\n" " \"kill_last_running\": \"<primary>Escape\",\n"
" \"force_kill_last_running\": \"<primary><shift>Escape\"\n" " \"force_kill_last_running\": \"<primary><shift>Escape\",\n"
" \"next_tab\": \"<primary><alt>Right\",\n"
" \"previous_tab\": \"<primary><alt>Left\",\n"
" \"close_tab\": \"<primary>w\"\n"
" },\n" " },\n"
" \"project\": {\n" " \"project\": {\n"
#ifdef _WIN32 #ifdef _WIN32

3
src/menu.cc

@ -61,6 +61,9 @@ Menu::Menu() {
" <menuitem action=\"ProjectForceKillLastRunning\"/>\n" " <menuitem action=\"ProjectForceKillLastRunning\"/>\n"
" </menu>\n" " </menu>\n"
" <menu action=\"WindowMenu\">\n" " <menu action=\"WindowMenu\">\n"
" <menuitem action=\"WindowNextTab\"/>\n"
" <menuitem action=\"WindowPreviousTab\"/>\n"
" <separator/>\n"
" <menuitem action=\"WindowCloseTab\"/>\n" " <menuitem action=\"WindowCloseTab\"/>\n"
" </menu>\n" " </menu>\n"
" <menu action=\"PluginMenu\">\n" " <menu action=\"PluginMenu\">\n"

15
src/window.cc

@ -355,6 +355,19 @@ void Window::create_menu() {
Singleton::info()->set_text(""); 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] () { menu.action_group->add(Gtk::Action::create("HelpAbout", "About"), [this] () {
about.show(); about.show();
about.present(); about.present();
@ -366,7 +379,7 @@ bool Window::on_key_press_event(GdkEventKey *event) {
entry_box.hide(); entry_box.hide();
} }
#ifdef __APPLE__ //For Apple's Command-left, right, up, down keys #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) { if(event->keyval==GDK_KEY_Left) {
event->keyval=GDK_KEY_Home; event->keyval=GDK_KEY_Home;
event->state=event->state & GDK_SHIFT_MASK; event->state=event->state & GDK_SHIFT_MASK;

Loading…
Cancel
Save