<commit_before>require 'utils'

Action = {}
Action.__index = Action

function Action.Close()
  return function(win) win:close() end
end

function Action.Maximize()
  return function(win) win:maximize() end
end

function Action.FullScreen()
  return function(win) win:setFullScreen(true) end
end

function Action.Snap()
  return function(win) if not utils.isFullScreen(win) then hs.grid.snap(win) end end
end

function Action.MoveToScreen(screenIndex)
  return function(win) utils.pushToScreen(win, hs.screen.allScreens()[screenIndex]) end
end

function Action.MoveToNextScreen()
  return function(win) utils.pushToScreen(win, win:screen():next()) end
end

function Action.MoveToPreviousScreen()
  return function(win) utils.pushToScreen(win, win:screen():previous()) end
end

function Action.MoveToUnit(x, y, w, h)
  return function(win)
    if not utils.isFullScreen(win) then
      win:moveToUnit({x = x, y = y, w = w, h = h}):ensureIsInScreenBounds()
    end
  end
end

function Action.PositionTopLeft()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft({x = screenFrame.x, y = screenFrame.y})
  end
end

function Action.PositionBottomLeft()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft({x = screenFrame.x, y = screenFrame.y + screenFrame.h - win:size().h})
  end
end

function Action.PositionTopRight()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft({x = screenFrame.x + screenFrame.w - win:size().w, y = screenFrame.y})
  end
end

function Action.PositionBottomRight()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft({x = screenFrame.x + screenFrame.w - win:size().w, y = screenFrame.y + screenFrame.h - win:size().h})
  end
end

function Action.Resize(w, h)
  return function(win)
    local screenFrame = win:screen():frame()
    win:setSize({w = w * screenFrame.w, h = h * screenFrame.h})
  end
end

function Action.EnsureIsInScreenBounds()
  return function(win)
    win:ensureIsInScreenBounds()
  end
end

----------------------------------------------------------------------------------------------------

return Action<commit_msg>use geometry functions to create objects<commit_after>require 'utils'

Action = {}
Action.__index = Action

function Action.Close()
  return function(win) win:close() end
end

function Action.Maximize()
  return function(win) win:maximize() end
end

function Action.FullScreen()
  return function(win) win:setFullScreen(true) end
end

function Action.Snap()
  return function(win) if not utils.isFullScreen(win) then hs.grid.snap(win) end end
end

function Action.MoveToScreen(screenIndex)
  return function(win) utils.pushToScreen(win, hs.screen.allScreens()[screenIndex]) end
end

function Action.MoveToNextScreen()
  return function(win) utils.pushToScreen(win, win:screen():next()) end
end

function Action.MoveToPreviousScreen()
  return function(win) utils.pushToScreen(win, win:screen():previous()) end
end

function Action.MoveToUnit(x, y, w, h)
  return function(win)
    if not utils.isFullScreen(win) then
      win:moveToUnit(hs.geometry.rect(x, y, w, h)):ensureIsInScreenBounds()
    end
  end
end

function Action.PositionTopLeft()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft(hs.geometry.point(screenFrame.x, screenFrame.y))
  end
end

function Action.PositionBottomLeft()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft(hs.geometry.point(screenFrame.x, screenFrame.y + screenFrame.h - win:size().h))
  end
end

function Action.PositionTopRight()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft(hs.geometry.point(screenFrame.x + screenFrame.w - win:size().w, screenFrame.y))
  end
end

function Action.PositionBottomRight()
  return function(win)
    local screenFrame = win:screen():frame()
    win:setTopLeft(hs.geometry.point(screenFrame.x + screenFrame.w - win:size().w, screenFrame.y + screenFrame.h - win:size().h))
  end
end

function Action.Resize(w, h)
  return function(win)
    local screenFrame = win:screen():frame()
    win:setSize(hs.geometry.size(w * screenFrame.w, h * screenFrame.h))
  end
end

function Action.EnsureIsInScreenBounds()
  return function(win)
    win:ensureIsInScreenBounds()
  end
end

----------------------------------------------------------------------------------------------------

return Action
{'fraction_non_alphanumeric': 0.16327443524938492, 'fraction_numerical': 0.0, 'mean_word_length': 3.871459694989107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2908908', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1390, 'n_words': 328}