This was hard to track down because lua's print implicitly hides tiny fractions, making non-integers look like integers. So there's a gotcha here: ensure that parameters to edit.initialize are integers. I'm documenting it on the caller and also defensively converting to an int inside the callee.
ACEWU2ORP2QPYQQL2MXWLOQGAG4XBU5YWOO57K6KJBPJU4VDNH5AC {"on.mouse_released":178,"Box_heights":277,"on":1,"on.keychord_pressed":311,"Page":324,"A":309,"on.update":315,"on.textinput":177,"clip_all":265,"parent":337,"Surface":196,"scale":7,"on.code_changed":306,"on.draw":310,"font":228,"vx":5,"Cursor_node":172,"Viewport":303,"clip":236,"on.mouse_pressed":179,"vy":8,"initialize_editor":338,"box_height":317,"B":316,"compute_layout":335,"on.initialize":304,"to_text":180}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)obj.editor = edit.initialize_state(vy(obj.y), math.floor(vx(obj.x)), math.ceil(vx(obj.x+obj.w)), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.initialize":304,"Surface":196,"B":316,"on.draw":310,"on":1,"vx":5,"on.mouse_released":178,"Viewport":303,"initialize_editor":337,"box_height":317,"vy":8,"compute_layout":335,"to_text":180,"Page":324,"on.keychord_pressed":311,"Box_heights":277,"on.mouse_pressed":179,"on.code_changed":306,"Cursor_node":172,"font":228,"clip":236,"parent":336,"clip_all":265,"scale":7,"on.textinput":177,"on.update":315,"A":309}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), math.floor(vx(obj.x)), math.ceil(vx(obj.x+obj.w)), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.mouse_released":178,"initialize_editor":336,"on.update":315,"to_text":180,"compute_layout":335,"A":309,"box_height":317,"Box_heights":277,"Page":324,"clip":236,"on.code_changed":306,"on.textinput":177,"Surface":196,"on":1,"on.draw":310,"vx":5,"clip_all":265,"Viewport":303,"B":316,"vy":8,"scale":7,"parent":335,"Cursor_node":172,"font":228,"on.initialize":304,"on.mouse_pressed":179,"on.keychord_pressed":311}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), math.ceil(vx(obj.x+obj.w)), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"parent":334,"font":228,"on.mouse_released":178,"on.update":315,"box_height":317,"on.keychord_pressed":311,"compute_layout":335,"to_text":180,"Page":324,"clip":236,"on.code_changed":306,"scale":7,"on.initialize":304,"Surface":196,"A":309,"on.draw":310,"Box_heights":277,"initialize_editor":333,"vx":5,"on.mouse_pressed":179,"Viewport":303,"on":1,"Cursor_node":172,"vy":8,"B":316,"clip_all":265,"on.textinput":177}
compute_layout = function(node, x,y, nodes_to_render)-- append to nodes_to_render flattened instructions to render a hierarchy of nodes-- return x,y rendered until (surface coordinates)if node.type == 'text' then-- leaf node containing raw textnode.x = xnode.y = y-- render background if necessarylocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)end-- render contentsif node.width thennode.w = node.widthelsenode.w = 0for i,s in ipairs(node.data) dolocal text = love.graphics.newText(font(20), node.data)local width = text:getWidth()print(node.data[i], 'has width', width)if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)end-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
{"parent":333,"font":228,"on.mouse_released":178,"on.update":315,"box_height":317,"on.keychord_pressed":311,"compute_layout":334,"to_text":180,"Page":324,"clip":236,"on.code_changed":306,"scale":7,"on.initialize":304,"Surface":196,"A":309,"on.draw":310,"Box_heights":277,"initialize_editor":333,"vx":5,"on.mouse_pressed":179,"Viewport":303,"on":1,"Cursor_node":172,"vy":8,"B":316,"clip_all":265,"on.textinput":177}
compute_layout = function(node, x,y, nodes_to_render)-- append to nodes_to_render flattened instructions to render a hierarchy of nodes-- return x,y rendered until (surface coordinates)if node.type == 'text' then-- leaf node containing raw textnode.x = xnode.y = y-- render background if necessarylocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)end-- render contentsif node.width thennode.w = node.widthelsenode.w = 0for i,s in ipairs(node.data) dolocal text = love.graphics.newText(20, node.data)local width = text:getWidth()print(node.data[i], 'has width', width)if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)end-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}table.insert(nodes_to_render, node_to_render)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
{"parent":332,"font":228,"on.mouse_released":178,"on.update":315,"box_height":317,"on.keychord_pressed":311,"compute_layout":301,"to_text":180,"Page":324,"clip":236,"on.code_changed":306,"scale":7,"on.initialize":304,"Surface":196,"A":309,"on.draw":310,"Box_heights":277,"initialize_editor":333,"vx":5,"on.mouse_pressed":179,"Viewport":303,"on":1,"Cursor_node":172,"vy":8,"B":316,"clip_all":265,"on.textinput":177}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":331,"box_height":317,"on.mouse_pressed":179,"initialize_editor":332,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":330,"box_height":317,"on.mouse_pressed":179,"initialize_editor":331,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":329,"box_height":317,"on.mouse_pressed":179,"initialize_editor":330,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)--[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":328,"box_height":317,"on.mouse_pressed":179,"initialize_editor":329,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)----[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))-- ]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":327,"box_height":317,"on.mouse_pressed":179,"initialize_editor":328,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)--[[print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))]]obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":326,"box_height":317,"on.mouse_pressed":179,"initialize_editor":327,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))print('left', vx(obj.x))print('right', vx(obj.x+obj.w))print('width', vx(obj.x+obj.w)-vx(obj.x))obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":325,"box_height":317,"on.mouse_pressed":179,"initialize_editor":326,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('width', obj.w, 'scales to', scale(obj.w))obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":324,"box_height":317,"on.mouse_pressed":179,"initialize_editor":325,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
initialize_editor = function(obj)if obj.w then-- use an editor to wrap the textlocal scaled_fontsize = scale(20)local scaled_lineheight = math.floor(scaled_fontsize*1.3)print('init', obj.data[1], obj.w)print('at zoom', Viewport.zoom)print('with width', obj.w)obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, scaled_lineheight)obj.editor.lines = load_array(obj.data)Text.redraw_all(obj.editor)endend
{"on.keychord_pressed":311,"scale":7,"Page":324,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":323,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},--[[{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},]]-- { type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={--[[{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},]]{ type='rows', width=90, data={-- {type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":323,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":322,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},--[[{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},]]-- { type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={--[[{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},]]{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":322,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":321,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},--[[{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},]]-- { type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={{ type='rows', width=90, data={{type='text', data={'abc'},},-- {type='text', data={'abc'},},}},{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":321,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":320,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},--[[{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},]]-- { type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":320,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":319,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},-- { type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":319,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":318,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={-- { type='text', data={''},},{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},{ type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":318,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":317,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
Page = {-- pagetype='cols', x=0, y=0,width=800, data={--[[-- editor covering left side{type='text',name='editor',doc='prose goes here, on the left half of the window',margin=Margin_left,data={-- "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",'1','2','3','mno','Acb','g','hij','klm','nop',},width=400, bg={r=1,g=1,b=0}},]]-- a table on the right{ type='rows', name='searches', margin=50, data={{ type='text', data={''},},{ type='cols', data={{ type='text', data={'search:'},},{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},}},{ type='text', data={'table:'},},{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={{ type='rows', width=90, data={{type='text', data={'abc'},},{type='text', data={'abc'},},}},{ type='rows', width=90, data={{type='text', data={'def'},},{type='text', data={'def'},},}},}},}},},}
{"on.keychord_pressed":311,"scale":7,"Page":312,"on.code_changed":306,"clip":236,"clip_all":265,"on.textinput":177,"Surface":196,"on.initialize":304,"font":228,"A":309,"vx":5,"Box_heights":277,"Viewport":303,"B":316,"compute_layout":301,"vy":8,"Cursor_node":172,"on":1,"parent":316,"box_height":317,"on.mouse_pressed":179,"initialize_editor":313,"on.mouse_released":178,"to_text":180,"on.update":315,"on.draw":310}
box_height = function(node)-- return the height of a node. The result is scaled.print('computing box height based on font size', node.scaled_fontsize, node.editor.font_height, node.editor.line_height)if #node.editor.lines > 1 then Box_heights = {} endlocal y = 0for i=1,#node.editor.lines dolocal line = node.editor.lines[i]if node.editor.line_cache[i] == nil thennode.editor.line_cache[i] = {}endnode.editor.line_cache[i].fragments = nilnode.editor.line_cache[i].screen_line_starting_pos = nilText.compute_fragments(node.editor, i)Text.populate_screen_line_starting_pos(node.editor, i)y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_posif #node.editor.lines > 1 thentable.insert(Box_heights, y)endText.clear_screen_line_cache(node.editor, i)endreturn yend