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CLKQA4MANGSAC
Top_screen_line_starting_pos = screen_line_starting_pos
print('previous screen line starts at '..tostring(screen_line_starting_pos)..' of its line')
if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos then
Top_screen_line_starting_pos = screen_line_starting_pos
end
Top_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index-1]
local s = string.sub(Lines[Cursor_line].data, Top_screen_line_starting_pos)
Cursor_pos = Text.nearest_cursor_pos(s, Cursor_x)
new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index-1]
print('switching pos of screen line at cursor from '..tostring(screen_line_starting_pos)..' to '..tostring(new_screen_line_starting_pos))
if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos then
Top_screen_line_starting_pos = new_screen_line_starting_pos
print('also setting pos of top of screen to '..tostring(Top_screen_line_starting_pos))
end
local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)
Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
print('cursor pos is now '..tostring(Cursor_pos))
end
end
end
function Text.pos_at_start_of_cursor_screen_line()
if Lines[Cursor_line].screen_line_starting_pos == nil then
return 1,1
end
for i=#Lines[Cursor_line].screen_line_starting_pos,1,-1 do
local spos = Lines[Cursor_line].screen_line_starting_pos[i]
if spos <= Cursor_pos then
return i,spos
love.window.setMode(0, 0) -- maximize
Screen_width, Screen_height, Screen_flags = love.window.getMode()
-- shrink slightly to account for window decoration
Screen_width = Screen_width-100
Screen_height = Screen_height-100
--? love.window.setMode(0, 0) -- maximize
--? Screen_width, Screen_height, Screen_flags = love.window.getMode()
--? -- shrink slightly to account for window decoration
--? Screen_width = Screen_width-100
--? Screen_height = Screen_height-100
Screen_width = 120
Screen_height = 200