X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup.rb;h=ed144589a705abd854573e9b9f6eddf247ec458a;hb=723e222e5143badf905bc80034f0f86690378e6f;hp=93369a5f62e01933491cd4aaa352013d673fd7ef;hpb=c1109326ae9116f0c814258b310333e13b2c3730;p=sup diff --git a/lib/sup.rb b/lib/sup.rb index 93369a5..ed14458 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -5,19 +5,10 @@ require 'thread' require 'fileutils' require 'gettext' require 'curses' - -## 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. - -require 'dl/import' -module LibC - extend DL::Importable - dlload Config::CONFIG['arch'] =~ /darwin/ ? "libc.dylib" : "libc.so.6" - extern "void setlocale(int, const char *)" +begin + require 'fastthread' +rescue LoadError end -LibC.setlocale(6, "") # LC_ALL == 6 class Object ## this is for debugging purposes because i keep calling #id on the @@ -33,7 +24,7 @@ class Module vars = props.map { |p| "@#{p}" } klass = self path = klass.name.gsub(/::/, "/") - + klass.instance_eval do define_method(:to_yaml_properties) { vars } define_method(:to_yaml_type) { "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}" } @@ -53,7 +44,6 @@ module Redwood COLOR_FN = File.join(BASE_DIR, "colors.yaml") SOURCE_FN = File.join(BASE_DIR, "sources.yaml") LABEL_FN = File.join(BASE_DIR, "labels.txt") - PERSON_FN = File.join(BASE_DIR, "people.txt") CONTACT_FN = File.join(BASE_DIR, "contacts.txt") DRAFT_DIR = File.join(BASE_DIR, "drafts") SENT_FN = File.join(BASE_DIR, "sent.mbox") @@ -64,6 +54,8 @@ module Redwood YAML_DOMAIN = "masanjin.net" YAML_DATE = "2006-10-01" + DEFAULT_INDEX = 'ferret' + ## record exceptions thrown in threads nicely @exceptions = [] @exception_mutex = Mutex.new @@ -115,22 +107,22 @@ module Redwood end def start - Redwood::PersonManager.new Redwood::PERSON_FN - Redwood::SentManager.new Redwood::SENT_FN - Redwood::ContactManager.new Redwood::CONTACT_FN - Redwood::LabelManager.new Redwood::LABEL_FN - Redwood::AccountManager.new $config[:accounts] - Redwood::DraftManager.new Redwood::DRAFT_DIR - Redwood::UpdateManager.new - Redwood::PollManager.new - Redwood::SuicideManager.new Redwood::SUICIDE_FN - Redwood::CryptoManager.new + Redwood::SentManager.init $config[:sent_source] || 'sup://sent' + Redwood::ContactManager.init Redwood::CONTACT_FN + Redwood::LabelManager.init Redwood::LABEL_FN + Redwood::AccountManager.init $config[:accounts] + Redwood::DraftManager.init Redwood::DRAFT_DIR + Redwood::UpdateManager.init + Redwood::PollManager.init + Redwood::SuicideManager.init Redwood::SUICIDE_FN + Redwood::CryptoManager.init + Redwood::UndoManager.init + Redwood::SourceManager.init end def finish Redwood::LabelManager.save if Redwood::LabelManager.instantiated? Redwood::ContactManager.save if Redwood::ContactManager.instantiated? - Redwood::PersonManager.save if Redwood::PersonManager.instantiated? Redwood::BufferManager.deinstantiate! if Redwood::BufferManager.instantiated? end @@ -141,7 +133,7 @@ module Redwood def report_broken_sources opts={} return unless BufferManager.instantiated? - broken_sources = Index.sources.select { |s| s.error.is_a? FatalSourceError } + broken_sources = SourceManager.sources.select { |s| s.error.is_a? FatalSourceError } unless broken_sources.empty? BufferManager.spawn_unless_exists("Broken source notification for #{broken_sources.join(',')}", opts) do TextMode.new(< true, :confirm_top_posting => true, :discard_snippets_from_encrypted_messages => false, + :default_attachment_save_dir => "", + :sent_source => "sup://sent" } begin FileUtils.mkdir_p Redwood::BASE_DIR @@ -236,31 +230,28 @@ require "sup/hook" ## we have to initialize this guy first, because other classes must ## reference it in order to register hooks, and they do that at parse ## time. -Redwood::HookManager.new Redwood::HOOK_DIR +Redwood::HookManager.init Redwood::HOOK_DIR ## everything we need to get logging working -require "sup/buffer" -require "sup/keymap" -require "sup/mode" -require "sup/modes/scroll-mode" -require "sup/modes/text-mode" -require "sup/modes/log-mode" require "sup/logger" -module Redwood - def log s; Logger.log s; end - module_function :log -end +Redwood::Logger.init.add_sink $stderr +include Redwood::LogsStuff ## determine encoding and character set $encoding = Locale.current.charset if $encoding - Redwood::log "using character set encoding #{$encoding.inspect}" + debug "using character set encoding #{$encoding.inspect}" else - Redwood::log "warning: can't find character set by using locale, defaulting to utf-8" - $encoding = "utf-8" + warn "can't find character set by using locale, defaulting to utf-8" + $encoding = "UTF-8" end -## now everything else (which can feel free to call Redwood::log at load time) +require "sup/buffer" +require "sup/keymap" +require "sup/mode" +require "sup/modes/scroll-mode" +require "sup/modes/text-mode" +require "sup/modes/log-mode" require "sup/update" require "sup/suicide" require "sup/message-chunks" @@ -281,6 +272,7 @@ require "sup/tagger" require "sup/draft" require "sup/poll" require "sup/crypto" +require "sup/undo" require "sup/horizontal-selector" require "sup/modes/line-cursor-mode" require "sup/modes/help-mode"