[Nym3-commit] r158 - trunk/nym3/Client
jr at komite.net
jr at komite.net
Fri Feb 11 01:36:34 CET 2005
Author: jr
Date: 2005-02-11 01:36:30 +0100 (Fri, 11 Feb 2005)
New Revision: 158
Modified:
trunk/nym3/Client/testcurses.py
Log:
- basic line input capabilities test
Modified: trunk/nym3/Client/testcurses.py
===================================================================
--- trunk/nym3/Client/testcurses.py 2005-01-29 21:17:57 UTC (rev 157)
+++ trunk/nym3/Client/testcurses.py 2005-02-11 00:36:30 UTC (rev 158)
@@ -1,6 +1,7 @@
import curses
import curses.wrapper
import curses.ascii
+import curses.textpad
import re
import math
@@ -164,64 +165,76 @@
"""The class that contains the tab holding one user accounts
"""
- def __init__(self, base):
- os.chdir(base)
- kr = base + os.sep + 'keyring'
- kr_exists = False
- try:
- self.key_ring = pickle.load()
- except pickle.UnPicklingError:
- self.key_ring = None
- try:
- os.chdir("pending")
- except:
- pass
- else:
- #treat pending messages
- os.chdir('..')
+ def __init__(self, base, fscreen):
+ """ base : the repertory where the account are located
+ fscreen : father screen
+ """
+ self.tab = []
+ self.screen = fscreen
+# os.chdir(base)
+# kr = base + os.sep + 'keyring'
+# kr_exists = False
+# try:
+# self.key_ring = Keyring(kr)
+# except:
+# self.key_ring = None
+# try:
+# os.chdir("pending")
+# except:
+# pass
+# else:
+# #treat pending messages
+# os.chdir('..')
+#
+# files = os.listdir(os.getcwd())
+# def is_useful_dir(f):
+# try:
+# if stat.IS_DIR(os.stat(f)[stat.ST_MODE]):
+# #has f the good format
+# return True
+# except:
+# pass
+# return False
+#
+# files = filter(is_useful_dir, files)
+# self.attr = {}
+# for d in files:
+# self.attr[d] = False
+# if self.key_ring != None:
+# #set the attributes of usable files to True
+# pass
+# self.tab = attr.keys()
+# self.tab.sort()
- files = os.listdir(os.getcwd())
- def is_useful_dir(f):
- try:
- if stat.IS_DIR(os.stat(f)[stat.ST_MODE]):
- #has f the good format
- return True
- except:
- pass
- return False
-
- files = filter(is_useful_dir, files)
- self.attr = {}
- for d in files:
- self.attr[d] = False
- if self.key_ring != None:
- #set the attributes of usable files to True
- pass
- self.tab = attr.keys()
- self.tab.sort()
-
def size(self):
"""return the size of the table"""
return len(self.tab)
def line(self, i):
"""return the content of the line i"""
- flag = ''
- if self.attr[self.tab[i]]:
- flag += 'U'
+# flag = ''
+# if self.attr[self.tab[i]]:
+# flag += 'U'
+# else:
+# flag += ' '
+# return flag + ' ' + self.tab[i], 1
+ if i < len(self.tab) and i >= 0:
+ return self.tab[i], 0
else:
- flag += ' '
- return flag + ' ' + self.tab[i], 1
-
+ return "", 0
+
def get_actions(self):
return {
- ord('\n'): self.idle,
+ ord('a'): self.append,
ord(' '): self.idle,
}
def idle(self):
pass
-
+
+ def append(self):
+ self.tab.append(self.screen.get_string())
+
class Pager:
""" this class takes care of the display of a message in a pager.
It does the approptiate display in a provided window"""
@@ -407,7 +420,8 @@
curses.KEY_UP : self.on_K_up,
curses.KEY_RESIZE : self.on_resize,
ord('\n') : self.view,
- ord(' ') : self.view
+ ord(' ') : self.view,
+ ord('a') : self.account
}
self.pager_action = {
ord('q') : self.pager_quit,
@@ -423,6 +437,7 @@
#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.main_tab = None
(self.maxline, self.maxcol) = screen.getmaxyx()
self.index = 0 #index of the active line
self.fstindex = 0 #index of the lowest line displayed
@@ -558,8 +573,12 @@
self.draw_picture()
def quit(self):
- self.active = False
-
+ if self.main_tab == None:
+ self.active = False
+ else:
+ self.set_tab(self.main_tab)
+ self.main_tab = None
+
def view(self):
self.mode = Screen_ctx.MODE_PAGER
self.pager_give_win()
@@ -640,7 +659,21 @@
self.pager.set_win(sub)
else:
self.pager.set_win(None)
-
+
+ def account(self):
+ if self.main_tab == None:
+ self.main_tab = self.tab
+ self.set_tab(Account_tab("", self))
+
+ def get_string(self):
+ sub = self.screen.subwin(self.maxline - 1, 0)
+ tb = curses.textpad.Textbox(sub)
+ sub.clrtoeol()
+ s = tb.edit()
+ del (tb)
+ del (sub)
+ return s
+
def func(stdscr):
curses.curs_set(0)
#define here our colors pair
More information about the Nym3-commit
mailing list