Merge text0
This commit is contained in:
commit
e70e67859d
12
edit.lua
12
edit.lua
|
@ -78,7 +78,7 @@ function edit.check_locs(State)
|
|||
-- if State is inconsistent (i.e. file changed by some other program),
|
||||
-- throw away all cursor state entirely
|
||||
if edit.invalid1(State, State.screen_top1)
|
||||
or edit.invalid1(State, State.cursor1)
|
||||
or edit.invalid_cursor1(State)
|
||||
or not Text.le1(State.screen_top1, State.cursor1) then
|
||||
State.screen_top1 = {line=1, pos=1}
|
||||
State.cursor1 = {line=1, pos=1}
|
||||
|
@ -92,6 +92,16 @@ function edit.invalid1(State, loc1)
|
|||
return loc1.pos > #State.lines[loc1.line].data
|
||||
end
|
||||
|
||||
-- cursor loc in particular differs from other locs in one way:
|
||||
-- pos might occur just after end of line
|
||||
function edit.invalid_cursor1(State)
|
||||
local cursor1 = State.cursor1
|
||||
if cursor1.line > #State.lines then return true end
|
||||
local l = State.lines[cursor1.line]
|
||||
if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing line
|
||||
return cursor1.pos > #State.lines[cursor1.line].data + 1
|
||||
end
|
||||
|
||||
-- return y drawn until
|
||||
function edit.draw(State, fg, hide_cursor)
|
||||
if #State.lines ~= #State.line_cache then
|
||||
|
|
Loading…
Reference in New Issue