jenkins-bot has submitted this change and it was merged.

Change subject: Add support for backgroud colors in terminal
......................................................................


Add support for backgroud colors in terminal

Add support for green/red background colors.

Modify diff lib to benefit from this improvement.

Bug: T135344
Change-Id: I6d125e46ba35abcd9603c54f39b52a532cb5f8d2
---
M pywikibot/diff.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/userinterfaces/terminal_interface_unix.py
M pywikibot/userinterfaces/terminal_interface_win32.py
4 files changed, 17 insertions(+), 3 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  Xqt: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index cc55fd9..7ef2914 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -58,6 +58,10 @@
             '+': 'lightgreen',
             '-': 'lightred',
         }
+        self.bg_colors = {
+            '+': 'Blightgreen',
+            '-': 'Blightred',
+        }
 
         self.diff = list(self.create_diff())
         self.diff_plain_text = u''.join(self.diff)
@@ -155,8 +159,12 @@
             char_tagged = char
             if color_closed:
                 if char_ref != ' ':
+                    if char != ' ':
+                        apply_color = self.colors[color]
+                    else:
+                        apply_color = self.bg_colors[color]
                     char_tagged = color_format('{color}{0}',
-                                               char, color=self.colors[color])
+                                               char, color=apply_color)
                     color_closed = False
             else:
                 if char_ref == ' ':
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py 
b/pywikibot/userinterfaces/terminal_interface_base.py
index 6aa3d2b..dbae726 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -47,6 +47,8 @@
     'lightpurple',
     'lightyellow',
     'white',
+    'Blightgreen',
+    'Blightred',
 ]
 
 colorTagR = re.compile('\03{(?P<name>%s|previous)}' % '|'.join(colors))
diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py 
b/pywikibot/userinterfaces/terminal_interface_unix.py
index f9ba31e..9f37d58 100755
--- a/pywikibot/userinterfaces/terminal_interface_unix.py
+++ b/pywikibot/userinterfaces/terminal_interface_unix.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """User interface for unix terminals."""
 #
-# (C) Pywikibot team, 2003-2015
+# (C) Pywikibot team, 2003-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -31,6 +31,8 @@
     'lightpurple': chr(27) + '[95m',    # Light Purple tag (Magenta)
     'lightaqua':   chr(27) + '[96m',    # Light Aqua tag (Cyan)
     'white':       chr(27) + '[97m',    # White start tag (Bright White)
+    'Blightgreen': chr(27) + '[102m',   # Background Light Red tag
+    'Blightred':   chr(27) + '[101m',   # Background Light Green tag
 }
 
 
diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py 
b/pywikibot/userinterfaces/terminal_interface_win32.py
index 43db049..5ce98e8 100755
--- a/pywikibot/userinterfaces/terminal_interface_win32.py
+++ b/pywikibot/userinterfaces/terminal_interface_win32.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """User interface for Win32 terminals."""
 #
-# (C) Pywikibot team, 2003-2015
+# (C) Pywikibot team, 2003-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -40,6 +40,8 @@
     'lightpurple': 13,
     'lightyellow': 14,
     'white':       15,
+    'Blightgreen': 32,   # background color green.
+    'Blightred':   64,   # background color red.
 }
 
 colorTagR = re.compile('\03{(?P<name>%s)}' % 
'|'.join(list(windowsColors.keys())))

-- 
To view, visit https://gerrit.wikimedia.org/r/288821
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6d125e46ba35abcd9603c54f39b52a532cb5f8d2
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.w...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.w...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to