]> git.cworth.org Git - sup/blobdiff - lib/sup/colormap.rb
Merge branch 'hook-local-vars' into next
[sup] / lib / sup / colormap.rb
index 296692b8d9efbac3ba628fab4fa9cde2d832c26e..fbbbfc9e9405d1be3eb88d4dd647b6e96e9e85d8 100644 (file)
@@ -11,42 +11,45 @@ class Colormap
                    Curses::COLOR_YELLOW, Curses::COLOR_BLUE,
                    Curses::COLOR_MAGENTA, Curses::COLOR_CYAN,
                    Curses::COLOR_WHITE, Curses::COLOR_DEFAULT]
-  NUM_COLORS = 15
+  NUM_COLORS = (CURSES_COLORS.size - 1) * (CURSES_COLORS.size - 1)
 
   DEFAULT_COLORS = {
     :status => { :fg => "white", :bg => "blue", :attrs => ["bold"] },
-    :index_old => { :fg => "white", :bg => "black" },
-    :index_new => { :fg => "white", :bg => "black", :attrs => ["bold"] },
-    :index_starred => { :fg => "yellow", :bg => "black", :attrs => ["bold"] },
-    :index_draft => { :fg => "red", :bg => "black", :attrs => ["bold"] },
-    :labellist_old => { :fg => "white", :bg => "black" },
-    :labellist_new => { :fg => "white", :bg => "black", :attrs => ["bold"] },
-    :twiddle => { :fg => "blue", :bg => "black" },
-    :label => { :fg => "yellow", :bg => "black" },
+    :index_old => { :fg => "white", :bg => "default" },
+    :index_new => { :fg => "white", :bg => "default", :attrs => ["bold"] },
+    :index_starred => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
+    :index_draft => { :fg => "red", :bg => "default", :attrs => ["bold"] },
+    :labellist_old => { :fg => "white", :bg => "default" },
+    :labellist_new => { :fg => "white", :bg => "default", :attrs => ["bold"] },
+    :twiddle => { :fg => "blue", :bg => "default" },
+    :label => { :fg => "yellow", :bg => "default" },
     :message_patina => { :fg => "black", :bg => "green" },
     :alternate_patina => { :fg => "black", :bg => "blue" },
     :missing_message => { :fg => "black", :bg => "red" },
-    :attachment => { :fg => "cyan", :bg => "black" },
-    :cryptosig_valid => { :fg => "yellow", :bg => "black", :attrs => ["bold"] },
-    :cryptosig_unknown => { :fg => "cyan", :bg => "black" },
+    :attachment => { :fg => "cyan", :bg => "default" },
+    :cryptosig_valid => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
+    :cryptosig_unknown => { :fg => "cyan", :bg => "default" },
     :cryptosig_invalid => { :fg => "yellow", :bg => "red", :attrs => ["bold"] },
-    :generic_notice_patina => { :fg => "cyan", :bg => "black" },
-    :quote_patina => { :fg => "yellow", :bg => "black" },
-    :sig_patina => { :fg => "yellow", :bg => "black" },
-    :quote => { :fg => "yellow", :bg => "black" },
-    :sig => { :fg => "yellow", :bg => "black" },
-    :to_me => { :fg => "green", :bg => "black" },
-    :starred => { :fg => "yellow", :bg => "black", :attrs => ["bold"] },
+    :generic_notice_patina => { :fg => "cyan", :bg => "default" },
+    :quote_patina => { :fg => "yellow", :bg => "default" },
+    :sig_patina => { :fg => "yellow", :bg => "default" },
+    :quote => { :fg => "yellow", :bg => "default" },
+    :sig => { :fg => "yellow", :bg => "default" },
+    :to_me => { :fg => "green", :bg => "default" },
+    :starred => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
     :starred_patina => { :fg => "yellow", :bg => "green", :attrs => ["bold"] },
     :alternate_starred_patina => { :fg => "yellow", :bg => "blue", :attrs => ["bold"] },
-    :snippet => { :fg => "cyan", :bg => "black" },
-    :option => { :fg => "white", :bg => "black" },
-    :tagged => { :fg => "red", :bg => "black", :attrs => ["bold"] },
-    :draft_notification => { :fg => "red", :bg => "black", :attrs => ["bold"] },
-    :completion_character => { :fg => "white", :bg => "black", :attrs => ["bold"] },
-    :horizontal_selector_selected => { :fg => "yellow", :bg => "black", :attrs => ["bold"] },
-    :horizontal_selector_unselected => { :fg => "cyan", :bg => "black" },
-    :search_highlight => { :fg => "black", :bg => "yellow", :attrs => ["bold"] }
+    :snippet => { :fg => "cyan", :bg => "default" },
+    :option => { :fg => "white", :bg => "default" },
+    :tagged => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
+    :draft_notification => { :fg => "red", :bg => "default", :attrs => ["bold"] },
+    :completion_character => { :fg => "white", :bg => "default", :attrs => ["bold"] },
+    :horizontal_selector_selected => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
+    :horizontal_selector_unselected => { :fg => "cyan", :bg => "default" },
+    :search_highlight => { :fg => "black", :bg => "yellow", :attrs => ["bold"] },
+    :system_buf => { :fg => "blue", :bg => "default" },
+    :regular_buf => { :fg => "white", :bg => "default" },
+    :modified_buffer => { :fg => "yellow", :bg => "default", :attrs => ["bold"] },
   }
   
   def initialize
@@ -126,7 +129,7 @@ class Colormap
       @next_id = (@next_id + 1) % NUM_COLORS
       @next_id += 1 if @next_id == 0 # 0 is always white on black
       id = @next_id
-      Redwood::log "colormap: for color #{sym}, using id #{id} -> #{fg}, #{bg}"
+      debug "colormap: for color #{sym}, using id #{id} -> #{fg}, #{bg}"
       Curses.init_pair id, fg, bg or raise ArgumentError,
         "couldn't initialize curses color pair #{fg}, #{bg} (key #{id})"
 
@@ -134,7 +137,7 @@ class Colormap
       ## delete the old mapping, if it exists
       if @users[cp]
         @users[cp].each do |usym|
-          Redwood::log "dropping color #{usym} (#{id})"
+          warn "dropping color #{usym} (#{id})"
           @entries[usym][3] = nil
         end
         @users[cp] = []
@@ -152,7 +155,7 @@ class Colormap
   ## to the default ones.
   def populate_colormap
     user_colors = if File.exists? Redwood::COLOR_FN
-      Redwood::log "loading user colors from #{Redwood::COLOR_FN}"
+      debug "loading user colors from #{Redwood::COLOR_FN}"
       Redwood::load_yaml_obj Redwood::COLOR_FN
     end
 
@@ -168,7 +171,7 @@ class Colormap
             fg = Curses.const_get "COLOR_#{ufg.upcase}"
           rescue NameError
             error ||= "Warning: there is no color named \"#{ufg}\", using fallback."
-            Redwood::log "Warning: there is no color named \"#{ufg}\""
+            warn "there is no color named \"#{ufg}\""
           end
         end
 
@@ -177,7 +180,7 @@ class Colormap
             bg = Curses.const_get "COLOR_#{ubg.upcase}"
           rescue NameError
             error ||= "Warning: there is no color named \"#{ubg}\", using fallback."
-            Redwood::log "Warning: there is no color named \"#{ubg}\""
+            warn "there is no color named \"#{ubg}\""
           end
         end
 
@@ -187,7 +190,7 @@ class Colormap
               Curses.const_get "A_#{a.upcase}"
             rescue NameError
               error ||= "Warning: there is no attribute named \"#{a}\", using fallback."
-              Redwood::log "Warning: there is no attribute named \"#{a}\", using fallback."
+              warn "there is no attribute named \"#{a}\", using fallback."
             end
           end
         end