about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-01 20:35:22 +0100
committerhut <hut@lavabit.com>2010-01-01 20:35:22 +0100
commit6f43de0af345c63216b03b1e2611abf98266d80a (patch)
tree57edee00e6a2ed0973c5db8ef204883032e72938
parent0a1bc7598776c360b469a64316a1c69c0a914b5f (diff)
downloadranger-6f43de0af345c63216b03b1e2611abf98266d80a.tar.gz
notify: merged into statusbar, allow to view the log in the pager
-rw-r--r--TODO5
-rw-r--r--doc/uml/12800220
-rw-r--r--doc/uml/128002.diagram12
-rw-r--r--doc/uml/134530.diagram5
-rw-r--r--ranger/actions.py16
-rw-r--r--ranger/defaults/keys.py18
-rw-r--r--ranger/fm.py2
-rw-r--r--ranger/fsobject/loader.py2
-rw-r--r--ranger/gui/defaultui.py25
-rw-r--r--ranger/gui/widgets/notify.py70
-rw-r--r--ranger/gui/widgets/statusbar.py58
11 files changed, 85 insertions, 148 deletions
diff --git a/TODO b/TODO
index 3e1d5c8a..62d9478e 100644
--- a/TODO
+++ b/TODO
@@ -27,3 +27,8 @@ Bugs
    (X) #17  10/01/01  why do bookmarks disappear sometimes?
    ( ) #18  10/01/01  fix notify widget (by adding a LogView?)
    (X) #19  10/01/01  resizing after pressing g
+
+
+Ideas
+
+   ( ) #20  10/01/01  use inotify to monitor filesystem changes
diff --git a/doc/uml/128002 b/doc/uml/128002
index d0d68427..0149fe5f 100644
--- a/doc/uml/128002
+++ b/doc/uml/128002
@@ -1067,26 +1067,6 @@ ${docstring}${members}
       end
     end
 
-    class 176002 "Notify"
-      visibility package 
-      cpp_decl ""
-      java_decl ""
-      php_decl ""
-      python_2_2 python_decl "class ${name}${inherit}:
-${docstring}${members}
-"
-      idl_decl ""
-      explicit_switch_type ""
-      
-      classrelation 193666 // <generalisation>
-	relation 191618 ---|>
-	  a public
-	    python "${type}"
-	    classrelation_ref 193666 // <generalisation>
-	  b parent class_ref 156034 // Widget
-      end
-    end
-
     class 176130 "TaskView"
       visibility package 
       cpp_decl ""
diff --git a/doc/uml/128002.diagram b/doc/uml/128002.diagram
index b101cd33..09164d16 100644
--- a/doc/uml/128002.diagram
+++ b/doc/uml/128002.diagram
@@ -60,10 +60,6 @@ classcanvas 138370 class_ref 175874 // StatusBar
   draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
   xyz 682 364 2000
 end
-classcanvas 142338 class_ref 176002 // Notify
-  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
-  xyz 682 418 2000
-end
 classcanvas 142850 class_ref 176130 // TaskView
   draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
   xyz 681 562 2000
@@ -187,14 +183,6 @@ relationcanvas 138498 relation_ref 191490 // <generalisation>
   no_role_a no_role_b
   no_multiplicity_a no_multiplicity_b
 end
-relationcanvas 142466 relation_ref 191618 // <generalisation>
-  geometry HVH
-  from ref 142338 z 2001 to point 655 437
-  line 142594 z 2001 to point 655 324
-  line 142722 z 2001 to ref 134530
-  no_role_a no_role_b
-  no_multiplicity_a no_multiplicity_b
-end
 relationcanvas 142978 relation_ref 191746 // <generalisation>
   geometry HVH
   from ref 142850 z 2001 to point 655 581
diff --git a/doc/uml/134530.diagram b/doc/uml/134530.diagram
index 82785c7f..8ddb4d31 100644
--- a/doc/uml/134530.diagram
+++ b/doc/uml/134530.diagram
@@ -54,7 +54,7 @@ classcanvas 132610 class_ref 156034 // Widget
 end
 classcanvas 133250 class_ref 135170 // BrowserColumn
   draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
-  xyz 553 430 2023
+  xyz 526 453 2023
 end
 classcanvas 133506 class_ref 135042 // TitleBar
   draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
@@ -173,8 +173,7 @@ relationcanvas 136450 relation_ref 184706 // <association>
   no_multiplicity_a no_multiplicity_b
 end
 relationcanvas 136834 relation_ref 170626 // <association>
-  from ref 129666 z 2007 to point 564 94
-  line 137090 z 2007 to ref 128258
+  from ref 129666 z 2007 to ref 128258
   no_role_a no_role_b
   no_multiplicity_a no_multiplicity_b
 end
diff --git a/ranger/actions.py b/ranger/actions.py
index c1ea7485..62b55b81 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -177,6 +177,13 @@ class Actions(EnvironmentAware, SettingsAware):
 		lines = trimmed_lines_of_docstring(command.__doc__)
 		pager.set_source(lines)
 	
+	def display_log(self):
+		if not hasattr(self.ui, 'open_pager'):
+			return
+
+		pager = self.ui.open_pager()
+		pager.set_source(self.log)
+	
 	def display_file(self):
 		if not hasattr(self.ui, 'open_embedded_pager'):
 			return
@@ -275,12 +282,9 @@ class Actions(EnvironmentAware, SettingsAware):
 			pass
 	
 	def notify(self, text, duration=4, bad=False):
-		try:
-			method = self.ui.display
-		except AttributeError:
-			pass
-		else:
-			return method(text, duration=duration, bad=bad)
+		self.log.appendleft(text)
+		if hasattr(self.ui, 'notify'):
+			self.ui.notify(text, duration=duration, bad=bad)
 	
 	def mark(self, all=False, toggle=False, val=None, movedown=None):
 		"""
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 5732b793..7cd92004 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -59,6 +59,8 @@ def initialize_commands(command_list):
 
 	bind(TAB, fm.search(order='tag'))
 
+	bind(ctrl('p'), fm.display_log())
+
 	hint('t', "show_//h//idden //p//review_files //d//irectories_first " \
 			"//a//uto_load_preview //c//ollapse_preview")
 	bind('th', fm.toggle_boolean_option('show_hidden'))
@@ -141,7 +143,7 @@ def initialize_commands(command_list):
 	bind('r', fm.open_console(cmode.OPEN_QUICK))
 
 	def test(arg):
-		arg.fm.notify("bla")
+		arg.fm.notify(str(arg.n))
 	bind('x', test)
 
 	# definitions which require their own function:
@@ -234,18 +236,18 @@ def initialize_pager_commands(command_list):
 	initialize_embedded_pager_commands(command_list)
 	bind('q', 'i', ESC, KEY_F1, lambda arg: arg.fm.ui.close_pager())
 
-def initialize_embedded_pager_commands(command_list):
-	system_functions(command_list)
-	bind, hint = make_abbreviations(command_list)
-
 	bind('j', KEY_DOWN, nwrap.move(relative=1))
 	bind('k', KEY_DOWN, nwrap.move(relative=-1))
 	bind('gg', KEY_DOWN, nwrap.move(absolute=0))
 	bind('G', KEY_DOWN, nwrap.move(absolute=-1))
-	
-	bind('q', 'i', ESC, lambda arg: arg.fm.ui.close_embedded_pager())
+
 	bind('h', wdg.move_horizontal(relative=-4))
 	bind('l', wdg.move_horizontal(relative=4))
-	bind('Q', 'ZZ', fm.exit())
+	command_list.rebuild_paths()
 
+def initialize_embedded_pager_commands(command_list):
+	system_functions(command_list)
+	bind, hint = make_abbreviations(command_list)
+
+	bind('q', 'i', ESC, lambda arg: arg.fm.ui.close_embedded_pager())
 	command_list.rebuild_paths()
diff --git a/ranger/fm.py b/ranger/fm.py
index e70e9f3c..ebb84b70 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -1,4 +1,5 @@
 from time import time
+from collections import deque
 
 from ranger.actions import Actions
 from ranger.container import Bookmarks
@@ -17,6 +18,7 @@ class FM(Actions):
 		"""Initialize FM."""
 		Actions.__init__(self)
 		self.ui = ui
+		self.log = deque(maxlen=20)
 		self.bookmarks = bookmarks
 		self.tags = tags
 		self.loader = Loader()
diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py
index 3a2020fb..a67c75fb 100644
--- a/ranger/fsobject/loader.py
+++ b/ranger/fsobject/loader.py
@@ -106,7 +106,7 @@ class Loader(FileManagerAware):
 			item.load_generator = None
 			self.queue.popleft()
 		except Exception as err:
-			self.fm.ui.display(str(err), bad=True)
+			self.fm.notify(str(err), bad=True)
 	
 	def has_work(self):
 		"""Is there anything to load?"""
diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py
index ccbe2578..ca233df9 100644
--- a/ranger/gui/defaultui.py
+++ b/ranger/gui/defaultui.py
@@ -10,7 +10,6 @@ class DefaultUI(UI):
 		from ranger.gui.widgets.console import Console
 		from ranger.gui.widgets.statusbar import StatusBar
 		from ranger.gui.widgets.taskview import TaskView
-		from ranger.gui.widgets.notify import Notify
 		from ranger.gui.widgets.pager import Pager
 
 		# Create a title bar
@@ -27,10 +26,6 @@ class DefaultUI(UI):
 		self.taskview.visible = False
 		self.add_child(self.taskview)
 
-		# Create the (initially hidden) notify bar
-		self.notify = Notify(self.win)
-		self.add_child(self.notify)
-
 		# Create the status bar
 		self.status = StatusBar(self.win, self.browser.main_column)
 		self.add_child(self.status)
@@ -50,23 +45,15 @@ class DefaultUI(UI):
 		UI.update_size(self)
 		y, x = self.env.termsize
 
-		notify_hei = min(max(1, y - 4), self.notify.requested_height)
-
-		self.browser.resize(1, 0, y - 1 - notify_hei, x)
-		self.taskview.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.browser.resize(1, 0, y - 2, x)
+		self.taskview.resize(1, 0, y - 2, x)
+		self.pager.resize(1, 0, y - 2, x)
 		self.titlebar.resize(0, 0, 1, x)
 		self.status.resize(y - 1, 0, 1, x)
 		self.console.resize(y - 1, 0, 1, x)
 	
-	def poke(self):
-		UI.poke(self)
-		if self.notify.requested_height != self.notify.hei:
-			self.update_size()
-	
-	def display(self, *a, **k):
-		return self.notify.display(*a, **k)
+	def notify(self, *a, **k):
+		return self.status.notify(*a, **k)
 
 	def close_pager(self):
 		if self.console.visible:
@@ -122,4 +109,4 @@ class DefaultUI(UI):
 			self.titlebar.throbber = string
 
 	def hint(self, text=None):
-		self.status.override = text
+		self.status.hint = text
diff --git a/ranger/gui/widgets/notify.py b/ranger/gui/widgets/notify.py
deleted file mode 100644
index 8b783fdb..00000000
--- a/ranger/gui/widgets/notify.py
+++ /dev/null
@@ -1,70 +0,0 @@
-"""Notify is a bar which displays messages."""
-
-from . import Widget
-from time import time
-from collections import deque
-
-class Notify(Widget):
-	requested_height = 1
-	max_size = 5
-	textcontainer = None
-
-	def __init__(self, win):
-		Widget.__init__(self, win)
-		self.textcontainer = deque(maxlen=self.max_size)
-
-	def poke(self):
-		for i in reversed(range(len(self.textcontainer))):
-			msg = self.textcontainer[i]
-			if msg.elapse and time() > msg.elapse:
-				msg.alive = False
-				del self.textcontainer[i]
-		self.requested_height = len(self.textcontainer) + 1
-
-	def draw(self):
-		import curses, socket, os
-
-		i = 0
-		for msg in self.textcontainer:
-			if i >= self.hei - 1:
-				break
-
-			how = msg.bad and 'bad' or 'good'
-			self.color_at(i, 0, self.wid,\
-					'in_notify', 'background', how)
-			self.color('in_notify', 'message', how)
-			self.addstr(i, 0, msg.text)
-			i += 1
-
-		self.color_reset()
-	
-	def display(self, text, duration=4, bad=False):
-		msg = Message(self.textcontainer, text, duration, bad)
-		self.textcontainer.append(msg)
-		return msg
-
-class Message(object):
-	elapse = None
-	text = None
-	bad = False
-	alive = True
-	container = None
-
-	def __init__(self, container, text, duration, bad):
-		self.text = text
-		self.bad = bad
-		self.container = container
-		self.set_duration(duration)
-	
-	def set_duration(self, n=4):
-		if n:
-			self.elapse = time() + n
-		else:
-			self.elapse = None
-
-	def delete(self):
-		self.alive = False
-		try:
-			self.container.remove(self)
-		except ValueError:
-			pass
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 94e62d0b..af4870aa 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -13,33 +13,53 @@ from os import getuid
 from time import strftime, localtime
 
 from ranger.gui.bar import Bar
+from ranger import log
 
 class StatusBar(Widget):
 	__doc__ = __doc__
 	owners = {}
 	groups = {}
 	timeformat = '%Y-%m-%d %H:%M'
-	override = None
+	hint = None
+	msg = None
 
 	old_cf = None
 	old_mtime = None
+	old_hint = None
 	result = None
 
 	def __init__(self, win, column=None):
 		Widget.__init__(self, win)
 		self.column = column
 	
+	def notify(self, text, duration=4, bad=False):
+		self.msg = Message(text, duration, bad)
+	
 	def draw(self):
 		"""Draw the statusbar"""
 
-		# each item in the returned array looks like:
-		# [ list_with_color_tags,       string       ]
-		# [ ['permissions', 'allowed'], '-rwxr-xr-x' ]
+		log("a")
 
-		if self.override and isinstance(self.override, str):
-			self._draw_message()
+		if self.hint and isinstance(self.hint, str):
+			if self.old_hint != self.hint:
+				self.need_redraw = True
+			if self.need_redraw:
+				self._draw_hint()
 			return
 
+		if self.old_hint and not self.hint:
+			self.old_hint = None
+			self.need_redraw = True
+
+		if self.msg:
+			if self.msg.is_alive():
+				log("b")
+				self._draw_message()
+				return
+			else:
+				self.msg = None
+				self.need_redraw = True
+
 		try:
 			mtime = self.env.cf.stat.st_mtime
 		except:
@@ -69,12 +89,18 @@ class StatusBar(Widget):
 		bar.shrink_by_removing(self.wid)
 
 		self.result = bar.combine()
-
+	
 	def _draw_message(self):
+		self.win.erase()
+		self.color('in_statusbar', self.msg.bad and 'bad' or 'good')
+		self.addnstr(0, 0, self.msg.text, self.wid)
+
+	def _draw_hint(self):
+		self.win.erase()
 		highlight = True
 		space_left = self.wid
 		starting_point = self.x
-		for string in self.override.split('//'):
+		for string in self.hint.split('//'):
 			highlight = not highlight
 			if highlight:
 				self.color('in_statusbar', 'text', 'highlight')
@@ -82,7 +108,7 @@ class StatusBar(Widget):
 				self.color('in_statusbar', 'text')
 
 			try:
-				self.win.addnstr(self.y, starting_point, string, space_left)
+				self.addnstr(0, starting_point, string, space_left)
 			except:
 				break
 			space_left -= len(string)
@@ -183,3 +209,17 @@ class StatusBar(Widget):
 			self.color(*part.lst)
 			self.addstr(part.string)
 		self.color_reset()
+
+from time import time
+class Message(object):
+	elapse = None
+	text = None
+	bad = False
+
+	def __init__(self, text, duration, bad):
+		self.text = text
+		self.bad = bad
+		self.elapse = time() + duration
+	
+	def is_alive(self):
+		return time() <= self.elapse