Created
June 3, 2024 14:14
-
-
Save vigo/2b3207ccd0e72bda92806dc01f9b3f38 to your computer and use it in GitHub Desktop.
Arrange TextMate windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run | |
tell application "Finder" | |
set DesktopSize to bounds of window of desktop | |
set DesktopWidth to item 3 of DesktopSize | |
set DesktopHeight to item 4 of DesktopSize | |
end tell | |
tell application "TextMate" | |
activate | |
set WindowsList to (every window where visible is true) | |
set n to count of WindowsList | |
if n = 1 then return | |
if n > 4 then | |
say "sorry, max 4" | |
return | |
end if | |
set blockSize to DesktopWidth / 3 | |
set blockSizeW to DesktopWidth / 2 | |
set blockSizeH to DesktopHeight / 2 | |
if n = 2 then | |
set the bounds of the first window to {0, 0, blockSizeW, DesktopHeight} | |
set the bounds of the second window to {blockSizeW, 0, DesktopWidth, DesktopHeight} | |
end if | |
if n = 3 then | |
set the bounds of the first window to {0, 0, blockSize, DesktopHeight} | |
set the bounds of the second window to {blockSize, 0, (blockSize * 2), DesktopHeight} | |
set the bounds of the third window to {(blockSize * 2), 0, DesktopWidth, DesktopHeight} | |
end if | |
if n = 4 then | |
set the bounds of the first window to {0, 0, blockSizeW, blockSizeH} | |
set the bounds of the second window to {blockSizeW, 0, DesktopWidth, blockSizeH} | |
set the bounds of the third window to {0, blockSizeH, blockSizeW, DesktopHeight} | |
set the bounds of the fourth window to {blockSizeW, blockSizeH, DesktopWidth, DesktopHeight} | |
end if | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment