[Nym3-commit] r151 - trunk/nym3/Client
jr at komite.net
jr at komite.net
Mon Jan 3 00:09:01 CET 2005
Author: jr
Date: 2005-01-03 00:08:59 +0100 (Mon, 03 Jan 2005)
New Revision: 151
Modified:
trunk/nym3/Client/testcurses.py
Log:
- add a function that sets a new tab in the screen_ctx:
- sets the tab
- sets the shortcuts
Modified: trunk/nym3/Client/testcurses.py
===================================================================
--- trunk/nym3/Client/testcurses.py 2005-01-01 23:19:37 UTC (rev 150)
+++ trunk/nym3/Client/testcurses.py 2005-01-02 23:08:59 UTC (rev 151)
@@ -73,7 +73,7 @@
"""Return a dict of key => functions"""
return { ord('f'): self.fetch,
ord('d'): self.delete }
-
+
def view(self):
"""Display the requested synopsis"""
# TODO : this needs a PAGER view.
@@ -336,21 +336,9 @@
self.HIGHLIGHT = curses.color_pair(1)
self.STATUS = curses.color_pair(2)
self.BROKENLINE = curses.color_pair(3)
- # the screen itself
- self.screen = screen
- #the table, in fact a class with a method size() and line(i), and
- #other action based on the lines
- self.tab = tab
- tab.ctx = self
- (self.maxline, self.maxcol) = screen.getmaxyx()
- self.index = 0 #index of the active line
- self.fstindex = 0 #index of the lowest line displayed
- self.fstpos = 1 #index of the line on the screen where the first
- #line of the table is displayed
- self.listrange = max (0, self.maxline - 3)
- self.pager = Pager(screen, self.BROKENLINE)
- self.action = {
- ord('q') : self.quit,
+ #the actions
+ self.default_action = {
+ ord('q') : self.quit,
ord('t') : self.tag,
ord(';') : self.settagprefix,
curses.KEY_DOWN : self.on_K_down,
@@ -359,7 +347,6 @@
ord('\n') : self.view,
ord(' ') : self.view
}
-
self.pager_action = {
ord('q') : self.pager_quit,
curses.KEY_DOWN : self.pager_on_K_down,
@@ -368,18 +355,38 @@
curses.KEY_NPAGE : self.pager_on_K_npage,
curses.KEY_PPAGE : self.pager_on_K_ppage
}
+
+ # the screen itself
+ self.screen = screen
+ #the table, in fact a class with a method size() and line(i), and
+ #other action based on the lines
+ self.set_tab(tab)
+ (self.maxline, self.maxcol) = screen.getmaxyx()
+ self.index = 0 #index of the active line
+ self.fstindex = 0 #index of the lowest line displayed
+ self.fstpos = 1 #index of the line on the screen where the first
+ #line of the table is displayed
+ self.listrange = max (0, self.maxline - 3)
+ self.pager = Pager(screen, self.BROKENLINE)
+
self.mode = Screen_ctx.MODE_MENU
+ #number of times the screen has been displayed (for debugging purpose)
self.nd = 0
- shortcuts = tab.get_actions()
- for i in shortcuts.keys():
- self.action[i] = shortcuts[i]
self.tagprefix = False
self.tagged = {}
self.bufferline= ""
self.draw_picture()
-
+ def set_tab(self, newtab):
+ self.action = {}
+ for key, value in self.default_action.iteritems():
+ self.action[key] = value
+ for key, value in newtab.get_actions().iteritems():
+ self.action[key] = value
+ self.tab = newtab
+ self.tab.ctx = self
+
def message(self):
rl, rc = self.screen.getmaxyx()
s = "%d lr: %d mc: %d ml: %d rc: %d rl: %d" % (self.nd, self.listrange,
@@ -492,9 +499,9 @@
self.active = False
def view(self):
- self.mode = Screen_ctx.MODE_PAGER
- self.pager_give_win()
- self.pager.set_msg(self.tab.view())
+ self.mode = Screen_ctx.MODE_PAGER
+ self.pager_give_win()
+ self.pager.set_msg(self.tab.view())
def on_K_down(self):
if self.index < self.tab.size() - 1:
More information about the Nym3-commit
mailing list