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RLVASQMHDYUYY5T67D3QC
K4OBZSHEBIZBAKPH3F7ASDGCPLB7D5W5QLFJQYSM5XOYDPB4BUHAC
QLTJG7Q33ABBTDJ55K3OPLNSYBFBIVRS3UABXEY73RHYMOOJ542QC
FKNXK2OAH4U2V2TXCHWE4C3Z5DROBIIPSXUWFKP7Q3DSNOKFFL5AC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
AVTNUQYRBW7IX2YQ3KDLVQ23RGW3BAKTAE7P73ASBYNKOHMQMH5AC
AJB4LFRBMIRBEDWJ3OW7GQIMD2BZBVQ62GH4TE2FISWZKSAHRF4QC
XSLCFVFHBXYPJDGOFULVB7UAWQY5CRDY4QKKHDXSZTSVLCHDL54QC
Z4KNS42NJZTQKUQZ7B5NYU2U4VOCUQCBFT2D7423MAXKF7NQ5ZJAC
3QQZ7W4EJ7G4HQM5IYWXICMAHVRGERY4X6AOC6LOV5NSZ4OBICSAC
DJGC4ZEFQZAAKF3YWQKHMHAP2KANFVQ2H7KWAC4PU3HPHP6WLSOAC
3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC
NOMLSMKK3XOFEG74ITJRBTCZGS3XETGIFV4UJOJIPS324BC3IF7QC
FS2ITYYHBLFT66YUC3ENPFYI2HOYHOVEPQIN7NQR6KF5MEK4NKZAC
-- resize helper
function Text.tweak_screen_top_and_cursor(State)
if State.screen_top1.pos == 1 then return end
Text.populate_screen_line_starting_pos(State, State.screen_top1.line)
local line = State.lines[State.screen_top1.line]
local line_cache = State.line_cache[State.screen_top1.line]
for i=2,#line_cache.screen_line_starting_pos do
local pos = line_cache.screen_line_starting_pos[i]
if pos == State.screen_top1.pos then
break
end
if pos > State.screen_top1.pos then
-- make sure screen top is at start of a screen line
local prev = line_cache.screen_line_starting_pos[i-1]
if State.screen_top1.pos - prev < pos - State.screen_top1.pos then
State.screen_top1.pos = prev
else
State.screen_top1.pos = pos
end
break
end
end
-- make sure cursor is on screen
if Text.lt1(State.cursor1, State.screen_top1) then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
elseif State.cursor1.line >= State.screen_bottom1.line then
--? print('too low')
if Text.cursor_out_of_screen(State) then
--? print('tweak')
State.cursor1 = {
line=State.screen_bottom1.line,
pos=Text.to_pos_on_line(State, State.screen_bottom1.line, State.right-5, App.screen.height-5),
}
end
end
end
-- resize helper
function Text.tweak_screen_top_and_cursor(State)
if State.screen_top1.pos == 1 then return end
Text.populate_screen_line_starting_pos(State, State.screen_top1.line)
local line = State.lines[State.screen_top1.line]
local line_cache = State.line_cache[State.screen_top1.line]
for i=2,#line_cache.screen_line_starting_pos do
local pos = line_cache.screen_line_starting_pos[i]
if pos == State.screen_top1.pos then
break
end
if pos > State.screen_top1.pos then
-- make sure screen top is at start of a screen line
local prev = line_cache.screen_line_starting_pos[i-1]
if State.screen_top1.pos - prev < pos - State.screen_top1.pos then
State.screen_top1.pos = prev
else
State.screen_top1.pos = pos
end
break
end
end
-- make sure cursor is on screen
if Text.lt1(State.cursor1, State.screen_top1) then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
elseif State.cursor1.line >= State.screen_bottom1.line then
--? print('too low')
if Text.cursor_out_of_screen(State) then
--? print('tweak')
State.cursor1 = {
line=State.screen_bottom1.line,
pos=Text.to_pos_on_line(State, State.screen_bottom1.line, State.right-5, App.screen.height-5),
}
end
end
end
* `App.resize(w,h)` -- called when you resize the app window. Provides new
window dimensions in `w` and `h`. Don't bother updating `App.screen.width`
and `App.screen.height`, that will happen automatically before calling
`on.resize`.
(Based on [LÖVE](https://love2d.org/wiki/love.resize))
* `App.filedropped(file)` -- called when a file icon is dragged and dropped on
the app window. Provides in `file` an object representing the file that was
dropped, that will respond to the following messages:
* `file:getFilename()` returning a string name
* `file:read()` returning the entire file contents in a single string
(Based on [LÖVE](https://love2d.org/wiki/love.filedropped).)
function App.resize(w,h)
if Current_app == 'run' then
if run.resize then run.resize(w,h) end
elseif Current_app == 'source' then
if source.resize then source.resize(w,h) end
else
assert(false, 'unknown app "'..Current_app..'"')
end
Last_resize_time = Current_time
end
-- some hysteresis while resizing
if Current_time < Last_resize_time + 0.1 then
return
end
--