bin/sup in sup-0.10.2 vs bin/sup in sup-0.11
- old
+ new
@@ -10,14 +10,19 @@
no_ncursesw = true
end
require 'fileutils'
require 'trollop'
-require "sup"; Redwood::check_library_version_against "0.10.2"
+require "sup"; Redwood::check_library_version_against "0.11"
+if ENV['SUP_PROFILE']
+ require 'ruby-prof'
+ RubyProf.start
+end
+
if no_ncursesw
- debug "No 'ncursesw' gem detected. Install it for wide character support."
+ info "No 'ncursesw' gem detected. Install it for wide character support."
end
$opts = Trollop::options do
version "sup v#{Redwood::VERSION}"
banner <<EOS
@@ -32,11 +37,10 @@
opt :no_threads, "Turn off threading. Helps with debugging. (Necessarily disables background polling for new messages.)"
opt :no_initial_poll, "Don't poll for new messages when starting."
opt :search, "Search for this query upon startup", :type => String
opt :compose, "Compose message to this recipient upon startup", :type => String
opt :subject, "When composing, use this subject", :type => String, :short => "j"
- opt :index, "Use this index type ('auto' for autodetect)", :default => "auto"
end
Trollop::die :subject, "requires --compose" if $opts[:subject] && !$opts[:compose]
Redwood::HookManager.register "startup", <<EOS
@@ -81,11 +85,19 @@
k.add :compose, "Compose new message", 'm', 'c'
k.add :nothing, "Do nothing", :ctrl_g
k.add :recall_draft, "Edit most recent draft message", 'R'
k.add :show_inbox, "Show the Inbox buffer", 'I'
k.add :show_console, "Show the Console buffer", '~'
+
+ ## Submap for less often used keybindings
+ k.add_multi "reload (c)olors, rerun (k)eybindings hook", 'O' do |kk|
+ kk.add :reload_colors, "Reload colors", 'c'
+ kk.add :run_keybindings_hook, "Rerun keybindings hook", 'k'
+ end
end
+
+Redwood::Keymap.run_hook global_keymap
## the following magic enables wide characters when used with a ruby
## ncurses.so that's been compiled against libncursesw. (note the w.) why
## this works, i have no idea. much like pretty much every aspect of
## dealing with curses. cargo cult programming at its best.
@@ -132,45 +144,38 @@
Ncurses.echo
Ncurses.endwin
end
module_function :start_cursing, :stop_cursing
-Index.init $opts[:index]
+Index.init
Index.lock_interactively or exit
-if Index.is_a_deprecated_ferret_index?
- FERRET_DEPRECATION_WARNING_FN = File.join BASE_DIR, "you-have-been-warned-about-ferret-deprecation"
- unless File.exist? FERRET_DEPRECATION_WARNING_FN
+begin
+ Redwood::start
+ Index.load
+ Index.start_sync_worker unless $opts[:no_threads]
+
+ if Redwood::SourceManager.sources.any? { |x| x.is_a? Redwood::MBox::SSHLoader }
$stderr.puts <<EOS
-Warning! Your 30-day trial period for using Sup is almost over!
+mbox+ssh sources are deprecated and will be removed in the next release.
+Running rsync in your before-poll hook is a good alternative.
-To purchase the full version of Sup, please see http://sup.rubyforge.org/.
+Press enter to continue.
+EOS
+ $stdin.gets
+ end
-Just kidding. BUT! You are using an old Ferret index. The Ferret backend is
-deprecated and support will be removed in the next version of Sup.
+ if Redwood::SourceManager.sources.any? { |x| x.is_a? Redwood::IMAP }
+ $stderr.puts <<EOS
+IMAP sources are deprecated and will be removed in the next release.
+Running offlineimap or fetchmail in your before-poll hook is a good alternative.
-You should convert to Xapian before that happens.
-
-The conversion process may take several hours. It is safe and interruptable.
-You can start it at any point by typing:
-
- sup-convert-ferret-index
-
-Press enter to continue and be on your way. You won't see this message
-again, just a brief reminder at shutdown.
+Press enter to continue.
EOS
-
$stdin.gets
- FileUtils.touch FERRET_DEPRECATION_WARNING_FN
end
-end
-begin
- Redwood::start
- Index.load
- Index.start_sync_worker unless $opts[:no_threads]
-
$die = false
trap("TERM") { |x| $die = true }
trap("WINCH") { |x| BufferManager.sigwinch_happened! }
if(s = Redwood::SourceManager.source_for DraftManager.source_name)
@@ -232,10 +237,11 @@
mode.edit_message
end
unless $opts[:no_threads]
PollManager.start
+ IdleManager.start
Index.start_lock_update_thread
end
if $opts[:search]
SearchResultsMode.spawn_from_query $opts[:search]
@@ -256,27 +262,30 @@
BufferManager.completely_redraw_screen
end
next
end
+ IdleManager.ping
+
if c == 410
## this is ncurses's way of telling us it's detected a refresh.
## since we have our own sigwinch handler, we don't do anything.
next
end
bm.erase_flash
- action = begin
- if bm.handle_input c
+ action =
+ begin
+ if bm.handle_input c
+ :nothing
+ else
+ bm.resolve_input_with_keymap c, global_keymap
+ end
+ rescue InputSequenceAborted
:nothing
- else
- bm.resolve_input_with_keymap c, global_keymap
end
- rescue InputSequenceAborted
- :nothing
- end
case action
when :quit_now
break if bm.kill_all_buffers_safely
when :quit_ask
if bm.ask_yes_or_no "Really quit?"
@@ -295,13 +304,18 @@
bm.spawn_unless_exists("buffer list", :system => true) { BufferListMode.new }
when :list_contacts
b, new = bm.spawn_unless_exists("Contact List") { ContactListMode.new }
b.mode.load_in_background if new
when :search
- query = BufferManager.ask :search, "search all messages: "
- next unless query && query !~ /^\s*$/
- SearchResultsMode.spawn_from_query query
+ query = BufferManager.ask :search, "Search all messages (enter for saved searches): "
+ unless query.nil?
+ if query.empty?
+ bm.spawn_unless_exists("Saved searches") { SearchListMode.new }
+ else
+ SearchResultsMode.spawn_from_query query
+ end
+ end
when :search_unread
SearchResultsMode.spawn_from_query "is:unread"
when :list_labels
labels = LabelManager.all_labels.map { |l| LabelManager.string_for l }
user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
@@ -337,10 +351,19 @@
when :show_inbox
BufferManager.raise_to_front ibuf
when :show_console
b, new = bm.spawn_unless_exists("Console", :system => true) { ConsoleMode.new }
b.mode.run
+ when :reload_colors
+ Colormap.reset
+ Colormap.populate_colormap
+ bm.completely_redraw_screen
+ bm.flash "reloaded colors"
+ when :run_keybindings_hook
+ HookManager.clear_one 'keybindings'
+ Keymap.run_hook global_keymap
+ bm.flash "keybindings hook run"
when :nothing, InputSequenceAborted
when :redraw
bm.completely_redraw_screen
else
bm.flash "Unknown keypress '#{c.to_character}' for #{bm.focus_buf.mode.name}."
@@ -353,10 +376,11 @@
rescue Exception => e
Redwood::record_exception e, "main"
ensure
unless $opts[:no_threads]
PollManager.stop if PollManager.instantiated?
+ IdleManager.stop if IdleManager.instantiated?
Index.stop_lock_update_thread
end
HookManager.run "shutdown"
@@ -377,10 +401,15 @@
else
error "oh crap, an exception"
end
Index.unlock
+
+ if (fn = ENV['SUP_PROFILE'])
+ result = RubyProf.stop
+ File.open(fn, 'w') { |io| RubyProf::CallTreePrinter.new(result).print(io) }
+ end
end
unless Redwood::exceptions.empty?
File.open(File.join(BASE_DIR, "exception-log.txt"), "w") do |f|
Redwood::exceptions.each do |e, name|
@@ -402,12 +431,8 @@
EOS
Redwood::exceptions.each do |e, name|
puts "--- #{e.class.name} from thread: #{name}"
puts e.message, e.backtrace
end
-end
-
-if Index.is_a_deprecated_ferret_index?
- puts "Reminder: to update your Ferret index to Xapian, run sup-convert-ferret-index."
end
end