sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 46fd86641778b9448cdfb653af7f76630a0dce62
parent c578ee67b08e490f4c314a90aee4401c32b74ae9
Author: Markus Klinik <markus.klinik@gmx.de>
Date:   Sun, 29 Apr 2012 16:36:26 +0200

support setting the color of normal text

- message bodies
- system log
- inlined attachments

Not sure if I missed a spot

Diffstat:
M lib/sup/buffer.rb | 2 +-
M lib/sup/colormap.rb | 1 +
M lib/sup/message_chunks.rb | 4 ++--
M lib/sup/modes/completion_mode.rb | 6 +++---
M lib/sup/modes/line_cursor_mode.rb | 4 ++--
M lib/sup/modes/scroll_mode.rb | 8 ++++----
6 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -709,7 +709,7 @@ EOS
     end
 
     Ncurses.mutex.lock unless opts[:sync] == false
-    Ncurses.attrset Colormap.color_for(:none)
+    Ncurses.attrset Colormap.color_for(:text_color)
     adj = @asking ? 2 : 1
     m.each_with_index do |s, i|
       Ncurses.mvaddstr Ncurses.rows - i - adj, 0, s + (" " * [Ncurses.cols - s.length, 0].max)
diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb
@@ -26,6 +26,7 @@ class Colormap
   @@instance = nil
 
   DEFAULT_COLORS = {
+    :text => { :fg => "white", :bg => "black" },
     :status => { :fg => "white", :bg => "blue", :attrs => ["bold"] },
     :index_old => { :fg => "white", :bg => "default" },
     :index_new => { :fg => "white", :bg => "default", :attrs => ["bold"] },
diff --git a/lib/sup/message_chunks.rb b/lib/sup/message_chunks.rb
@@ -130,7 +130,7 @@ EOS
       end
     end
 
-    def color; :none end
+    def color; :text_color end
     def patina_color; :attachment_color end
     def patina_text
       if expandable?
@@ -191,7 +191,7 @@ EOS
     def quotable?; true end
     def expandable?; false end
     def viewable?; false end
-    def color; :none end
+    def color; :text_color end
   end
 
   class Quote
diff --git a/lib/sup/modes/completion_mode.rb b/lib/sup/modes/completion_mode.rb
@@ -38,11 +38,11 @@ private
           suffix = s[(@prefix_len + 1) .. -1]
           char = s[@prefix_len].chr
 
-          @lines.last += [[:none, sprintf("%#{max_length - suffix.length - 1}s", prefix)],
+          @lines.last += [[:text_color, sprintf("%#{max_length - suffix.length - 1}s", prefix)],
                           [:completion_character_color, char],
-                          [:none, suffix + INTERSTITIAL]]
+                          [:text_color, suffix + INTERSTITIAL]]
         else
-          @lines.last += [[:none, sprintf("%#{max_length}s#{INTERSTITIAL}", s)]]
+          @lines.last += [[:text_color, sprintf("%#{max_length}s#{INTERSTITIAL}", s)]]
         end
       else
         @lines << "" if i % num_per == 0
diff --git a/lib/sup/modes/line_cursor_mode.rb b/lib/sup/modes/line_cursor_mode.rb
@@ -47,9 +47,9 @@ protected
 
   def draw_line ln, opts={}
     if ln == @curpos
-      super ln, :highlight => true, :debug => opts[:debug]
+      super ln, :highlight => true, :debug => opts[:debug], :color => :text_color
     else
-      super
+      super ln, :color => :text_color
     end
   end
 
diff --git a/lib/sup/modes/scroll_mode.rb b/lib/sup/modes/scroll_mode.rb
@@ -43,12 +43,12 @@ class ScrollMode < Mode
 
   def draw
     ensure_mode_validity
-    (@topline ... @botline).each { |ln| draw_line ln }
+    (@topline ... @botline).each { |ln| draw_line ln, :color => :text_color }
     ((@botline - @topline) ... buffer.content_height).each do |ln|
       if @twiddles
         buffer.write ln, 0, "~", :color => :twiddle_color
       else
-        buffer.write ln, 0, ""
+        buffer.write ln, 0, "", :color => :text_color
       end
     end
     @status = "lines #{@topline + 1}:#{@botline}/#{lines}"
@@ -208,7 +208,7 @@ protected
       # return
   end
 
-  def matching_text_array s, regex, oldcolor=:none
+  def matching_text_array s, regex, oldcolor=:text_color
     s.split(regex).map do |text|
       next if text.empty?
       if text =~ regex
@@ -244,7 +244,7 @@ protected
   end
 
   def draw_line_from_string ln, s, opts
-    buffer.write ln - @topline, 0, s[@leftcol .. -1], :highlight => opts[:highlight]
+    buffer.write ln - @topline, 0, s[@leftcol .. -1], :highlight => opts[:highlight], :color => opts[:color]
   end
 end