From 073d34090869558e586d64d96b6f75c05719a095 Mon Sep 17 00:00:00 2001 From: Derek Schmidt Date: Fri, 1 Mar 2019 18:04:45 -0700 Subject: [PATCH] Change control scheme to make more sense Ctrl+Enter (or the standard ^D / EOT) to confirm, Escape to quit. Since we're asking for a raw escape, we also need to tweak the curses escape detection timeout a little, otherwise the user would have to wait a whole second for the keystroke to register --- toot/ui/app.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toot/ui/app.py b/toot/ui/app.py index 0a02759..eeb930e 100644 --- a/toot/ui/app.py +++ b/toot/ui/app.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import webbrowser +import os from toot import __version__, api @@ -360,7 +361,7 @@ class EntryModal(Modal): self.window.erase() self.window.box() - draw_lines(self.window, ["{} (^G to confirm):".format(self.title)], 1, 2, Color.WHITE) + draw_lines(self.window, ["{} (Ctrl+Enter to confirm):".format(self.title)], 1, 2, Color.WHITE) if self.footer: window_height, window_width = self.window.getmaxyx() draw_lines(self.window, [self.footer], window_height - self.pad_y + 1, 2, Color.WHITE) @@ -399,11 +400,11 @@ class EntryModal(Modal): if self.cursor_pos + 1 <= len(self.content): self.cursor_pos += 1 - elif ch == curses.ascii.ctrl(ord('q')): - self.content = [] + elif ch in (curses.ascii.RS, curses.ascii.EOT): return False - elif ch == curses.ascii.ctrl(ord('g')): + elif ch == curses.ascii.ESC: + self.content = [] return False self.draw() @@ -423,7 +424,7 @@ class EntryModal(Modal): class ComposeModal(EntryModal): def __init__(self, stdscr, default_cw=None): - super().__init__(stdscr, title="Compose a toot", footer="^G to submit, ^Q to quit, ^S to mark sensitive (cw)") + super().__init__(stdscr, title="Compose a toot", footer="Ctrl+Enter to submit, ESC to quit, ^S to mark sensitive (cw)") self.cw = default_cw self.cwmodal = EntryModal(stdscr, title="Content warning", size=(1, 60), default=self.cw) @@ -449,6 +450,7 @@ class TimelineApp: self.stdscr = None def run(self): + os.environ.setdefault('ESCDELAY', '25') curses.wrapper(self._wrapped_run) def _wrapped_run(self, stdscr):