updating from browser works now
[public/library.git] / cursestest.py
index 3c42f24..524061f 100755 (executable)
@@ -28,27 +28,35 @@ def simplePrintw(stdscr):
     stdscr.refresh()
     stdscr.getch()
 
-def menutest(w, l):
+def menutest(stdscr, l):
+    curses.curs_set(0)
+    (rows,cols)=stdscr.getmaxyx()
+    w = curses.newwin(10,40,(rows-10)/2, (cols-40)/2)
+    w.keypad(1)
     i=0
     for mitem in l:
         w.addstr(i,0,mitem)
         i+=1
 
     highlight=0
+    w.chgat(highlight,0, curses.A_REVERSE)
+    w.refresh()
     ch=w.getch()
-    while (ch!=curses.KEY_F1):
+    while (ch!=113): # leave on q
         if ch==curses.KEY_UP:
             if highlight!=0:
-                w.chgat(highlight,0, 16, 0)
+                w.chgat(highlight,0, 0)
                 highlight -= 1
-                w.chgat(highlight,0, 16, curses.A_REVERSE)
+                w.chgat(highlight,0, curses.A_REVERSE)
         if ch==curses.KEY_DOWN:
-            if highlight!=len(l):
-                w.chgat(highlight,0, 16, 0)
+            if highlight!=len(l)-1:
+                w.chgat(highlight,0, 0)
                 highlight += 1
-                w.chgat(highlight,0, 16, curses.A_REVERSE)
+                w.chgat(highlight,0, curses.A_REVERSE)
         w.refresh()
         ch = w.getch()
+    
+    curses.curs_set(1)
 
 
 menu = ["item 1", "poo", "add book/article/stuff", "update", "remove"]