[Nym3-commit] r159 - trunk/nym3/Client

jr at komite.net jr at komite.net
Fri Feb 11 17:54:31 CET 2005


Author: jr
Date: 2005-02-11 17:54:29 +0100 (Fri, 11 Feb 2005)
New Revision: 159

Modified:
   trunk/nym3/Client/testcurses.py
Log:
- make account tab the entry tab
- start the account creation process (input of servername and nym list)


Modified: trunk/nym3/Client/testcurses.py
===================================================================
--- trunk/nym3/Client/testcurses.py	2005-02-11 00:36:30 UTC (rev 158)
+++ trunk/nym3/Client/testcurses.py	2005-02-11 16:54:29 UTC (rev 159)
@@ -165,12 +165,11 @@
     """The class that contains the tab holding one user accounts
     """
     
-    def __init__(self, base, fscreen):
+    def __init__(self, base):
 	""" 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
@@ -226,6 +225,8 @@
     def get_actions(self):
 	return {
 		ord('a'): self.append,
+		ord('c'): self.create,
+		ord('\n'): self.idle,
 		ord(' '): self.idle,
 		}
     
@@ -233,8 +234,18 @@
 	pass
 
     def append(self):
-	self.tab.append(self.screen.get_string())
-		
+	self.tab.append(self.ctx.get_string("append: "))
+
+    def create(self):
+	#ask for a server name
+	server_name = self.ctx.get_string("server name: ")
+	#ask for a list of nym
+	nym_list = self.ctx.get_string_list("nym :")
+	#generate keys, keyring
+	#generate uninitialized user object
+	#generate surbs
+	#send the initialization 3 messages
+	
 class Pager:
     """ this class takes care of the display of a message in a pager.
     It does the approptiate display in a provided window"""
@@ -421,7 +432,6 @@
 		curses.KEY_RESIZE : self.on_resize,
 		ord('\n') : self.view,
 		ord(' ') : self.view,
-		ord('a') : self.account
 		}
 	self.pager_action = {
 		ord('q') : self.pager_quit,
@@ -663,17 +673,45 @@
     def account(self):
 	if self.main_tab == None:
 	    self.main_tab = self.tab
-	    self.set_tab(Account_tab("", self))
+	    self.set_tab(Account_tab(""))
 
-    def get_string(self):
+    def get_string(self, st):
 	sub = self.screen.subwin(self.maxline - 1, 0)
+	sub.addstr(st)
+	sub.clrtoeol()
 	tb = curses.textpad.Textbox(sub)
-	sub.clrtoeol()
 	s = tb.edit()
 	del (tb)
 	del (sub)
-	return s	
+	return s[len(st):]	
 
+    def get_string_list(self, st):
+	ret = True
+	sub = self.screen.subwin(self.maxline - 1, 0)
+	sub.addstr(st)
+	(y, x) = sub.getyx()
+	l = []
+	class End_bool:
+	    """contains a boolean and a validator that is passed to edit"""
+	    def __init__(self):
+		self.ret = True
+
+	    def validator(self, c):
+		if c == curses.ascii.BEL:
+		    self.ret = False
+		return c
+	    
+	b = End_bool()
+	while b.ret:
+	    sub.move(y, x)
+	    sub.clrtoeol()
+	    tb = curses.textpad.Textbox(sub)
+	    s = tb.edit(b.validator)
+	    l.append(s[len(st):])
+	del (tb)
+	del (sub)
+	return l
+	
 def func(stdscr):
     curses.curs_set(0)
     #define here our colors pair
@@ -684,7 +722,7 @@
     #broken line indicator
     curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
     stdscr.scrollok(False)
-    ctx = Screen_ctx(stdscr, Synbox_tab())
+    ctx = Screen_ctx(stdscr, Account_tab(""))
     ctx.execute()
 
 curses.wrapper(func)



More information about the Nym3-commit mailing list