about summary refs log tree commit diff stats
path: root/zet.tlv
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-02-09 23:41:36 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-02-09 23:41:36 -0800
commitcf521f99049769f0ed4709c49fbde2e33b19e62c (patch)
tree5eb3273d93f24a9bcbce1cd97d3d898aac65e319 /zet.tlv
parent7786462a8d70f5931086ce4b0ce027f222aa644b (diff)
downloadteliva-cf521f99049769f0ed4709c49fbde2e33b19e62c.tar.gz
zet.tlv: bugfixes to editor cursor handling
Diffstat (limited to 'zet.tlv')
-rw-r--r--zet.tlv9
1 files changed, 4 insertions, 5 deletions
diff --git a/zet.tlv b/zet.tlv
index 5c47136..4e087e3 100644
--- a/zet.tlv
+++ b/zet.tlv
@@ -781,7 +781,7 @@
   editz_render:
     >function editz_render(window, s, cursor, top, minbottom, left, right)
     >  local h, w = window:getmaxyx()
-    >  local cursor_y, cursor_x, cursor_c = 0, 0, 'c'
+    >  local cursor_y, cursor_x = 0, 0
     >  window:attrset(curses.color_pair(view_settings.current_zettel_bg))
     >  for y=top,minbottom-1 do
     >    for x=left,right-1 do
@@ -794,7 +794,6 @@
     >    if i == cursor then
     >      cursor_y = y
     >      cursor_x = x
-    >      cursor_c = s[i]
     >    end
     >    if s[i] ~= '\n' then
     >      window:addstr(s[i])
@@ -820,7 +819,7 @@
     >    cursor_y = y
     >    cursor_x = x
     >  end
-    >  window:mvaddstr(cursor_y, cursor_x, cursor_c)
+    >  window:mvaddstr(cursor_y, cursor_x, '')
     >end
 - __teliva_timestamp:
     >Wed Feb  9 08:25:05 2022
@@ -832,7 +831,7 @@
     >  local bottom = top + view_settings.height
     >  local left = (render_state.curr_w - 1) * (view_settings.width + view_settings.hmargin)
     >  local right = left + view_settings.width
-    >  local cursor = string.len(zettels[current_zettel_id].data)
+    >  local cursor = string.len(zettels[current_zettel_id].data)+1
     >  local quit = false
     >  curses.curs_set(1)
     >  while not quit do
@@ -872,7 +871,7 @@
     >  elseif key == 5 then  -- ctrl-e
     >    return true, prose, cursor
     >  elseif key == 10 or (key >= 32 and key < 127) then
-    >    prose = prose:insert(string.char(key), cursor)
+    >    prose = prose:insert(string.char(key), cursor-1)
     >    cursor = cursor+1
     >  end
     >  return false, prose, cursor