Subject: [sup-talk] Odd key bug

From: [email-masked] (Edward Z. Yang)
Date: Mon, 27 Jul 2009 13:13:01 -0400

After I finish editing a message and exit out of my editor (vim),
if I try to press up arrow in order to move my focus to the
reply mode field to toggle it, I get the errors:

    unknown keypress '^[' for compose-mode
    unknown keypress 'A' for compose-mode

It then works properly.  A guess is something is messing with the
terminal?  This is 100% reproduceable.

Cheers,
Edward

---

From: [email-masked] (William Morgan)
Date: Mon, 27 Jul 2009 10:33:57 -0700

> terminal?  This is 100% reproduceable.

This happens to me too. Maybe there's some more curses weirdness that
needs to happen when shelling out---you can see the current magic spell
at buffer.rb circa line 724, in BufferManager#shell_out. I've just
suffered through it for the past three years.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Alex Vandiver)
Date: Mon, 27 Jul 2009 13:27:33 -0400

> terminal?  This is 100% reproduceable.

As another data point, I also see this, with emacs as my editor.
 - Alex
-- 
Networking -- only one letter away from not working

---

From: [email-masked] (Ben Walton)
Date: Mon, 27 Jul 2009 13:52:02 -0400

> As another data point, I also see this, with emacs as my editor.

And I saw it with vim until I switched to emacs a few months back.  I
wonder if this is anything to do with how these curses apps interact
with the 'alternate' screen buffer or something?  For the record, I've
always run sup inside of screen...

I've just been suffering through it too.  Edward, you've given voice
to this insidious little annoyance! :)

-Ben
-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090727/580ec624/attachment.bin>

---

From: [email-masked] (Edward Z. Yang)
Date: Mon, 27 Jul 2009 14:13:12 -0400

> suffered through it for the past three years.

I tried cargo culting a few extra function calls from the web, to no
avail.  Man, where's an ncurses expert when you need them...

Cheers,
Edward

---

From: [email-masked] (Edward Z. Yang)
Date: Mon, 27 Jul 2009 14:30:46 -0400

I currently suspect that if I send a null character to the stdscr
(which would require bin/sup to be rewritten a little to make stdscr
globally available) it would serve as a decent workaround.  I don't
actually know how global variables work in Ruby.

(Basically, add stdscr.keypad(0) when we return from the external shell.)

Cheers,
Edward

---

From: [email-masked] (Tarko Tikan)
Date: Mon, 27 Jul 2009 21:47:00 +0300

hey,

> reply mode field to toggle it, I get the errors:

Running sup in screen and seeing it aswell.

As the discussion goes around external editor (and problems switching to and back), I want to throw up an question/idea.

Currently, as the external editor is run, there is no way to switch between sup and external editor (for obvious reasons). Is anyone aware of any better idea how to integrate vim (even better, any editor) into sup and still have the excellent buffer system. Currently, going between received emails, and the one being composed, is a real pain.

Inventing own editor is ofc one solution but it sounds silly to do it from scratch.

-- 
tarko

---

From: [email-masked] (Edward Z. Yang)
Date: Mon, 27 Jul 2009 15:15:27 -0400

Alex Vandiver points out that stdscr is a member variable of Ncurses.
As such, this patch appears to fix the issue.

However, my rationale in my previous message was completely bogus (I
checked the manpage and keypad does NOT send a null key); thus,
I have no fucking clue why this works.  Perhaps forcibly setting this
setting clears some internal buffer.  Either 1 or 0 works, we probably
want 1 since that's what bin/sup sets.

Yay cargo culting! Whoo!

>From 61696b6a097a949545db52b4a537d74f8256d807 Mon Sep 17 00:00:00 2001
From: Edward Z. Yang <ezyang at mit.edu>
Date: Mon, 27 Jul 2009 15:03:58 -0400
Subject: [PATCH] Fix broken arrow keypresses after shelling out.

Signed-off-by: Edward Z. Yang <ezyang at mit.edu>
---
 lib/sup/buffer.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 8eedf96..5f52d1d 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -723,6 +723,7 @@ EOS
     Ncurses.sync do
       Ncurses.endwin
       system command
+      Ncurses.stdscr.keypad 1
       Ncurses.refresh
       Ncurses.curs_set 0
     end
-- 
1.6.3.3

---

From: [email-masked] (Andrew Pimlott)
Date: Mon, 27 Jul 2009 13:11:53 -0700

On Mon, Jul 27, 2009 at 09:47:00PM +0300, Tarko Tikan wrote:
> Currently, as the external editor is run, there is no way to switch between sup and external editor (for obvious reasons). Is anyone aware of any better idea how to integrate vim (even better, any editor) into sup and still have the excellent buffer system.

My idea is to make sup act like a shell and implement job control, so
when you ctrl-z out of your editor, you're back in sup.  You can have
multiple editors stopped in the background, and resume any of them at
any point.

Andrew

---

From: [email-masked] (William Morgan)
Date: Tue, 28 Jul 2009 08:17:52 -0700

> As such, this patch appears to fix the issue.

Applied with great relish direct to master. Thanks!

> want 1 since that's what bin/sup sets.

Welcome to ncurses programming. Much like fortran, everyone who once
knew what this stuff meant has since died.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Ben Walton)
Date: Tue, 28 Jul 2009 11:31:24 -0400

> knew what this stuff meant has since died.

...or is making a 'mint' maintaining crap^H^H^H^Hcode from the 80's?
<grin>

-Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090728/7f69db3f/attachment.bin>