Skip to content

Instantly share code, notes, and snippets.

@sumikawa
Created January 29, 2017 05:49
Show Gist options
  • Save sumikawa/3665f98c7392d2dad8dc02a97999c7fd to your computer and use it in GitHub Desktop.
Save sumikawa/3665f98c7392d2dad8dc02a97999c7fd to your computer and use it in GitHub Desktop.
diff --git files/prefpane/checkbox.xml files/prefpane/checkbox.xml
index 152a9c6..df6156e 100644
--- files/prefpane/checkbox.xml
+++ files/prefpane/checkbox.xml
@@ -1018,6 +1018,14 @@
<name>Remap Command_L to Option_L</name>
<sysctl>remap.app_term_commandL2optionL</sysctl>
</item>
+ <item>
+ <name>Remap Ctrl+Tab to Command+Shift+BracketRight</name>
+ <sysctl>remap.app_term_ctrlTab2commandShiftBracketright</sysctl>
+ </item>
+ <item>
+ <name>Remap Ctrl+Shift+Tab to Command+Shift+BracketLeft</name>
+ <sysctl>remap.app_term_ctrlShiftTab2commandShiftBracketleft</sysctl>
+ </item>
</list>
</item>
</list>
diff --git files/share/reset files/share/reset
index 1344d56..f69d37a 100644
--- files/share/reset
+++ files/share/reset
@@ -182,6 +182,8 @@ option.keypad2spaces_modifier_shift 0
remap.app_vm_commandspace2optionbackquote 0
remap.app_finder_return2commandO 0
remap.app_term_commandL2optionL 0
+remap.app_term_ctrlTab2commandShiftBracketright 0
+remap.app_term_ctrlShiftTab2commandShiftBracketleft 0
remap.qwerty2colemak 0
remap.pc_application2commandL 0
remap.pc_application2controlL 0
diff --git src/core/kext/remap.cpp src/core/kext/remap.cpp
index 5452e97..6bc2bee 100644
--- src/core/kext/remap.cpp
+++ src/core/kext/remap.cpp
@@ -1862,6 +1862,53 @@ namespace org_pqrs_KeyRemap4MacBook {
}
}
+ void
+ remap_app_term_ctrlShiftTab2commandShiftBracketleft(const RemapParams &params)
+ {
+ static ModifierCanceling mc_controlL;
+ static ModifierCanceling mc_controlR;
+
+ if (! config.remap_app_term_ctrlShiftTab2commandShiftBracketleft) return;
+
+ if (! (params.activeApplicationInfo)->is_terminal) return;
+
+ if (params.ex_origKey != KeyCode::TAB) return;
+
+ if (allFlagStatus.isHeldDown_control() && allFlagStatus.isHeldDown_shift()) {
+ if (allFlagStatus.controlL.isHeldDown()) {
+ mc_controlL.keyRelease(params, ModifierFlag::CONTROL_L);
+ } else {
+ mc_controlR.keyRelease(params, ModifierFlag::CONTROL_R);
+ }
+ allFlagStatus.commandL.temporary_increase();
+ *(params.key) = KeyCode::BRACKET_LEFT;
+ }
+ }
+
+ void
+ remap_app_term_ctrlTab2commandShiftBracketright(const RemapParams &params)
+ {
+ static ModifierCanceling mc_controlL;
+ static ModifierCanceling mc_controlR;
+
+ if (! config.remap_app_term_ctrlTab2commandShiftBracketright) return;
+
+ if (! (params.activeApplicationInfo)->is_terminal) return;
+
+ if (params.ex_origKey != KeyCode::TAB) return;
+
+ if (allFlagStatus.isHeldDown_control()) {
+ if (allFlagStatus.controlL.isHeldDown()) {
+ mc_controlL.keyRelease(params, ModifierFlag::CONTROL_L);
+ } else {
+ mc_controlR.keyRelease(params, ModifierFlag::CONTROL_R);
+ }
+ allFlagStatus.shiftL.temporary_increase();
+ allFlagStatus.commandL.temporary_increase();
+ *(params.key) = KeyCode::BRACKET_RIGHT;
+ }
+ }
+
// ----------------------------------------
void
remap_qwerty2colemak(const RemapParams &params)
@@ -2748,6 +2795,8 @@ org_pqrs_KeyRemap4MacBook::remap_core(const RemapParams &params)
// *** Note: we need to call remap_app_term_commandL2optionL as possible late. ***
// *** If any *2commandL remappings is enable, remap_app_term_commandL2optionL needs to handle it ***
remap_app_term_commandL2optionL(params);
+ remap_app_term_ctrlShiftTab2commandShiftBracketleft(params);
+ remap_app_term_ctrlTab2commandShiftBracketright(params);
// ------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment