start rendering the initialized thread
This required a little more restructuring of Global_state. It's not flat now, it's hierarchical again, but in a different way. after commit 3d89b8eb9d: post \- reply A \- reply B \- reply C after commit f9f7dab9b7: post reply A reply B reply C after this commit: row \- col \- indent 0 \- post \- col \- indent 1 \- reply A \- col \- indent 2 \- reply B \- col \- indent 1 \- reply C The indents are just invisible rectangles of different widths with 0 height. One change I had to make was to initialize_editor. Neither luaML and driver load lines from disk, but that's arguably the common scenario to support.
This commit is contained in:
parent
551e072926
commit
37d5358290
|
@ -2,7 +2,7 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
if mouse_press_consumed_by_any_button_handler(Global_state, x,y, mouse_button) then
|
||||
return
|
||||
end
|
||||
if Global_state.items then
|
||||
if Global_state.root then
|
||||
mouse_press_on_surface(x,y, mouse_button)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,6 @@
|
|||
on.code_change = function()
|
||||
print('code changed')
|
||||
A()
|
||||
if Global_state.root then
|
||||
A()
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ initialize_editor = function(obj)
|
|||
local scaled_fontsize = scale(20)
|
||||
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
|
||||
obj.editor = edit.initialize_state(Menu_bar_height + 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)
|
||||
obj.editor.lines = obj.data
|
||||
Text.redraw_all(obj.editor)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,6 @@
|
|||
on.initialize = function()
|
||||
local font = love.graphics.getFont()
|
||||
font:setLineHeight(1.3)
|
||||
Files = love.filesystem.getDirectoryItems('data')
|
||||
for i=#Files,1,-1 do
|
||||
if (not Files[i]:match('%.md$')) or Files[i]:match('%-%d+.md$') then
|
||||
|
@ -6,6 +8,4 @@ on.initialize = function()
|
|||
end
|
||||
end
|
||||
table.sort(Files)
|
||||
new_definition()
|
||||
A()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
on.draw = function()
|
||||
Global_state.button_handlers = {}
|
||||
local font = love.graphics.getFont()
|
||||
font:setLineHeight(1.3)
|
||||
if Global_state.items == nil then
|
||||
if Global_state.root == nil then
|
||||
-- TODO: use surface for file picker as well
|
||||
draw_file_picker()
|
||||
else
|
||||
draw_surface()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
0028-A
6
0028-A
|
@ -1,11 +1,9 @@
|
|||
A = function(preserve_screen_top_of_cursor_node)
|
||||
-- print('A')
|
||||
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
|
||||
-- translate Definitions to Surface
|
||||
-- translate Global_state.root to Surface
|
||||
Surface = {}
|
||||
for key,node in pairs(Definitions) do
|
||||
compute_layout(node, node.x,node.y, Surface, preserve_screen_top_of_cursor_node)
|
||||
end
|
||||
compute_layout(Global_state.root, 0,0, Surface, preserve_screen_top_of_cursor_node)
|
||||
-- continue the pipeline
|
||||
B(preserve_screen_top_of_cursor_node)
|
||||
-- TODO: ugly that we're manipulating editor objects twice
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
Definitions = {
|
||||
-- table mapping names to boxes where we edit their definitions
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
new_definition = function()
|
||||
if Cursor_node then
|
||||
Cursor_node.show_cursor = false
|
||||
end
|
||||
table.insert(Definitions, {
|
||||
type='text',
|
||||
data={''},
|
||||
x=Spawn_point.x, y=Spawn_point.y,
|
||||
width=600,
|
||||
bg=Border_color, -- TODO: bg isn't accurate if obj.drawmode = 'line'
|
||||
})
|
||||
Viewport.x = Spawn_point.x-30
|
||||
Viewport.y = Spawn_point.y-30
|
||||
Cursor_node = Definitions[#Definitions]
|
||||
Cursor_node.show_cursor = true
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
update_font_size = function(n)
|
||||
Font_height = n
|
||||
love.graphics.setFont(love.graphics.newFont(Font_height))
|
||||
local font = love.graphics.getFont()
|
||||
font:setLineHeight(1.3)
|
||||
Line_height = math.floor(Font_height*1.3)
|
||||
Menu_bar_height = 5 + Line_height + 5
|
||||
if Global_state.items then
|
||||
for _,item in ipairs(Global_state.items) do
|
||||
edit.update_font_settings(item, n)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
open_thread = function(filename)
|
||||
Global_state.items = {}
|
||||
load_subtree(filename, Global_state.items)
|
||||
Global_state.root = rows()
|
||||
load_subtree(filename, Global_state.root.data, 0)
|
||||
love.window.setTitle('pothi.love - '..filename)
|
||||
A()
|
||||
end
|
|
@ -1,8 +1,14 @@
|
|||
load_subtree = function(filename, out, depth)
|
||||
-- load a file and recursively all replies to it
|
||||
-- print('load_subtree', filename)
|
||||
local item = initialize_item(filename)
|
||||
table.insert(out, item)
|
||||
local item = initialize_item(filename, depth)
|
||||
-- every item is a row consisting of two columns:
|
||||
-- one column of padding and another of text
|
||||
local row = cols()
|
||||
table.insert(row.data,
|
||||
{type='rectangle', w=depth*Indent, h=0})
|
||||
table.insert(row.data, item)
|
||||
table.insert(out, row)
|
||||
for i,reply_id in ipairs(item.metadata.replies) do
|
||||
local reply = load_subtree(reply_id, out, depth+1)
|
||||
end
|
||||
|
|
|
@ -5,6 +5,8 @@ initialize_item = function(filename, depth)
|
|||
result.data = result.lines
|
||||
result.lines = nil
|
||||
-- more fields
|
||||
result.type = 'text'
|
||||
result.width = Width
|
||||
result.depth = depth
|
||||
result.metadata = load_metadata(filename)
|
||||
return result
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Indent = 20 -- number of pixels to indent replies by
|
|
@ -0,0 +1 @@
|
|||
Width = 600
|
Loading…
Reference in New Issue