]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/tui-window-factory.py
75932147895ddddb65bc9e15d9c66a17226fb2b4
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / tui-window-factory.py
1 # Copyright (C) 2023-2025 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17 class TestWindow:
18 def __init__(self, tui_win, msg):
19 self.msg = msg
20 self.tui_win = tui_win
21 print("Entering TestWindow.__init__: %s" % self.msg)
22
23 def render(self):
24 self.tui_win.erase()
25 self.tui_win.write("TestWindow (%s)" % self.msg)
26
27 def __del__(self):
28 print("Entering TestWindow.__del__: %s" % self.msg)
29
30
31 class TestWindowFactory:
32 def __init__(self, msg):
33 self.msg = msg
34 print("Entering TestWindowFactory.__init__: %s" % self.msg)
35
36 def __call__(self, tui_win):
37 print("Entering TestWindowFactory.__call__: %s" % self.msg)
38 return TestWindow(tui_win, self.msg)
39
40 def __del__(self):
41 print("Entering TestWindowFactory.__del__: %s" % self.msg)
42
43
44 def register_window_factory(msg):
45 gdb.register_window_type("test_window", TestWindowFactory(msg))
46
47
48 print("Python script imported")