Subject: [sup-talk] [PATCH] Title bar and status bar widget

From: [email-masked] (Marcus Williams)
Date: Thu, 08 Nov 2007 10:44:44 +0000

This patch adds two new hooks that allow you to set the title bar of a
terminal (default is no title, to support non-terminal users) and the
status bar of sup (default is standard status bar string).

status-bar-widget
-----------------
File: /home/marcus/.sup/hooks/status-bar-widget.rb
Generates the contents of the status bar
Variables:
  total: Total number of messages in inbox
  spam: Total number of messages marked as spam
  new: Total number of messages marked as unread (new)
  mode: Mode string
  status: Mode status
  title: Mode title

terminal-title-widget
---------------------
File: /home/marcus/.sup/hooks/terminal-title-widget.rb
Generates the contents of the title bar
Variables:
  total: Total number of messages in inbox
  spam: Total number of messages marked as spam
  new: Total number of messages marked as unread (new)
  mode: Mode string
  status: Mode status
  title: Mode title

So I have in my terminal-title-widget.rb (giving me a quick way to see
if I have any email when iconised):

"Sup/#{Redwood::VERSION} - #{new} unread of #{total} messages"

In my title bar this looks like

Sup/0.2 - 12 unread of 4520 messages

Note that the numbers come from the index, so if you read a message
and dont save (via '$') the display doesnt know about those changes.
Incoming messages go straight to index so will update it
automatically.

If its any use I could add counts for other forms of messages
(starred/killed etc) but I only use the spam, new and total and I only
use spam to track what the before-add-message hook is doing :)

Marcus

---

From: [email-masked] (vasudeva)
Date: Thu, 8 Nov 2007 07:10:27 -0500

> status bar of sup (default is standard status bar string).

A case for :confirm_no_patches ? ;)

/></

--
linkswarm.com :: Collaborative Insolence
vasudeva.linkswarm.com/gallery :: For The Faint of Heart

---

From: [email-masked] (Marcus Williams)
Date: Fri, 09 Nov 2007 07:40:32 +0000

> A case for :confirm_no_patches ? ;)

Oops! :) Attached this time....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widgets-patch
Type: application/octet-stream
Size: 2037 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071109/5cedd47f/attachment.obj

---

From: [email-masked] (William Morgan)
Date: Sun, 11 Nov 2007 16:48:39 -0800

Hi Marcus,

> status bar of sup (default is standard status bar string).

This patch actually has a problem, which you can see if you try and use
"say" from within one of those hooks, or if you insert an error into the
hook code.

The problem is that the hooks are executed from draw_status, which is
executed within the context of a lock on Ncurses.mutex.
BufferManager#flash (which is triggered by both a call to #say and an
error) cannot be called within that lock or a double-lock exception
occurs.

So, either Ncurses.mutex needs to be a reentrant lock (I have played
around with this but haven't yet been able to get it to work), or the
code that runs these hooks needs to run outside of the lock (which takes
place in BufferManager#draw_screen and #completely_redraw_screen).

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

---

From: [email-masked] (Marcus Williams)
Date: Mon, 12 Nov 2007 09:23:59 +0000

> place in BufferManager#draw_screen and #completely_redraw_screen).

Presumably after the unlock, rather than before the lock on the mutex
if the stuff is redrawing? I'll resubmit later today.

Marcus

---

From: [email-masked] (William Morgan)
Date: Mon, 12 Nov 2007 09:02:13 -0800

> if the stuff is redrawing? I'll resubmit later today.

Actually I think the best would be to call the hooks before the lock,
and pass in the values to actually be drawn into the locked code, so
that the draw happens within the lock. It means adding a couple
arguments to some of these methods, probably.

---

From: [email-masked] (Marcus Williams)
Date: Mon, 12 Nov 2007 22:07:17 +0000

> arguments to some of these methods, probably.

Attached is a patch for this. Not sure if this is the best way of
doing it as I've used accessors on buffer class rather than passing
args.

Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widget-diffs
Type: application/octet-stream
Size: 2692 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071112/a834f4e4/attachment.obj

---

From: [email-masked] (William Morgan)
Date: Mon, 26 Nov 2007 12:42:48 -0800

> doing it as I've used accessors on buffer class rather than passing

I've added this functionality to SVN trunk, although I had to deviate
pretty far from the patch in order to get everything right. I also
changed the variable names slightly. Check it out and see if it does
everything you want.

---

From: [email-masked] (Marcus Williams)
Date: Mon, 26 Nov 2007 20:45:47 +0000

> changed the variable names slightly. Check it out and see if it does

On it now - cant get the title text to work yet, but I might be
missing something. Just trying to re-jig my shell and pipe patches so
that the shell one is in bin/sup. Will submit soon.

Marcus