about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-30 21:35:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-03-30 21:36:34 -0700
commit3618487289928c6d57526421350ea0ae9823809b (patch)
treecbc9d16faf552a2c33eff9d6be28459d3c725000
parentb56590ddc986ab07ce105fef6c5ab8d48c8599cd (diff)
downloadteliva-3618487289928c6d57526421350ea0ae9823809b.tar.gz
toot-toot: disable ctrl-k
Rather than invest LoC in asking for confirmation or an undo feature,
just have people restart to clear the page.

I fucking suck for how many ways I can come up with to lose data in a
text editor. It really should have been fucking obvious that clearing
the page so easily was a footgun just waiting to happen.
-rw-r--r--toot-toot.tlv51
1 files changed, 51 insertions, 0 deletions
diff --git a/toot-toot.tlv b/toot-toot.tlv
index 0e524db..2c322a2 100644
--- a/toot-toot.tlv
+++ b/toot-toot.tlv
@@ -918,3 +918,54 @@
     >Typing '===' on its own lines, surrounded by empty lines, partitions prose and gives all segments independent character counts. Good for threads (tweetstorms).
     >
     >Scrolling support is rudimentary. Keys to scroll are independent of cursor movement, so cursor can move off the screen and confusingly 'get lost'.
+- __teliva_timestamp:
+    >Wed Mar 30 21:33:17 2022
+  update:
+    >function update(window)
+    >  local key = window:getch()
+    >  local h, w = window:getmaxyx()
+    >  if key == curses.KEY_LEFT then
+    >    if cursor > 1 then
+    >      cursor = cursor-1
+    >    end
+    >  elseif key == curses.KEY_RIGHT then
+    >    if cursor <= #prose then
+    >      cursor = cursor+1
+    >    end
+    >  elseif key == curses.KEY_DOWN then
+    >    cursor = cursor_down(prose, cursor, w)
+    >  elseif key == curses.KEY_UP then
+    >    cursor = cursor_up(prose, cursor, w)
+    >  elseif key == curses.KEY_BACKSPACE or key == 8 or key == 127 then  -- ctrl-h, ctrl-?, delete
+    >    if cursor > 1 then
+    >      cursor = cursor-1
+    >      prose = prose:remove(cursor)
+    >    end
+    >  elseif key == 6 then  -- ctrl-f
+    >    first_toot = first_toot+1
+    >  elseif key == 2 then  -- ctrl-b
+    >    if first_toot > 1 then
+    >      first_toot = first_toot-1
+    >    end
+    >  elseif key == 23 then  -- ctrl-w
+    >    local out = io.open('toot', 'w')
+    >    if out ~= nil then
+    >      out:write(prose, '\n')
+    >      out:close()
+    >    end
+    >  elseif key == 10 or (key >= 32 and key < 127) then
+    >    prose = prose:insert(string.char(key), cursor-1)
+    >    cursor = cursor+1
+    >  end
+    >end
+- __teliva_timestamp:
+    >Wed Mar 30 21:33:44 2022
+  __teliva_note:
+    >Get rid of the ctrl-k shortcut. Makes it too easy to lose data. To clear the page just quit and restart.
+  menu:
+    >-- To show app-specific hotkeys in the menu bar, add hotkey/command
+    >-- arrays of strings to the menu array.
+    >menu = {
+    >  {'^w', 'write to "toot"'},
+    >  {'^f|^b', 'scroll'},
+    >}