about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Manual_tests.md3
-rw-r--r--app.lua14
-rw-r--r--commands.lua4
-rw-r--r--drawing.lua10
-rw-r--r--drawing_tests.lua42
-rw-r--r--edit.lua42
-rw-r--r--keychord.lua2
-rw-r--r--log_browser.lua10
-rw-r--r--main.lua26
-rw-r--r--run.lua18
-rw-r--r--source.lua40
-rw-r--r--source_edit.lua46
-rw-r--r--source_text.lua6
-rw-r--r--source_text_tests.lua161
-rw-r--r--text.lua6
-rw-r--r--text_tests.lua161
16 files changed, 280 insertions, 311 deletions
diff --git a/Manual_tests.md b/Manual_tests.md
index 80ddc6c..45154e3 100644
--- a/Manual_tests.md
+++ b/Manual_tests.md
@@ -46,6 +46,9 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking.
 * Like any high-level language, it's easy to accidentally alias two non-scalar
   variables. I wish there was a way to require copy when assigning.
 
+* I wish I could require pixel coordinates to integers. The editor defensively
+  converts input margins to integers.
+
 * My test harness automatically runs `test_*` methods -- but only at the
   top-level. I wish there was a way to raise warnings if someone defines such
   a function inside a dict somewhere.
diff --git a/app.lua b/app.lua
index 212f755..e717220 100644
--- a/app.lua
+++ b/app.lua
@@ -144,7 +144,7 @@ function App.initialize_for_test()
   App.screen.init({width=100, height=50})
   App.screen.contents = {}  -- clear screen
   App.filesystem = {}
-  App.fake_key_pressed = {}
+  App.fake_keys_pressed = {}
   App.fake_mouse_state = {x=-1, y=-1}
   if App.initialize_globals then App.initialize_globals() end
 end
@@ -237,15 +237,15 @@ function App.setClipboardText(s)
   App.clipboard = s
 end
 
-App.fake_key_pressed = {}
+App.fake_keys_pressed = {}
 function App.fake_key_press(key)
-  App.fake_key_pressed[key] = true
+  App.fake_keys_pressed[key] = true
 end
 function App.fake_key_release(key)
-  App.fake_key_pressed[key] = nil
+  App.fake_keys_pressed[key] = nil
 end
 function App.modifier_down(key)
-  return App.fake_key_pressed[key]
+  return App.fake_keys_pressed[key]
 end
 
 App.fake_mouse_state = {x=-1, y=-1}  -- x,y always set
@@ -286,7 +286,7 @@ end
 -- not all keys are textinput
 -- TODO: handle chords of multiple keys
 function App.run_after_keychord(chord)
-  App.keychord_pressed(chord)
+  App.keychord_press(chord)
   App.keyreleased(chord)
   App.screen.contents = {}
   App.draw()
@@ -397,7 +397,7 @@ function App.disable_tests()
   App.run_after_mouse_click = nil
   App.run_after_mouse_press = nil
   App.run_after_mouse_release = nil
-  App.fake_key_pressed = nil
+  App.fake_keys_pressed = nil
   App.fake_key_press = nil
   App.fake_key_release = nil
   App.fake_mouse_state = nil
diff --git a/commands.lua b/commands.lua
index dd096ac..b1ac5ab 100644
--- a/commands.lua
+++ b/commands.lua
@@ -151,7 +151,7 @@ function reset_file_navigator()
   File_navigation.candidates = File_navigation.all_candidates
 end
 
-function keychord_pressed_on_file_navigator(chord, key)
+function keychord_press_on_file_navigator(chord, key)
   log(2, 'file navigator: '..chord)
   log(2, {name='file_navigator_state', files=File_navigation.candidates, index=File_navigation.index})
   if chord == 'escape' then
@@ -289,7 +289,7 @@ function file_index(fy, fx, fwidth)
   return best_guess
 end
 
-function textinput_on_file_navigator(t)
+function text_input_on_file_navigator(t)
   File_navigation.filter = File_navigation.filter..t
   File_navigation.candidates = source.file_navigator_candidates()
 end
diff --git a/drawing.lua b/drawing.lua
index 0343f85..99193c6 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -127,7 +127,7 @@ function Drawing.draw_pending_shape(drawing, top, left,right)
   local mx = Drawing.coord(pmx-left, width)
   local my = Drawing.coord(pmy-top, width)
   -- recreate pixels from coords to precisely mimic how the drawing will look
-  -- after mouse_released
+  -- after mouse_release
   pmx,pmy = px(mx), py(my)
   local shape = drawing.pending
   if shape.mode == nil then
@@ -218,7 +218,7 @@ function Drawing.in_drawing(drawing, line_cache, x,y, left,right)
   return y >= line_cache.starty and y < line_cache.starty + Drawing.pixels(drawing.h, width) and x >= left and x < right
 end
 
-function Drawing.mouse_pressed(State, drawing_index, x,y, mouse_button)
+function Drawing.mouse_press(State, drawing_index, x,y, mouse_button)
   local drawing = State.lines[drawing_index]
   local line_cache = State.line_cache[drawing_index]
   local cx = Drawing.coord(x-State.left, State.width)
@@ -235,7 +235,7 @@ function Drawing.mouse_pressed(State, drawing_index, x,y, mouse_button)
     local j = Drawing.find_or_insert_point(drawing.points, cx, cy, State.width)
     drawing.pending = {mode=State.current_drawing_mode, center=j}
   elseif State.current_drawing_mode == 'move' then
-    -- all the action is in mouse_released
+    -- all the action is in mouse_release
   elseif State.current_drawing_mode == 'name' then
     -- nothing
   else
@@ -292,7 +292,7 @@ function Drawing.relax_constraints(drawing, p)
   end
 end
 
-function Drawing.mouse_released(State, x,y, mouse_button)
+function Drawing.mouse_release(State, x,y, mouse_button)
   if State.current_drawing_mode == 'move' then
     State.current_drawing_mode = State.previous_drawing_mode
     State.previous_drawing_mode = nil
@@ -389,7 +389,7 @@ function Drawing.mouse_released(State, x,y, mouse_button)
   end
 end
 
-function Drawing.keychord_pressed(State, chord)
+function Drawing.keychord_press(State, chord)
   if chord == 'C-p' and not App.mouse_down(1) then
     State.current_drawing_mode = 'freehand'
   elseif App.mouse_down(1) and chord == 'l' then
diff --git a/drawing_tests.lua b/drawing_tests.lua
index feadd85..12e9329 100644
--- a/drawing_tests.lua
+++ b/drawing_tests.lua
@@ -165,7 +165,7 @@ function test_keys_do_not_affect_shape_when_mouse_up()
   edit.run_after_keychord(Editor_state, 'o')
   -- no change to drawing mode
   check_eq(Editor_state.current_drawing_mode, 'line', 'F - test_keys_do_not_affect_shape_when_mouse_up/drawing_mode')
-  -- no change to text either because we didn't run the textinput event
+  -- no change to text either because we didn't run the text_input event
 end
 
 function test_draw_circle_mid_stroke()
@@ -185,7 +185,7 @@ function test_draw_circle_mid_stroke()
   -- draw a circle
   App.mouse_move(Editor_state.left+4, Editor_state.top+Drawing_padding_top+4)  -- hover on drawing
   edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
-  edit.run_after_textinput(Editor_state, 'o')
+  edit.run_after_text_input(Editor_state, 'o')
   edit.run_after_mouse_release(Editor_state, Editor_state.left+35+30, Editor_state.top+Drawing_padding_top+36, 1)
   local drawing = Editor_state.lines[1]
   check_eq(#drawing.shapes, 1, 'F - test_draw_circle_mid_stroke/#shapes')
@@ -214,7 +214,7 @@ function test_draw_arc()
   -- draw an arc
   edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
   App.mouse_move(Editor_state.left+35+30, Editor_state.top+Drawing_padding_top+36)
-  edit.run_after_textinput(Editor_state, 'a')  -- arc mode
+  edit.run_after_text_input(Editor_state, 'a')  -- arc mode
   edit.run_after_mouse_release(Editor_state, Editor_state.left+35+50, Editor_state.top+Drawing_padding_top+36+50, 1)  -- 45°
   local drawing = Editor_state.lines[1]
   check_eq(#drawing.shapes, 1, 'F - test_draw_arc/#shapes')
@@ -245,10 +245,10 @@ function test_draw_polygon()
   check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_polygon/baseline/#shapes')
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
-  edit.run_after_textinput(Editor_state, 'g')  -- polygon mode
+  edit.run_after_text_input(Editor_state, 'g')  -- polygon mode
   -- second point
   App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36)
-  edit.run_after_textinput(Editor_state, 'p')  -- add point
+  edit.run_after_text_input(Editor_state, 'p')  -- add point
   -- final point
   edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+26, 1)
   local drawing = Editor_state.lines[1]
@@ -284,13 +284,13 @@ function test_draw_rectangle()
   check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_rectangle/baseline/#shapes')
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
-  edit.run_after_textinput(Editor_state, 'r')  -- rectangle mode
+  edit.run_after_text_input(Editor_state, 'r')  -- rectangle mode
   -- second point/first edge
   App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   -- override second point/first edge
   App.mouse_move(Editor_state.left+75, Editor_state.top+Drawing_padding_top+76)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   -- release (decides 'thickness' of rectangle perpendicular to first edge)
   edit.run_after_mouse_release(Editor_state, Editor_state.left+15, Editor_state.top+Drawing_padding_top+26, 1)
   local drawing = Editor_state.lines[1]
@@ -329,13 +329,13 @@ function test_draw_rectangle_intermediate()
   check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_rectangle_intermediate/baseline/#shapes')
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
-  edit.run_after_textinput(Editor_state, 'r')  -- rectangle mode
+  edit.run_after_text_input(Editor_state, 'r')  -- rectangle mode
   -- second point/first edge
   App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   -- override second point/first edge
   App.mouse_move(Editor_state.left+75, Editor_state.top+Drawing_padding_top+76)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   local drawing = Editor_state.lines[1]
   check_eq(#drawing.points, 3, 'F - test_draw_rectangle_intermediate/#points')  -- currently includes every point added
   local pending = drawing.pending
@@ -366,13 +366,13 @@ function test_draw_square()
   check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_square/baseline/#shapes')
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
-  edit.run_after_textinput(Editor_state, 's')  -- square mode
+  edit.run_after_text_input(Editor_state, 's')  -- square mode
   -- second point/first edge
   App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   -- override second point/first edge
   App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+66)
-  edit.run_after_textinput(Editor_state, 'p')
+  edit.run_after_text_input(Editor_state, 'p')
   -- release (decides which side of first edge to draw square on)
   edit.run_after_mouse_release(Editor_state, Editor_state.left+15, Editor_state.top+Drawing_padding_top+26, 1)
   local drawing = Editor_state.lines[1]
@@ -421,7 +421,7 @@ function test_name_point()
   -- enter 'name' mode without moving the mouse
   edit.run_after_keychord(Editor_state, 'C-n')
   check_eq(Editor_state.current_drawing_mode, 'name', 'F - test_name_point/mode:1')
-  edit.run_after_textinput(Editor_state, 'A')
+  edit.run_after_text_input(Editor_state, 'A')
   check_eq(p2.name, 'A', 'F - test_name_point')
   -- still in 'name' mode
   check_eq(Editor_state.current_drawing_mode, 'name', 'F - test_name_point/mode:2')
@@ -594,13 +594,13 @@ function test_delete_point_from_polygon()
   edit.draw(Editor_state)
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
-  edit.run_after_textinput(Editor_state, 'g')  -- polygon mode
+  edit.run_after_text_input(Editor_state, 'g')  -- polygon mode
   -- second point
   App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36)
-  edit.run_after_textinput(Editor_state, 'p')  -- add point
+  edit.run_after_text_input(Editor_state, 'p')  -- add point
   -- third point
   App.mouse_move(Editor_state.left+35, Editor_state.top+Drawing_padding_top+26)
-  edit.run_after_textinput(Editor_state, 'p')  -- add point
+  edit.run_after_text_input(Editor_state, 'p')  -- add point
   -- fourth point
   edit.run_after_mouse_release(Editor_state, Editor_state.left+14, Editor_state.top+Drawing_padding_top+16, 1)
   local drawing = Editor_state.lines[1]
@@ -626,10 +626,10 @@ function test_delete_point_from_polygon()
   edit.draw(Editor_state)
   -- first point
   edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
-  edit.run_after_textinput(Editor_state, 'g')  -- polygon mode
+  edit.run_after_text_input(Editor_state, 'g')  -- polygon mode
   -- second point
   App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36)
-  edit.run_after_textinput(Editor_state, 'p')  -- add point
+  edit.run_after_text_input(Editor_state, 'p')  -- add point
   -- third point
   edit.run_after_mouse_release(Editor_state, Editor_state.left+14, Editor_state.top+Drawing_padding_top+16, 1)
   local drawing = Editor_state.lines[1]
@@ -671,7 +671,7 @@ function test_undo_name_point()
 --?   print('a', Editor_state.lines.current_drawing)
   -- enter 'name' mode without moving the mouse
   edit.run_after_keychord(Editor_state, 'C-n')
-  edit.run_after_textinput(Editor_state, 'A')
+  edit.run_after_text_input(Editor_state, 'A')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(p2.name, 'A', 'F - test_undo_name_point/baseline')
   check_eq(#Editor_state.history, 3, 'F - test_undo_name_point/baseline/history:2')
diff --git a/edit.lua b/edit.lua
index 4e8cec6..86c15cf 100644
--- a/edit.lua
+++ b/edit.lua
@@ -55,8 +55,8 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
     em = App.newText(love.graphics.getFont(), 'm'),  -- widest possible character width
 
     top = top,
-    left = left,
-    right = right,
+    left = math.floor(left),
+    right = math.floor(right),
     width = right-left,
 
     filename = love.filesystem.getUserDirectory()..'/lines.txt',  -- '/' should work even on Windows
@@ -124,7 +124,7 @@ function edit.quit(State)
   end
 end
 
-function edit.mouse_pressed(State, x,y, mouse_button)
+function edit.mouse_press(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print('press', State.selection1.line, State.selection1.pos)
   for line_index,line in ipairs(State.lines) do
@@ -151,7 +151,7 @@ function edit.mouse_pressed(State, x,y, mouse_button)
   end
 end
 
-function edit.mouse_released(State, x,y, mouse_button)
+function edit.mouse_release(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print('release')
   for line_index,line in ipairs(State.lines) do
@@ -179,19 +179,19 @@ function edit.mouse_released(State, x,y, mouse_button)
 --?   print('selection:', State.selection1.line, State.selection1.pos)
 end
 
-function edit.textinput(State, t)
+function edit.text_input(State, t)
   if State.search_term then
     State.search_term = State.search_term..t
     State.search_text = nil
     Text.search_next(State)
   else
     for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    Text.textinput(State, t)
+    Text.text_input(State, t)
   end
   schedule_save(State)
 end
 
-function edit.keychord_pressed(State, chord, key)
+function edit.keychord_press(State, chord, key)
   if State.selection1.line and
       -- printable character created using shift key => delete selection
       -- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys)
@@ -307,11 +307,11 @@ function edit.keychord_pressed(State, chord, key)
   -- dispatch to text
   else
     for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    Text.keychord_pressed(State, chord)
+    Text.keychord_press(State, chord)
   end
 end
 
-function edit.key_released(State, key, scancode)
+function edit.key_release(State, key, scancode)
 end
 
 function edit.update_font_settings(State, font_height)
@@ -339,21 +339,21 @@ function edit.initialize_test_state()
       15)  -- line height
 end
 
--- all textinput events are also keypresses
+-- all text_input events are also keypresses
 -- TODO: handle chords of multiple keys
-function edit.run_after_textinput(State, t)
-  edit.keychord_pressed(State, t)
-  edit.textinput(State, t)
-  edit.key_released(State, t)
+function edit.run_after_text_input(State, t)
+  edit.keychord_press(State, t)
+  edit.text_input(State, t)
+  edit.key_release(State, t)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
 end
 
--- not all keys are textinput
+-- not all keys are text_input
 function edit.run_after_keychord(State, chord)
-  edit.keychord_pressed(State, chord)
-  edit.key_released(State, chord)
+  edit.keychord_press(State, chord)
+  edit.key_release(State, chord)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -361,9 +361,9 @@ end
 
 function edit.run_after_mouse_click(State, x,y, mouse_button)
   App.fake_mouse_press(x,y, mouse_button)
-  edit.mouse_pressed(State, x,y, mouse_button)
+  edit.mouse_press(State, x,y, mouse_button)
   App.fake_mouse_release(x,y, mouse_button)
-  edit.mouse_released(State, x,y, mouse_button)
+  edit.mouse_release(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -371,7 +371,7 @@ end
 
 function edit.run_after_mouse_press(State, x,y, mouse_button)
   App.fake_mouse_press(x,y, mouse_button)
-  edit.mouse_pressed(State, x,y, mouse_button)
+  edit.mouse_press(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -379,7 +379,7 @@ end
 
 function edit.run_after_mouse_release(State, x,y, mouse_button)
   App.fake_mouse_release(x,y, mouse_button)
-  edit.mouse_released(State, x,y, mouse_button)
+  edit.mouse_release(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
diff --git a/keychord.lua b/keychord.lua
index 7be57d2..3b43519 100644
--- a/keychord.lua
+++ b/keychord.lua
@@ -8,7 +8,7 @@ function App.keypressed(key, scancode, isrepeat)
     return
   end
   -- include the modifier(s) when the non-modifer is pressed
-  App.keychord_pressed(App.combine_modifiers(key), key)
+  App.keychord_press(App.combine_modifiers(key), key)
 end
 
 function App.combine_modifiers(key)
diff --git a/log_browser.lua b/log_browser.lua
index 91f02eb..76596f2 100644
--- a/log_browser.lua
+++ b/log_browser.lua
@@ -194,7 +194,7 @@ end
 function log_browser.quit(State)
 end
 
-function log_browser.mouse_pressed(State, x,y, mouse_button)
+function log_browser.mouse_press(State, x,y, mouse_button)
   local line_index = log_browser.line_index(State, x,y)
   if line_index == nil then
     -- below lower margin
@@ -262,13 +262,13 @@ function log_browser.line_index(State, mx,my)
   end
 end
 
-function log_browser.mouse_released(State, x,y, mouse_button)
+function log_browser.mouse_release(State, x,y, mouse_button)
 end
 
-function log_browser.textinput(State, t)
+function log_browser.text_input(State, t)
 end
 
-function log_browser.keychord_pressed(State, chord, key)
+function log_browser.keychord_press(State, chord, key)
   -- move
   if chord == 'up' then
     while State.screen_top1.line > 1 do
@@ -319,5 +319,5 @@ function log_browser.height(State, line_index)
   end
 end
 
-function log_browser.keyreleased(State, key, scancode)
+function log_browser.key_release(State, key, scancode)
 end
diff --git a/main.lua b/main.lua
index e9a7da5..34ece94 100644
--- a/main.lua
+++ b/main.lua
@@ -107,9 +107,9 @@ end
 
 function App.filedropped(file)
   if Current_app == 'run' then
-    if run.filedropped then run.filedropped(file) end
+    if run.file_drop then run.file_drop(file) end
   elseif Current_app == 'source' then
-    if source.filedropped then source.filedropped(file) end
+    if source.file_drop then source.file_drop(file) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -154,7 +154,7 @@ function App.update(dt)
   end
 end
 
-function App.keychord_pressed(chord, key)
+function App.keychord_press(chord, key)
   -- ignore events for some time after window in focus (mostly alt-tab)
   if Current_time < Last_focus_time + 0.01 then
     return
@@ -184,9 +184,9 @@ function App.keychord_pressed(chord, key)
     return
   end
   if Current_app == 'run' then
-    if run.keychord_pressed then run.keychord_pressed(chord, key) end
+    if run.keychord_press then run.keychord_press(chord, key) end
   elseif Current_app == 'source' then
-    if source.keychord_pressed then source.keychord_pressed(chord, key) end
+    if source.keychord_press then source.keychord_press(chord, key) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -199,9 +199,9 @@ function App.textinput(t)
   end
   --
   if Current_app == 'run' then
-    if run.textinput then run.textinput(t) end
+    if run.text_input then run.text_input(t) end
   elseif Current_app == 'source' then
-    if source.textinput then source.textinput(t) end
+    if source.text_input then source.text_input(t) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -214,9 +214,9 @@ function App.keyreleased(chord, key)
   end
   --
   if Current_app == 'run' then
-    if run.key_released then run.key_released(chord, key) end
+    if run.key_release then run.key_release(chord, key) end
   elseif Current_app == 'source' then
-    if source.key_released then source.key_released(chord, key) end
+    if source.key_release then source.key_release(chord, key) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -225,9 +225,9 @@ end
 function App.mousepressed(x,y, mouse_button)
 --?   print('mouse press', x,y)
   if Current_app == 'run' then
-    if run.mouse_pressed then run.mouse_pressed(x,y, mouse_button) end
+    if run.mouse_pressed then run.mouse_press(x,y, mouse_button) end
   elseif Current_app == 'source' then
-    if source.mouse_pressed then source.mouse_pressed(x,y, mouse_button) end
+    if source.mouse_pressed then source.mouse_press(x,y, mouse_button) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -235,9 +235,9 @@ end
 
 function App.mousereleased(x,y, mouse_button)
   if Current_app == 'run' then
-    if run.mouse_released then run.mouse_released(x,y, mouse_button) end
+    if run.mouse_release then run.mouse_release(x,y, mouse_button) end
   elseif Current_app == 'source' then
-    if source.mouse_released then source.mouse_released(x,y, mouse_button) end
+    if source.mouse_release then source.mouse_release(x,y, mouse_button) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
diff --git a/run.lua b/run.lua
index 8d03aa2..77ef241 100644
--- a/run.lua
+++ b/run.lua
@@ -101,7 +101,7 @@ function run.resize(w, h)
   Text.tweak_screen_top_and_cursor(Editor_state, Editor_state.left, Editor_state.right)
 end
 
-function run.filedropped(file)
+function run.file_drop(file)
   -- first make sure to save edits on any existing file
   if Editor_state.next_save then
     save_to_disk(Editor_state)
@@ -154,24 +154,24 @@ function run.mouse_pressed(x,y, mouse_button)
   return edit.mouse_pressed(Editor_state, x,y, mouse_button)
 end
 
-function run.mouse_released(x,y, mouse_button)
+function run.mouse_release(x,y, mouse_button)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.mouse_released(Editor_state, x,y, mouse_button)
+  return edit.mouse_release(Editor_state, x,y, mouse_button)
 end
 
-function run.textinput(t)
+function run.text_input(t)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.textinput(Editor_state, t)
+  return edit.text_input(Editor_state, t)
 end
 
-function run.keychord_pressed(chord, key)
+function run.keychord_press(chord, key)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.keychord_pressed(Editor_state, chord, key)
+  return edit.keychord_press(Editor_state, chord, key)
 end
 
-function run.key_released(key, scancode)
+function run.key_release(key, scancode)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.key_released(Editor_state, key, scancode)
+  return edit.key_release(Editor_state, key, scancode)
 end
 
 -- use this sparingly
diff --git a/source.lua b/source.lua
index b04b5b3..c3bd85b 100644
--- a/source.lua
+++ b/source.lua
@@ -197,7 +197,7 @@ function source.resize(w, h)
 --?   print('end resize')
 end
 
-function source.filedropped(file)
+function source.file_drop(file)
   -- first make sure to save edits on any existing file
   if Editor_state.next_save then
     save_to_disk(Editor_state)
@@ -213,7 +213,7 @@ function source.filedropped(file)
   love.window.setTitle('text.love - source')
 end
 
--- a copy of source.filedropped when given a filename
+-- a copy of source.file_drop when given a filename
 function source.switch_to_file(filename)
   -- first make sure to save edits on any existing file
   if Editor_state.next_save then
@@ -285,14 +285,14 @@ function source.settings()
   }
 end
 
-function source.mouse_pressed(x,y, mouse_button)
+function source.mouse_press(x,y, mouse_button)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
 --?   print('mouse click', x, y)
 --?   print(Editor_state.left, Editor_state.right)
 --?   print(Log_browser_state.left, Log_browser_state.right)
   if Show_file_navigator and y < Menu_status_bar_height + File_navigation.num_lines * Editor_state.line_height then
     -- send click to buttons
-    edit.mouse_pressed(Editor_state, x,y, mouse_button)
+    edit.mouse_press(Editor_state, x,y, mouse_button)
     return
   end
   if x < Editor_state.right + Margin_right then
@@ -301,45 +301,45 @@ function source.mouse_pressed(x,y, mouse_button)
       Focus = 'edit'
       return
     end
-    edit.mouse_pressed(Editor_state, x,y, mouse_button)
+    edit.mouse_press(Editor_state, x,y, mouse_button)
   elseif Show_log_browser_side and Log_browser_state.left <= x and x < Log_browser_state.right then
 --?     print('click on log_browser side')
     if Focus ~= 'log_browser' then
       Focus = 'log_browser'
       return
     end
-    log_browser.mouse_pressed(Log_browser_state, x,y, mouse_button)
+    log_browser.mouse_press(Log_browser_state, x,y, mouse_button)
     for _,line_cache in ipairs(Editor_state.line_cache) do line_cache.starty = nil end  -- just in case we scroll
   end
 end
 
-function source.mouse_released(x,y, mouse_button)
+function source.mouse_release(x,y, mouse_button)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   if Focus == 'edit' then
-    return edit.mouse_released(Editor_state, x,y, mouse_button)
+    return edit.mouse_release(Editor_state, x,y, mouse_button)
   else
-    return log_browser.mouse_released(Log_browser_state, x,y, mouse_button)
+    return log_browser.mouse_release(Log_browser_state, x,y, mouse_button)
   end
 end
 
-function source.textinput(t)
+function source.text_input(t)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   if Show_file_navigator then
-    textinput_on_file_navigator(t)
+    text_input_on_file_navigator(t)
     return
   end
   if Focus == 'edit' then
-    return edit.textinput(Editor_state, t)
+    return edit.text_input(Editor_state, t)
   else
-    return log_browser.textinput(Log_browser_state, t)
+    return log_browser.text_input(Log_browser_state, t)
   end
 end
 
-function source.keychord_pressed(chord, key)
+function source.keychord_press(chord, key)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
 --?   print('source keychord')
   if Show_file_navigator then
-    keychord_pressed_on_file_navigator(chord, key)
+    keychord_press_on_file_navigator(chord, key)
     return
   end
   if chord == 'C-l' then
@@ -380,18 +380,18 @@ function source.keychord_pressed(chord, key)
     return
   end
   if Focus == 'edit' then
-    return edit.keychord_pressed(Editor_state, chord, key)
+    return edit.keychord_press(Editor_state, chord, key)
   else
-    return log_browser.keychord_pressed(Log_browser_state, chord, key)
+    return log_browser.keychord_press(Log_browser_state, chord, key)
   end
 end
 
-function source.key_released(key, scancode)
+function source.key_release(key, scancode)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   if Focus == 'edit' then
-    return edit.key_released(Editor_state, key, scancode)
+    return edit.key_release(Editor_state, key, scancode)
   else
-    return log_browser.keychord_pressed(Log_browser_state, chordkey, scancode)
+    return log_browser.keychord_press(Log_browser_state, chordkey, scancode)
   end
 end
 
diff --git a/source_edit.lua b/source_edit.lua
index 8c1b37d..f9722eb 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -208,7 +208,7 @@ function edit.quit(State)
   end
 end
 
-function edit.mouse_pressed(State, x,y, mouse_button)
+function edit.mouse_press(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print('press')
   if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then
@@ -227,7 +227,7 @@ function edit.mouse_pressed(State, x,y, mouse_button)
         --    sets cursor
         --  press and hold to start a selection: sets selection on press, cursor on release
         --  press and hold, then press shift: ignore shift
-        --    i.e. mouse_released should never look at shift state
+        --    i.e. mouse_release should never look at shift state
         State.old_cursor1 = State.cursor1
         State.old_selection1 = State.selection1
         State.mousepress_shift = App.shift_down()
@@ -243,18 +243,18 @@ function edit.mouse_pressed(State, x,y, mouse_button)
         State.lines.current_drawing_index = line_index
         State.lines.current_drawing = line
         Drawing.before = snapshot(State, line_index)
-        Drawing.mouse_pressed(State, line_index, x,y, mouse_button)
+        Drawing.mouse_press(State, line_index, x,y, mouse_button)
         break
       end
     end
   end
 end
 
-function edit.mouse_released(State, x,y, mouse_button)
+function edit.mouse_release(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print('release')
   if State.lines.current_drawing then
-    Drawing.mouse_released(State, x,y, mouse_button)
+    Drawing.mouse_release(State, x,y, mouse_button)
     schedule_save(State)
     if Drawing.before then
       record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)})
@@ -287,7 +287,7 @@ function edit.mouse_released(State, x,y, mouse_button)
   end
 end
 
-function edit.textinput(State, t)
+function edit.text_input(State, t)
   if State.search_term then
     State.search_term = State.search_term..t
     State.search_text = nil
@@ -302,13 +302,13 @@ function edit.textinput(State, t)
     local drawing_index, drawing = Drawing.current_drawing(State)
     if drawing_index == nil then
       for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-      Text.textinput(State, t)
+      Text.text_input(State, t)
     end
   end
   schedule_save(State)
 end
 
-function edit.keychord_pressed(State, chord, key)
+function edit.keychord_press(State, chord, key)
   if State.selection1.line and
       not State.lines.current_drawing and
       -- printable character created using shift key => delete selection
@@ -461,7 +461,7 @@ function edit.keychord_pressed(State, chord, key)
     local drawing_index, drawing = Drawing.current_drawing(State)
     if drawing_index then
       local before = snapshot(State, drawing_index)
-      Drawing.keychord_pressed(State, chord)
+      Drawing.keychord_press(State, chord)
       record_undo_event(State, {before=before, after=snapshot(State, drawing_index)})
       schedule_save(State)
     end
@@ -493,7 +493,7 @@ function edit.keychord_pressed(State, chord, key)
     schedule_save(State)
   else
     for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    Text.keychord_pressed(State, chord)
+    Text.keychord_press(State, chord)
   end
 end
 
@@ -511,7 +511,7 @@ function edit.eradicate_locations_after_the_fold(State)
   end
 end
 
-function edit.key_released(State, key, scancode)
+function edit.key_release(State, key, scancode)
 end
 
 function edit.update_font_settings(State, font_height)
@@ -539,21 +539,21 @@ function edit.initialize_test_state()
       15)  -- line height
 end
 
--- all textinput events are also keypresses
+-- all text_input events are also keypresses
 -- TODO: handle chords of multiple keys
-function edit.run_after_textinput(State, t)
-  edit.keychord_pressed(State, t)
-  edit.textinput(State, t)
-  edit.key_released(State, t)
+function edit.run_after_text_input(State, t)
+  edit.keychord_press(State, t)
+  edit.text_input(State, t)
+  edit.key_release(State, t)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
 end
 
--- not all keys are textinput
+-- not all keys are text_input
 function edit.run_after_keychord(State, chord)
-  edit.keychord_pressed(State, chord)
-  edit.key_released(State, chord)
+  edit.keychord_press(State, chord)
+  edit.key_release(State, chord)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -561,9 +561,9 @@ end
 
 function edit.run_after_mouse_click(State, x,y, mouse_button)
   App.fake_mouse_press(x,y, mouse_button)
-  edit.mouse_pressed(State, x,y, mouse_button)
+  edit.mouse_press(State, x,y, mouse_button)
   App.fake_mouse_release(x,y, mouse_button)
-  edit.mouse_released(State, x,y, mouse_button)
+  edit.mouse_release(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -571,7 +571,7 @@ end
 
 function edit.run_after_mouse_press(State, x,y, mouse_button)
   App.fake_mouse_press(x,y, mouse_button)
-  edit.mouse_pressed(State, x,y, mouse_button)
+  edit.mouse_press(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
@@ -579,7 +579,7 @@ end
 
 function edit.run_after_mouse_release(State, x,y, mouse_button)
   App.fake_mouse_release(x,y, mouse_button)
-  edit.mouse_released(State, x,y, mouse_button)
+  edit.mouse_release(State, x,y, mouse_button)
   App.screen.contents = {}
   edit.update(State, 0)
   edit.draw(State)
diff --git a/source_text.lua b/source_text.lua
index 3e70343..71f4f7b 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -353,7 +353,7 @@ function Text.compute_fragmentsB(State, line_index, x)
   end
 end
 
-function Text.textinput(State, t)
+function Text.text_input(State, t)
   if App.mouse_down(1) then return end
   if App.ctrl_down() or App.alt_down() or App.cmd_down() then return end
   local before = snapshot(State, State.cursor1.line)
@@ -381,8 +381,8 @@ function Text.insert_at_cursor(State, t)
   end
 end
 
--- Don't handle any keys here that would trigger love.textinput above.
-function Text.keychord_pressed(State, chord)
+-- Don't handle any keys here that would trigger text_input above.
+function Text.keychord_press(State, chord)
 --?   print('chord', chord, State.selection1.line, State.selection1.pos)
   --== shortcuts that mutate text
   if chord == 'return' then
diff --git a/source_text_tests.lua b/source_text_tests.lua
index 5cd0f02..64f041f 100644
--- a/source_text_tests.lua
+++ b/source_text_tests.lua
@@ -65,7 +65,7 @@ function test_insert_first_character()
   Editor_state.lines = load_array{}
   Text.redraw_all(Editor_state)
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   local y = Editor_state.top
   App.screen.check(y, 'a', 'F - test_insert_first_character/screen:1')
 end
@@ -267,26 +267,27 @@ function test_move_past_end_of_word_on_next_line()
   check_eq(Editor_state.cursor1.pos, 4, 'F - test_move_past_end_of_word_on_next_line/pos')
 end
 
-function test_click_with_mouse()
-  io.write('\ntest_click_with_mouse')
-  -- display two lines with cursor on one of them
-  App.screen.init{width=50, height=80}
+function test_click_moves_cursor()
+  io.write('\ntest_click_moves_cursor')
+  App.screen.init{width=50, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def'}
+  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
   Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=2, pos=1}
+  Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
-  -- click on the other line
-  edit.draw(Editor_state)
-  edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse/cursor:line')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse/selection is empty to avoid perturbing future edits')
+  Editor_state.selection1 = {}
+  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
+  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_moves_cursor/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_moves_cursor/cursor:pos')
+  -- selection is empty to avoid perturbing future edits
+  check_nil(Editor_state.selection1.line, 'F - test_click_moves_cursor/selection:line')
+  check_nil(Editor_state.selection1.pos, 'F - test_click_moves_cursor/selection:pos')
 end
 
-function test_click_with_mouse_to_left_of_line()
-  io.write('\ntest_click_with_mouse_to_left_of_line')
+function test_click_to_left_of_line()
+  io.write('\ntest_click_to_left_of_line')
   -- display a line with the cursor in the middle
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -299,13 +300,13 @@ function test_click_with_mouse_to_left_of_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left-4,Editor_state.top+5, 1)
   -- cursor moves to start of line
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_to_left_of_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_to_left_of_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_to_left_of_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_to_left_of_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_takes_margins_into_account')
+function test_click_takes_margins_into_account()
+  io.write('\ntest_click_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -319,13 +320,13 @@ function test_click_with_mouse_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_empty_line()
-  io.write('\ntest_click_with_mouse_on_empty_line')
+function test_click_on_empty_line()
+  io.write('\ntest_click_on_empty_line')
   -- display two lines with the first one empty
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -338,7 +339,7 @@ function test_click_with_mouse_on_empty_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_empty_line/cursor')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_empty_line/cursor')
 end
 
 function test_draw_text()
@@ -395,8 +396,8 @@ function test_draw_word_wrapping_text()
   App.screen.check(y, 'ghi', 'F - test_draw_word_wrapping_text/screen:3')
 end
 
-function test_click_with_mouse_on_wrapping_line()
-  io.write('\ntest_click_with_mouse_on_wrapping_line')
+function test_click_on_wrapping_line()
+  io.write('\ntest_click_on_wrapping_line')
   -- display two lines with cursor on one of them
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -409,13 +410,13 @@ function test_click_with_mouse_on_wrapping_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_on_wrapping_line_takes_margins_into_account')
+function test_click_on_wrapping_line_takes_margins_into_account()
+  io.write('\ntest_click_on_wrapping_line_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -429,9 +430,9 @@ function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
 function test_draw_text_wrapping_within_word()
@@ -605,8 +606,8 @@ function test_select_text()
   App.fake_key_press('lshift')
   edit.run_after_keychord(Editor_state, 'S-right')
   App.fake_key_release('lshift')
-  edit.key_released(Editor_state, 'lshift')
-  -- selection persists even after shift is released
+  edit.key_release(Editor_state, 'lshift')
+  -- selection persists even after shift is release
   check_eq(Editor_state.selection1.line, 1, 'F - test_select_text/selection:line')
   check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text/selection:pos')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_select_text/cursor:line')
@@ -645,7 +646,7 @@ function test_edit_deletes_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- press a key
-  edit.run_after_textinput(Editor_state, 'x')
+  edit.run_after_text_input(Editor_state, 'x')
   -- selected text is deleted and replaced with the key
   check_eq(Editor_state.lines[1].data, 'xbc', 'F - test_edit_deletes_selection')
 end
@@ -664,9 +665,9 @@ function test_edit_with_shift_key_deletes_selection()
   edit.draw(Editor_state)
   -- mimic precise keypresses for a capital letter
   App.fake_key_press('lshift')
-  edit.keychord_pressed(Editor_state, 'd', 'd')
-  edit.textinput(Editor_state, 'D')
-  edit.key_released(Editor_state, 'd')
+  edit.keychord_press(Editor_state, 'd', 'd')
+  edit.text_input(Editor_state, 'D')
+  edit.key_release(Editor_state, 'd')
   App.fake_key_release('lshift')
   -- selected text is deleted and replaced with the key
   check_nil(Editor_state.selection1.line, 'F - test_edit_with_shift_key_deletes_selection')
@@ -768,7 +769,7 @@ function test_edit_wrapping_text()
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'g')
+  edit.run_after_text_input(Editor_state, 'g')
   local y = Editor_state.top
   App.screen.check(y, 'abc', 'F - test_edit_wrapping_text/screen:1')
   y = y + Editor_state.line_height
@@ -856,24 +857,6 @@ function test_insert_from_clipboard()
   App.screen.check(y, 'def', 'F - test_insert_from_clipboard/screen:3')
 end
 
-function test_move_cursor_using_mouse()
-  io.write('\ntest_move_cursor_using_mouse')
-  App.screen.init{width=50, height=60}
-  Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=1, pos=1}
-  Editor_state.screen_top1 = {line=1, pos=1}
-  Editor_state.screen_bottom1 = {}
-  Editor_state.selection1 = {}
-  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
-  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_move_cursor_using_mouse/selection:line')
-  check_nil(Editor_state.selection1.pos, 'F - test_move_cursor_using_mouse/selection:pos')
-end
-
 function test_select_text_using_mouse()
   io.write('\ntest_select_text_using_mouse')
   App.screen.init{width=50, height=60}
@@ -1189,8 +1172,8 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_
   App.screen.check(y, 'kl', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:3')
 end
 
-function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()
-  io.write('\ntest_page_down_followed_by_down_arrow_does_not_scroll_screen_up')
+function test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up()
+  io.write('\ntest_pagedown_followed_by_down_arrow_does_not_scroll_screen_up')
   App.screen.init{width=Editor_state.left+30, height=60}
   Editor_state = edit.initialize_test_state()
   Editor_state.lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
@@ -1200,27 +1183,27 @@ function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   local y = Editor_state.top
-  App.screen.check(y, 'abc', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1')
+  App.screen.check(y, 'abc', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'def', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:2')
+  App.screen.check(y, 'def', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:2')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'ghij', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:3')
+  App.screen.check(y, 'ghij', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:3')
   -- after hitting pagedown the screen scrolls down to start of a long line
   edit.run_after_keychord(Editor_state, 'pagedown')
-  check_eq(Editor_state.screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/screen_top')
-  check_eq(Editor_state.cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:pos')
+  check_eq(Editor_state.screen_top1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/screen_top')
+  check_eq(Editor_state.cursor1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:pos')
   -- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll up
   edit.run_after_keychord(Editor_state, 'down')
-  check_eq(Editor_state.screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen_top')
-  check_eq(Editor_state.cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 5, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:pos')
+  check_eq(Editor_state.screen_top1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen_top')
+  check_eq(Editor_state.cursor1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 5, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/cursor:pos')
   y = Editor_state.top
-  App.screen.check(y, 'ghij', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:1')
+  App.screen.check(y, 'ghij', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:1')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'kl', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:2')
+  App.screen.check(y, 'kl', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:2')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'mno', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:3')
+  App.screen.check(y, 'mno', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:3')
 end
 
 function test_up_arrow_moves_cursor()
@@ -1520,7 +1503,7 @@ function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bot
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- after hitting the inserting_text key the screen does not scroll down
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   check_eq(Editor_state.screen_top1.line, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:pos')
@@ -1546,9 +1529,9 @@ function test_typing_on_bottom_line_scrolls_down()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:3')
   -- after typing something the line wraps and the screen scrolls down
-  edit.run_after_textinput(Editor_state, 'j')
-  edit.run_after_textinput(Editor_state, 'k')
-  edit.run_after_textinput(Editor_state, 'l')
+  edit.run_after_text_input(Editor_state, 'j')
+  edit.run_after_text_input(Editor_state, 'k')
+  edit.run_after_text_input(Editor_state, 'l')
   check_eq(Editor_state.screen_top1.line, 2, 'F - test_typing_on_bottom_line_scrolls_down/screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'F - test_typing_on_bottom_line_scrolls_down/cursor:line')
   check_eq(Editor_state.cursor1.pos, 7, 'F - test_typing_on_bottom_line_scrolls_down/cursor:pos')
@@ -1700,9 +1683,9 @@ function test_position_cursor_on_recently_edited_wrapping_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'xyz', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline1/screen:3')
   -- add to the line until it's wrapping over 3 screen lines
-  edit.run_after_textinput(Editor_state, 's')
-  edit.run_after_textinput(Editor_state, 't')
-  edit.run_after_textinput(Editor_state, 'u')
+  edit.run_after_text_input(Editor_state, 's')
+  edit.run_after_text_input(Editor_state, 't')
+  edit.run_after_text_input(Editor_state, 'u')
   check_eq(Editor_state.cursor1.pos, 28, 'F - test_position_cursor_on_recently_edited_wrapping_line/cursor:pos')
   y = Editor_state.top
   App.screen.check(y, 'abc def ghi ', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline2/screen:1')
@@ -1900,7 +1883,7 @@ function test_undo_insert_text()
   Editor_state.screen_bottom1 = {}
   -- insert a character
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'g')
+  edit.run_after_text_input(Editor_state, 'g')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_undo_insert_text/baseline/cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'F - test_undo_insert_text/baseline/cursor:pos')
   check_nil(Editor_state.selection1.line, 'F - test_undo_insert_text/baseline/selection:line')
@@ -1976,7 +1959,7 @@ function test_undo_restores_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- delete selected text
-  edit.run_after_textinput(Editor_state, 'x')
+  edit.run_after_text_input(Editor_state, 'x')
   check_eq(Editor_state.lines[1].data, 'xbc', 'F - test_undo_restores_selection/baseline')
   check_nil(Editor_state.selection1.line, 'F - test_undo_restores_selection/baseline:selection')
   -- undo
@@ -1999,7 +1982,7 @@ function test_search()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'd')
+  edit.run_after_text_input(Editor_state, 'd')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_search/1/cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/1/cursor:pos')
@@ -2008,7 +1991,7 @@ function test_search()
   Editor_state.screen_top1 = {line=1, pos=1}
   -- search for second occurrence
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'de')
+  edit.run_after_text_input(Editor_state, 'de')
   edit.run_after_keychord(Editor_state, 'down')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(Editor_state.cursor1.line, 4, 'F - test_search/2/cursor:line')
@@ -2027,7 +2010,7 @@ function test_search_upwards()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   -- search for previous occurrence
   edit.run_after_keychord(Editor_state, 'up')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_upwards/2/cursor:line')
@@ -2046,7 +2029,7 @@ function test_search_wrap()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   edit.run_after_keychord(Editor_state, 'return')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap/1/cursor:line')
@@ -2065,7 +2048,7 @@ function test_search_wrap_upwards()
   edit.draw(Editor_state)
   -- search upwards for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   edit.run_after_keychord(Editor_state, 'up')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap_upwards/1/cursor:line')
diff --git a/text.lua b/text.lua
index ff958f9..9447a0d 100644
--- a/text.lua
+++ b/text.lua
@@ -145,7 +145,7 @@ function Text.compute_fragments(State, line_index)
   end
 end
 
-function Text.textinput(State, t)
+function Text.text_input(State, t)
   if App.mouse_down(1) then return end
   if App.ctrl_down() or App.alt_down() or App.cmd_down() then return end
   local before = snapshot(State, State.cursor1.line)
@@ -166,8 +166,8 @@ function Text.insert_at_cursor(State, t)
   State.cursor1.pos = State.cursor1.pos+1
 end
 
--- Don't handle any keys here that would trigger love.textinput above.
-function Text.keychord_pressed(State, chord)
+-- Don't handle any keys here that would trigger text_input above.
+function Text.keychord_press(State, chord)
 --?   print('chord', chord, State.selection1.line, State.selection1.pos)
   --== shortcuts that mutate text
   if chord == 'return' then
diff --git a/text_tests.lua b/text_tests.lua
index 7f9b2e4..fddee75 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -37,7 +37,7 @@ function test_insert_first_character()
   Editor_state.lines = load_array{}
   Text.redraw_all(Editor_state)
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   local y = Editor_state.top
   App.screen.check(y, 'a', 'F - test_insert_first_character/screen:1')
 end
@@ -239,26 +239,27 @@ function test_move_past_end_of_word_on_next_line()
   check_eq(Editor_state.cursor1.pos, 4, 'F - test_move_past_end_of_word_on_next_line/pos')
 end
 
-function test_click_with_mouse()
-  io.write('\ntest_click_with_mouse')
-  -- display two lines with cursor on one of them
-  App.screen.init{width=50, height=80}
+function test_click_moves_cursor()
+  io.write('\ntest_click_moves_cursor')
+  App.screen.init{width=50, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def'}
+  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
   Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=2, pos=1}
+  Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
-  -- click on the other line
-  edit.draw(Editor_state)
-  edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse/cursor:line')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse/selection is empty to avoid perturbing future edits')
+  Editor_state.selection1 = {}
+  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
+  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_moves_cursor/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_moves_cursor/cursor:pos')
+  -- selection is empty to avoid perturbing future edits
+  check_nil(Editor_state.selection1.line, 'F - test_click_moves_cursor/selection:line')
+  check_nil(Editor_state.selection1.pos, 'F - test_click_moves_cursor/selection:pos')
 end
 
-function test_click_with_mouse_to_left_of_line()
-  io.write('\ntest_click_with_mouse_to_left_of_line')
+function test_click_to_left_of_line()
+  io.write('\ntest_click_to_left_of_line')
   -- display a line with the cursor in the middle
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -271,13 +272,13 @@ function test_click_with_mouse_to_left_of_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left-4,Editor_state.top+5, 1)
   -- cursor moves to start of line
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_to_left_of_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_to_left_of_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_to_left_of_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_to_left_of_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_takes_margins_into_account')
+function test_click_takes_margins_into_account()
+  io.write('\ntest_click_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -291,13 +292,13 @@ function test_click_with_mouse_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_empty_line()
-  io.write('\ntest_click_with_mouse_on_empty_line')
+function test_click_on_empty_line()
+  io.write('\ntest_click_on_empty_line')
   -- display two lines with the first one empty
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -310,7 +311,7 @@ function test_click_with_mouse_on_empty_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_empty_line/cursor')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_empty_line/cursor')
 end
 
 function test_draw_text()
@@ -367,8 +368,8 @@ function test_draw_word_wrapping_text()
   App.screen.check(y, 'ghi', 'F - test_draw_word_wrapping_text/screen:3')
 end
 
-function test_click_with_mouse_on_wrapping_line()
-  io.write('\ntest_click_with_mouse_on_wrapping_line')
+function test_click_on_wrapping_line()
+  io.write('\ntest_click_on_wrapping_line')
   -- display two lines with cursor on one of them
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -381,13 +382,13 @@ function test_click_with_mouse_on_wrapping_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_on_wrapping_line_takes_margins_into_account')
+function test_click_on_wrapping_line_takes_margins_into_account()
+  io.write('\ntest_click_on_wrapping_line_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -401,9 +402,9 @@ function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
 function test_draw_text_wrapping_within_word()
@@ -577,8 +578,8 @@ function test_select_text()
   App.fake_key_press('lshift')
   edit.run_after_keychord(Editor_state, 'S-right')
   App.fake_key_release('lshift')
-  edit.key_released(Editor_state, 'lshift')
-  -- selection persists even after shift is released
+  edit.key_release(Editor_state, 'lshift')
+  -- selection persists even after shift is release
   check_eq(Editor_state.selection1.line, 1, 'F - test_select_text/selection:line')
   check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text/selection:pos')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_select_text/cursor:line')
@@ -617,7 +618,7 @@ function test_edit_deletes_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- press a key
-  edit.run_after_textinput(Editor_state, 'x')
+  edit.run_after_text_input(Editor_state, 'x')
   -- selected text is deleted and replaced with the key
   check_eq(Editor_state.lines[1].data, 'xbc', 'F - test_edit_deletes_selection')
 end
@@ -636,9 +637,9 @@ function test_edit_with_shift_key_deletes_selection()
   edit.draw(Editor_state)
   -- mimic precise keypresses for a capital letter
   App.fake_key_press('lshift')
-  edit.keychord_pressed(Editor_state, 'd', 'd')
-  edit.textinput(Editor_state, 'D')
-  edit.key_released(Editor_state, 'd')
+  edit.keychord_press(Editor_state, 'd', 'd')
+  edit.text_input(Editor_state, 'D')
+  edit.key_release(Editor_state, 'd')
   App.fake_key_release('lshift')
   -- selected text is deleted and replaced with the key
   check_nil(Editor_state.selection1.line, 'F - test_edit_with_shift_key_deletes_selection')
@@ -740,7 +741,7 @@ function test_edit_wrapping_text()
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'g')
+  edit.run_after_text_input(Editor_state, 'g')
   local y = Editor_state.top
   App.screen.check(y, 'abc', 'F - test_edit_wrapping_text/screen:1')
   y = y + Editor_state.line_height
@@ -828,24 +829,6 @@ function test_insert_from_clipboard()
   App.screen.check(y, 'def', 'F - test_insert_from_clipboard/screen:3')
 end
 
-function test_move_cursor_using_mouse()
-  io.write('\ntest_move_cursor_using_mouse')
-  App.screen.init{width=50, height=60}
-  Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=1, pos=1}
-  Editor_state.screen_top1 = {line=1, pos=1}
-  Editor_state.screen_bottom1 = {}
-  Editor_state.selection1 = {}
-  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
-  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_move_cursor_using_mouse/selection:line')
-  check_nil(Editor_state.selection1.pos, 'F - test_move_cursor_using_mouse/selection:pos')
-end
-
 function test_select_text_using_mouse()
   io.write('\ntest_select_text_using_mouse')
   App.screen.init{width=50, height=60}
@@ -1162,8 +1145,8 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_
   App.screen.check(y, 'kl', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:3')
 end
 
-function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()
-  io.write('\ntest_page_down_followed_by_down_arrow_does_not_scroll_screen_up')
+function test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up()
+  io.write('\ntest_pagedown_followed_by_down_arrow_does_not_scroll_screen_up')
   App.screen.init{width=Editor_state.left+30, height=60}
   Editor_state = edit.initialize_test_state()
   Editor_state.lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
@@ -1173,27 +1156,27 @@ function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   local y = Editor_state.top
-  App.screen.check(y, 'abc', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1')
+  App.screen.check(y, 'abc', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'def', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:2')
+  App.screen.check(y, 'def', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:2')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'ghij', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:3')
+  App.screen.check(y, 'ghij', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:3')
   -- after hitting pagedown the screen scrolls down to start of a long line
   edit.run_after_keychord(Editor_state, 'pagedown')
-  check_eq(Editor_state.screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/screen_top')
-  check_eq(Editor_state.cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:pos')
+  check_eq(Editor_state.screen_top1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/screen_top')
+  check_eq(Editor_state.cursor1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:pos')
   -- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll up
   edit.run_after_keychord(Editor_state, 'down')
-  check_eq(Editor_state.screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen_top')
-  check_eq(Editor_state.cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 5, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:pos')
+  check_eq(Editor_state.screen_top1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen_top')
+  check_eq(Editor_state.cursor1.line, 3, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 5, 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/cursor:pos')
   y = Editor_state.top
-  App.screen.check(y, 'ghij', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:1')
+  App.screen.check(y, 'ghij', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:1')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'kl', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:2')
+  App.screen.check(y, 'kl', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:2')
   y = y + Editor_state.line_height
-  App.screen.check(y, 'mno', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:3')
+  App.screen.check(y, 'mno', 'F - test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up/screen:3')
 end
 
 function test_up_arrow_moves_cursor()
@@ -1493,7 +1476,7 @@ function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bot
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- after hitting the inserting_text key the screen does not scroll down
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   check_eq(Editor_state.screen_top1.line, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:pos')
@@ -1519,9 +1502,9 @@ function test_typing_on_bottom_line_scrolls_down()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:3')
   -- after typing something the line wraps and the screen scrolls down
-  edit.run_after_textinput(Editor_state, 'j')
-  edit.run_after_textinput(Editor_state, 'k')
-  edit.run_after_textinput(Editor_state, 'l')
+  edit.run_after_text_input(Editor_state, 'j')
+  edit.run_after_text_input(Editor_state, 'k')
+  edit.run_after_text_input(Editor_state, 'l')
   check_eq(Editor_state.screen_top1.line, 2, 'F - test_typing_on_bottom_line_scrolls_down/screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'F - test_typing_on_bottom_line_scrolls_down/cursor:line')
   check_eq(Editor_state.cursor1.pos, 7, 'F - test_typing_on_bottom_line_scrolls_down/cursor:pos')
@@ -1673,9 +1656,9 @@ function test_position_cursor_on_recently_edited_wrapping_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'xyz', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline1/screen:3')
   -- add to the line until it's wrapping over 3 screen lines
-  edit.run_after_textinput(Editor_state, 's')
-  edit.run_after_textinput(Editor_state, 't')
-  edit.run_after_textinput(Editor_state, 'u')
+  edit.run_after_text_input(Editor_state, 's')
+  edit.run_after_text_input(Editor_state, 't')
+  edit.run_after_text_input(Editor_state, 'u')
   check_eq(Editor_state.cursor1.pos, 28, 'F - test_position_cursor_on_recently_edited_wrapping_line/cursor:pos')
   y = Editor_state.top
   App.screen.check(y, 'abc def ghi ', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline2/screen:1')
@@ -1873,7 +1856,7 @@ function test_undo_insert_text()
   Editor_state.screen_bottom1 = {}
   -- insert a character
   edit.draw(Editor_state)
-  edit.run_after_textinput(Editor_state, 'g')
+  edit.run_after_text_input(Editor_state, 'g')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_undo_insert_text/baseline/cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'F - test_undo_insert_text/baseline/cursor:pos')
   check_nil(Editor_state.selection1.line, 'F - test_undo_insert_text/baseline/selection:line')
@@ -1949,7 +1932,7 @@ function test_undo_restores_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- delete selected text
-  edit.run_after_textinput(Editor_state, 'x')
+  edit.run_after_text_input(Editor_state, 'x')
   check_eq(Editor_state.lines[1].data, 'xbc', 'F - test_undo_restores_selection/baseline')
   check_nil(Editor_state.selection1.line, 'F - test_undo_restores_selection/baseline:selection')
   -- undo
@@ -1972,7 +1955,7 @@ function test_search()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'd')
+  edit.run_after_text_input(Editor_state, 'd')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_search/1/cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/1/cursor:pos')
@@ -1981,7 +1964,7 @@ function test_search()
   Editor_state.screen_top1 = {line=1, pos=1}
   -- search for second occurrence
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'de')
+  edit.run_after_text_input(Editor_state, 'de')
   edit.run_after_keychord(Editor_state, 'down')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(Editor_state.cursor1.line, 4, 'F - test_search/2/cursor:line')
@@ -2000,7 +1983,7 @@ function test_search_upwards()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   -- search for previous occurrence
   edit.run_after_keychord(Editor_state, 'up')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_upwards/2/cursor:line')
@@ -2019,7 +2002,7 @@ function test_search_wrap()
   edit.draw(Editor_state)
   -- search for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   edit.run_after_keychord(Editor_state, 'return')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap/1/cursor:line')
@@ -2038,7 +2021,7 @@ function test_search_wrap_upwards()
   edit.draw(Editor_state)
   -- search upwards for a string
   edit.run_after_keychord(Editor_state, 'C-f')
-  edit.run_after_textinput(Editor_state, 'a')
+  edit.run_after_text_input(Editor_state, 'a')
   edit.run_after_keychord(Editor_state, 'up')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap_upwards/1/cursor:line')