I'm feeling extremely stupid. Spent a couple of hours trying to track this down without success. I definitely saw it working for a bit, except that when it works things look different at different zoom levels. But now I can't even reproduce that.
My current best guess: there's an issue with various triggers and when they happen, rather than with box_height: on.draw compute_layout initialize_editor ??
OZNETUSGD7GQD3XDGBFEQBSXYE4UM6G5D6OBFVNQW3XLJERHU5WQC
remember cursor position within each definition
{"box_height":297,"on.keychord_pressed":200,"compute_layout":235,"Cursor_node":172,"on.code_changed":289,"on.textinput":177,"Surface":196,"to_text":180,"on.draw":293,"vx":5,"scale":7,"Viewport":233,"clip":236,"initialize_editor":290,"clip_all":265,"Page":296,"vy":8,"font":228,"on.update":239,"on.mouse_pressed":179,"parent":296,"on.mouse_released":178,"on":1,"Box_heights":277}
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 = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"box_height":295,"on.keychord_pressed":200,"compute_layout":235,"Cursor_node":172,"on.code_changed":289,"on.textinput":177,"Surface":196,"to_text":180,"on.draw":293,"vx":5,"scale":7,"Viewport":233,"clip":236,"initialize_editor":290,"clip_all":265,"Page":296,"vy":8,"font":228,"on.update":239,"on.mouse_pressed":179,"parent":295,"on.mouse_released":178,"on":1,"Box_heights":277}
Page = {
-- page
type='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'},},
}},
}},
}},
},
}
{"box_height":295,"on.keychord_pressed":200,"compute_layout":235,"Cursor_node":172,"on.code_changed":289,"on.textinput":177,"Surface":196,"to_text":180,"on.draw":293,"vx":5,"scale":7,"Viewport":233,"clip":236,"initialize_editor":290,"clip_all":265,"Page":263,"vy":8,"font":228,"on.update":239,"on.mouse_pressed":179,"parent":294,"on.mouse_released":178,"on":1,"Box_heights":277}
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 = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
end
return y
end
{"box_height":294,"on.keychord_pressed":200,"compute_layout":235,"Cursor_node":172,"on.code_changed":289,"on.textinput":177,"Surface":196,"to_text":180,"on.draw":293,"vx":5,"scale":7,"Viewport":233,"clip":236,"initialize_editor":290,"clip_all":265,"Page":263,"vy":8,"font":228,"on.update":239,"on.mouse_pressed":179,"parent":293,"on.mouse_released":178,"on":1,"Box_heights":277}
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 = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
end
return y
end
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
love.graphics.setColor(0,1,0)
for _,y in ipairs(Box_heights) do
love.graphics.line(vx(0), vy(y), vx(10), vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"Surface":196,"on.draw":293,"vx":5,"Viewport":233,"parent":292,"on":1,"clip":236,"clip_all":265,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"font":228,"on.update":239,"on.keychord_pressed":200,"Cursor_node":172,"Box_heights":277,"vy":8,"Page":263,"on.code_changed":289,"initialize_editor":290,"on.textinput":177,"box_height":291,"compute_layout":235,"scale":7}
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
love.graphics.setColor(0,1,0)
for _,y in ipairs(Box_heights) do
love.graphics.line(vx(0), vy(y), vx(10), vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"parent":291,"on.textinput":177,"to_text":180,"on.mouse_pressed":179,"on.mouse_released":178,"font":228,"on.update":239,"Page":263,"initialize_editor":290,"box_height":291,"on.keychord_pressed":200,"compute_layout":235,"clip":236,"clip_all":265,"Surface":196,"Box_heights":277,"on":1,"on.draw":292,"on.code_changed":289,"Cursor_node":172,"vy":8,"Viewport":233,"vx":5,"scale":7}
{"parent":290,"on.textinput":177,"to_text":180,"on.mouse_pressed":179,"on.mouse_released":178,"font":228,"on.update":239,"Page":263,"initialize_editor":290,"box_height":291,"on.keychord_pressed":200,"compute_layout":235,"clip":236,"clip_all":265,"Surface":196,"Box_heights":277,"on":1,"on.draw":286,"on.code_changed":289,"Cursor_node":172,"vy":8,"Viewport":233,"vx":5,"scale":7}
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 = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
end
return y
end
{"on.code_changed":289,"font":228,"Surface":196,"to_text":180,"clip_all":265,"on.draw":286,"on.textinput":177,"vx":5,"on":1,"Viewport":233,"parent":289,"vy":8,"scale":7,"on.mouse_pressed":179,"Cursor_node":172,"on.mouse_released":178,"Box_heights":277,"on.update":239,"box_height":285,"on.keychord_pressed":200,"compute_layout":235,"clip":236,"initialize_editor":290,"Page":263}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
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)
end
end
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(Page, Page.x,Page.y, Surface)
end
{"Surface":196,"on.draw":286,"vx":5,"Viewport":233,"vy":8,"to_text":180,"on":1,"on.mouse_pressed":179,"scale":7,"on.mouse_released":178,"parent":288,"clip_all":265,"box_height":285,"on.keychord_pressed":200,"compute_layout":235,"on.update":239,"initialize_editor":254,"Page":263,"clip":236,"on.textinput":177,"Box_heights":277,"on.code_changed":289,"font":228,"Cursor_node":172}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(Page, Page.x,Page.y, Surface)
end
{"Surface":196,"on.draw":286,"vx":5,"Viewport":233,"vy":8,"to_text":180,"on":1,"on.mouse_pressed":179,"scale":7,"on.mouse_released":178,"parent":287,"clip_all":265,"box_height":285,"on.keychord_pressed":200,"compute_layout":235,"on.update":239,"initialize_editor":254,"Page":263,"clip":236,"on.textinput":177,"Box_heights":277,"on.code_changed":288,"font":228,"Cursor_node":172}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(Page, Page.x,Page.y, Surface)
end
{"on.code_changed":287,"Surface":196,"clip_all":265,"on.draw":286,"on.textinput":177,"vx":5,"Viewport":233,"vy":8,"parent":286,"on.mouse_pressed":179,"Box_heights":277,"on.mouse_released":178,"scale":7,"on.update":239,"initialize_editor":254,"box_height":285,"clip":236,"compute_layout":235,"on.keychord_pressed":200,"Page":263,"Cursor_node":172,"font":228,"on":1,"to_text":180}
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
love.graphics.setColor(0,1,0)
for _,y in ipairs(Box_heights) do
love.graphics.line(vx(0), vy(y), vx(10), vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":286,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":285,"box_height":285,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":284,"box_height":285,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
print('box height', i, y)
table.insert(Box_heights, y)
end
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":283,"box_height":284,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
print('box height', i, y)
table.insert(Box_heights, y)
end
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":282,"box_height":283,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
print('box height', i, y)
table.insert(Box_heights, y)
end
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":281,"box_height":282,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
print('box height', i, y)
table.insert(Box_heights, y)
end
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":280,"box_height":281,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
end
return y
end
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
love.graphics.setColor(0,1,0)
for _,y in ipairs(Box_heights) do
love.graphics.line(vx(0), vy(y), vx(10), vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":280,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":279,"box_height":278,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
love.graphics.setColor(0,1,0)
for _,y in Box_heights do
love.graphics.line(vx(0), vy(y), vx(10), vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":279,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":278,"box_height":278,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":277,"box_height":278,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
box_height = function(node)
-- return the height of a node. The result is scaled.
Box_heights = {}
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
table.insert(Box_heights, y)
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on":1,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":276,"box_height":276,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"Box_heights":277}
Box_heights = {}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":275,"box_height":276,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
-- return the height of a node. The result is scaled.
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":274,"box_height":275,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
-- return the height of a node. The result is scaled.
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":273,"box_height":274,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
-- return the height of a node. The result is scaled.
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":272,"box_height":273,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
-- return the height of a node. The result is scaled.
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":272,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":271,"box_height":270,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
print('heights', obj.editor.line_height, obj.editor.font_height, obj.scaled_fontsize)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":271,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":270,"box_height":270,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":266,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":269,"box_height":270,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":266,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":268,"box_height":269,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + math.floor(scale(node.editor.line_height))*#node.editor.line_cache[i].screen_line_starting_pos
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":266,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":267,"box_height":268,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
-- y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
y = y + scale(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
print('height', i, node.editor.line_height, Viewport.zoom, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":266,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":266,"box_height":267,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + node.scaled_fontsize*#node.editor.line_cache[i].screen_line_starting_pos
-- y = y + scale(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
print('height', i, node.editor.line_height, Viewport.zoom, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('setting font', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":266,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":265,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":264,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":265,"on.mouse_released":178,"Cursor_node":172,"parent":264,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
clip_all = function()
for _,node in ipairs(Surface) do
if node.editor then
clip(node)
end
end
end
on.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for x=0,1000,100 do
love.graphics.line(vx(x),vy(-5), vx(x),vy(5))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":264,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":241,"on.mouse_released":178,"Cursor_node":172,"parent":263,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":262,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":241,"on.mouse_released":178,"Cursor_node":172,"parent":262,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":263,"clip":236,"scale":7,"on":1}
Page = {
-- page
type='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.draw = function()
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(vx(-5),vy(y), vx(5),vy(y))
end
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.code_changed":212,"font":228,"Surface":196,"on.draw":262,"vx":5,"Viewport":233,"to_text":180,"vy":8,"initialize_editor":254,"on.mouse_pressed":179,"clip_all":241,"on.mouse_released":178,"Cursor_node":172,"parent":261,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on.update":239,"Page":243,"clip":236,"scale":7,"on":1}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(obj.editor.left,vy(y), obj.editor.right,vy(y))
end
end
end
end
end
{"on.code_changed":212,"scale":7,"on.textinput":177,"Surface":196,"clip":236,"on.draw":261,"vx":5,"font":228,"Viewport":233,"on":1,"vy":8,"to_text":180,"on.mouse_pressed":179,"parent":260,"on.mouse_released":178,"initialize_editor":254,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"Page":243,"on.update":239,"Cursor_node":172,"clip_all":241}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for y=0,1000,100 do
love.graphics.line(obj.editor.left,y, obj.editor.right,y)
end
end
end
end
end
{"on.code_changed":212,"scale":7,"on.textinput":177,"Surface":196,"clip":236,"on.draw":260,"vx":5,"font":228,"Viewport":233,"on":1,"vy":8,"to_text":180,"on.mouse_pressed":179,"parent":259,"on.mouse_released":178,"initialize_editor":254,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"Page":243,"on.update":239,"Cursor_node":172,"clip_all":241}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for i=1,#obj.editor.lines do
local y = obj.y + obj.editor.line_cache[i].starty
love.graphics.line(obj.editor.left,y, obj.editor.right,y)
end
end
end
end
end
{"Page":243,"on.code_changed":212,"Surface":196,"to_text":180,"vx":5,"Viewport":233,"font":228,"initialize_editor":254,"vy":8,"Cursor_node":172,"on.mouse_pressed":179,"clip":236,"scale":7,"clip_all":241,"on.draw":259,"on.mouse_released":178,"parent":258,"on.update":239,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on":1}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for i=1,#obj.editor.lines do
local y = obj.y + obj.editor.line_cache[i].starty
love.graphics.line(0,y, 800,y)
end
end
end
end
end
{"Page":243,"on.code_changed":212,"Surface":196,"to_text":180,"vx":5,"Viewport":233,"font":228,"initialize_editor":254,"vy":8,"Cursor_node":172,"on.mouse_pressed":179,"clip":236,"scale":7,"clip_all":241,"on.draw":258,"on.mouse_released":178,"parent":257,"on.update":239,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on":1}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for i=1,#obj.editor.lines do
local y = vy(obj.editor.line_cache[i].starty)
love.graphics.line(0,y, 800,y)
end
end
end
end
end
{"Page":243,"on.code_changed":212,"Surface":196,"to_text":180,"vx":5,"Viewport":233,"font":228,"initialize_editor":254,"vy":8,"Cursor_node":172,"on.mouse_pressed":179,"clip":236,"scale":7,"clip_all":241,"on.draw":257,"on.mouse_released":178,"parent":256,"on.update":239,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on":1}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
love.graphics.setColor(1,0,0)
for i=1,#obj.editor.lines do
local y = vy(obj.editor.lines[i].starty)
love.graphics.line(0,y, 800,y)
end
end
end
end
end
{"Page":243,"on.code_changed":212,"Surface":196,"to_text":180,"vx":5,"Viewport":233,"font":228,"initialize_editor":254,"vy":8,"Cursor_node":172,"on.mouse_pressed":179,"clip":236,"scale":7,"clip_all":241,"on.draw":256,"on.mouse_released":178,"parent":255,"on.update":239,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on":1}
{"Page":243,"on.code_changed":212,"Surface":196,"to_text":180,"vx":5,"Viewport":233,"font":228,"initialize_editor":254,"vy":8,"Cursor_node":172,"on.mouse_pressed":179,"clip":236,"scale":7,"clip_all":241,"on.draw":234,"on.mouse_released":178,"parent":254,"on.update":239,"box_height":255,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"on":1}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + scale(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
print('height', i, node.editor.line_height, Viewport.zoom, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"on.code_changed":212,"on.textinput":177,"Surface":196,"to_text":180,"scale":7,"vx":5,"Viewport":233,"vy":8,"on":1,"Page":243,"parent":253,"on.draw":234,"on.mouse_pressed":179,"clip":236,"on.mouse_released":178,"clip_all":241,"on.update":239,"box_height":250,"on.keychord_pressed":200,"compute_layout":235,"font":228,"initialize_editor":254,"Cursor_node":172}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
print(obj.fontsize, scaled_fontsize, scaled_lineheight)
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)
end
end
{"font":228,"initialize_editor":253,"Surface":196,"Cursor_node":172,"on.draw":234,"parent":252,"vx":5,"on":1,"on.textinput":177,"to_text":180,"on.mouse_released":178,"vy":8,"on.update":239,"box_height":250,"on.keychord_pressed":200,"compute_layout":235,"on.mouse_pressed":179,"clip_all":241,"Page":243,"Viewport":233,"clip":236,"on.code_changed":212,"scale":7}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
print(obj.fontsize, scaled_fontsize, scaled_lineheight)
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)
end
end
{"initialize_editor":252,"on.mouse_pressed":179,"on.mouse_released":178,"Cursor_node":172,"on.update":239,"box_height":250,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"Page":243,"to_text":180,"on.code_changed":212,"scale":7,"Surface":196,"on.draw":234,"vx":5,"font":228,"clip":236,"Viewport":233,"clip_all":241,"on":1,"vy":8,"parent":251}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
print(obj.fontsize, scaled_fontsize, scaled_lineheight)
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)
end
end
{"initialize_editor":251,"on.mouse_pressed":179,"on.mouse_released":178,"Cursor_node":172,"on.update":239,"box_height":250,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"Page":243,"to_text":180,"on.code_changed":212,"scale":7,"Surface":196,"on.draw":234,"vx":5,"font":228,"clip":236,"Viewport":233,"clip_all":241,"on":1,"vy":8,"parent":250}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
print(scaled_fontsize, scaled_lineheight)
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)
end
end
{"initialize_editor":74,"on.mouse_pressed":179,"on.mouse_released":178,"Cursor_node":172,"on.update":239,"box_height":250,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"Page":243,"to_text":180,"on.code_changed":212,"scale":7,"Surface":196,"on.draw":234,"vx":5,"font":228,"clip":236,"Viewport":233,"clip_all":241,"on":1,"vy":8,"parent":249}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + scale(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
print('height', i, node.editor.line_height, Viewport.zoom, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"initialize_editor":74,"on.mouse_pressed":179,"on.mouse_released":178,"Cursor_node":172,"on.update":239,"box_height":249,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"Page":243,"to_text":180,"on.code_changed":212,"scale":7,"Surface":196,"on.draw":234,"vx":5,"font":228,"clip":236,"Viewport":233,"clip_all":241,"on":1,"vy":8,"parent":248}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + scale(node.editor.line_height)*#node.editor.line_cache[i].screen_line_starting_pos
print('height', i, node.editor.line_height, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"initialize_editor":74,"on.mouse_pressed":179,"on.mouse_released":178,"Cursor_node":172,"on.update":239,"box_height":248,"on.keychord_pressed":200,"compute_layout":235,"on.textinput":177,"Page":243,"to_text":180,"on.code_changed":212,"scale":7,"Surface":196,"on.draw":234,"vx":5,"font":228,"clip":236,"Viewport":233,"clip_all":241,"on":1,"vy":8,"parent":247}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.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_pos
print('height', i, node.editor.line_height, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"on.mouse_released":178,"on.update":239,"box_height":247,"on.keychord_pressed":200,"compute_layout":235,"parent":246,"Page":243,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.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_pos
print('height', i, node.editor.line_height, #node.editor.line_cache[i].screen_line_starting_pos, y)
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
{"on.mouse_released":178,"on.update":239,"box_height":246,"on.keychord_pressed":200,"compute_layout":235,"parent":245,"Page":243,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.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_pos
Text.clear_screen_line_cache(node.editor, i)
print('height', i, node.editor.line_height, #node.editor.line_cache[i].screen_line_starting_pos, y)
end
return y
end
{"on.mouse_released":178,"on.update":239,"box_height":245,"on.keychord_pressed":200,"compute_layout":235,"parent":244,"Page":243,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.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_pos
Text.clear_screen_line_cache(node.editor, i)
print('height', i, y)
end
return y
end
{"on.mouse_released":178,"on.update":239,"box_height":244,"on.keychord_pressed":200,"compute_layout":235,"parent":243,"Page":243,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.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_pos
Text.clear_screen_line_cache(node.editor, i)
print('height', i, y)
end
return y
end
{"on.mouse_released":178,"on.update":239,"box_height":44,"on.keychord_pressed":200,"compute_layout":235,"parent":242,"Page":243,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
Page = {
-- page
type='cols', x=0, y=20,
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.mouse_released":178,"on.update":239,"box_height":44,"on.keychord_pressed":200,"compute_layout":235,"parent":241,"Page":242,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
Page = {
-- page
type='cols', x=0, y=20,
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',
},
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.mouse_released":178,"on.update":239,"box_height":44,"on.keychord_pressed":200,"compute_layout":235,"parent":240,"Page":202,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":241,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
clip_all = function()
for _,node in ipairs(Surface) do
if node.editor then
clip(node)
print('node now rendering from', node.editor.screen_top1.line, node.editor.screen_top1.pos)
end
end
end
{"on.mouse_released":178,"on.update":239,"box_height":44,"on.keychord_pressed":200,"compute_layout":235,"parent":239,"Page":202,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":240,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
clip_all = function()
for _,node in ipairs(Surface) do
if node.editor then
clip(node)
end
end
end
on.update = function(dt)
if Pan then
Viewport.x = Pan.x - love.mouse.getX()
Viewport.y = Pan.y - love.mouse.getY()
end
if App.mouse_down(1) then
clip_all()
end
end
{"on.mouse_released":178,"on.update":239,"box_height":44,"on.keychord_pressed":200,"compute_layout":235,"parent":238,"Page":202,"on.textinput":177,"on.code_changed":212,"Surface":196,"on":1,"font":228,"to_text":180,"on.draw":234,"Viewport":233,"scale":7,"clip":236,"vy":8,"initialize_editor":74,"clip_all":237,"Cursor_node":172,"vx":5,"on.mouse_pressed":179}
on.update = function(dt)
if App.mouse_down(1) then
clip_all()
end
end
{"vx":5,"on.textinput":177,"Viewport":233,"vy":8,"on.mouse_pressed":179,"on.mouse_released":178,"scale":7,"on.update":238,"to_text":180,"on.keychord_pressed":200,"compute_layout":235,"parent":237,"Page":202,"clip_all":237,"box_height":44,"on.code_changed":212,"Cursor_node":172,"initialize_editor":74,"on":1,"clip":236,"Surface":196,"on.draw":234,"font":228}
{"vx":5,"on.textinput":177,"Viewport":233,"vy":8,"on.mouse_pressed":179,"on.mouse_released":178,"scale":7,"on.update":14,"to_text":180,"on.keychord_pressed":200,"compute_layout":235,"parent":236,"Page":202,"clip_all":237,"box_height":44,"on.code_changed":212,"Cursor_node":172,"initialize_editor":74,"on":1,"clip":236,"Surface":196,"on.draw":234,"font":228}
clip_all = function()
for _,node in ipairs(Surface) do
if node.type == 'text' then
clip(node)
end
end
end
{"vx":5,"on.textinput":177,"Viewport":233,"vy":8,"on.mouse_pressed":179,"on.mouse_released":178,"scale":7,"on.update":14,"to_text":180,"on.keychord_pressed":200,"compute_layout":235,"parent":235,"Page":202,"box_height":44,"on.code_changed":212,"Cursor_node":172,"initialize_editor":74,"on":1,"clip":236,"Surface":196,"on.draw":234,"font":228}
clip = function(node)
if Viewport.y <= node.y then
node.editor.screen_top1.line = 1
node.editor.screen_top1.pos = 1
return
end
end