about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-20 06:09:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-20 06:10:04 -0700
commit1573dd842590973252ffa82767e3ac1b5d23bf89 (patch)
tree8ce9327039b732781af4bcd1648774ba35bcf254
parent05ac4a5057ae8992fb920c6ba3641552ecd4c377 (diff)
downloadtext.love-1573dd842590973252ffa82767e3ac1b5d23bf89.tar.gz
start using some globals
-rw-r--r--main.lua2
-rw-r--r--text.lua10
2 files changed, 6 insertions, 6 deletions
diff --git a/main.lua b/main.lua
index b4059ad..014f8b4 100644
--- a/main.lua
+++ b/main.lua
@@ -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
diff --git a/text.lua b/text.lua
index b20809a..b6423b8 100644
--- a/text.lua
+++ b/text.lua
@@ -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