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XGN5WYC7ZW42EI2I6D5IJAC 2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC PJEQCTBL2ZX5Q7NJQ3KCWSHHBV2QWGYS5NVMRDNK5LOOIIRRIPHAC APX2PY6GAMJSUH7SFSMBFOQJBSAWLLOCKH4L4ZQP2VLHNEXJPREAC MD3W5IRAC6UQALQE4LJC52VQNDO3I3HXF3XE2XHDABXBYJBUVAXQC 7VGDIPLCFDG3PVE4JH3WDKZ4A7PG5UYW7TLFFFOWN2JEUZYYTFJQC R56CKHYZLUOTRK42EKTFC4KUUYI76PREFVFE2YKCZCODFKIJKAQQC 3XNFQDDNFGTN6ZFAB47AR6Q3663WLXDYC3K5TERYUWDM6U2FNOVAC LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC function Drawing.mouse_release(State, x,y, mouse_button)if line_cache.starty == nil then-- some event cleared starty just this frame-- draw in this frame will soon set starty-- just skip this framereturnendassert(drawing.mode == 'drawing')local pmx, pmy = App.mouse_x(), App.mouse_y()local mx = Drawing.coord(pmx-State.left, State.width)local my = Drawing.coord(pmy-line_cache.starty, State.width)if App.mouse_down(1) thenif Drawing.in_drawing(drawing, line_cache, pmx,pmy, State.left,State.right) thenif drawing.pending.mode == 'freehand' thentable.insert(drawing.pending.points, {x=mx, y=my})elseif drawing.pending.mode == 'move' thendrawing.pending.target_point.x = mxdrawing.pending.target_point.y = myDrawing.relax_constraints(drawing, drawing.pending.target_point_index)endendelseif State.current_drawing_mode == 'move' thenif Drawing.in_drawing(drawing, line_cache, pmx, pmy, State.left,State.right) thendrawing.pending.target_point.x = mxdrawing.pending.target_point.y = myDrawing.relax_constraints(drawing, drawing.pending.target_point_index)endelse-- do nothingendendfunction Drawing.relax_constraints(drawing, p)for _,shape in ipairs(drawing.shapes) doif shape.mode == 'manhattan' thenif shape.p1 == p thenshape.mode = 'line'elseif shape.p2 == p thenshape.mode = 'line'endelseif shape.mode == 'rectangle' or shape.mode == 'square' thenfor _,v in ipairs(shape.vertices) doif v == p thenshape.mode = 'polygon'endendendendendfunction Drawing.mouse_press(State, drawing_index, x,y, mouse_button)love.graphics.circle('line', cx,cy, Drawing.pixels(r, width))elseif shape.mode == 'arc' thenlocal center = drawing.points[shape.center]if mx < 0 or mx >= 256 or my < 0 or my >= drawing.h thenreturnendshape.end_angle = geom.angle_with_hint(center.x,center.y, mx,my, shape.end_angle)local cx,cy = px(center.x), py(center.y)love.graphics.arc('line', 'open', cx,cy, Drawing.pixels(shape.radius, width), shape.start_angle, shape.end_angle, 360)elseif shape.mode == 'move' then-- nothing pending; changes are immediately committedelseif shape.mode == 'name' then-- nothing pending; changes are immediately committedelseprint(shape.mode)assert(false)endendfunction Drawing.in_drawing(drawing, line_cache, x,y, left,right)if line_cache.starty == nil then return false end -- outside current pagelocal width = right-leftreturn y >= line_cache.starty and y < line_cache.starty + Drawing.pixels(drawing.h, width) and x >= left and x < rightendlocal r = round(geom.dist(center.x, center.y, mx, my))local cx,cy = px(center.x), py(center.y)
if show_line_numbers thenApp.color(Line_number_color)love.graphics.print(line_index, State.left-Line_number_width*App.width('m')+10,y)endinitialize_color()function Text.draw(State, line_index, y, startpos, hide_cursor, show_line_numbers)local line = State.lines[line_index]local line_cache = State.line_cache[line_index]line_cache.starty = yline_cache.startpos = startpos
edit.put_cursor_on_next_text_line(State)for i=1,math.floor(-dy) doText.down(State)endedit.put_cursor_on_next_text_line(State)for i=1,math.floor(dy) doText.up(State)endelseif dy < 0 thenState.cursor1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}y, screen_bottom1.pos = Text.draw(State, line_index, y, startpos, hide_cursor, show_line_numbers)--? print('=> y', y)elseif line.mode == 'drawing' theny = y+Drawing_padding_topDrawing.draw(State, line_index, y)y = y + Drawing.pixels(line.h, State.width) + Drawing_padding_bottomelseprint(line.mode)assert(false)local buttonx = State.left-Margin_left+4if show_line_numbers thenbuttonx = 4 -- HACK: position draw buttons at a fixed x on screenendbutton(State, 'draw', {x=buttonx, y=y+4, w=12,h=12, color={1,1,0},icon = icon.insert_drawing,onpress1 = function()Drawing.before = snapshot(State, line_index-1, line_index)table.insert(State.lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})table.insert(State.line_cache, line_index, {})if State.cursor1.line >= line_index thenState.cursor1.line = State.cursor1.line+1endschedule_save(State)record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})end,})function edit.draw(State, hide_cursor, show_line_numbers)State.button_handlers = {}App.color(Text_color)function edit.put_cursor_on_next_text_line(State)while true doif State.cursor1.line >= #State.lines thenbreakendif State.lines[State.cursor1.line].mode == 'text' thenbreakendState.cursor1.line = State.cursor1.line+1State.cursor1.pos = 1endendedit.put_cursor_on_next_text_line(State)endendfunction edit.invalid1(State, loc1)left = math.floor(left), -- left margin for text; line numbers go to the left of thisright = math.floor(right),
edit.draw(Editor_state, --[[hide cursor?]] Show_file_navigator, --[[show line numbers]] true)if Show_log_browser_side then-- dividerApp.color(Divider_color)love.graphics.rectangle('fill', App.screen.width/2-1,Menu_status_bar_height, 3,App.screen.height)--love.window.setTitle('text.love - source - '..Editor_state.filename)
source.switch_to_file(s..'.lua')love.window.setTitle('lines.love - source - '..Editor_state.filename)reset_file_navigator()endfunction move_candidate_to_front(s)local index = array.find(File_navigation.all_candidates, s)assert(index)table.remove(File_navigation.all_candidates, index)table.insert(File_navigation.all_candidates, 1, s)endfunction reset_file_navigator()Show_file_navigator = falseFile_navigation.index = 1File_navigation.filter = ''File_navigation.candidates = File_navigation.all_candidatesend
App.screen.width - Test_margin_right,Test_margin_right = 0-- Insulate tests from some key globals so I don't have to change the vast-- majority of tests when they're modified for the real app.if State.next_save and State.next_save < Current_time thenendState.search_backup = {cursor={line=State.cursor1.line, pos=State.cursor1.pos},screen_top={line=State.screen_top1.line, pos=State.screen_top1.pos},}