summaryrefslogtreecommitdiff
path: root/alot/commands/bufferlist.py
blob: 3edcb5c9ca7459a0325a6499c84537e6edebc2d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from alot.commands import Command, registerCommand
import globals

MODE = 'bufferlist'


@registerCommand(MODE, 'select')
class BufferFocusCommand(Command):
    """focus selected buffer"""
    def apply(self, ui):
        selected = ui.current_buffer.get_selected_buffer()
        ui.buffer_focus(selected)


@registerCommand(MODE, 'close')
class BufferCloseCommand(Command):
    """close focussed buffer"""
    def apply(self, ui):
        bufferlist = ui.current_buffer
        selected = bufferlist.get_selected_buffer()
        ui.apply_command(globals.BufferCloseCommand(buffer=selected))
        if bufferlist is not selected:
            bufferlist.rebuild()
        ui.update()