summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/__init__.py0
-rw-r--r--code/__init__.pycbin125 -> 0 bytes
-rw-r--r--code/debug.py12
-rw-r--r--code/defaultui.py16
-rw-r--r--code/directory.py70
-rw-r--r--code/directory.rb66
-rw-r--r--code/environment.py38
-rw-r--r--code/file.py6
-rw-r--r--code/fm.py65
-rw-r--r--code/fsobject.py87
-rw-r--r--code/fstype.py5
-rw-r--r--code/options.py5
-rw-r--r--code/ui.py48
-rw-r--r--code/wdisplay.py34
-rw-r--r--code/widget.py39
15 files changed, 0 insertions, 491 deletions
diff --git a/code/__init__.py b/code/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/code/__init__.py
+++ /dev/null
diff --git a/code/__init__.pyc b/code/__init__.pyc
deleted file mode 100644
index 2479f90e..00000000
--- a/code/__init__.pyc
+++ /dev/null
Binary files differdiff --git a/code/debug.py b/code/debug.py
deleted file mode 100644
index 12d5d654..00000000
--- a/code/debug.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# a module to faciliate debuggin
-
-LOGFILE = '/tmp/errorlog'
-
-def log(txt):
-	f = open(LOGFILE, 'a')
-	f.write("r1: ")
-	f.write(str(txt))
-	f.write("\n")
-	f.close()
-
-
diff --git a/code/defaultui.py b/code/defaultui.py
deleted file mode 100644
index d46c89c8..00000000
--- a/code/defaultui.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import ui
-import widget, wdisplay
-
-class DefaultUI(ui.UI):
-	def setup(self):
-		self.main_display = wdisplay.WDisplay(self.win, 0)
-		self.add_widget(self.main_display)
-		self.left_display = wdisplay.WDisplay(self.win, -1)
-		self.add_widget(self.left_display)
-	
-	def resize(self):
-		ui.UI.resize(self)
-		y, x = self.win.getmaxyx()
-		self.main_display.setdim(1, 40, 3, 37)
-		self.left_display.setdim(1, 0, 3, 37)
-
diff --git a/code/directory.py b/code/directory.py
deleted file mode 100644
index 4109ae2d..00000000
--- a/code/directory.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import fsobject
-import file, debug
-
-class Directory(fsobject.FSObject):
-	def __init__(self, path):
-		fsobject.FSObject.__init__(self, path)
-		self.content_loaded = False
-		self.scheduled = False
-		self.enterable = False
-
-		self.filenames = None
-		self.files = None
-		self.filter = None
-		self.pointed_index = None
-		self.pointed_file = None
-		self.index = None
-	
-	def load_content(self):
-		self.stop_if_frozen()
-		self.load_if_outdated()
-		self.content_loaded = True
-		import os
-		if self.exists:
-			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) # update the infostring
-			self.files = []
-			for name in self.filenames:
-				if os.path.isdir(name):
-					f = Directory(name)
-				else:
-					f = file.File(name)
-				f.load()
-				self.files.append(f)
-	
-	def load_content_once(self):
-		self.stop_if_frozen()
-		if not self.content_loaded:
-			self.load_content()
-			return True
-		return False
-
-	def load_content_if_outdated(self):
-		self.stop_if_frozen()
-		if self.load_content_once(): return True
-
-		import os
-		real_mtime = os.stat(self.path).st_mtime
-		cached_mtime = self.stat.st_mtime
-
-		if real_mtime != cached_mtime:
-			self.load_content()
-			return True
-		return False
-
-	def __len__(self):
-		if not self.accessible: raise fsobject.NotLoadedYet()
-		return len(self.filenames)
-	
-	def __getitem__(self, key):
-		if not self.accessible: raise fsobject.NotLoadedYet()
-		return self.files[key]
-
-if __name__ == '__main__':
-	d = Directory('.')
-	d.load_filenames()
-	print(d.filenames)
-	print(d[1])
-
diff --git a/code/directory.rb b/code/directory.rb
deleted file mode 100644
index 5c6e84c1..00000000
--- a/code/directory.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# A Class that contains data about directories
-class Directory
-	class LoadStatus
-		# @n contains a three bit number: x3x2x1
-		# x1:
-		# 0 = not scheduled
-		# 1 = scheduled
-		# x3x2:
-		# 00 = nothing loaded
-		# 01 = got the list of files
-		# 10 = <undefined>
-		# 11 = got the list of files and entry objects
-		def initialize(n = 0)
-			@n = 0
-		end
-
-		def got_files?
-			# is bit 2 nd 3 == 01
-			return n & 2 == 2
-		end
-
-		def scheduled?
-			# is the first bit 1?
-			return n & 1 == 1
-		end
-
-		def got_objects?
-			return n & 4 == 4
-		end
-		attr_accessor :n
-	end
-
-	def initialize(path)
-		@path = path
-		@status = LoadStatus.new(0)
-		@files = []
-		@sort_time = nil
-		@mtime = nil
-#		@width = 1000
-		@read = false
-		@free_space = nil
-		@empty = true
-		@scheduled = false
-	end
-
-	# {{{ Trivial
-	def inspect
-		return "<Directory: #{path}>"
-	end
-	alias to_s inspect
-
-	def size
-		return @files.size
-	end
-
-	def not_loaded?
-		return @level == 0
-	end
-	def file_list_loaded?
-		return @level >= 1
-	end
-	def ready?
-		return @level >= 2
-	end
-	# }}}
-end
diff --git a/code/environment.py b/code/environment.py
deleted file mode 100644
index 515fc8c6..00000000
--- a/code/environment.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import directory
-
-class Vector():
-	def __init__(self, x, y):
-		self.x = x
-		self.y = y
-
-class Environment():
-	# A collection of data which is relevant for more than
-	# one class.
-	def __init__(self, opt):
-		self.opt = opt
-		self.path = None
-		self.pathway = ()
-		self.directories = {}
-		self.pwd = None # current directory
-		self.cf = None # current file
-		self.keybuffer = ''
-		self.copy = None
-		self.termsize = Vector(80, 24)
-	
-	def at_level(self, level):
-		if level <= 0:
-			try:
-				return self.pathway[level - 1]
-			except IndexError:
-				return None
-		else:
-			return self.cf
-
-	def get_directory(self, path):
-		import os
-		path = os.path.abspath(path)
-		try:
-			return self.directories[path]
-		except KeyError:
-			self.directories[path] = directory.Directory(path)
-			return self.directories[path]
diff --git a/code/file.py b/code/file.py
deleted file mode 100644
index 9d813aad..00000000
--- a/code/file.py
+++ /dev/null
@@ -1,6 +0,0 @@
-import fsobject
-class File(fsobject.FSObject):
-	pass
-#	def __init__(self, path):
-#		fsobject.FSObject.__init__(self, path)
-
diff --git a/code/fm.py b/code/fm.py
deleted file mode 100644
index 924f6efc..00000000
--- a/code/fm.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import sys, os
-import ui, debug, file, directory, fstype
-
-class FM():
-	def __init__(self, environment):
-		self.env = environment
-
-	def feed(self, path, ui):
-		self.ui = ui
-		self.env.path = path
-		self.enter_dir(path)
-
-	def enter_dir(self, path):
-		# get the absolute path
-		path = os.path.normpath(os.path.join(self.env.path, path))
-
-		self.env.path = path
-		self.env.pwd = self.env.get_directory(path)
-
-		self.env.pwd.load_content()
-
-		# build the pathway, a tuple of directory objects which lie
-		# on the path to the current directory.
-		pathway = []
-		currentpath = '/'
-		for dir in path.split('/'):
-			currentpath = os.path.join(currentpath, dir)
-			debug.log(currentpath)
-			pathway.append(self.env.get_directory(currentpath))
-		self.env.pathway = tuple(pathway)
-
-		# set the current file.
-		if len(self.env.pwd) > 0:
-			self.env.cf = self.env.pwd[0]
-		else:
-			self.env.cf = None
-
-	def run(self):
-		while 1:
-			try:
-				self.ui.draw()
-			except KeyboardInterrupt:
-				self.interrupt()
-			except:
-				raise
-
-			try:
-				key = self.ui.get_next_key()
-				self.press(key)
-			except KeyboardInterrupt:
-				self.interrupt()
-
-	def press(self, key):
-		if (key == ord('q')):
-			raise SystemExit()
-		elif (key == ord('h')):
-			self.enter_dir('..')
-		elif (key == ord('l')):
-			self.enter_dir(self.env.cf.path)
-
-	def interrupt(self):
-		import time
-		self.buffer = ""
-		time.sleep(0.2)
-
diff --git a/code/fsobject.py b/code/fsobject.py
deleted file mode 100644
index f4268ef0..00000000
--- a/code/fsobject.py
+++ /dev/null
@@ -1,87 +0,0 @@
-import fstype
-
-class FrozenException(Exception): pass
-class NotLoadedYet(Exception): pass
-
-class FSObject(object):
-	def __init__(self, path):
-		if type(self) == FSObject:
-			raise TypeError("FSObject is an abstract class and cannot be initialized.")
-		self.path = path
-		self.exists = False
-		self.accessible = False
-		self.marked = False
-		self.tagged = False
-		self.frozen = False
-		self.loaded = False
-		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
-	# and caches it in instance attributes.
-	def load(self):
-		self.stop_if_frozen()
-		self.loaded = True
-
-		import os
-		try:
-			self.stat = os.stat(self.path)
-			self.islink = os.path.islink(self.path)
-			self.exists = True
-			self.accessible = True
-
-			if os.path.isdir(self.path):
-				self.type = fstype.Directory
-				self.infostring = ' %d' % len(os.listdir(self.path))
-			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
-
-	def load_once(self):
-		self.stop_if_frozen()
-		if not self.loaded:
-			self.load()
-			return True
-		return False
-
-	def load_if_outdated(self):
-		self.stop_if_frozen()
-		if self.load_once(): return True
-
-		import os
-		real_mtime = os.stat(self.path).st_mtime
-		cached_mtime = self.stat.st_mtime
-
-		if real_mtime != cached_mtime:
-			self.load()
-			return True
-		return False
-
-	def clone(self):
-		clone = type(self)(self.path)
-		for key in iter(self.__dict__):
-			clone.__dict__[key] = self.__dict__[key]
-		return clone
-
-	def frozen_clone(self):
-		clone = self.clone()
-		clone.frozen = True
-		return clone
-
-	def stop_if_frozen(self):
-		if self.frozen: raise FrozenException('Cannot modify datastructure while it is frozen')
-
diff --git a/code/fstype.py b/code/fstype.py
deleted file mode 100644
index 4bd0988d..00000000
--- a/code/fstype.py
+++ /dev/null
@@ -1,5 +0,0 @@
-class File: pass
-class Directory: pass
-class Nonexistent: pass
-class Unknown: pass
-
diff --git a/code/options.py b/code/options.py
deleted file mode 100644
index eed79f1e..00000000
--- a/code/options.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def get():
-	return []
-
-def dummy():
-	return []
diff --git a/code/ui.py b/code/ui.py
deleted file mode 100644
index d9c1de4e..00000000
--- a/code/ui.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import curses, debug
-class UI():
-	def __init__(self, env):
-		self.env = env
-
-		self.widgets = []
-		self.win = curses.initscr()
-		self.win.leaveok(1)
-		curses.noecho()
-		curses.halfdelay(3)
-
-		self.setup()
-		self.resize()
-
-	def setup(self):
-		pass
-
-	def resize(self):
-		self.env.termsize = self.win.getmaxyx()
-
-	def add_widget(self, widg):
-		self.widgets.append(widg)
-
-	def feed_env(self, env):
-		self.env = env
-
-	def exit(self):
-		curses.nocbreak()
-		curses.echo()
-		curses.endwin()
-
-	def draw(self):
-		self.win.erase()
-		for widg in self.widgets:
-			widg.feed_env(self.env)
-			widg.draw()
-		self.win.refresh()
-
-#		for i in range(1, len(self.env.pwd)):
-#			f = self.env.pwd.files[i]
-#			self.win.addstr(i, 0, f.path)
-#			if f.infostring: self.win.addstr(i, 50, f.infostring)
-
-	def get_next_key(self):
-		key = self.win.getch()
-		curses.flushinp()
-		return key
-
diff --git a/code/wdisplay.py b/code/wdisplay.py
deleted file mode 100644
index a564a6cb..00000000
--- a/code/wdisplay.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import widget
-import curses
-import file, directory
-
-class WDisplay(widget.Widget):
-	def __init__(self, win, level):
-		widget.Widget.__init__(self,win)
-		self.level = level
-
-	def feed_env(self, env):
-		self.target = env.at_level(self.level)
-
-	def draw(self):
-		if type(self.target) == file.File:
-			self.draw_file()
-		elif type(self.target) == directory.Directory:
-			self.draw_directory()
-		elif self.target is None:
-			self.win.addnstr(self.y, self.x, "---", self.wid)
-		else:
-			self.win.addnstr(self.y, self.x, "unknown type.", self.wid)
-
-	def draw_file(self):
-		self.win.addnstr(self.y, self.x, "this is a file.", self.wid)
-
-	def draw_directory(self):
-		self.target.load_content_once()
-		for i in range(self.hei):
-			try:
-				f = self.target[i]
-			except IndexError:
-				break
-			self.win.addnstr(self.y + i, self.x, self.target[i].path, self.wid)
-
diff --git a/code/widget.py b/code/widget.py
deleted file mode 100644
index e95e6a9d..00000000
--- a/code/widget.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import curses
-
-class OutOfBoundsException(Exception): pass
-
-class Widget():
-	def __init__(self, win):
-		self.win = win
-		self.setdim(0, 0, 0, 0)
-
-	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 or y + hei > maxy:
-			raise OutOfBoundsException()
-
-		self.x = x
-		self.y = y
-		self.wid = wid
-		self.hei = hei
-	
-	def contains_point(self, y, x):
-		return (x >= self.x and x < self.x + self.wid) and \
-				(y >= self.y and y < self.y + self.hei)
-
-	def feed_env(self):
-		pass
-
-	def feed(self):
-		pass
-
-	def click(self):
-		pass
-	
-	def draw(self):
-		pass
-
-	def destroy(self):
-		pass