C3DUID2HUFDX5WXG4YZX2TUHJ5OBVEAOPSBUSGZTJW7RB4SGK46QC
JBYPLGW2C3JYDIEYAUIRYGI33CWQJXUW2BTXYQWVK7FNMAL6FGUAC
GMDEH4RHOR6DJABQ5WVGY4GVUU3QPWFTPFUHYUOULTVJZA2FTPAQC
TGHAJBESCIEGWUE2D3FGLNOIAYT4D2IRGZKRXRMTUFW7QZETC7OAC
5BMR5HRT7GN5L4XB4ISP4JJP3ONZESHEEQBCTQE4EVEDL7MBSDGAC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
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
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":366,"y_of_schema1":364,"to_text":180,"Page":344,"line_height":365,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":365,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":363,"y_of_schema1":364,"to_text":180,"Page":344,"line_height":365,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":364,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
line_height = function(editor, line_index)
local line = editor.lines[line_index]
local line_cache = editor.line_cache[line_index]
return editor.line_height*#line_cache.screen_line_starting_pos
end
y_of_schema1 = function(editor, loc)
local result = 0
if loc.line == 1 and loc.pos == 1 then
return result
end
for i=1,loc.line-1 do
Text.populate_screen_line_starting_pos(editor, i)
result = result + line_height(editor, i)
end
Text.populate_screen_line_starting_pos(editor, loc.line)
for i,screen_line_starting_pos in ipairs(editor.line_cache[loc.line].screen_line_starting_pos) do
if screen_line_starting_pos >= loc.pos then
break
end
result = result + editor.line_height
end
return result
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":363,"y_of_schema1":364,"to_text":180,"Page":344,"line_height":362,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":363,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
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=#pane.lines+1, pos=1}, y_offset -- positive value
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":363,"to_text":180,"Page":344,"line_height":362,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":362,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":360,"to_text":180,"Page":344,"line_height":362,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":361,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
line_height = function(editor, line_index)
local line = State.lines[line_index]
local line_cache = State.line_cache[line_index]
return editor.line_height*#line_cache.screen_line_starting_pos
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":360,"to_text":180,"Page":344,"line_height":361,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":360,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
line_height = function(editor, line_index, left, right)
local line = State.lines[line_index]
local line_cache = State.line_cache[line_index]
return editor.line_height*#line_cache.screen_line_starting_pos
end
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, editor.left, editor.right)
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=#pane.lines+1, pos=1}, y_offset -- positive value
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":360,"to_text":180,"Page":344,"on.draw":346,"on":1,"A":309,"on.initialize":350,"Viewport":303,"parent":358,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"Surface":196,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
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)
return {line=1, pos=1}, 0
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, editor.left, editor.right)
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=#pane.lines+1, pos=1}, y_offset -- positive value
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"schema1_of_y":359,"Surface":196,"to_text":180,"on.draw":346,"on.initialize":350,"A":309,"on":1,"Viewport":303,"Page":344,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"parent":358,"on.mouse_release":178,"initialize_editor":338,"on.update":355}
update_editor_box = function(obj)
if obj.editor == nil then return end
if obj.y > Viewport.y then
obj.editor.screen_top1.line = 1
obj.editor.screen_top1.pos = 1
obj.editor.top = vy(obj.y)
else
obj.editor.screen_top1, obj.editor.top = schema1_of_y(obj.editor, Viewport.y - obj.y)
end
print('top', obj.editor.top)
print('screen_top1', obj.editor.screen_top1.line, obj.editor.screen_top1.pos)
obj.editor.left = math.floor(vx(obj.x))
obj.editor.right = math.ceil(vx(obj.x+obj.w))
edit.update_font_settings(obj.editor, scale(20))
Text.redraw_all(obj.editor)
end
{"box_height":345,"on.keychord_press":311,"compute_layout":354,"on.code_change":306,"Cursor_node":172,"font":353,"Surface":196,"to_text":180,"on.draw":346,"on.initialize":350,"A":309,"on":1,"Viewport":303,"Page":344,"B":352,"vy":8,"scale":7,"on.text_input":177,"update_editor_box":358,"vx":5,"on.mouse_press":179,"parent":357,"on.mouse_release":178,"initialize_editor":338,"on.update":355}