From 3618487289928c6d57526421350ea0ae9823809b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 30 Mar 2022 21:35:36 -0700 Subject: [PATCH] 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. --- toot-toot.tlv | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) 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'}, + >}