remove some duplication
This commit is contained in:
parent
4d1e7f922d
commit
9459d91abc
2
edit.lua
2
edit.lua
|
@ -119,7 +119,6 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c
|
||||||
end -- App.initialize_state
|
end -- App.initialize_state
|
||||||
|
|
||||||
function edit.fixup_cursor(State)
|
function edit.fixup_cursor(State)
|
||||||
if State.cursor1.line > #State.lines or State.lines[State.cursor1.line].mode ~= 'text' then
|
|
||||||
for i,line in ipairs(State.lines) do
|
for i,line in ipairs(State.lines) do
|
||||||
if line.mode == 'text' then
|
if line.mode == 'text' then
|
||||||
State.cursor1.line = i
|
State.cursor1.line = i
|
||||||
|
@ -127,7 +126,6 @@ function edit.fixup_cursor(State)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function edit.draw(State)
|
function edit.draw(State)
|
||||||
App.color(Text_color)
|
App.color(Text_color)
|
||||||
|
|
9
main.lua
9
main.lua
|
@ -47,8 +47,10 @@ function App.initialize(arg)
|
||||||
else
|
else
|
||||||
load_from_disk(Editor_state)
|
load_from_disk(Editor_state)
|
||||||
Text.redraw_all(Editor_state)
|
Text.redraw_all(Editor_state)
|
||||||
|
if Editor_state.cursor1.line > #Editor_state.lines or Editor_state.lines[Editor_state.cursor1.line].mode ~= 'text' then
|
||||||
edit.fixup_cursor(Editor_state)
|
edit.fixup_cursor(Editor_state)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
love.window.setTitle('lines.love - '..Editor_state.filename)
|
love.window.setTitle('lines.love - '..Editor_state.filename)
|
||||||
|
|
||||||
if #arg > 1 then
|
if #arg > 1 then
|
||||||
|
@ -125,12 +127,7 @@ function App.filedropped(file)
|
||||||
file:open('r')
|
file:open('r')
|
||||||
Editor_state.lines = load_from_file(file)
|
Editor_state.lines = load_from_file(file)
|
||||||
file:close()
|
file:close()
|
||||||
for i,line in ipairs(Editor_state.lines) do
|
edit.fixup_cursor(Editor_state)
|
||||||
if line.mode == 'text' then
|
|
||||||
Editor_state.cursor1.line = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
love.window.setTitle('lines.love - '..Editor_state.filename)
|
love.window.setTitle('lines.love - '..Editor_state.filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue