Culprit: premature optimization. Now we're back to a constant factor overhead to store fragments. But then again we only store them for lines on screen so this should be fine.
ET3DXVSEDGTJNX4C5TJ35CXSXNUVIUHBXYF6HCUFMVFQ2L7ESE5AC
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
if x >= editor.left and x <= editor.right then
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
break
end
end
end
{"on.keychord_press":45,"initialize_editors":62,"on.key_release":15,"on.draw":60,"Cursor_editor":16,"Editors":6,"fw_parent":62,"on.mouse_release":59,"fw_app":"broadsheet","on.initialize":36,"on":1,"on.mouse_press":63}
initialize_editors = function(font_height, filename, screen_top)
Editors = {}
love.graphics.setFont(love.graphics.newFont(font_height))
-- initialize multiple editor widgets
local emwidth = App.newText(love.graphics.getFont(), 'm'):getWidth()
local editor_width = 40*emwidth
local width_remaining = App.screen.width - Margin_left - Margin_right
local left = Margin_left
repeat
local editor = edit.initialize_state(Margin_top, left, left + math.min(editor_width, width_remaining), font_height, math.floor(font_height*1.3))
table.insert(Editors, editor)
width_remaining = width_remaining - editor_width - Margin_left
left = left + editor_width + Margin_left
until width_remaining < editor_width
-- have them all operate on the file's lines
Editors[1].filename = filename
load_from_disk(Editors[1])
Text.redraw_all(Editors[1])
Editors[1].screen_top = screen_top
edit.draw(Editors[1], Text_color) -- initialize screen_bottom1
for e=2,#Editors do
local editor = Editors[e]
editor.lines = Editors[1].lines
Text.redraw_all(editor) -- TODO: share fragments between editors
editor.screen_top1 = {line=Editors[e-1].screen_bottom1.line, pos=Editors[e-1].screen_bottom1.pos}
editor.cursor1 = {line=editor.screen_top1.line, pos=editor.screen_top1.pos}
edit.draw(editor, Text_color) -- initialize screen_bottom1
end
end
{"on.keychord_press":45,"initialize_editors":62,"on.key_release":15,"on.draw":60,"Cursor_editor":16,"Editors":6,"fw_parent":61,"on.mouse_release":59,"fw_app":"broadsheet","on":1,"on.mouse_press":61,"on.initialize":36}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
print(i, editor.cursor1.line, editor.cursor1.pos)
if x >= editor.left and x <= editor.right then
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
break
end
end
end
{"on.keychord_press":45,"initialize_editors":43,"fw_parent":60,"on.draw":60,"Cursor_editor":16,"Editors":6,"fw_app":"broadsheet","on":1,"on.mouse_release":59,"on.initialize":36,"on.key_release":15,"on.mouse_press":61}
on.draw = function()
for i,editor in ipairs(Editors) do
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"Editors":6,"fw_parent":59,"initialize_editors":43,"on.key_release":15,"on":1,"Cursor_editor":16,"on.mouse_press":58,"on.mouse_release":59,"on.initialize":36,"on.keychord_press":45,"on.draw":60,"fw_app":"broadsheet"}
on.mouse_release = function(x,y, mouse_button)
if Cursor_editor then
edit.mouse_release(Cursor_editor, x,y, mouse_button)
end
end
{"initialize_editors":43,"on.key_release":15,"on.draw":56,"Cursor_editor":16,"Editors":6,"fw_parent":58,"fw_app":"broadsheet","on.initialize":36,"on.mouse_release":59,"on.mouse_press":58,"on":1,"on.keychord_press":45}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
if x >= editor.left and x <= editor.right then
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
break
end
end
end
{"initialize_editors":43,"on.key_release":15,"on.draw":56,"Cursor_editor":16,"Editors":6,"fw_parent":57,"fw_app":"broadsheet","on.initialize":36,"on.mouse_release":48,"on.mouse_press":58,"on":1,"on.keychord_press":45}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
if x >= editor.left and x <= editor.right then
print('column', i, editor.selection1.line, editor.selection1.pos)
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
print('after mouse press', i, editor.selection1.line, editor.selection1.pos)
break
end
end
end
{"initialize_editors":43,"on.key_release":15,"on.draw":56,"Cursor_editor":16,"Editors":6,"fw_parent":56,"fw_app":"broadsheet","on.initialize":36,"on.mouse_release":48,"on.mouse_press":57,"on":1,"on.keychord_press":45}
on.draw = function()
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"initialize_editors":43,"on.key_release":15,"on.draw":56,"Cursor_editor":16,"Editors":6,"on.mouse_press":49,"fw_parent":55,"on":1,"on.mouse_release":48,"on.initialize":36,"fw_app":"broadsheet"}
on.draw = function()
Editors[1].left = 500
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"initialize_editors":43,"on.key_release":15,"on.draw":55,"Cursor_editor":16,"Editors":6,"on.mouse_press":49,"fw_parent":54,"on":1,"on.mouse_release":48,"on.initialize":36,"fw_app":"broadsheet"}
on.draw = function()
Editors[1].left = 100
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"initialize_editors":43,"on.key_release":15,"on.draw":54,"Cursor_editor":16,"Editors":6,"on.mouse_press":49,"fw_parent":53,"on":1,"on.mouse_release":48,"on.initialize":36,"fw_app":"broadsheet"}
on.draw = function()
Editors[1].left = 50
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"initialize_editors":43,"on.key_release":15,"on.draw":53,"Cursor_editor":16,"Editors":6,"on.mouse_press":49,"fw_parent":52,"on":1,"on.mouse_release":48,"on.initialize":36,"fw_app":"broadsheet"}
on.draw = function()
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"on.initialize":36,"on.key_release":15,"on.draw":52,"fw_parent":51,"on.mouse_press":49,"initialize_editors":43,"on.mouse_release":48,"on":1,"fw_app":"broadsheet","Cursor_editor":16,"Editors":6}
on.draw = function()
for _,editor in ipairs(Editors) do
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"on.initialize":36,"on.key_release":15,"on.draw":51,"fw_parent":50,"on.mouse_press":49,"initialize_editors":43,"on.mouse_release":48,"on":1,"fw_app":"broadsheet","Cursor_editor":16,"Editors":6}
on.draw = function()
for i,editor in ipairs(Editors) do
print(i, editor.selection1.line, editor.selection1.pos)
edit.draw(editor, Text_color, --[[hide cursor]] true)
end
end
{"on.keychord_press":45,"on.initialize":36,"on.key_release":15,"on.draw":50,"fw_parent":49,"on.mouse_press":49,"initialize_editors":43,"on.mouse_release":48,"on":1,"fw_app":"broadsheet","Cursor_editor":16,"Editors":6}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
print(i, editor.selection1)
if x >= editor.left and x <= editor.right then
print('column', i, editor.selection1.line, editor.selection1.pos)
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
print('after mouse press', i, editor.selection1.line, editor.selection1.pos)
break
end
end
end
{"on.keychord_press":45,"on.initialize":36,"on.key_release":15,"on.draw":12,"fw_parent":48,"on.mouse_press":49,"initialize_editors":43,"on.mouse_release":48,"on":1,"fw_app":"broadsheet","Cursor_editor":16,"Editors":6}
on.mouse_release = function(x,y, mouse_button)
if Cursor_editor then
print('release')
edit.mouse_release(Cursor_editor, x,y, mouse_button)
end
end
{"on.key_release":15,"Cursor_editor":16,"on.draw":12,"on.mouse_release":48,"on.mouse_press":47,"on.initialize":36,"Editors":6,"fw_parent":47,"on":1,"fw_app":"broadsheet","on.keychord_press":45,"initialize_editors":43}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
print(i, editor.selection1)
if x >= editor.left and x <= editor.right then
print('column', i)
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
break
end
end
end
{"on.key_release":15,"Cursor_editor":16,"on.draw":12,"on.mouse_release":19,"on.mouse_press":47,"on.initialize":36,"Editors":6,"fw_parent":46,"on":1,"fw_app":"broadsheet","on.keychord_press":45,"initialize_editors":43}
on.mouse_press = function(x,y, mouse_button)
for _,editor in ipairs(Editors) do
editor.selection1 = {}
end
for i,editor in ipairs(Editors) do
if x >= editor.left and x <= editor.right then
print('column', i)
Cursor_editor = editor
edit.mouse_press(editor, x,y, mouse_button)
break
end
end
end
{"on.key_release":15,"Cursor_editor":16,"on.draw":12,"on.mouse_release":19,"on.mouse_press":46,"on.initialize":36,"Editors":6,"fw_parent":45,"on":1,"fw_app":"broadsheet","on.keychord_press":45,"initialize_editors":43}