xref: /llvm-project/lldb/utils/lui/statuswin.py (revision 602e47c5f9fd2e14c7bfb6111e6558fa0d27c87f)
1##===-- statuswin.py -----------------------------------------*- Python -*-===##
2##
3# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4# See https://llvm.org/LICENSE.txt for license information.
5# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6##
7##===----------------------------------------------------------------------===##
8
9import lldb
10import lldbutil
11import cui
12import curses
13
14
15class StatusWin(cui.TextWin):
16    def __init__(self, x, y, w, h):
17        super(StatusWin, self).__init__(x, y, w)
18
19        self.keys = [  # ('F1', 'Help', curses.KEY_F1),
20            ("F3", "Cycle-focus", curses.KEY_F3),
21            ("F10", "Quit", curses.KEY_F10),
22        ]
23
24    def draw(self):
25        self.win.addstr(0, 0, "")
26        for key in self.keys:
27            self.win.addstr("{0}".format(key[0]), curses.A_REVERSE)
28            self.win.addstr(" {0} ".format(key[1]), curses.A_NORMAL)
29        super(StatusWin, self).draw()
30
31    def handleEvent(self, event):
32        if isinstance(event, int):
33            pass
34        elif isinstance(event, lldb.SBEvent):
35            if lldb.SBProcess.EventIsProcessEvent(event):
36                state = lldb.SBProcess.GetStateFromEvent(event)
37                status = lldbutil.state_type_to_str(state)
38                self.win.erase()
39                x = self.win.getmaxyx()[1] - len(status) - 1
40                self.win.addstr(0, x, status)
41        return
42