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
This commit is contained in:
parent
45bf2acba1
commit
073d340908
1 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import os
|
||||||
|
|
||||||
from toot import __version__, api
|
from toot import __version__, api
|
||||||
|
|
||||||
|
@ -360,7 +361,7 @@ class EntryModal(Modal):
|
||||||
self.window.erase()
|
self.window.erase()
|
||||||
self.window.box()
|
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:
|
if self.footer:
|
||||||
window_height, window_width = self.window.getmaxyx()
|
window_height, window_width = self.window.getmaxyx()
|
||||||
draw_lines(self.window, [self.footer], window_height - self.pad_y + 1, 2, Color.WHITE)
|
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):
|
if self.cursor_pos + 1 <= len(self.content):
|
||||||
self.cursor_pos += 1
|
self.cursor_pos += 1
|
||||||
|
|
||||||
elif ch == curses.ascii.ctrl(ord('q')):
|
elif ch in (curses.ascii.RS, curses.ascii.EOT):
|
||||||
self.content = []
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif ch == curses.ascii.ctrl(ord('g')):
|
elif ch == curses.ascii.ESC:
|
||||||
|
self.content = []
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.draw()
|
self.draw()
|
||||||
|
@ -423,7 +424,7 @@ class EntryModal(Modal):
|
||||||
|
|
||||||
class ComposeModal(EntryModal):
|
class ComposeModal(EntryModal):
|
||||||
def __init__(self, stdscr, default_cw=None):
|
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.cw = default_cw
|
||||||
self.cwmodal = EntryModal(stdscr, title="Content warning", size=(1, 60), default=self.cw)
|
self.cwmodal = EntryModal(stdscr, title="Content warning", size=(1, 60), default=self.cw)
|
||||||
|
|
||||||
|
@ -449,6 +450,7 @@ class TimelineApp:
|
||||||
self.stdscr = None
|
self.stdscr = None
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
os.environ.setdefault('ESCDELAY', '25')
|
||||||
curses.wrapper(self._wrapped_run)
|
curses.wrapper(self._wrapped_run)
|
||||||
|
|
||||||
def _wrapped_run(self, stdscr):
|
def _wrapped_run(self, stdscr):
|
||||||
|
|
Loading…
Reference in a new issue