summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--code/directory.py15
-rw-r--r--code/fm.py4
-rw-r--r--code/fsobject.py9
-rw-r--r--code/ui.py6
-rw-r--r--ranger2
-rw-r--r--test/tc_directory.py3
6 files changed, 30 insertions, 9 deletions
diff --git a/code/directory.py b/code/directory.py
index ef68d35f..da7c0948 100644
--- a/code/directory.py
+++ b/code/directory.py
@@ -1,5 +1,5 @@
 import fsobject
-import file
+import file, debug
 
 class Directory(fsobject.FSObject):
 	def __init__(self, path):
@@ -19,10 +19,17 @@ class Directory(fsobject.FSObject):
 		self.content_loaded = True
 		import os
 		if self.exists:
-			self.filenames = os.listdir(self.path)
+			basenames = os.listdir(self.path)
+			mapped = map(lambda name: os.path.join(self.path, name), basenames)
+			self.filenames = list(mapped)
+			self.infostring = ' %d' % len(self.filenames)
+			debug.log('infostring set!')
 			self.files = []
 			for name in self.filenames:
-				f = file.File(name)
+				if os.path.isdir(name):
+					f = Directory(name)
+				else:
+					f = file.File(name)
 				f.load()
 				self.files.append(f)
 	
@@ -36,7 +43,7 @@ class Directory(fsobject.FSObject):
 	
 	def __getitem__(self, key):
 		if not self.accessible: raise fsobject.NotLoadedYet()
-		return self.filenames[key]
+		return self.files[key]
 
 if __name__ == '__main__':
 	d = Directory('.')
diff --git a/code/fm.py b/code/fm.py
index c2fe30a4..6631aee4 100644
--- a/code/fm.py
+++ b/code/fm.py
@@ -1,5 +1,5 @@
 import sys
-import ui, debug, directory
+import ui, debug, directory, fstype
 
 class FM():
 	def __init__(self, options, environment):
@@ -25,6 +25,8 @@ class FM():
 		try:
 			while 1:
 				try:
+#					if type(self.env.cf) is directory.Directory:
+#						self.env.cf.load_content_once()
 					self.ui.feed(self.env.directories, self.env.pwd, self.env.cf, self.env.termsize)
 					self.ui.draw()
 				except KeyboardInterrupt:
diff --git a/code/fsobject.py b/code/fsobject.py
index 1e194ac9..148976d2 100644
--- a/code/fsobject.py
+++ b/code/fsobject.py
@@ -17,6 +17,8 @@ class FSObject(object):
 		self.islink = False
 		self.brokenlink = False
 		self.stat = None
+		self.infostring = None
+		self.permissions = None
 		self.type = fstype.Unknown
 
 	# load() reads useful information about the file from the file system
@@ -34,10 +36,17 @@ class FSObject(object):
 
 			if os.path.isdir(self.path):
 				self.type = fstype.Directory
+				self.infostring = '--'
 			elif os.path.isfile(self.path):
 				self.type = fstype.File
+				self.infostring = ' %d' % self.stat.st_size
+			else:
+				self.type = fstype.Unknown
+				self.infostring = None
+
 		except OSError:
 			self.islink = False
+			self.infostring = None
 			self.type = fstype.Nonexistent
 			self.exists = False
 			self.accessible = False
diff --git a/code/ui.py b/code/ui.py
index 7d8fd828..3994d7ce 100644
--- a/code/ui.py
+++ b/code/ui.py
@@ -1,4 +1,4 @@
-import curses
+import curses, debug
 class UI():
 	def __init__(self, options):
 		self.scr = curses.initscr()
@@ -31,7 +31,9 @@ class UI():
 		import time
 		self.scr.erase()
 		for i in range(1, len(self.pwd)):
-			self.scr.addstr(i, 0, self.pwd[i])
+			f = self.pwd.files[i]
+			self.scr.addstr(i, 0, f.path)
+			if f.infostring: self.scr.addstr(i, 50, f.infostring)
 		self.scr.refresh()
 
 	def get_next_key(self):
diff --git a/ranger b/ranger
index 8e63ec86..4973e42f 100644
--- a/ranger
+++ b/ranger
@@ -15,7 +15,7 @@ def main():
 	import locale
 	locale.setlocale(locale.LC_ALL, 'en_US.utf8')
 
-	path = '.'
+	path = '..'
 	opt = options.get()
 	env = environment.Environment()
 
diff --git a/test/tc_directory.py b/test/tc_directory.py
index 69717ba2..f97f9913 100644
--- a/test/tc_directory.py
+++ b/test/tc_directory.py
@@ -1,7 +1,7 @@
 import unittest
 import sys, os
 sys.path.append('../code')
-import directory, fsobject, file
+import directory, fsobject, file, debug
 
 TESTDIR = os.path.realpath(os.path.join(os.path.dirname(sys.argv[0]), 'testdir'))
 TESTFILE = os.path.join(TESTDIR, 'testfile5234148')
@@ -30,6 +30,7 @@ class Test1(unittest.TestCase):
 		# Get the filenames you expect it to have and sort both before
 		# comparing. I don't expect any order after only loading the filenames.
 		assumed_filenames = os.listdir(TESTDIR)
+		assumed_filenames = list(map(lambda str: os.path.join(TESTDIR, str), assumed_filenames))
 		assumed_filenames.sort()
 		dir.filenames.sort()
 
Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os.path
import sys
rangerpath = os.path.join(os.path.dirname(__file__), '..')
if sys.path[1] != rangerpath:
	sys.path[1:1] = [rangerpath]

import unittest
import curses

from ranger.gui import ui

from testlib import Fake, OK, raise_ok

ui.curses = Fake()

class Test(unittest.TestCase):
	def setUp(self):

		self.fm = Fake()
		self.ui = ui.UI(env=Fake(), fm=self.fm)

		def fakesetup():
			self.ui.widget = Fake()
			self.ui.add_child(self.ui.widget)
		self.ui.setup = fakesetup

		self.ui.initialize()

	def tearDown(self):
		self.ui.destroy()

	def test_passing(self):
		# Test whether certain method calls are passed to widgets
		widget = self.ui.widget

		widget.draw = raise_ok
		self.assertRaises(OK, self.ui.draw)
		widget.__clear__()

		widget.finalize = raise_ok
		self.assertRaises(OK, self.ui.finalize)
		widget.__clear__()

		widget.press = raise_ok
		random_key = 123
		self.assertRaises(OK, self.ui.handle_key, random_key)
		widget.__clear__()

		widget.destroy = raise_ok
		self.assertRaises(OK, self.ui.destroy)
		widget.__clear__()

if __name__ == '__main__':
	unittest.main()