about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-09 13:45:52 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-09 13:47:41 -0700
commitfe170fc579cc084061f6dce70aa9b4e966148ca7 (patch)
tree3ff48d57828ec7c96c7f7ba32564fb58d625b0ca
parent25190676ea2a7cee59c57506ccefaed82ee6fb79 (diff)
downloadview.love-fe170fc579cc084061f6dce70aa9b4e966148ca7.tar.gz
experiment: blinking cursor
I've tried to keep the time period of the blinking similar to my
terminal.

Honestly I'm no longer sure if any of my experiments are showing a
statistically significant result. Let's see how it feels over a period
of time.
-rw-r--r--main.lua4
-rw-r--r--text.lua9
2 files changed, 10 insertions, 3 deletions
diff --git a/main.lua b/main.lua
index 2812dd5..9b6fb35 100644
--- a/main.lua
+++ b/main.lua
@@ -82,6 +82,9 @@ Search_backup = nil  -- stuff to restore when cancelling search
 -- resize
 Last_resize_time = nil
 
+-- blinking cursor
+Cursor_time = 0
+
 end  -- App.initialize_globals
 
 function App.initialize(arg)
@@ -249,6 +252,7 @@ function App.draw()
 end
 
 function App.update(dt)
+  Cursor_time = Cursor_time + dt
   -- some hysteresis while resizing
   if Last_resize_time then
     if love.timer.getTime() - Last_resize_time < 0.1 then
diff --git a/text.lua b/text.lua
index b8c3909..69b8c37 100644
--- a/text.lua
+++ b/text.lua
@@ -85,9 +85,12 @@ end
 --  draw with small line_width of 100
 
 function Text.draw_cursor(x, y)
-  love.graphics.setColor(1,0,0, 0.8)
-  love.graphics.rectangle('fill', x,y, 3,Line_height)
-  love.graphics.setColor(0,0,0)
+  -- blink every 0.5s
+  if math.floor(Cursor_time*2)%2 == 0 then
+    love.graphics.setColor(1,0,0)
+    love.graphics.rectangle('fill', x,y, 3,Line_height)
+    love.graphics.setColor(0,0,0)
+  end
   Cursor_x = x
   Cursor_y = y+Line_height
 end