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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doif x >= editor.left and x <= editor.right thenCursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)breakendendend
{"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 widgetslocal emwidth = App.newText(love.graphics.getFont(), 'm'):getWidth()local editor_width = 40*emwidthlocal width_remaining = App.screen.width - Margin_left - Margin_rightlocal left = Margin_leftrepeatlocal 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_leftleft = left + editor_width + Margin_leftuntil width_remaining < editor_width-- have them all operate on the file's linesEditors[1].filename = filenameload_from_disk(Editors[1])Text.redraw_all(Editors[1])Editors[1].screen_top = screen_topedit.draw(Editors[1], Text_color) -- initialize screen_bottom1for e=2,#Editors dolocal editor = Editors[e]editor.lines = Editors[1].linesText.redraw_all(editor) -- TODO: share fragments between editorseditor.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_bottom1endend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doprint(i, editor.cursor1.line, editor.cursor1.pos)if x >= editor.left and x <= editor.right thenCursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)breakendendend
{"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) doedit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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 thenedit.mouse_release(Cursor_editor, x,y, mouse_button)endend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doif x >= editor.left and x <= editor.right thenCursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)breakendendend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doif x >= editor.left and x <= editor.right thenprint('column', i, editor.selection1.line, editor.selection1.pos)Cursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)print('after mouse press', i, editor.selection1.line, editor.selection1.pos)breakendendend
{"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) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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 = 500for i,editor in ipairs(Editors) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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 = 100for i,editor in ipairs(Editors) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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 = 50for i,editor in ipairs(Editors) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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) doedit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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) doprint(i, editor.selection1.line, editor.selection1.pos)edit.draw(editor, Text_color, --[[hide cursor]] true)endend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doprint(i, editor.selection1)if x >= editor.left and x <= editor.right thenprint('column', i, editor.selection1.line, editor.selection1.pos)Cursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)print('after mouse press', i, editor.selection1.line, editor.selection1.pos)breakendendend
{"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 thenprint('release')edit.mouse_release(Cursor_editor, x,y, mouse_button)endend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doprint(i, editor.selection1)if x >= editor.left and x <= editor.right thenprint('column', i)Cursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)breakendendend
{"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) doeditor.selection1 = {}endfor i,editor in ipairs(Editors) doif x >= editor.left and x <= editor.right thenprint('column', i)Cursor_editor = editoredit.mouse_press(editor, x,y, mouse_button)breakendendend
{"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}