summary refs log tree commit diff stats
path: root/ranger/gui/widget.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/gui/widget.py')
-rw-r--r--ranger/gui/widget.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/ranger/gui/widget.py b/ranger/gui/widget.py
index 9c64cc1a..cb78062b 100644
--- a/ranger/gui/widget.py
+++ b/ranger/gui/widget.py
@@ -1,7 +1,12 @@
-import curses
-from ranger.gui.colorscheme import get_color
 
-class OutOfBoundsException(Exception): pass
+class OutOfBoundsException(Exception):
+	pass
+
+def combine(keylist, keys):
+	if type(keylist) in (list, tuple):
+		return tuple(tuple(keylist) + keys)
+	else:
+		return tuple((keylist, ) + keys)
 
 class Widget():
 	def __init__(self, win, colorscheme):
@@ -9,17 +14,29 @@ class Widget():
 		self.colorscheme = colorscheme
 		self.setdim(0, 0, 0, 0)
 
-	def color(self, fg = -1, bg = -1, attr = 0):
-		self.win.attrset(attr | curses.color_pair(get_color(fg, bg)))
+	def color(self, keylist = None, *keys):
+		keys = combine(keylist, keys)
+		self.win.attrset(self.colorscheme.get_attr(*keys))
+
+	def color_at(self, y, x, wid, keylist = None, *keys):
+		keys = combine(keylist, keys)
+		self.win.chgat(y, x, wid, self.colorscheme.get_attr(*keys))
+	
+	def color_reset(self):
+		Widget.color(self, 'reset')
 
 	def setdim(self, y, x, hei=None, wid=None):
 		maxy, maxx = self.win.getmaxyx()
+
 		wid = wid or maxx - x
 		hei = hei or maxy - y
+
 		if x + wid > maxx and y + hei > maxy:
 			raise OutOfBoundsException("X and Y out of bounds!")
+
 		if x + wid > maxx:
 			raise OutOfBoundsException("X out of bounds!")
+
 		if y + hei > maxy:
 			raise OutOfBoundsException("Y out of bounds!")