unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] alot: send batch keypresses back to urwid
@ 2013-03-16 18:42 Chris Mason
  2013-03-17 14:32 ` [PATCH] alot: send batch keypresses back to urwid (v2) Chris Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Mason @ 2013-03-16 18:42 UTC (permalink / raw)
  To: notmuch, Patrick Totzke

Looks like the urwid code is sending us arrays of [ 'j', 'j', 'j' ... ]
when I hold down the key, but alot is only acting on one of them.

This changes the fire routine to send back all the keys that were sent
to us.  It may be a horrible idea, and I'm not sure if urwid always sends us
arrays of the same thing.

But it's dramatically faster, so how can it be bad?

Signed-off-by: Chris Mason <chris.mason@fusionio.com>

diff --git a/alot/ui.py b/alot/ui.py
index 5d4dd4a..b8ced29 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -119,12 +119,12 @@ class UI(object):
                 self.input_queue = []
                 self.update()
 
-            def fire(ignored, cmdline):
+            def fire(ignored, cmdline, count):
                 clear()
                 logging.debug("cmdline: '%s'" % cmdline)
                 # move keys are always passed
                 if cmdline in ['move up', 'move down', 'move page up', 'move page down']:
-                    return [cmdline[5:]]
+                    return [cmdline[5:]] * count
                 elif not self._locked:
                     try:
                         self.apply_commandline(cmdline)
@@ -147,7 +147,7 @@ class UI(object):
                             self.mainloop.remove_alarm(self._alarm)
                         self._alarm = self.mainloop.set_alarm_in(timeout, fire, cmdline)
                     else:
-                        return fire(self.mainloop, cmdline)
+                        return fire(self.mainloop, cmdline, len(keys))
 
             elif not candidates:
                 # case: no sequence with prefix keyseq is mapped

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] alot: send batch keypresses back to urwid (v2)
  2013-03-16 18:42 [PATCH] alot: send batch keypresses back to urwid Chris Mason
@ 2013-03-17 14:32 ` Chris Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Mason @ 2013-03-17 14:32 UTC (permalink / raw)
  To: Chris Mason, notmuch, Patrick Totzke

Looks like the urwid code is sending us arrays of [ 'j', 'j', 'j' ... ]
when I hold down the key, but alot is only acting on one of them.
 
This changes the fire routine to send back all the keys that were sent
to us.  It may be a horrible idea, and I'm not sure if urwid always sends us
arrays of the same thing.

But it's dramatically faster, so how can it be bad?  V2 catches the
second caller of fire()

Signed-off-by: Chris Mason <chris.mason@fusionio.com>

diff --git a/alot/ui.py b/alot/ui.py
index 3593c60..cdc66a6 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -119,18 +119,20 @@ class UI(object):
                 self.input_queue = []
                 self.update()
 
-            def fire(ignored, cmdline):
+            def fire(ignored, cmdline, count):
                 clear()
                 logging.debug("cmdline: '%s'" % cmdline)
                 # move keys are always passed
                 if cmdline in ['move up', 'move down', 'move page up',
                                'move page down']:
-                    return [cmdline[5:]]
+                    return [cmdline[5:]] * count
                 elif not self._locked:
                     try:
                         self.apply_commandline(cmdline)
                     except CommandParseError, e:
                         self.notify(e.message, priority='error')
+            def fire_one(ignored, cmdline):
+                return fire(ignored, cmdline, 1)
 
             key = keys[0]
             self.input_queue.append(key)
@@ -147,9 +149,9 @@ class UI(object):
                         if self._alarm is not None:
                             self.mainloop.remove_alarm(self._alarm)
                         self._alarm = self.mainloop.set_alarm_in(
-                            timeout, fire, cmdline)
+                            timeout, fire_one, cmdline)
                     else:
-                        return fire(self.mainloop, cmdline)
+                        return fire(self.mainloop, cmdline, len(keys))
 
             elif not candidates:
                 # case: no sequence with prefix keyseq is mapped

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-17 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-16 18:42 [PATCH] alot: send batch keypresses back to urwid Chris Mason
2013-03-17 14:32 ` [PATCH] alot: send batch keypresses back to urwid (v2) Chris Mason

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).