]> git.cworth.org Git - sup/blobdiff - lib/sup.rb
detect character set correctly (but unix-centrically)
[sup] / lib / sup.rb
index f7ce4bf4a86fc29a8d953a81d55209eed3c2a772..5bb27bab27153f4bba115b830f2c907c7d765b87 100644 (file)
@@ -32,7 +32,7 @@ class Module
 end
 
 module Redwood
-  VERSION = "0.2"
+  VERSION = "0.3"
 
   BASE_DIR   = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup")
   CONFIG_FN  = File.join(BASE_DIR, "config.yaml")
@@ -49,16 +49,6 @@ module Redwood
   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]
@@ -204,6 +194,7 @@ else
     :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
@@ -234,6 +225,16 @@ module Redwood
   module_function :log
 end
 
+## determine encoding and character set. there MUST be a better way to
+## do this.
+  $encoding = `locale -c LC_CTYPE|head -6|tail -1`.chomp
+  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"
@@ -255,6 +256,7 @@ 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"