changeset 20993:31a12af0aaaf

color of editor margins adapted to currently chosen style (bug #46706) * file-editor-tab.cc (update_lexer): set the margin colors depending on the background color of the current style
author Torsten <ttl@justmail.de>
date Mon, 28 Dec 2015 09:06:51 +0100
parents 73e92fca3c78
children dd1dcef1ee33
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sun Dec 27 10:50:32 2015 -0500
+++ b/libgui/src/m-editor/file-editor-tab.cc	Mon Dec 28 09:06:51 2015 +0100
@@ -617,9 +617,25 @@
   lexer->readSettings (*settings);
 
   _edit_area->setLexer (lexer);
+
   _edit_area->setCaretForegroundColor (lexer->color (0));
   _edit_area->setIndentationGuidesForegroundColor (lexer->color (0));
 
+  // set margin colors depending on selected background color of the lexer
+  QColor bg = lexer->paper (0), fg;
+  int h, s, v, factor=-1;
+  bg.getHsv (&h,&s,&v);
+
+  if (v < 96)
+    factor = 2;
+
+  bg.setHsv (h,s/2,v + factor*40);
+  fg.setHsv (h,s/2,v + (factor+1)*40);
+
+  _edit_area->setMarginsForegroundColor (lexer->color (0));
+  _edit_area->setMarginsBackgroundColor (bg);
+  _edit_area->setFoldMarginColors (bg,fg);
+
   // fix line number width with respect to the font size of the lexer
   if (settings->value ("editor/showLineNumbers", true).toBool ())
     auto_margin_width ();