k.add :edit_as_new, "Edit message as new", 'D'
k.add :save_to_disk, "Save message/attachment to disk", 's'
k.add :search, "Search for messages from particular people", 'S'
+ k.add :archive_and_kill, "Archive thread and kill buffer", 'A'
end
## there are a couple important instance variables we hold to lay
@layout[latest].state = :open if @layout[latest].state == :closed
@layout[earliest].state = :detailed if earliest.has_label?(:unread) || @thread.size == 1
- BufferManager.say("Loading message bodies...") { update }
+ regen_text
end
def draw_line ln, opts={}
## TODO: don't recalculate EVERYTHING just to add a stupid little
## star to the display
update
- UpdateManager.relay :starred, m
+ UpdateManager.relay self, :starred, m
end
def toggle_expanded
end
end
- ## kinda slow for large threads. TODO: fasterify
def cleanup
- BufferManager.say "Marking messages as read..." do
- @thread.each do |m, d, p|
- if m && m.has_label?(:unread)
- m.remove_label :unread
- UpdateManager.relay :read, m
- end
- end
- end
+ @thread.remove_label :unread
+ UpdateManager.relay self, :read, @thread
@layout = @text = nil
end
+ def archive_and_kill
+ @thread.remove_label :inbox
+ UpdateManager.relay self, :archived, @thread
+ BufferManager.kill_buffer_safely buffer
+ end
+
private
def initial_state_for m
@text += chunk_to_lines m, nil, @text.length, depth, parent
next
end
-
- ## we're occasionally called on @threads that have had messages
- ## added to them since initialization. luckily we regen_text on
- ## the entire thread every time the user does anything besides
- ## scrolling (basically), so we can just slap this on here.
- ##
- ## to pick nits, the niceness that i do in the constructor with
- ## 'latest' etc. (for automatically opening just the latest
- ## message if everything's been read) will not be valid, but
- ## that's just a nicety and hopefully this won't happen too
- ## often.
-
- unless @layout.member? m
- l = @layout[m] = Layout.new
- l.state = initial_state_for m
- l.color = prevm && @layout[prevm].color == :message_patina_color ? :alternate_patina_color : :message_patina_color
- end
- l = @layout[m]
+ l = @layout[m] or next # TODO: figure out why this is nil sometimes
## build the patina
text = chunk_to_lines m, l.state, @text.length, depth, parent, @layout[m].color
def view_attachment a
BufferManager.flash "viewing #{a.content_type} attachment..."
- a.view!
+ success = a.view!
BufferManager.erase_flash
BufferManager.completely_redraw_screen
+ BufferManager.flash "Couldn't execute view command." unless success
end
end