change a helper slightly
This commit is contained in:
parent
0e20565e17
commit
0a12e4c733
18
edit.lua
18
edit.lua
|
@ -113,7 +113,7 @@ function edit.check_locs(State)
|
||||||
or not edit.cursor_on_text(State)
|
or not edit.cursor_on_text(State)
|
||||||
or not Text.le1(State.screen_top1, State.cursor1) then
|
or not Text.le1(State.screen_top1, State.cursor1) then
|
||||||
State.screen_top1 = {line=1, pos=1}
|
State.screen_top1 = {line=1, pos=1}
|
||||||
edit.put_cursor_on_first_text_line(State)
|
edit.put_cursor_on_next_text_line(State)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -139,12 +139,16 @@ function edit.cursor_on_text(State)
|
||||||
and State.lines[State.cursor1.line].mode == 'text'
|
and State.lines[State.cursor1.line].mode == 'text'
|
||||||
end
|
end
|
||||||
|
|
||||||
function edit.put_cursor_on_first_text_line(State)
|
function edit.put_cursor_on_next_text_line(State)
|
||||||
for i,line in ipairs(State.lines) do
|
while true do
|
||||||
if line.mode == 'text' then
|
if State.cursor1.line >= #State.lines then
|
||||||
State.cursor1 = {line=i, pos=1}
|
break
|
||||||
break
|
end
|
||||||
end
|
if State.lines[State.cursor1.line].mode == 'text' then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
State.cursor1.line = State.cursor1.line+1
|
||||||
|
State.cursor1.pos = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ function edit.check_locs(State)
|
||||||
or not edit.cursor_on_text(State)
|
or not edit.cursor_on_text(State)
|
||||||
or not Text.le1(State.screen_top1, State.cursor1) then
|
or not Text.le1(State.screen_top1, State.cursor1) then
|
||||||
State.screen_top1 = {line=1, pos=1}
|
State.screen_top1 = {line=1, pos=1}
|
||||||
edit.put_cursor_on_first_text_line(State)
|
edit.put_cursor_on_next_text_line(State)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -131,12 +131,16 @@ function edit.cursor_on_text(State)
|
||||||
and State.lines[State.cursor1.line].mode == 'text'
|
and State.lines[State.cursor1.line].mode == 'text'
|
||||||
end
|
end
|
||||||
|
|
||||||
function edit.put_cursor_on_first_text_line(State)
|
function edit.put_cursor_on_next_text_line(State)
|
||||||
for i,line in ipairs(State.lines) do
|
while true do
|
||||||
if line.mode == 'text' then
|
if State.cursor1.line >= #State.lines then
|
||||||
State.cursor1 = {line=i, pos=1}
|
break
|
||||||
break
|
end
|
||||||
end
|
if State.lines[State.cursor1.line].mode == 'text' then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
State.cursor1.line = State.cursor1.line+1
|
||||||
|
State.cursor1.pos = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue