Subject: [sup-talk] interface blinking and corrupted on the console

From: [email-masked] (Giorgio Lando)
Date: Sat, 05 Jan 2008 13:58:50 +0100

Hi, yet another issue. When I run sup on the plain console or on the
framebuffer, it starts to beep and continues forever;  everything
blinks; keybindings seem to work (or at least I am able to get out with
q).

This does not happen in X; also if I run sup into a screen session on
the onsole everything works fine. Looking at my environment variables,
the only thing which seems to distinguish the plain console from screen
on the console is the TERM variable, which on the console is set to
"linux". I have no similar issues with other ncurses apps on the
console.

Should I set TERM to something else?
Giorgio Lando

---

From: [email-masked] (William Morgan)
Date: Sat, 05 Jan 2008 10:33:14 -0800

> blinks; keybindings seem to work (or at least I am able to get out with

I believe this is because of the way we're trying to set the X window
title. This patch should help temporarily:

--- cut here ---
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index fa1afe6..7f0ad81 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -262,7 +262,7 @@ EOS
         get_status_and_title @focus_buf # must be called outside of the ncurses
       end
 
-    print "\033]2;#{title}\07" if title
+    #print "\033]2;#{title}\07" if title
 
     Ncurses.mutex.lock unless opts[:sync] == false

--- cut here ---

> the only thing which seems to distinguish the plain console from
> screen on the console is the TERM variable, which on the console is
> set to "linux". I have no similar issues with other ncurses apps on
> the console.

Does anyone know what the correct approach is for determining whether to
set the title or not? Is it a matter of checking $TERM?

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Marcus Williams)
Date: Sat, 05 Jan 2008 20:11:14 +0000

> set the title or not? Is it a matter of checking $TERM?

I think checking if $TERM is one of "xterm.*" and "rxvt.*". I'd also
add "screen" to the list as well (because screen deals with it and my
main usage of sup is during a screen session :) and maybe "cyg.*" for
whatever the cygwin term variable is (I think its cygwin but might be
cygterm cant remember).  Needs to be a regex because you get stuff
like xterm-color.

Marcus

---

From: [email-masked] (Giorgio Lando)
Date: Sat, 05 Jan 2008 22:32:26 +0100

>      Ncurses.mutex.lock unless opts[:sync] == false

Yes, the patch fixes the issue.
> set the title or not? Is it a matter of checking $TERM?
It seems so, set title works fine both in *rxvt and screen for me,
except for the fact that the title in screen persists after I quit sup;
but this may be also seen as the correct behaviour.
Giorgio

---

From: [email-masked] (Marcus Williams)
Date: Sat, 05 Jan 2008 22:01:22 +0000

> but this may be also seen as the correct behaviour.

I'd probably agree this is correct behaviour - vim does the same
thing. I run my xterms with a title set in the bash prompt (so I get
current host/user/directory in the xterm) so when I drop out of sup it
changes to the bash set title.

Marcus

---

From: [email-masked] (Giorgio Lando)
Date: Sun, 06 Jan 2008 23:54:03 +0100

>      Ncurses.mutex.lock unless opts[:sync] == false
Yes I confirm that this is the cause of blinking & corruption in the
plain console, since
the patch blocks this behaviour.
Thanks again
Giorgio

---

From: [email-masked] (William Morgan)
Date: Wed, 09 Jan 2008 08:09:48 -0800

> cygterm cant remember).  Needs to be a regex because you get stuff

Ok, I just committed this to git master:

commit 9722a770cadd44ddc4af6ddcb56eb8edb35c93b9
Author: William Morgan <wmorgan-sup at masanjin.net>
Date:   Wed Jan 9 08:06:39 2008 -0800

    only set terminal title if $TERM is an xterm or rxvt variant

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index fa1afe6..782695b 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -63,6 +63,7 @@ class Buffer
     @title = opts[:title] || ""
     @force_to_top = opts[:force_to_top] || false
     @x, @y, @width, @height = 0, 0, width, height
+    @in_x = ENV["TERM"] =~ /(xterm|rxvt)/
   end
 
   def content_height; @height - 1; end
@@ -262,7 +263,7 @@ EOS
         get_status_and_title @focus_buf # must be called outside of the ncurses
       end
 
-    print "\033]2;#{title}\07" if title
+    print "\033]2;#{title}\07" if title && @in_x

---

From: [email-masked] (Giorgio Lando)
Date: Wed, 09 Jan 2008 18:49:18 +0100

>     only set terminal title if $TERM is an xterm or rxvt variant

Thanks. It would be nice if you could add the screen variants, because it works fine in screen,
as someone else already noted. 
Giorgio

---

From: [email-masked] (William Morgan)
Date: Wed, 09 Jan 2008 10:09:12 -0800

Excerpts from Giorgio Lando's message of Wed Jan 09 09:49:18 -0800 2008:
> Thanks. It would be nice if you could add the screen variants, because
> it works fine in screen, as someone else already noted.

Whoops. Added!

---

From: [email-masked] (Marcus Williams)
Date: Wed, 09 Jan 2008 21:09:47 +0000

>     only set terminal title if $TERM is an xterm or rxvt variant

I get lots of @in_x not initialised errors at the terminal title line
(that ends && @in_x) Is the initialise routine called before the
buffer titles are set?

Marcus

---

From: [email-masked] (William Morgan)
Date: Wed, 09 Jan 2008 15:02:05 -0800

> (that ends && @in_x) Is the initialise routine called before the

Whoops, I did something silly. Try it now. I just applied:

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index f724f88..2a78787 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -63,7 +63,6 @@ class Buffer
     @title = opts[:title] || ""
     @force_to_top = opts[:force_to_top] || false
     @x, @y, @width, @height = 0, 0, width, height
-    @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/
   end
 
   def content_height; @height - 1; end
@@ -178,6 +177,7 @@ EOS
     @textfields = {}
     @flash = nil
     @shelled = @asking = false
+    @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/
 
     self.class.i_am_the_instance self
   end

---

From: [email-masked] (Marcus Williams)
Date: Thu, 10 Jan 2008 11:37:45 +0000

> Whoops, I did something silly. Try it now. I just applied:

Fixed. Thanks.