annotate frontends/sortilege_old/statusbar.py @ 439:866dbb0d7d87

plugin maildir: maildir now use PersistentBinaryDictionary to store profile specific data /!\ profile needs to be connected for maildir/imap/smtp plugins to work, this has to be fixed
author Goffi <goffi@goffi.org>
date Sat, 03 Dec 2011 15:50:09 +0100
parents b1794cbb88e5
children 2a072735e459
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
goffi@necton2
parents:
diff changeset
4 """
goffi@necton2
parents:
diff changeset
5 sortilege: a SAT frontend
228
b1794cbb88e5 2011 copyright upgrade
Goffi <goffi@goffi.org>
parents: 112
diff changeset
6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
goffi@necton2
parents:
diff changeset
22
goffi@necton2
parents:
diff changeset
23 import curses
goffi@necton2
parents:
diff changeset
24 from window import Window
goffi@necton2
parents:
diff changeset
25 import os
goffi@necton2
parents:
diff changeset
26
goffi@necton2
parents:
diff changeset
27 class StatusBar(Window):
goffi@necton2
parents:
diff changeset
28 """This class manage the edition of text"""
goffi@necton2
parents:
diff changeset
29
goffi@necton2
parents:
diff changeset
30 def __init__(self, parent, code="utf-8"):
goffi@necton2
parents:
diff changeset
31 self.__parent=parent
goffi@necton2
parents:
diff changeset
32 self.__code=code
goffi@necton2
parents:
diff changeset
33 self.__items=set()
goffi@necton2
parents:
diff changeset
34
goffi@necton2
parents:
diff changeset
35 Window.__init__(self, self.__parent, 1, self.__parent.getmaxyx()[1], self.__parent.getmaxyx()[0]-2,0, code=code)
goffi@necton2
parents:
diff changeset
36
goffi@necton2
parents:
diff changeset
37 def __len__(self):
goffi@necton2
parents:
diff changeset
38 return len(self.__items)
goffi@necton2
parents:
diff changeset
39
goffi@necton2
parents:
diff changeset
40 def resizeAdapt(self):
goffi@necton2
parents:
diff changeset
41 """Adapt window size to self.__parent size.
goffi@necton2
parents:
diff changeset
42 Must be called when self.__parent is resized."""
goffi@necton2
parents:
diff changeset
43 self.resize(1, self.__parent.getmaxyx()[1], self.__parent.getmaxyx()[0]-2,0)
goffi@necton2
parents:
diff changeset
44 self.update()
goffi@necton2
parents:
diff changeset
45
goffi@necton2
parents:
diff changeset
46 def update(self):
goffi@necton2
parents:
diff changeset
47 if self.isHidden():
goffi@necton2
parents:
diff changeset
48 return
goffi@necton2
parents:
diff changeset
49 Window.update(self)
goffi@necton2
parents:
diff changeset
50 x=0
goffi@necton2
parents:
diff changeset
51 for item in self.__items:
goffi@necton2
parents:
diff changeset
52 pitem="[%s] " % item
goffi@necton2
parents:
diff changeset
53 self.addYXStr(0, x, pitem, curses.A_REVERSE)
goffi@necton2
parents:
diff changeset
54 x = x + len(pitem)
goffi@necton2
parents:
diff changeset
55 if x>=self.rWidth:
goffi@necton2
parents:
diff changeset
56 break
goffi@necton2
parents:
diff changeset
57 self.addYXStr(0, x, (self.rWidth-x)*" ", curses.A_REVERSE)
goffi@necton2
parents:
diff changeset
58 self.noutrefresh()
goffi@necton2
parents:
diff changeset
59
goffi@necton2
parents:
diff changeset
60 def clear_text(self):
goffi@necton2
parents:
diff changeset
61 """Clear the text of the edit box"""
goffi@necton2
parents:
diff changeset
62 del(self.__items[:])
goffi@necton2
parents:
diff changeset
63
goffi@necton2
parents:
diff changeset
64 def add_item(self, item):
goffi@necton2
parents:
diff changeset
65 self.__items.add(item)
goffi@necton2
parents:
diff changeset
66 self.update()
goffi@necton2
parents:
diff changeset
67
goffi@necton2
parents:
diff changeset
68 def remove_item(self, item):
goffi@necton2
parents:
diff changeset
69 if item in self.__items:
goffi@necton2
parents:
diff changeset
70 self.__items.remove(item)
goffi@necton2
parents:
diff changeset
71 self.update()