start using some globals

This commit is contained in:
Kartik K. Agaram 2022-05-20 06:09:37 -07:00
parent 05ac4a5057
commit 1573dd8425
2 changed files with 6 additions and 6 deletions

View File

@ -130,7 +130,7 @@ function love.draw()
y = y + Drawing.pixels(line.h) + 10 -- padding
else
line.y = y
y = Text.draw(line, Line_width, line_index, Cursor_line, Cursor_pos)
y = Text.draw(line, Line_width, line_index)
y = y + math.floor(15*Zoom) -- text height
end
end

View File

@ -3,7 +3,7 @@ Text = {}
local utf8 = require 'utf8'
function Text.draw(line, line_width, line_index, cursor_line, cursor_pos)
function Text.draw(line, line_width, line_index)
love.graphics.setColor(0,0,0)
-- wrap long lines
local x = 25
@ -30,15 +30,15 @@ function Text.draw(line, line_width, line_index, cursor_line, cursor_pos)
love.graphics.draw(frag_text, x,y, 0, Zoom)
-- render cursor if necessary
local frag_len = utf8.len(frag)
if line_index == cursor_line then
if pos <= cursor_pos and pos + frag_len > cursor_pos then
Text.draw_cursor(x+Text.cursor_x2(frag, cursor_pos-pos+1), y)
if line_index == Cursor_line then
if pos <= Cursor_pos and pos + frag_len > Cursor_pos then
Text.draw_cursor(x+Text.cursor_x2(frag, Cursor_pos-pos+1), y)
end
end
x = x + frag_width
pos = pos + frag_len
end
if line_index == cursor_line and cursor_pos == pos then
if line_index == Cursor_line and Cursor_pos == pos then
Text.draw_cursor(x, y)
end
return y