42 lines · python
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-exception6##7##===----------------------------------------------------------------------===##8 9import lldb10import lldbutil11import cui12import curses13 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 pass34 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) - 140 self.win.addstr(0, x, status)41 return42