lib/sup.rb in sup-0.3 vs lib/sup.rb in sup-0.4

- old
+ new

@@ -1,10 +1,11 @@ require 'rubygems' require 'yaml' require 'zlib' require 'thread' require 'fileutils' +require 'gettext' require 'curses' class Object ## this is for debugging purposes because i keep calling #id on the ## wrong object and i want it to throw an exception @@ -30,11 +31,11 @@ end end end module Redwood - VERSION = "0.3" + VERSION = "0.4" BASE_DIR = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup") CONFIG_FN = File.join(BASE_DIR, "config.yaml") SOURCE_FN = File.join(BASE_DIR, "sources.yaml") LABEL_FN = File.join(BASE_DIR, "labels.txt") @@ -47,20 +48,10 @@ HOOK_DIR = File.join(BASE_DIR, "hooks") YAML_DOMAIN = "masanjin.net" YAML_DATE = "2006-10-01" -## determine encoding and character set -## probably a better way to do this - $ctype = ENV["LC_CTYPE"] || ENV["LANG"] || "en-US.utf-8" - $encoding = - if $ctype =~ /\.(.*)?/ - $1 - else - "utf-8" - end - ## record exceptions thrown in threads nicely def reporting_thread name if $opts[:no_threads] yield else @@ -202,10 +193,11 @@ :ask_for_cc => true, :ask_for_bcc => false, :ask_for_subject => true, :confirm_no_attachments => true, :confirm_top_posting => true, + :discard_snippets_from_encrypted_messages => false, } begin FileUtils.mkdir_p Redwood::BASE_DIR Redwood::save_yaml_obj $config, Redwood::CONFIG_FN rescue StandardError => e @@ -232,10 +224,19 @@ module Redwood def log s; Logger.log s; end module_function :log end +## determine encoding and character set + $encoding = Locale.current.charset + if $encoding + Redwood::log "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" + end + ## now everything else (which can feel free to call Redwood::log at load time) require "sup/update" require "sup/suicide" require "sup/message-chunks" require "sup/message" @@ -253,9 +254,10 @@ require "sup/contact" require "sup/tagger" require "sup/draft" require "sup/poll" require "sup/crypto" +require "sup/horizontal-selector" require "sup/modes/line-cursor-mode" require "sup/modes/help-mode" require "sup/modes/edit-message-mode" require "sup/modes/compose-mode" require "sup/modes/resume-mode"