Programming environment for editing various of my live apps without restarting them.
schema1_of_y = function(editor, y)
	-- return line/pos of screen line starting near a given y offset,
	-- and the (negative) offset remaining after the calculation
	-- invariants:
	-- 	- 0 >= y_offset >= -Line_height
	-- 	- let loc, y_offset = schema1_of_y(pane, y)
	-- 		y + y_offset == y_of_schema1(pane, loc)
	assert(y >= 0)
	local y_offset = y
	for i=1,#editor.lines do
		Text.populate_screen_line_starting_pos(editor, i)
		local height = line_height(editor, i)
		if y_offset < height then
			local line = editor.lines[i]
			local nlines = math.floor(y_offset/editor.line_height)
			assert(nlines >= 0 and nlines < #editor.line_cache[i].screen_line_starting_pos)
			local pos = editor.line_cache[i].screen_line_starting_pos[nlines+1]  -- switch to 1-indexing
			y_offset = y_offset - nlines*editor.line_height
			return {line=i, pos=pos}, -y_offset
		end
		y_offset = y_offset - height
	end
	-- y is below the pane
	return {line=#editor.lines+1, pos=1}, y_offset  -- positive value
end