V757LVMS3JLDGEPVTWCX2WEFIWDIZOTPTTGRX3IODGBTJ6IHQHNAC
Q65423XUYWJ5ESAH2B63MJKJUXSTQDANPZRRMQNYTDF3YGT5HLRAC
2GVF47BINWURV2RS7QY6BOOV4X7NX2WWAF2CG42DSCCKI7MVSJ4QC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
ICUW7F3XQLURK4LSNPH5E3NDEFSRHKATEUHH2UPFJTMHYR3ZJF3QC
MYQNSDA3BKAVX3AKPKUDVFOL7B2O53O7U75B6Y673HJZGOULFBYAC
PNHUONCTGKL3FJIGCGRKTJ532MAK7JXWIFAITS3M7C4YDHCAMTGAC
ILOA5BYFTQKBSHLFMMZUVPQ2JXBFJD62ERQFBTDK2WSRXUN525VQC
7Y7C7N6OVIL4YT33DYCBAPTH7COHOAWQGHGPUNBNLYQ2HW65PWFAC
LLQC2M2IMEJBJQXZTKC3OAKG5WKHSERXKAKCYHQRUZZD6CVRIHAQC
R2ASHK5CEE3PTRLS37GP4PXJ7HIGJ6UD72KKBI57UDJI7VRROQGQC
-- some constants people might like to tweak
Text_color = {r=0, g=0, b=0}
Cursor_color = {r=1, g=0, b=0}
Highlight_color = {r=0.7, g=0.7, b=0.9} -- selected text
Margin_top = 15
Margin_left = 25
Margin_right = 25
edit = {}
-- run in both tests and a real run
local result = {
lines = {{data=''}}, -- array of strings
-- Lines can be too long to fit on screen, in which case they _wrap_ into
-- multiple _screen lines_.
-- rendering wrapped text lines needs some additional short-lived data per line:
-- startpos, the index of data the line starts rendering from, can only be >1 for topmost line on screen
line_cache = {},
-- Given wrapping, any potential location for the text cursor can be described in two ways:
-- * schema 1: As a combination of line index and position within a line (in utf8 codepoint units)
-- * schema 2: As a combination of line index, screen line index within the line, and a position within the screen line.
--
-- Most of the time we'll only persist positions in schema 1, translating to
-- schema 2 when that's convenient.
--
-- Make sure these coordinates are never aliased, so that changing one causes
-- action at a distance.
-- fragments: snippets of the line guaranteed to not straddle screen lines
-- screen_line_starting_pos: optional array of grapheme indices if it wraps over more than one screen line
-- screen_line_starting_pos: optional array of codepoint indices if it wraps over more than one screen line
selection1 = {},
-- some extra state to compute selection between mouse press and release
old_cursor1 = nil,
old_selection1 = nil,
mousepress_shift = nil,
-- cursor coordinates in pixels
cursor_x = 0,
cursor_y = 0,
font_height = font_height,
line_height = line_height,
top = top,
left = math.floor(left),
right = math.floor(right),
width = right-left,
filename = love.filesystem.getSourceBaseDirectory()..'/lines.txt', -- '/' should work even on Windows
next_save = nil,
-- undo
history = {},
next_history = 1,
-- search
search_term = nil,
search_backup = nil, -- stuff to restore when cancelling search
}
return result
or not Text.le1(State.screen_top1, State.cursor1) then
State.screen_top1 = {line=1, pos=1}
State.cursor1 = {line=1, pos=1}
end
end
function edit.invalid1(State, loc1)
if loc1.line > #State.lines then return true end
local l = State.lines[loc1.line]
if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing line
return loc1.pos > #State.lines[loc1.line].data