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S7IXAC R2ASHK5CEE3PTRLS37GP4PXJ7HIGJ6UD72KKBI57UDJI7VRROQGQC 2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC WLWNS6FBT6D3HKOFWDPBKLK7KS73LJJLWLHNWX3YJ723OHJBZGDQC MOAEVTKJCOJPY66OF74FOQIDQ4L2IP3JIKZLOYGHNRVKNQARSESAC LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC table.insert(event.lines, deepcopy(State.lines[i]))endreturn eventendfunction patch(lines, from, to)--? if #from.lines == 1 and #to.lines == 1 then--? assert(from.start_line == from.end_line)--? assert(to.start_line == to.end_line)--? assert(from.start_line == to.start_line)--? lines[from.start_line] = to.lines[1]--? return--? end
Text.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaks--? print('clearing line caches')-- Perform some early sanity checking here, in hopes that we correctly call-- this whenever we change editor state.if State.right <= State.left thenassert(false, ('Right margin %d must be to the right of the left margin %d'):format(State.right, State.left))endendfunction Text.in_line(State, line_index, x,y)local line = State.lines[line_index]local line_cache = State.line_cache[line_index]endendendendend-- return the location of the start of the bottom-most line on screenfunction Text.screen_bottom1(State)-- duplicate some logic from love.draw-- does not modify State (except to populate line_cache)local loc2 = Text.to2(State, State.screen_top1)local y = State.topwhile true doif State.lines[loc2.line].mode == 'text' theny = y + State.line_heightelseif State.lines[loc2.line].mode == 'drawing' theny = y + Drawing_padding_height + Drawing.pixels(State.lines[loc2.line].h, State.width)endif y + State.line_height > App.screen.height then break endlocal next_loc2 = Text.next_screen_line(State, loc2)if Text.eq2(next_loc2, loc2) then break endloc2 = next_loc2endreturn Text.to1(State, loc2)endendText.clear_screen_line_cache(State, State.cursor1.line)
-- screen_line_starting_pos: optional array of codepoint indices if it wraps over more than one screen lineText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksschedule_save(State)end-- clipboardschedule_save(State)endelseif chord == 'C-y' thenelseif chord == 'return' thenState.search_term = nilline_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.
local line = State.lines[i]if line.mode == 'text' thentable.insert(event.lines, {mode='text', data=line.data}) -- I've forgotten: should we deepcopy(line.data)?elseif line.mode == 'drawing' thentable.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})elseassert(false, ('unknown line mode %s'):format(line.mode))end
table.insert(event.lines, deepcopy(State.lines[i]))
function patch_placeholders(line_cache, from, to)assert(from.start_line == to.start_line, 'failed to patch undo operation')for i=from.end_line,from.start_line,-1 dotable.remove(line_cache, i)endassert(#to.lines == to.end_line-to.start_line+1, 'failed to patch undo operation')for i=1,#to.lines dotable.insert(line_cache, to.start_line+i-1, {})endend
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
Text.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaks
-- 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
Text.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaksText.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaks