make a few names consistent with snake_case

This commit is contained in:
Kartik K. Agaram 2023-08-30 06:43:01 -07:00
parent ca4ad8a9e5
commit 7e97a2a1e7
4 changed files with 20 additions and 20 deletions

22
app.lua
View File

@ -169,12 +169,12 @@ function App.screen.check(y, expected_contents, msg)
check_eq(contents, expected_contents, msg) check_eq(contents, expected_contents, msg)
end end
-- If you access the time using App.getTime instead of love.timer.getTime, -- If you access the time using App.get_time instead of love.timer.getTime,
-- tests will be able to move the time back and forwards as needed using -- tests will be able to move the time back and forwards as needed using
-- App.wait_fake_time below. -- App.wait_fake_time below.
App.time = 1 App.time = 1
function App.getTime() function App.get_time()
return App.time return App.time
end end
function App.wait_fake_time(t) function App.wait_fake_time(t)
@ -185,16 +185,16 @@ function App.width(text)
return love.graphics.getFont():getWidth(text) return love.graphics.getFont():getWidth(text)
end end
-- If you access the clipboard using App.getClipboardText and -- If you access the clipboard using App.get_clipboard and App.set_clipboard
-- App.setClipboardText instead of love.system.getClipboardText and -- instead of love.system.getClipboardText and love.system.setClipboardText
-- love.system.setClipboardText respectively, tests will be able to manipulate -- respectively, tests will be able to manipulate the clipboard by
-- the clipboard by reading/writing App.clipboard. -- reading/writing App.clipboard.
App.clipboard = '' App.clipboard = ''
function App.getClipboardText() function App.get_clipboard()
return App.clipboard return App.clipboard
end end
function App.setClipboardText(s) function App.set_clipboard(s)
App.clipboard = s App.clipboard = s
end end
@ -417,9 +417,9 @@ function App.disable_tests()
end end
end end
end end
App.getTime = love.timer.getTime App.get_time = love.timer.getTime
App.getClipboardText = love.system.getClipboardText App.get_clipboard = love.system.getClipboardText
App.setClipboardText = love.system.setClipboardText App.set_clipboard = love.system.setClipboardText
App.key_down = love.keyboard.isDown App.key_down = love.keyboard.isDown
App.mouse_move = love.mouse.setPosition App.mouse_move = love.mouse.setPosition
App.mouse_down = love.mouse.isDown App.mouse_down = love.mouse.isDown

View File

@ -459,13 +459,13 @@ function edit.keychord_press(State, chord, key)
elseif chord == 'C-c' then elseif chord == 'C-c' then
local s = Text.selection(State) local s = Text.selection(State)
if s then if s then
App.setClipboardText(s) App.set_clipboard(s)
end end
elseif chord == 'C-x' then elseif chord == 'C-x' then
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
local s = Text.cut_selection(State, State.left, State.right) local s = Text.cut_selection(State, State.left, State.right)
if s then if s then
App.setClipboardText(s) App.set_clipboard(s)
end end
schedule_save(State) schedule_save(State)
elseif chord == 'C-v' then elseif chord == 'C-v' then
@ -474,7 +474,7 @@ function edit.keychord_press(State, chord, key)
-- and sometimes scroll when we didn't quite need to. -- and sometimes scroll when we didn't quite need to.
local before_line = State.cursor1.line local before_line = State.cursor1.line
local before = snapshot(State, before_line) local before = snapshot(State, before_line)
local clipboard_data = App.getClipboardText() local clipboard_data = App.get_clipboard()
for _,code in utf8.codes(clipboard_data) do for _,code in utf8.codes(clipboard_data) do
local c = utf8.char(code) local c = utf8.char(code)
if c == '\n' then if c == '\n' then

View File

@ -379,15 +379,15 @@ and [the Lua manual](https://www.lua.org/manual/5.1/manual.html#5.7).
### desiderata ### desiderata
* `App.getTime()` -- returns the number of seconds elapsed since some * `App.get_time()` -- returns the number of seconds elapsed since some
unspecified start time. unspecified start time.
(Based on [LÖVE](https://love2d.org/wiki/love.timer.getTime).) (Based on [LÖVE](https://love2d.org/wiki/love.timer.getTime).)
* `App.getClipboardText()` -- returns a string with the current clipboard * `App.get_clipboard()` -- returns a string with the current clipboard
contents. contents.
(Based on [LÖVE](https://love2d.org/wiki/love.system.getClipboardText).) (Based on [LÖVE](https://love2d.org/wiki/love.system.getClipboardText).)
* `App.setClipboardText(text)` -- stores the string `text` in the clipboard. * `App.set_clipboard(text)` -- stores the string `text` in the clipboard.
(Based on [LÖVE](https://love2d.org/wiki/love.system.setClipboardText).) (Based on [LÖVE](https://love2d.org/wiki/love.system.setClipboardText).)
* `array.find(arr, elem)` -- scan table `arr` for `elem` assuming it's * `array.find(arr, elem)` -- scan table `arr` for `elem` assuming it's

View File

@ -448,13 +448,13 @@ function edit.keychord_press(State, chord, key)
elseif chord == 'C-c' then elseif chord == 'C-c' then
local s = Text.selection(State) local s = Text.selection(State)
if s then if s then
App.setClipboardText(s) App.set_clipboard(s)
end end
elseif chord == 'C-x' then elseif chord == 'C-x' then
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
local s = Text.cut_selection(State, State.left, State.right) local s = Text.cut_selection(State, State.left, State.right)
if s then if s then
App.setClipboardText(s) App.set_clipboard(s)
end end
schedule_save(State) schedule_save(State)
elseif chord == 'C-v' then elseif chord == 'C-v' then
@ -463,7 +463,7 @@ function edit.keychord_press(State, chord, key)
-- and sometimes scroll when we didn't quite need to. -- and sometimes scroll when we didn't quite need to.
local before_line = State.cursor1.line local before_line = State.cursor1.line
local before = snapshot(State, before_line) local before = snapshot(State, before_line)
local clipboard_data = App.getClipboardText() local clipboard_data = App.get_clipboard()
for _,code in utf8.codes(clipboard_data) do for _,code in utf8.codes(clipboard_data) do
local c = utf8.char(code) local c = utf8.char(code)
if c == '\n' then if c == '\n' then