Merge lines.love

This commit is contained in:
Kartik K. Agaram 2023-06-05 22:37:26 -07:00
commit 64c4015167
3 changed files with 22 additions and 8 deletions

View File

@ -229,7 +229,7 @@ end
function App.fake_key_release(key)
App.fake_keys_pressed[key] = nil
end
function App.modifier_down(key)
function App.key_down(key)
return App.fake_keys_pressed[key]
end
@ -444,7 +444,7 @@ function App.disable_tests()
App.getTime = love.timer.getTime
App.getClipboardText = love.system.getClipboardText
App.setClipboardText = love.system.setClipboardText
App.modifier_down = love.keyboard.isDown
App.key_down = love.keyboard.isDown
App.mouse_move = love.mouse.setPosition
App.mouse_down = love.mouse.isDown
App.mouse_x = love.mouse.getX

View File

@ -34,19 +34,19 @@ function App.any_modifier_down()
end
function App.ctrl_down()
return App.modifier_down('lctrl') or App.modifier_down('rctrl')
return App.key_down('lctrl') or App.key_down('rctrl')
end
function App.alt_down()
return App.modifier_down('lalt') or App.modifier_down('ralt')
return App.key_down('lalt') or App.key_down('ralt')
end
function App.shift_down()
return App.modifier_down('lshift') or App.modifier_down('rshift')
return App.key_down('lshift') or App.key_down('rshift')
end
function App.cmd_down()
return App.modifier_down('lgui') or App.modifier_down('rgui')
return App.key_down('lgui') or App.key_down('rgui')
end
function App.is_cursor_movement(key)

View File

@ -251,8 +251,16 @@ visible on screen.
### keyboard primitives
* `App.modifier_down(key)` -- returns `true` if the given key (doesn't
actually have to be just a modifier) is currently pressed.
* `App.is_cursor_movement(key)` -- return `true` if `key` is a cursor movement
key (arrow keys, page-up/down, home/end)
* `App.cmd_down()`, `App.ctrl_down`, `App.alt_down()`, `App.shift_down()` --
predicates for different modifier keys.
* `App.any_modifier_down()` -- returns `true` if any of the modifier keys is
currently pressed.
* `App.key_down(key)` -- returns `true` if the given key is currently pressed.
(Based on [LÖVE](https://love2d.org/wiki/love.keyboard.isDown).)
### interacting with files
@ -309,6 +317,12 @@ and [the Lua manual](https://www.lua.org/manual/5.1/manual.html#5.7).
* `App.setClipboardText(text)` -- stores the string `text` in the clipboard.
(Based on [LÖVE](https://love2d.org/wiki/love.system.setClipboardText).)
* `array.find(arr, elem)` -- scan table `arr` for `elem` assuming it's
organized as an array (just numeric indices).
* `array.any(arr, f)` -- scan table `arr` for any elements satisfying
predicate `f`. Return first such element or `false` if none.
There's much more I could include here; check out [the LÖVE manual](https://love2d.org/wiki)
and [the Lua manual](https://www.lua.org/manual/5.1/manual.html).