finishing fixing bugs from last commit
[public/library.git] / form.py
diff --git a/form.py b/form.py
index cd53151..2e9110f 100644 (file)
--- a/form.py
+++ b/form.py
@@ -1,4 +1,5 @@
 import curses
+import sys
 
 class formWindow:
     mx = my = 0
@@ -52,7 +53,7 @@ class formWindow:
         self.hb.refresh()
         self.updateGeometry()
         self.w.box()
-        self.w.addstr(0,(self.mx-len(self.caption))/2,self.caption)
+        self.w.addstr(0,(self.mx-len(self.caption))//2,self.caption)
         r=self.top
         for l in self.labels:
             c = self.left-len(l)-2
@@ -86,7 +87,7 @@ class formWindow:
         self.hl = new
         self.row = self.hl + self.top
         if new == len(self.labels):
-            self.bt+=1
+            self.bt =1
             self.bt = min(self.bt,1)
             self.row+=1
         else:
@@ -105,7 +106,8 @@ class formWindow:
 
     def insert(self,ch):
         c = self.cursor
-        self.entries[self.hl]=self.entries[self.hl][:c] +ch+  self.entries[self.hl][c:]
+        #sys.stderr.write(str(type(ch)))
+        self.entries[self.hl]=self.entries[self.hl][:c] +ch.decode('utf-8')+  self.entries[self.hl][c:]
         self.drawRow(self.hl)
         self.mvCursor(+1)
         self.highlight()
@@ -220,12 +222,15 @@ class bookForm(formWindow):
                 if book != {}:
                     self.updateEntries(book)
                 self.refresh()
+                self.mvHighlight(+7)
             if self.hl==1:          # lookup by lccn
                 book = self.lookup_lccn(self.entries[1])
                 if book != {}:
                     self.updateEntries(book)
                 self.refresh()
-        formWindow.handleInput(self,ch)
+                self.mvHighlight(+6)
+        else:
+            formWindow.handleInput(self,ch)
 
 class categoryForm(formWindow):
     caption = "Add a Category"