Mercurial > libervia-backend
annotate frontends/sortilege_old/statusbar.py @ 598:af900f49df89
misc: add ctags_links to .hgignore
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Feb 2013 20:08:15 +0100 |
parents | 952322b1d490 |
children | 84a6e83157c2 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 sortilege: a SAT frontend | |
228 | 6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
0 | 10 the Free Software Foundation, either version 3 of the License, or |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
16 GNU Affero General Public License for more details. |
0 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
0 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
22 | |
23 import curses | |
24 from window import Window | |
25 import os | |
26 | |
27 class StatusBar(Window): | |
28 """This class manage the edition of text""" | |
29 | |
30 def __init__(self, parent, code="utf-8"): | |
31 self.__parent=parent | |
32 self.__code=code | |
33 self.__items=set() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
480
diff
changeset
|
34 |
0 | 35 Window.__init__(self, self.__parent, 1, self.__parent.getmaxyx()[1], self.__parent.getmaxyx()[0]-2,0, code=code) |
36 | |
37 def __len__(self): | |
38 return len(self.__items) | |
39 | |
40 def resizeAdapt(self): | |
41 """Adapt window size to self.__parent size. | |
42 Must be called when self.__parent is resized.""" | |
43 self.resize(1, self.__parent.getmaxyx()[1], self.__parent.getmaxyx()[0]-2,0) | |
44 self.update() | |
45 | |
46 def update(self): | |
47 if self.isHidden(): | |
48 return | |
49 Window.update(self) | |
50 x=0 | |
51 for item in self.__items: | |
52 pitem="[%s] " % item | |
53 self.addYXStr(0, x, pitem, curses.A_REVERSE) | |
54 x = x + len(pitem) | |
55 if x>=self.rWidth: | |
56 break | |
57 self.addYXStr(0, x, (self.rWidth-x)*" ", curses.A_REVERSE) | |
58 self.noutrefresh() | |
59 | |
60 def clear_text(self): | |
61 """Clear the text of the edit box""" | |
62 del(self.__items[:]) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
480
diff
changeset
|
63 |
0 | 64 def add_item(self, item): |
65 self.__items.add(item) | |
66 self.update() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
480
diff
changeset
|
67 |
0 | 68 def remove_item(self, item): |
69 if item in self.__items: | |
70 self.__items.remove(item) | |
71 self.update() |