30 lines
1.1 KiB
Plaintext
30 lines
1.1 KiB
Plaintext
initialize_editors = function(font_height, filename, screen_top)
|
|
Editors = {}
|
|
local font = love.graphics.newFont(font_height)
|
|
love.graphics.setFont(font)
|
|
-- initialize multiple editor widgets
|
|
local editor_width = 40*font:getWidth('m')
|
|
local width_remaining = App.screen.width - Margin_left - Margin_right
|
|
local left = Margin_left
|
|
repeat
|
|
local editor = edit.initialize_state(Margin_top, left, left + math.min(editor_width, width_remaining), font, font_height, math.floor(font_height*1.3))
|
|
table.insert(Editors, editor)
|
|
width_remaining = width_remaining - editor_width - Margin_left
|
|
left = left + editor_width + Margin_left
|
|
until width_remaining < editor_width
|
|
-- have them all operate on the file's lines
|
|
if filename then
|
|
love.window.setTitle('broadsheet.love - ' .. filename)
|
|
Editors[1].filename = filename
|
|
load_from_disk(Editors[1])
|
|
end
|
|
Text.redraw_all(Editors[1])
|
|
for e=2,#Editors do
|
|
local editor = Editors[e]
|
|
editor.lines = Editors[1].lines
|
|
Text.redraw_all(editor) -- TODO: share fragments between editors
|
|
end
|
|
Editors[1].screen_top1 = screen_top
|
|
resync_editors()
|
|
end
|