Implement wrap around for the damn 0 (should be 123..90 not 0123..9)

This commit is contained in:
2025-01-03 20:02:27 +01:00
parent 6a4e25cdb8
commit 4aaedac17c

View File

@@ -136,6 +136,9 @@ internal static class Program {
}
private static void Swap(int index) {
index = (index - 1) % NumProc;
if (index < 0) index = NumProc - 1;
if (index >= NumProc) return;
Console.WriteLine($"Swapping window at index {index}");
var process = GetForegroundProcess();
if (process == null) return;
@@ -172,6 +175,8 @@ internal static class Program {
}
private static void TabTo(int index) {
index = (index - 1) % NumProc;
if (index < 0) index = NumProc - 1;
if (index >= NumProc) return;
Console.WriteLine($"Tab to window at index {index}");
@@ -203,8 +208,8 @@ internal static class Program {
for (int i = 0; i < NumProc; i++) {
windows[i] = null;
HotKeyManager.RegisterHotKey(Keys.D1 + i, KeyModifiers.Alt);
HotKeyManager.RegisterHotKey(Keys.D1 + i, KeyModifiers.Alt | KeyModifiers.Shift);
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt);
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt | KeyModifiers.Shift);
}
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
@@ -217,10 +222,10 @@ internal static class Program {
}
if (e.Modifiers == KeyModifiers.Alt) {
TabTo(e.Key - Keys.D1);
TabTo(e.Key - Keys.D0);
}
else if (e.Modifiers == (KeyModifiers.Alt | KeyModifiers.Shift)) {
Swap(e.Key - Keys.D1);
Swap(e.Key - Keys.D0);
}
}