lib/sup/modes/thread_view_mode.rb in sup-0.22.1 vs lib/sup/modes/thread_view_mode.rb in sup-0.23
- old
+ new
@@ -8,12 +8,10 @@
class ChunkLayout
attr_accessor :state
end
- INDENT_SPACES = 2 # how many spaces to indent child messages
-
HookManager.register "detailed-headers", <<EOS
Add or remove headers from the detailed header display of a message.
Variables:
message: The message whose headers are to be formatted.
headers: A hash of header (name, value) pairs, initialized to the default
@@ -52,10 +50,11 @@
register_keymap do |k|
k.add :toggle_detailed_header, "Toggle detailed header", 'h'
k.add :show_header, "Show full message header", 'H'
k.add :show_message, "Show full message (raw form)", 'V'
+ k.add :reload, "Update message in thread", '@'
k.add :activate_chunk, "Expand/collapse or activate item", :enter
k.add :expand_all_messages, "Expand/collapse all messages", 'E'
k.add :edit_draft, "Edit draft", 'e'
k.add :send_draft, "Send draft", 'y'
k.add :edit_labels, "Edit or add labels for a thread", 'l'
@@ -125,10 +124,11 @@
## Chunks to ChunkLayouts. @message_lines is a map from row #s to
## Message objects. @chunk_lines is a map from row #s to Chunk
## objects. @person_lines is a map from row #s to Person objects.
def initialize thread, hidden_labels=[], index_mode=nil
+ @indent_spaces = $config[:indent_spaces]
super :slip_rows => $config[:slip_rows]
@thread = thread
@hidden_labels = hidden_labels
## used for dispatch-and-next
@@ -203,10 +203,14 @@
def toggle_detailed_header
m = @message_lines[curpos] or return
@layout[m].state = (@layout[m].state == :detailed ? :open : :detailed)
update
end
+
+ def reload
+ update
+ end
def reply type_arg=nil
m = @message_lines[curpos] or return
mode = ReplyMode.new m, type_arg
BufferManager.spawn "Reply to #{m.subj}", mode
@@ -387,11 +391,11 @@
chunk = @chunk_lines[curpos] or return
case chunk
when Chunk::Attachment
default_dir = $config[:default_attachment_save_dir]
default_dir = ENV["HOME"] if default_dir.nil? || default_dir.empty?
- default_fn = File.expand_path File.join(default_dir, chunk.safe_filename)
+ default_fn = File.expand_path File.join(default_dir, chunk.filesafe_filename)
fn = BufferManager.ask_for_filename :filename, "Save attachment to file or directory: ", default_fn, true
# if user selects directory use file name from message
if fn and File.directory? fn
fn = File.join(fn, chunk.filename)
@@ -416,11 +420,11 @@
num = 0
num_errors = 0
m.chunks.each do |chunk|
next unless chunk.is_a?(Chunk::Attachment)
- fn = File.join(folder, chunk.safe_filename)
+ fn = File.join(folder, chunk.filesafe_filename)
num_errors += 1 unless save_to_file(fn, false) { |f| f.print chunk.raw_content }
num += 1
end
if num == 0
@@ -559,11 +563,11 @@
def jump_to_message m, force_alignment=false
l = @layout[m]
## boundaries of the message
- message_left = l.depth * INDENT_SPACES
+ message_left = l.depth * @indent_spaces
message_right = message_left + l.width
## calculate leftmost colum
left = if force_alignment # force mode: align exactly
message_left
@@ -767,18 +771,17 @@
# [[:text_color, "Some text"]]
# [[:text_color, " continued here"]]
# ]
linetext = @text.slice(curpos, @text.length).flatten(1)
- .take_while{|d| d[0] == :text_color and d[1].strip != ""} # Only take up to the first "" alone on its line
+ .take_while{|d| [:text_color, :sig_color].include?(d[0]) and d[1].strip != ""} # Only take up to the first "" alone on its line
.map{|d| d[1].strip}.join("").strip
found = false
- (linetext || "").scan(URI::regexp).each do |matches|
+ URI.extract(linetext || "").each do |match|
begin
- link = $& # ruby magic: $& is the whole regexp match
- u = URI.parse(link)
+ u = URI.parse(match)
next unless u.absolute?
next unless ["http", "https"].include?(u.scheme)
reallink = Shellwords.escape(u.to_s)
BufferManager.flash "Going to #{reallink} ..."
@@ -884,11 +887,11 @@
text = chunk_to_lines c, cl.state, @text.length, depth
(0 ... text.length).each do |i|
@chunk_lines[@text.length + i] = c
@message_lines[@text.length + i] = m
- lw = text[i].flatten.select { |x| x.is_a? String }.map { |x| x.display_length }.sum - (depth * INDENT_SPACES)
+ lw = text[i].flatten.select { |x| x.is_a? String }.map { |x| x.display_length }.sum - (depth * @indent_spaces)
l.width = lw if lw > l.width
end
@text += text
end
@layout[m].bot = @text.length
@@ -989,10 +992,10 @@
return lines
end
## todo: check arguments on this overly complex function
def chunk_to_lines chunk, state, start, depth, parent=nil, color=nil, star_color=nil
- prefix = " " * INDENT_SPACES * depth
+ prefix = " " * @indent_spaces * depth
case chunk
when :fake_root
[[[:missing_message_color, "#{prefix}<one or more unreceived messages>"]]]
when nil
[[[:missing_message_color, "#{prefix}<an unreceived message>"]]]