I know there's been some discussion about opening URLs from e-mails in Sup, and because many people use Sup via an SSH session, client-side solutions are not universally useful... but here is a patch that seems to copy a URL on the currently highlighted line to the X selection buffer. (From there I use Kupfer http://kaizer.se/wiki/kupfer/ to open the link in a web client.) Obviously you can do something similar with a mouse but I use a netbook and try to avoid using the trackpad if I can.
It relies on having the program xsel available in your path. I've never fiddled in Ruby before so accept my apologies if the lines are ridiculous, and also if this has been done before by others. For the reasons I mention (not universal, requires xsel) I don't expect it to make it into the Sup code base but I put it out here in case it suits anyone else. --- lib/sup/modes/line-cursor-mode.rb | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/lib/sup/modes/line-cursor-mode.rb b/lib/sup/modes/line-cursor-mode.rb index 1cae994..e65cbee 100644 --- a/lib/sup/modes/line-cursor-mode.rb +++ b/lib/sup/modes/line-cursor-mode.rb @@ -8,6 +8,7 @@ class LineCursorMode < ScrollMode k.add :cursor_down, "Move cursor down one line", :down, 'j' k.add :cursor_up, "Move cursor up one line", :up, 'k' k.add :select, "Select this item", :enter + k.add :selurl, "Copy URL to selection", 'u' end attr_reader :curpos @@ -90,6 +91,18 @@ protected set_cursor_pos botline - 1 if @curpos > botline - 1 end + def selurl + regex = /(?:http|https|mailto):\/\/\S+/i + this_line = self[curpos][0][1] + match = regex.match(this_line) + return if not match + + output = pipe_to_process("xsel -i") do |stream| + stream.print match + end + BufferManager.flash "selected url #{match}" + end + def cursor_down call_load_more_callbacks buffer.content_height if @curpos >= lines - [buffer.content_height/2,1].max return false unless @curpos < lines - 1 -- 1.7.3.2 _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel