first commandline arg: window dimensions

[?]
Jun 7, 2022, 9:11 PM
46ASCE5K5QRO6BZNJPW4CJZCRVVG76S3GENIBGNGB352CP3DLDCQC

Dependencies

  • [2] NEXUNNCF extract a function
  • [3] Z4KNS42N to open a file without a terminal, drag it on!
  • [4] AVQ5MC5D finish uppercasing all globals
  • [5] 73OCE2MC after much struggle, a brute-force undo
  • [6] AVTNUQYR basic test-enabled framework
  • [7] XSLCFVFH .
  • [8] AD34IX2Z couple more tests
  • [9] AJB4LFRB try to maintain a reasonable line width
  • [10] OTIBCAUJ love2d scaffold

Change contents

  • replacement in main.lua at line 88
    [3.1738][2.8:39]()
    initialize_window_geometry()
    [3.1738]
    [3.47]
    if arg[1] == '-geometry' then
    initialize_window_geometry(arg[2])
    table.remove(arg, 2)
    table.remove(arg, 1)
    else
    initialize_window_geometry()
    end
  • replacement in main.lua at line 115
    [3.1320][2.64:384]()
    function initialize_window_geometry()
    -- maximize window
    love.window.setMode(0, 0) -- maximize
    App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
    -- shrink slightly to account for window decoration
    App.screen.width = App.screen.width-100
    App.screen.height = App.screen.height-100
    [3.1320]
    [2.384]
    function initialize_window_geometry(geometry_spec)
    local geometry_initialized
    if geometry_spec then
    geometry_initialized = parse_geometry_spec(geometry_spec)
    end
    if not geometry_initialized then
    -- maximize window
    love.window.setMode(0, 0) -- maximize
    App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
    -- shrink slightly to account for window decoration
    App.screen.width = App.screen.width-100
    App.screen.height = App.screen.height-100
    end
  • edit in main.lua at line 132
    [2.625]
    [2.625]
    end
    function parse_geometry_spec(geometry_spec)
    local width, height, x, y = geometry_spec:match('(%d+)x(%d+)%+(%d+)%+(%d+)')
    if width == nil then
    print('invalid geometry spec: '..geometry_spec)
    print('expected format: {width}x{height}+{x}+{y}')
    return false
    end
    App.screen.width = math.floor(tonumber(width))
    App.screen.height = math.floor(tonumber(height))
    App.screen.flags = {x=math.floor(tonumber(x)), y=math.floor(tonumber(y))}
    return true