summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--ranger/gui/displayable.py29
-rw-r--r--ranger/gui/widgets/filelist.py2
3 files changed, 25 insertions, 9 deletions
diff --git a/TODO b/TODO
index bfd80a4d..55e44420 100644
--- a/TODO
+++ b/TODO
@@ -3,13 +3,13 @@ Console
    (X) #0   09/12/06  console commands
    (X) #1   09/12/06  quick find
    (X) #2   09/12/06  open with
-   ( ) #3   09/12/06  MVC for widgets
    (X) #4   09/12/06  history for console
    ( ) #13  09/12/27  display docstring of a command
 
 
 General
 
+   ( ) #3   09/12/06  MVC for widgets
    (X) #5   09/12/06  move code from fm into objects
    (X) #6   09/12/06  move main to __init__
    (X) #7   09/12/06  cooler titlebar
@@ -18,3 +18,4 @@ General
    (X) #10  09/12/24  sorting
    (X) #11  09/12/27  filter
    (X) #12  09/12/27  jump through the list in a specific order
+   ( ) #14  09/12/29  make filelists inherit from pagers
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 40731449..404f66a0 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -18,9 +18,14 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 
 		self.x = 0
 		self.y = 0
+		self.yy = 0
+		self.xx = 0
+		self.absx = 0
+		self.absy = 0
 		self.wid = 0
 		self.hei = 0
 		self.colorscheme = self.settings.colorscheme
+		self.parent = None
 
 		if win is not None:
 			if isinstance(self, UI):
@@ -143,17 +148,25 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 			if y + hei > maxy:
 				raise OutOfBoundsException("Y out of bounds!")
 
-		try:
-			self.win.resize(hei, wid)
-		except:
-			# Not enough space for resizing...
+		if hei != self.hei or wid != self.wid:
 			try:
-				self.win.mvderwin(0, 0)
 				self.win.resize(hei, wid)
 			except:
-				raise OutOfBoundsException("Resizing Failed!")
+				# Not enough space for resizing...
+				try:
+					self.win.mvderwin(0, 0)
+					self.win.resize(hei, wid)
+				except:
+					raise OutOfBoundsException("Resizing Failed!")
+
+		if y != self.absy or x != self.absx:
+			self.win.mvderwin(y, x)
+
+		self.yy, self.xx = y, x
+		if self.parent:
+			self.yy += self.parent.yy
+			self.xx += self.parent.xx
 
-		self.win.mvderwin(y, x)
 		self.absy, self.absx = y, x
 		self.x = 0
 		self.y = 0
@@ -229,6 +242,8 @@ class DisplayableContainer(Displayable):
 
 	def add_obj(self, *objs):
 		self.container.extend(objs)
+		for obj in objs:
+			obj.parent = self
 
 	def destroy(self):
 		"""Recursively called on objects in container"""
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index b2adc7e2..43f3834a 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -33,7 +33,7 @@ class FileList(Widget, DisplayableContainer):
 			pass
 
 		elif self.target.type is T_DIRECTORY:
-			index = self.scroll_begin + event.y - 1
+			index = self.scroll_begin + event.y - self.yy
 
 			if event.pressed(1):
 				if not self.main_display: