From 15460916962835ef650c705579de05151d116a5a Mon Sep 17 00:00:00 2001 From: joten Date: Wed, 28 Jan 2015 23:45:58 +0100 Subject: [PATCH] Adopted franckspike's more general Manager_loop --- doc/CREDITS.md | 2 ++ src/Manager.ahk | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/CREDITS.md b/doc/CREDITS.md index 7a09834..3a1a4e6 100644 --- a/doc/CREDITS.md +++ b/doc/CREDITS.md @@ -15,6 +15,7 @@ summarizes these sources (of ideas or code): + Window information handling patches - memory leaks - flickering windows +* [morinted](https://github.com/morinted): [Read in sound volume](https://github.com/fuhsjr00/bug.n/issues/11) #### Ideas or concepts @@ -24,6 +25,7 @@ summarizes these sources (of ideas or code): #### Code snippets +* [franckspike](https://github.com/franckspike): [More general loop function](https://github.com/franckspike/bug.n/commit/e4e615512b363e8c342bf02cf9067cfeb4cc5d57#diff-e42236c27dedd9350fa8c9b9654fd485) * fures: System + Network monitor - with net history graph (AutoHotkey forum) * maestrith: Script Writer (github.com/maestrith/Script_Writer) * PhiLho: [AC/Battery status](http://www.autohotkey.com/forum/topic7633.html) diff --git a/src/Manager.ahk b/src/Manager.ahk index 8e5b102..07b0371 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -281,17 +281,17 @@ Manager_lockWorkStation() } ;; Unambiguous: Re-use WIN+L as a hotkey in bug.n (http://www.autohotkey.com/community/viewtopic.php?p=500903&sid=eb3c7a119259b4015ff045ef80b94a81#p500903) -Manager_loop(index, increment, lowerBound, upperBound) -{ - index += increment - If (index > upperBound) - index := lowerBound - If (index < lowerBound) - index := upperBound - If (upperBound = 0) - index := 0 +Manager_loop(index, increment, lowerBound, upperBound) { + If (upperBound <= 0) Or (upperBound < lowerBound) Or (upperBound = 0) + Return, 0 - Return, index + numberOfIndexes := upperBound - lowerBound + 1 + lowerBoundBasedIndex := index - lowerBound + lowerBoundBasedIndex := Mod(lowerBoundBasedIndex + increment, numberOfIndexes) + If (lowerBoundBasedIndex < 0) + lowerBoundBasedIndex += numberOfIndexes + + Return, lowerBound + lowerBoundBasedIndex } Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hideTitle, action = "")