Package: lfm

Version: 0.91.2-1
Followup-For: Bug #388150
Tags: patch
Severity: Important

I did some follow-up on this, and found the following:

lfm only choked if I used the terminal kterm, which I use by default
for multilingual text.  I tried it in a couple other terms (mrxvt,
xterm, and gnome-terminal) and it did not choke.  Note that I also
tried katerm (found in package aterm-ml) and it too choked.

I was still curious as to why it choked in kterm.  I tracked it down
to ncurses in python2.[3,4].  In lfm, throughout the file
messages.py, the function curs_set() is used to control the
visibility of the cursor.  If lfm attempts to set the cursor using
curses.curs_set(0,1,2) then it kicks out an error and the program
halts.

Apparently this is a known problem (at least to the author of lfm),
because in lfm/messages.py next to the curs_set() statements are
comments to the effect that this may not work in some terminals.

I've attached a patch that preserves the cursor setting function for
terminals that don't choke on curses.curs_set() yet simply ignores
the cursor setting function for terminals that do choke on it like
kterm and katerm.

The patch makes lfm usable again for these terminals, but the
problem most likely lies with the kterm/aterm packages.  I will
check the bug reports for those packages and if necessary file a new
report about this curses.curs_set() problem.

Kevin

-- 
Kevin Coyner  GnuPG key: 1024D/8CE11941
diff -ur -x debian -x build lfm-0.91.2-orig/lfm/messages.py 
lfm-0.91.2/lfm/messages.py
--- lfm-0.91.2-orig/lfm/messages.py     2004-07-22 12:00:21.000000000 -0400
+++ lfm-0.91.2/lfm/messages.py  2006-09-20 14:17:35.000000000 -0400
@@ -535,7 +535,10 @@
                         try:         # some terminals don't allow '2'
                             curses.curs_set(2)
                         except:
-                            curses.curs_set(1)
+                            try:
+                                curses.curs_set(1)
+                            except:
+                                pass
                     if selected != -1:
                         self.text = files.join(self.text, selected)
                         self.pos = len(self.text)
@@ -650,7 +653,10 @@
         try:         # some terminals don't allow '2'
             curses.curs_set(2)
         except:
-            curses.curs_set(1)
+            try:
+                curses.curs_set(1)
+            except:
+                pass
 
         answer = 1
         quit = 0
@@ -673,14 +679,23 @@
                     try:         # some terminals don't allow '2'
                         curses.curs_set(2)
                     except:
-                        curses.curs_set(1)
+                        try:
+                            curses.curs_set(1)
+                        except:
+                            pass
                 elif self.active_entry_i == 1:
                     self.btns.active = 1
-                    curses.curs_set(0)
+                    try:
+                        curses.curs_set(0)
+                    except:
+                        pass
                     answer = 1
                 else:
                     self.btns.active = 2
-                    curses.curs_set(0)
+                    try:
+                        curses.curs_set(0)
+                    except:
+                        pass
                     answer = 0
             elif ans == 0x14:            # Ctrl-T
                 # this is a hack, we need to return to refresh Entry
@@ -691,7 +706,10 @@
                 quit = 1
                 answer = 1
 
-        curses.curs_set(0)
+        try:
+            curses.curs_set(0)
+        except:
+            pass
         if answer:
             # save new historic entries
             if self.with_historic:
@@ -773,7 +791,10 @@
         try:         # some terminals don't allow '2'
             curses.curs_set(2)
         except:
-            curses.curs_set(1)
+            try:
+                curses.curs_set(1)
+            except:
+                pass
 
         answer = 1
         quit = 0
@@ -796,21 +817,33 @@
                     try:         # some terminals don't allow '2'
                         curses.curs_set(2)
                     except:
-                        curses.curs_set(1)
+                        try:
+                            curses.curs_set(1)
+                        except:
+                            pass
                 elif self.active_entry_i == 1:
                     self.active_entry = self.entry2
                     self.btns.active = 0
                     try:         # some terminals don't allow '2'
                         curses.curs_set(2)
                     except:
-                        curses.curs_set(1)
+                        try:
+                            curses.curs_set(1)
+                        except:
+                            pass
                 elif self.active_entry_i == 2:
                     self.btns.active = 1
-                    curses.curs_set(0)
+                    try:
+                        curses.curs_set(0)
+                    except:
+                        pass
                     answer = 1
                 else:
                     self.btns.active = 2
-                    curses.curs_set(0)
+                    try:
+                        curses.curs_set(0)
+                    except:
+                        pass
                     answer = 0
             elif ans == 0x14:            # Ctrl-T
                 # this is a hack, we need to return to refresh Entry
@@ -823,7 +856,10 @@
                 quit = 1
                 answer = 1
 
-        curses.curs_set(0)
+        try:
+            curses.curs_set(0)
+        except:
+            pass
         if answer:
             # save new historic entries
             if self.with_historic:
@@ -855,7 +891,10 @@
             print 'Can\'t create window'
             sys.exit(-1)
         self.win.keypad(1)
-        curses.curs_set(0)
+        try:
+            curses.curs_set(0)
+        except:
+            pass
         self.win.attrset(curses.color_pair(4))
         self.win.bkgdset(curses.color_pair(4))
 
@@ -993,7 +1032,10 @@
             print 'Can\'t create window'
             sys.exit(-1)
         self.win.keypad(1)
-        curses.curs_set(0)
+        try:
+            curses.curs_set(0)
+        except:
+            pass
         self.win.attrset(curses.color_pair(4))
         self.win.bkgdset(curses.color_pair(4))
         self.entries = entries
@@ -1284,7 +1326,10 @@
             print 'Can\'t create window'
             sys.exit(-1)
         self.win.keypad(1)
-        curses.curs_set(0)
+        try:
+            curses.curs_set(0)
+        except:
+            pass
         self.win.attrset(curses.color_pair(1))
         self.win.bkgdset(curses.color_pair(1))
 

Reply via email to