summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorSebastian Jeltsch <sjeltsch@kip.uni-heidelberg.de>2013-04-19 17:19:01 +0200
committerSebastian Jeltsch <sjeltsch@kip.uni-heidelberg.de>2013-04-20 21:14:11 +0200
commit8647ba703142e3a93d6f89f5d7454eda59ba06ca (patch)
tree0a0cbf8c1d11a87a7643e5880d69183bdb12ab9f /alot
parent8189b587b25af5cf98095158a625f75c60f8c354 (diff)
more vim-like movements
added: * ctrl d = half page down * ctrl u = half page up * G = focus last entry (only search buffer for now)
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py9
-rw-r--r--alot/commands/globals.py5
-rw-r--r--alot/commands/search.py13
-rw-r--r--alot/defaults/default.bindings3
4 files changed, 29 insertions, 1 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 9dea1e23..1d3eec30 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -282,9 +282,18 @@ class SearchBuffer(Buffer):
thread = threadlinewidget.get_thread()
return thread
+ def consume_pipe(self):
+ while not self.threadlist.empty:
+ self.threadlist._get_next_item()
+
def focus_first(self):
self.body.set_focus(0)
+ def focus_last(self):
+ self.consume_pipe()
+ num_lines = len(self.threadlist.get_lines())
+ self.body.set_focus(num_lines-1)
+
class ThreadBuffer(Buffer):
"""displays a thread as a tree of messages"""
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 6ed95166..70eccba2 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -796,7 +796,7 @@ class ComposeCommand(Command):
@registerCommand(MODE, 'move', help='move focus in current buffer',
arguments=[(['movement'], {
'nargs':argparse.REMAINDER,
- 'help':'up, down, page up, page down, first'})])
+ 'help':'up, down, [half]page up, [half]page down, first'})])
class MoveCommand(Command):
"""move in widget"""
def __init__(self, movement=None, **kwargs):
@@ -809,6 +809,9 @@ class MoveCommand(Command):
def apply(self, ui):
if self.movement in ['up', 'down', 'page up', 'page down']:
ui.mainloop.process_input([self.movement])
+ elif self.movement in [ 'halfpage down', 'halfpage up']:
+ ui.mainloop.process_input(
+ ui.mainloop.screen_size[1]/2 * [self.movement.split()[-1]])
elif self.movement == 'first':
ui.current_buffer.focus_first()
else:
diff --git a/alot/commands/search.py b/alot/commands/search.py
index db718807..04da8f96 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -6,6 +6,7 @@ import logging
from alot.commands import Command, registerCommand
from alot.commands.globals import PromptCommand
+from alot.commands.globals import MoveCommand
from alot.db.errors import DatabaseROError
from alot import commands
@@ -228,3 +229,15 @@ class TagCommand(Command):
# flush index
if self.flush:
ui.apply_command(commands.globals.FlushCommand(callback=refresh))
+
+@registerCommand(MODE, 'move', help='move focus in search buffer',
+ arguments=[(['movement'], {
+ 'nargs': argparse.REMAINDER,
+ 'help': 'last'})])
+class MoveFocusCommand(MoveCommand):
+ def apply(self, ui):
+ logging.debug(self.movement)
+ if self.movement == 'last':
+ ui.current_buffer.focus_last()
+ else:
+ MoveCommand.apply(self, ui)
diff --git a/alot/defaults/default.bindings b/alot/defaults/default.bindings
index e5409a19..132b6d90 100644
--- a/alot/defaults/default.bindings
+++ b/alot/defaults/default.bindings
@@ -6,6 +6,8 @@ j = move down
k = move up
'g g' = move first
' ' = move page down
+'ctrl d' = move halfpage down
+'ctrl u' = move halfpage up
@ = refresh
? = help bindings
I = search tag:inbox AND NOT tag:killed
@@ -36,6 +38,7 @@ q = exit
l = retagprompt
O = refineprompt
| = refineprompt
+ G = move last
[envelope]
a = prompt 'attach ~/'