VN3MTXFKOWZ7J3IZVWM45RT2HFGXTMNITZZRNSZZMY3HLXGOWG5AC
OWYI7OJT4JQK5R5ABHIYXJDVFBHQ2BRRLQ657OTND6KIPKGXGLBQC
57OGXVHZ44WNWVKNCMPJT7SAOF4MR4GXJ4ZQKHUFAKLZBB6ERDLAC
7VGDIPLCFDG3PVE4JH3WDKZ4A7PG5UYW7TLFFFOWN2JEUZYYTFJQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
LF7BWEG4DKQI7NMXMZC4LC2BE5PB42HK5PD6OYBNIDMAZBJASOKQC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
5STHSG4UB2SC4EZWOQHPQM43BLC4X2EJTNSSYRF35XEYVMTOID5AC
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 not edit.cursor_on_text(State)
or not Text.le1(State.screen_top1, State.cursor1) then
State.screen_top1 = {line=1, pos=1}
edit.put_cursor_on_first_text_line(State)
end
end
function edit.invalid1(State, loc1)
return loc1.line > #State.lines
or loc1.pos > #State.lines[loc1.line].data
end
function edit.cursor_on_text(State)
return State.cursor1.line <= #State.lines
and State.lines[State.cursor1.line].mode == 'text'
end
function edit.put_cursor_on_first_text_line(State)
State.cursor1 = {line=i, pos=1}