[docs] Fix build-docs.sh
[llvm-project.git] / lldb / utils / lui / sandbox.py
blob8bb4e3595f805a8893d5c881bd1b1d05dcdc3144
1 #!/usr/bin/env python
2 ##===-- sandbox.py -------------------------------------------*- Python -*-===##
3 ##
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ##
8 ##===----------------------------------------------------------------------===##
11 import curses
13 import os
14 import signal
15 import sys
17 try:
18 import queue
19 except ImportError:
20 import Queue as queue
22 import cui
24 event_queue = None
27 class SandboxUI(cui.CursesUI):
29 def __init__(self, screen, event_queue):
30 super(SandboxUI, self).__init__(screen, event_queue)
32 height, width = self.screen.getmaxyx()
33 w2 = width / 2
34 h2 = height / 2
36 self.wins = []
37 #self.wins.append(cui.TitledWin(w2, h2, w2, h2, "Test Window 4"))
38 list_win = cui.ListWin(w2, h2, w2, h2)
39 for i in range(0, 40):
40 list_win.addItem('Item %s' % i)
41 self.wins.append(list_win)
42 self.wins.append(cui.TitledWin(0, 0, w2, h2, "Test Window 1"))
43 self.wins.append(cui.TitledWin(w2, 0, w2, h2, "Test Window 2"))
44 self.wins.append(cui.TitledWin(0, h2, w2, h2, "Test Window 3"))
46 # def callback(s, content):
47 # self.wins[0].win.scroll(1)
48 # self.wins[0].win.addstr(10, 0, '%s: %s' % (s, content))
49 # self.wins[0].win.scroll(1)
50 # self.el.showPrompt(10, 0)
52 # self.wins[0].win.scrollok(1)
53 # self.el = cui.CursesEditLine(self.wins[0].win, None,
54 # lambda c: callback('got', c), lambda c: callback('tab', c))
55 #self.el.prompt = '>>> '
56 #self.el.showPrompt(10, 0)
58 def handleEvent(self, event):
59 if isinstance(event, int):
60 if event == ord('q'):
61 sys.exit(0)
62 # self.el.handleEvent(event)
63 super(SandboxUI, self).handleEvent(event)
66 def main(screen):
67 global event_queue
68 event_queue = queue.Queue()
70 sandbox = SandboxUI(screen, event_queue)
71 sandbox.eventLoop()
73 if __name__ == "__main__":
74 try:
75 curses.wrapper(main)
76 except KeyboardInterrupt:
77 exit()