Skip to content

Commit

Permalink
Update README add centering modes and full height or width at current…
Browse files Browse the repository at this point in the history
… size.
  • Loading branch information
jasonm23 committed Sep 13, 2015
1 parent f874d42 commit cb098cc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ The following rocks are required:

# Changelog

### Additional Quick Resize and Centering Macros

- Resize and Move modes are now just cursor operated, Vi and Emacs
shorcuts are removed, I did this assuming resize and move modes are
probably unused, and I want more keys in this layer/mode to add
macros. (If you are using hjkl or fbnp to resize or move, open an issue)

- Centered & Wide centered (full height) size + position within Resize and Moving Mode.
- Move or Resize Mode + C = Full height, half width window of display size, centered.
- Move or Resize Mode + B = Full height, 6/8ths width window of display size, centered.

- Full Width - Resize Mode + W
- Half Width - Resize Mode + H
- Full Height - Resize Mode + T

### Fix up 2015-07-20

- Cleaned up README
Expand Down
29 changes: 16 additions & 13 deletions grid.moon
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,25 @@ class Grid
snap: (win=hs.window.focusedWindow!) => if win\isStandard! then @set(win, @get(win), win\screen!)
snapAll: => for win in *hs.window.visibleWindows! do @snap(win)

resizeWider: (win=nil) => @adjustWindow(win, (f) -> {w: min(f.w + 1.0, @width - f.x)})
resizeThinner: (win=nil) => @adjustWindow(win, (f) -> {w: max(f.w - 1.0, 1.0)})
resizeShorter: (win=nil) => @adjustWindow(win, (f) -> {y: f.y, h: max(f.h - 1.0, 1.0)})
resizeTaller: (win=nil) => @adjustWindow(win, (f) -> {y: f.y, h: min(f.h + 1.0, @height - f.y)})
resizeWider: (win=nil) => @adjustWindow(win, (f) -> {w: min(f.w + 1.0, @width - f.x)})
resizeThinner: (win=nil) => @adjustWindow(win, (f) -> {w: max(f.w - 1.0, 1.0)})
resizeShorter: (win=nil) => @adjustWindow(win, (f) -> {y: f.y, h: max(f.h - 1.0, 1.0)})
resizeTaller: (win=nil) => @adjustWindow(win, (f) -> {y: f.y, h: min(f.h + 1.0, @height - f.y)})

wide: (win=nil) => @adjustWindow(win, (f) -> {x: 0, w: @width})
tall: (win=nil) => @adjustWindow(win, (f) -> {y: 0, h: @height})
fullWidth: (win=nil) => @adjustWindow(win, (f) -> {x: 0, w: @width})
halfWidth: (win=nil) => @adjustWindow(win, (f) -> {w: @width / 2})
centered: (win=nil) => @adjustWindow(win, (f) -> {x: @width / 4, h: @height, y: 0, w: @width / 2})
wideCentered: (win=nil) => @adjustWindow(win, (f) -> {x: @width / 8, h: @height, y: 0, w: (@width / 8) * 6})
fullHeight: (win=nil) => @adjustWindow(win, (f) -> {y: 0, h: @height})

moveUp: (win=nil) => @adjustWindow(win, (f) -> {y: max(0.0, f.y - 1.0)})
moveDown: (win=nil) => @adjustWindow(win, (f) -> {y: min(@height - f.h, f.y + 1.0)})
moveLeft: (win=nil) => @adjustWindow(win, (f) -> {x: max(0.0, f.x - 1.0)})
moveRight: (win=nil) => @adjustWindow(win, (f) -> {x: min(@width - f.w, f.x + 1.0)})
moveUp: (win=nil) => @adjustWindow(win, (f) -> {y: max(0.0, f.y - 1.0)})
moveDown: (win=nil) => @adjustWindow(win, (f) -> {y: min(@height - f.h, f.y + 1.0)})
moveLeft: (win=nil) => @adjustWindow(win, (f) -> {x: max(0.0, f.x - 1.0)})
moveRight: (win=nil) => @adjustWindow(win, (f) -> {x: min(@width - f.w, f.x + 1.0)})

positionTopLeft: (win=nil) => @adjustWindow(win, (f) -> {x: 0.0, y: 0.0})
positionBottomLeft: (win=nil) => @adjustWindow(win, (f) -> {x: 0.0, y: @height - f.h})
positionTopRight: (win=nil) => @adjustWindow(win, (f) -> {x: @width - f.w, y: 0.0})
positionTopLeft: (win=nil) => @adjustWindow(win, (f) -> {x: 0.0, y: 0.0})
positionBottomLeft: (win=nil) => @adjustWindow(win, (f) -> {x: 0.0, y: @height - f.h})
positionTopRight: (win=nil) => @adjustWindow(win, (f) -> {x: @width - f.w, y: 0.0})
positionBottomRight: (win=nil) => @adjustWindow(win, (f) -> {x: @width - f.w, y: @height - f.h})

{
Expand Down
28 changes: 9 additions & 19 deletions main.moon
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ hs.hotkey.bind mash, "W", Action.MoveToUnit({x: 0.5, y: 0.0, w: 0.5, h: 0.5}
hs.hotkey.bind mash, "A", Action.MoveToUnit({x: 0.0, y: 0.5, w: 0.5, h: 0.5})\perform
hs.hotkey.bind mash, "S", Action.MoveToUnit({x: 0.5, y: 0.5, w: 0.5, h: 0.5})\perform

hs.hotkey.bind mash, "0", grid1\tall
hs.hotkey.bind mash, "9", grid1\wide

modalMods = {"cmd", "alt"}

appsMode = HotkeyModal "Apps", modalMods, "a"
Expand Down Expand Up @@ -77,29 +74,22 @@ resizeMode\bind {}, "UP", grid1\resizeShorter
resizeMode\bind {}, "DOWN", grid1\resizeTaller
resizeMode\bind {}, "LEFT", grid1\resizeThinner
resizeMode\bind {}, "RIGHT", grid1\resizeWider
resizeMode\bind {}, "K", grid1\resizeShorter
resizeMode\bind {}, "J", grid1\resizeTaller
resizeMode\bind {}, "H", grid1\resizeThinner
resizeMode\bind {}, "L", grid1\resizeWider
resizeMode\bind {}, "P", grid1\resizeShorter
resizeMode\bind {}, "N", grid1\resizeTaller
resizeMode\bind {}, "B", grid1\resizeThinner
resizeMode\bind {}, "F", grid1\resizeWider
resizeMode\bind {}, "T", grid1\fullHeight
resizeMode\bind {}, "W", grid1\fullWidth
resizeMode\bind {}, "B", grid1\wideCentered
resizeMode\bind {}, "H", grid1\halfWidth
resizeMode\bind {}, "C", grid1\centered

resizeMode\bind {}, "M", moveMode\enter
resizeMode\bind {}, "RETURN", resizeMode\exit

moveMode\bind {}, "UP", grid1\moveUp
moveMode\bind {}, "DOWN", grid1\moveDown
moveMode\bind {}, "LEFT", grid1\moveLeft
moveMode\bind {}, "RIGHT", grid1\moveRight
moveMode\bind {}, "K", grid1\moveUp
moveMode\bind {}, "J", grid1\moveDown
moveMode\bind {}, "H", grid1\moveLeft
moveMode\bind {}, "L", grid1\moveRight
moveMode\bind {}, "P", grid1\moveUp
moveMode\bind {}, "N", grid1\moveDown
moveMode\bind {}, "B", grid1\moveLeft
moveMode\bind {}, "F", grid1\moveRight
moveMode\bind {}, "C", grid1\centered
moveMode\bind {}, "B", grid1\wideCentered

moveMode\bind {}, "R", resizeMode\enter
moveMode\bind {}, "RETURN", moveMode\exit

Expand Down

0 comments on commit cb098cc

Please sign in to comment.