migrate old settings, attempt #3
This time we have to handle absolute filenames. Now lines-polygon-experiment fork should merge successfully, at least.
This commit is contained in:
parent
6ac45b75b9
commit
d1d05fe5c9
10
source.lua
10
source.lua
|
@ -86,8 +86,13 @@ end
|
||||||
function source.initialize_edit_side()
|
function source.initialize_edit_side()
|
||||||
load_from_disk(Editor_state)
|
load_from_disk(Editor_state)
|
||||||
Text.redraw_all(Editor_state)
|
Text.redraw_all(Editor_state)
|
||||||
Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
|
if File_navigation.cursors[Editor_state.filename] then
|
||||||
Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
|
Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
|
||||||
|
Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
|
||||||
|
else
|
||||||
|
Editor_state.screen_top1 = {line=1, pos=1}
|
||||||
|
Editor_state.cursor1 = {line=1, pos=1}
|
||||||
|
end
|
||||||
|
|
||||||
-- We currently start out with side B collapsed.
|
-- We currently start out with side B collapsed.
|
||||||
-- Other options:
|
-- Other options:
|
||||||
|
@ -129,6 +134,7 @@ function source.load_settings()
|
||||||
end
|
end
|
||||||
Editor_state = edit.initialize_state(Margin_top, Margin_left, right, settings.font_height, math.floor(settings.font_height*1.3))
|
Editor_state = edit.initialize_state(Margin_top, Margin_left, right, settings.font_height, math.floor(settings.font_height*1.3))
|
||||||
Editor_state.filename = settings.filename
|
Editor_state.filename = settings.filename
|
||||||
|
Editor_state.filename = basename(Editor_state.filename) -- migrate settings that used full paths; we now support only relative paths within the app
|
||||||
if settings.cursors then
|
if settings.cursors then
|
||||||
File_navigation.cursors = settings.cursors
|
File_navigation.cursors = settings.cursors
|
||||||
Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
|
Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
|
||||||
|
|
|
@ -216,3 +216,39 @@ end
|
||||||
function is_relative_path(path)
|
function is_relative_path(path)
|
||||||
return not is_absolute_path(path)
|
return not is_absolute_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function dirname(path)
|
||||||
|
local os_path_separator = package.config:sub(1,1)
|
||||||
|
if os_path_separator == '/' then
|
||||||
|
-- POSIX systems permit backslashes in filenames
|
||||||
|
return path:match('.*/') or './'
|
||||||
|
elseif os_path_separator == '\\' then
|
||||||
|
return path:match('.*[/\\]') or './'
|
||||||
|
else
|
||||||
|
error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_dirname()
|
||||||
|
check_eq(dirname('a/b'), 'a/', 'F - test_dirname')
|
||||||
|
check_eq(dirname('x'), './', 'F - test_dirname/current')
|
||||||
|
end
|
||||||
|
|
||||||
|
function basename(path)
|
||||||
|
local os_path_separator = package.config:sub(1,1)
|
||||||
|
if os_path_separator == '/' then
|
||||||
|
-- POSIX systems permit backslashes in filenames
|
||||||
|
return string.gsub(path, ".*/(.*)", "%1")
|
||||||
|
elseif os_path_separator == '\\' then
|
||||||
|
return string.gsub(path, ".*[/\\](.*)", "%1")
|
||||||
|
else
|
||||||
|
error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function empty(h)
|
||||||
|
for _,_ in pairs(h) do
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue