diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-05-17 19:48:12 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-05-17 19:48:12 -0700 |
commit | 40b1780bcab572ac4088343405b7a9c25500a0b3 (patch) | |
tree | f242d94df1b5cbd9df6043711dc1ab28f24505bc | |
parent | 2aa8c67a22e26e9b4bdf733904be6fa6cfdab0d1 (diff) | |
download | lines.love-40b1780bcab572ac4088343405b7a9c25500a0b3.tar.gz |
longer names for indices in long loops
-rw-r--r-- | main.lua | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/main.lua b/main.lua index ce5b5ed..57a7d7b 100644 --- a/main.lua +++ b/main.lua @@ -100,19 +100,19 @@ function love.draw() love.graphics.rectangle('fill', 0, 0, Screen_width-1, Screen_height-1) love.graphics.setColor(0, 0, 0) local y = 0 - for i,line in ipairs(Lines) do + for line_index,line in ipairs(Lines) do y = y+15*Zoom line.y = y if line.mode == 'text' and line.data == '' then button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0}, icon = icon.insert_drawing, onpress1 = function() - table.insert(Lines, i, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}}) - if Cursor_line >= i then + table.insert(Lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}}) + if Cursor_line >= line_index then Cursor_line = Cursor_line+1 end end}) - if i == Cursor_line then + if line_index == Cursor_line then love.graphics.setColor(0,0,0) love.graphics.print('_', 25, y+6) -- drop the cursor down a bit to account for the increased font size end @@ -123,7 +123,7 @@ function love.draw() love.graphics.setColor(0,0,0) local text = love.graphics.newText(love.graphics.getFont(), line.data) love.graphics.draw(text, 25,y, 0, Zoom) - if i == Cursor_line then + if line_index == Cursor_line then -- cursor love.graphics.print('_', cursor_x(line.data, Cursor_pos), y+6) -- drop the cursor down a bit to account for the increased font size end @@ -162,11 +162,11 @@ end function love.mousepressed(x,y, button) propagate_to_button_handlers(x,y, button) - for i,line in ipairs(Lines) do + for line_index,line in ipairs(Lines) do if line.mode == 'text' then -- move cursor if x >= 16 and y >= line.y and y < y+15*Zoom then - Cursor_line = i + Cursor_line = line_index Cursor_pos = nearest_cursor_pos(line.data, x, 1) end elseif line.mode == 'drawing' then @@ -628,7 +628,7 @@ function keychord_pressed(chord) drawing.pending.mode = 'line' elseif chord == 'C-l' then Current_mode = 'line' - local drawing,i,shape = select_shape_at_mouse() + local drawing,_,shape = select_shape_at_mouse() if drawing then convert_line(drawing, shape) end @@ -647,12 +647,12 @@ function keychord_pressed(chord) drawing.pending.mode = 'manhattan' elseif chord == 'C-m' and not love.mouse.isDown('1') then Current_mode = 'manhattan' - local drawing,i,shape = select_shape_at_mouse() + local drawing,_,shape = select_shape_at_mouse() if drawing then convert_horvert(drawing, shape) end elseif chord == 'C-s' and not love.mouse.isDown('1') then - local drawing,i,shape = select_shape_at_mouse() + local drawing,_,shape = select_shape_at_mouse() if drawing then smoothen(shape) end @@ -691,7 +691,7 @@ function keychord_pressed(chord) end drawing.points[i].deleted = true end - local drawing,i,shape = select_shape_at_mouse() + local drawing,_,shape = select_shape_at_mouse() if drawing then shape.mode = 'deleted' end |