summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/defaults/keys.py3
-rw-r--r--ranger/gui/defaultui.py20
-rw-r--r--ranger/gui/displayable.py23
-rw-r--r--ranger/gui/widgets/filelist.py10
-rw-r--r--ranger/gui/widgets/filelistcontainer.py4
-rw-r--r--ranger/gui/widgets/notify.py6
6 files changed, 46 insertions, 20 deletions
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 5e764ddd..654b1c7b 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -140,6 +140,9 @@ def initialize_commands(command_list):
 	bind('!', fm.open_console(cmode.OPEN))
 	bind('r', fm.open_console(cmode.OPEN_QUICK))
 
+	def test(arg):
+		arg.fm.notify("bla")
+	bind('x', test)
 
 	# definitions which require their own function:
 	def ggG(default):
diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py
index 1bb62d72..135ef0b5 100644
--- a/ranger/gui/defaultui.py
+++ b/ranger/gui/defaultui.py
@@ -21,12 +21,6 @@ class DefaultUI(UI):
 		self.add_obj(self.filelist_container)
 		self.main_filelist = self.filelist_container.main_filelist
 
-		self.status = StatusBar(self.win, self.main_filelist)
-		self.add_obj(self.status)
-		self.console = Console(self.win)
-		self.add_obj(self.console)
-		self.console.visible = False
-
 		self.pman = ProcessManager(self.win)
 		self.pman.visible = False
 		self.add_obj(self.pman)
@@ -34,6 +28,12 @@ class DefaultUI(UI):
 		self.notify = Notify(self.win)
 		self.add_obj(self.notify)
 
+		self.status = StatusBar(self.win, self.main_filelist)
+		self.add_obj(self.status)
+		self.console = Console(self.win)
+		self.add_obj(self.console)
+		self.console.visible = False
+
 		self.pager = Pager(self.win)
 		self.add_obj(self.pager)
 
@@ -44,10 +44,10 @@ class DefaultUI(UI):
 
 		notify_hei = self.notify.requested_height
 
-		self.filelist_container.resize(1, 0, y - 2 - notify_hei, x)
-		self.pman.resize(1, 0, y - 2 - notify_hei, x)
-		self.pager.resize(1, 0, y - 2 - notify_hei, x)
-		self.notify.resize(y - 1 - notify_hei, 0, notify_hei, x)
+		self.filelist_container.resize(1, 0, y - 1 - notify_hei, x)
+		self.pman.resize(1, 0, y - 1 - notify_hei, x)
+		self.pager.resize(1, 0, y - 1 - notify_hei, x)
+		self.notify.resize(y - notify_hei, 0, notify_hei, x)
 		self.titlebar.resize(0, 0, 1, x)
 		self.status.resize(y - 1, 0, 1, x)
 		self.console.resize(y - 1, 0, 1, x)
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 62ff41f9..95645e2c 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -1,4 +1,5 @@
 from ranger.shared import FileManagerAware, EnvironmentAware, SettingsAware
+from ranger import log
 
 class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 	focused = False
@@ -7,6 +8,7 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 	colorscheme = None
 
 	def __init__(self, win, env=None, fm=None, settings=None):
+		from ranger.gui.ui import UI
 		if env is not None:
 			self.env = env
 		if fm is not None:
@@ -21,7 +23,10 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 		self.colorscheme = self.settings.colorscheme
 
 		if win is not None:
-			self.win = win
+			if isinstance(self, UI):
+				self.win = win
+			else:
+				self.win = win.derwin(1, 1, 0, 0)
 
 	def __nonzero__(self):
 		"""Always True"""
@@ -123,6 +128,9 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 			if x < 0 or y < 0:
 				raise OutOfBoundsException("Starting point below zero!")
 
+			if wid < 1 or hei < 1:
+				raise OutOfBoundsException("WID and HEI must be >=1!")
+
 			if x + wid > maxx and y + hei > maxy:
 				raise OutOfBoundsException("X and Y out of bounds!")
 
@@ -132,8 +140,17 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 			if y + hei > maxy:
 				raise OutOfBoundsException("Y out of bounds!")
 
-		self.x = x
-		self.y = y
+		try:
+			self.win.resize(max(1,hei), wid)
+		except:
+			log(self.__class__)
+			log("failed to resize {0}x{1}  {2}x{3}".format(y,x,hei,wid))
+		log("moving {2} to {0}x{1}".format(y, x, self.__class__.__name__))
+		self.win.mvderwin(y, x)
+		self.absx = x
+		self.absy = x
+		self.x = 0
+		self.y = 0
 		self.wid = wid
 		self.hei = hei
 
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index d8fc1073..6af13944 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -217,13 +217,19 @@ class FileList(Widget, DisplayableContainer):
 					self.win.addnstr(self.y + line, self.x + 1,
 							text, self.wid - 2)
 			else:
-				self.win.addnstr(self.y + line, self.x, text, self.wid)
+				try:
+					self.win.addnstr(self.y + line, self.x, text, self.wid)
+				except:
+					break
 
 			if self.display_infostring and drawed.infostring:
 				info = drawed.infostring
 				x = self.x + self.wid - 1 - len(info)
 				if x > self.x:
-					self.win.addstr(self.y + line, x, str(info) + ' ')
+					try:
+						self.win.addstr(self.y + line, x, str(info) + ' ')
+					except:
+						break
 
 			self.color_at(self.y + line, self.x, self.wid, this_color)
 
diff --git a/ranger/gui/widgets/filelistcontainer.py b/ranger/gui/widgets/filelistcontainer.py
index 494a3e0f..f50ea7cb 100644
--- a/ranger/gui/widgets/filelistcontainer.py
+++ b/ranger/gui/widgets/filelistcontainer.py
@@ -29,7 +29,7 @@ class FileListContainer(Widget, DisplayableContainer):
 		if preview: offset += 1
 
 		for level in range(len(ratios)):
-			fl = FileList(win, level + offset)
+			fl = FileList(self.win, level + offset)
 			self.add_obj(fl)
 
 		try:
@@ -40,7 +40,7 @@ class FileListContainer(Widget, DisplayableContainer):
 			self.main_filelist.display_infostring = True
 			self.main_filelist.main_display = True
 
-		self.pager = Pager(win, embedded=True)
+		self.pager = Pager(self.win, embedded=True)
 		self.add_obj(self.pager)
 	
 	def resize(self, y, x, hei, wid):
diff --git a/ranger/gui/widgets/notify.py b/ranger/gui/widgets/notify.py
index bb159ea7..ea35700f 100644
--- a/ranger/gui/widgets/notify.py
+++ b/ranger/gui/widgets/notify.py
@@ -5,7 +5,7 @@ from time import time
 from collections import deque
 
 class Notify(Widget):
-	requested_height = 0
+	requested_height = 1
 	max_size = 5
 	textcontainer = None
 
@@ -19,7 +19,7 @@ class Notify(Widget):
 			if msg.elapse and time() > msg.elapse:
 				msg.alive = False
 				del self.textcontainer[i]
-		self.requested_height = len(self.textcontainer)
+		self.requested_height = len(self.textcontainer) + 1
 
 	def draw(self):
 		import curses, socket, os
@@ -27,7 +27,7 @@ class Notify(Widget):
 
 		i = 0
 		for msg in self.textcontainer:
-			if i >= self.hei:
+			if i >= self.hei - 1:
 				break
 
 			how = msg.bad and 'bad' or 'good'