1*56bb7041Schristos# Copyright (C) 2020 Free Software Foundation, Inc.
2*56bb7041Schristos#
3*56bb7041Schristos# This program is free software; you can redistribute it and/or modify
4*56bb7041Schristos# it under the terms of the GNU General Public License as published by
5*56bb7041Schristos# the Free Software Foundation; either version 3 of the License, or
6*56bb7041Schristos# (at your option) any later version.
7*56bb7041Schristos#
8*56bb7041Schristos# This program is distributed in the hope that it will be useful,
9*56bb7041Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
10*56bb7041Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11*56bb7041Schristos# GNU General Public License for more details.
12*56bb7041Schristos#
13*56bb7041Schristos# You should have received a copy of the GNU General Public License
14*56bb7041Schristos# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15*56bb7041Schristos
16*56bb7041Schristos# A TUI window implemented in Python.
17*56bb7041Schristos
18*56bb7041Schristosimport gdb
19*56bb7041Schristos
20*56bb7041Schristosthe_window = None
21*56bb7041Schristos
22*56bb7041Schristosclass TestWindow:
23*56bb7041Schristos    def __init__(self, win):
24*56bb7041Schristos        global the_window
25*56bb7041Schristos        the_window = win
26*56bb7041Schristos        self.count = 0
27*56bb7041Schristos        self.win = win
28*56bb7041Schristos        win.title = "This Is The Title"
29*56bb7041Schristos
30*56bb7041Schristos    def render(self):
31*56bb7041Schristos        self.win.erase()
32*56bb7041Schristos        w = self.win.width
33*56bb7041Schristos        h = self.win.height
34*56bb7041Schristos        self.win.write("Test: " + str(self.count) + " " + str(w) + "x" + str(h))
35*56bb7041Schristos        self.count = self.count + 1
36*56bb7041Schristos
37*56bb7041Schristosgdb.register_window_type("test", TestWindow)
38*56bb7041Schristos
39*56bb7041Schristos# A TUI window "constructor" that always fails.
40*56bb7041Schristosdef failwin(win):
41*56bb7041Schristos    raise RuntimeError("Whoops")
42*56bb7041Schristos
43*56bb7041Schristosgdb.register_window_type("fail", failwin)
44